@app.context_processor
def inject_global_vars():
- return dict(gif_data=get_gif_data(), current_user_playlists=get_current_user_playlists())
+ use_json = request.args.get("request-type", None) == "ajax"
+ return dict(gif_data=get_gif_data(), current_user_playlists=get_current_user_playlists(), use_json=use_json, dumps=json.dumps)
################################################################################
<!-- Page-specific head fields -->
{% block head %}
{% endblock %}
+ <script>
+ document.addEventListener("click", (event) => {
+ // TODO - what links do we actually want to match? Use URL?
+ if (!event.target.matches(".navbar a")) {
+ return;
+ }
+ event.preventDefault();
+
+ // Update URL in browser window
+ window.history.pushState({}, "", event.target.href);
+
+ // Make AJAX request
+ var url = new URL(event.target.href);
+ url.searchParams.set("request-type", "ajax")
+
+ // Update HTML
+ getPageAjax(url);
+ });
+ async function getPageAjax(url) {
+ var data = await fetch(url).then((response) => response.json());
+ console.log(data);
+ }
+ </script>
</head>
<body>
-{% extends "base.html" %}
+{% if use_json %}{% extends "base.json" %}{% else %}{% extends "base.html" %}{% endif %}
{% block title %}Little Song Place{% endblock %}
NOW
-
-SOON
-- Break up main.py, test_offline.py
- AJAX pages so songs can play during navigation
+ - Nav bar
+ - Forms
+ - Back (history stack)
+ - Other on-site links (songs, profiles, tags, etc.)
+- Break up main.py, test_offline.py
- Pinned profile playlists
+SOON
- Image support in comments, descriptions, bios, etc.
- Player minimize button
- Shuffle all page