diff --git a/src/app.py b/src/app.py index 43c4f1e..6b0e9d8 100644 --- a/src/app.py +++ b/src/app.py @@ -10,21 +10,21 @@ pages = { "template": "home.html", "title": "Andrew Simonson - Portfolio Home", "description": "Andrew Simonson's Digital Portfolio home", - "canonical": "", + "canonical": "/", }, "projects": { "template": "projects.html", "projects": proj, "title": "Andrew Simonson - Projects", "description": "Recent projects by Andrew Simonson on his lovely portfolio website :)", - "canonical": "projects", + "canonical": "/projects", }, "about": { "template": "about.html", "timeline": timeline, "title": "Andrew Simonson - About Me", "description": "About Andrew Simonson", - "canonical": "about", + "canonical": "/about", }, } @@ -33,13 +33,10 @@ Minify(app=app, html=True, js=True, cssless=True) socketio = SocketIO(app) -@socketio.on("goto") +@app.route('/api/goto/') def goto(location): - sid = flask.request.sid pagevars = pages[location] - output = [location, flask.render_template(pagevars["template"], var=pagevars), pagevars['title']] - socketio.emit("goto", output, to=sid) - + return [pagevars, flask.render_template(pagevars["template"], var=pagevars)] @app.route("/") def home(): diff --git a/src/static/js/responsive.js b/src/static/js/responsive.js index 934d7b5..23459f1 100644 --- a/src/static/js/responsive.js +++ b/src/static/js/responsive.js @@ -88,25 +88,22 @@ function toggleMenu() { } } -let socket = io(); +const loc = "https://asimonson.com" -function emit(event) { - socket.emit(event); -} - -function emitData(event, data) { - socket.emit(event, data) -} - -socket.on('goto', (page) => { - pagename = page[0]; - content = page[1]; - let root = document.getElementById('root'); +async function goto(location) { + let a = await fetch(loc + "/api/goto/" + location, { + credentials: "include", + method: "GET", + mode: "cors", + }); + const response = await a.json(); + const metadata = response[0]; + const content = response[1]; + let root = document.getElementById("root"); root.innerHTML = content; - root.querySelectorAll("script").forEach(x => { + root.querySelectorAll("script").forEach((x) => { eval(x.innerHTML); }); - document.querySelector('title').textContent = page[2]; - if (pagename == 'home') pagename = '/'; - history.pushState(null, null, pagename); -}); \ No newline at end of file + document.querySelector("title").textContent = metadata['title']; + history.pushState(null, null, metadata['canonical']); +} diff --git a/src/templates/header.html b/src/templates/header.html index c4883ba..aad2e84 100644 --- a/src/templates/header.html +++ b/src/templates/header.html @@ -52,9 +52,8 @@ href="{{ url_for('static', filename='css/head.css') }}" /> - + - @@ -67,7 +66,7 @@
-
+
{% for i in range(9) %}
@@ -86,17 +85,17 @@