142 lines
5.1 KiB
HTML
142 lines
5.1 KiB
HTML
{% extends "thoughts/page.html" %}
|
|
{% load static %}
|
|
|
|
{% block title %}Thoughts{% endblock %}
|
|
|
|
{% block head %}
|
|
{% if not is_first_page %}
|
|
<link rel="canonical" href="/?page={{ page.slug }}">
|
|
{% else %}
|
|
<link rel="canonical" href="/">
|
|
{% endif %}
|
|
|
|
<link href="{% static 'thoughts/codehighlight.css' %}" rel="stylesheet">
|
|
|
|
<!-- Open Graph + Twitter card -->
|
|
<meta name="twitter:card" content="summary">
|
|
<meta content="Thoughts" property="og:title">
|
|
<meta content="Thoughts" name="twitter:title">
|
|
|
|
{% spaceless %}
|
|
{% for thought in thoughts %}
|
|
{% if thought.uuid == highlighted %}
|
|
<meta content="{{ thought.text }}" property="og:description">
|
|
<meta content="{{ thought.text }}" name="twitter:description">
|
|
|
|
{% if thought.get_media_type == "png" or thought.get_media_type == "jpeg" %}
|
|
<meta content="{{ thought.media.url }}" property="og:image">
|
|
<meta content="{{ thought.media.url }}" name="twitter:image">
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% endspaceless %}
|
|
{% endblock %}
|
|
|
|
{% block headerright %}
|
|
<nav class="nav" id="main-nav" aria-label="Navigation">
|
|
<span class="nav-item"><a href="/about">About this site</a></span>
|
|
|
|
<span class="nav-item"><a href="/search">Search</a></span>
|
|
|
|
{% if authenticated %}
|
|
<span class="nav-item"><a href="/post">Post</a></span>
|
|
{% endif %}
|
|
</nav>
|
|
{% endblock %}
|
|
|
|
{% block main %}
|
|
<nav class="nav top" aria-label="History Navigation">
|
|
{% if not is_first_page %}
|
|
<span class="nav-item"><a href="?page={{ previous_page_slug }}">Newer</a></span>
|
|
{% endif %}
|
|
|
|
<span class="nav-item"><span class="current-page">{{ page.formatted_name }}</span></span>
|
|
|
|
{% if not is_last_page %}
|
|
<span class="nav-item"><a href="?page={{ next_page_slug }}">Older</a></span>
|
|
{% endif %}
|
|
</nav>
|
|
|
|
{% for thought in thoughts %}
|
|
<div class="thought{% if thought.uuid == highlighted %} highlighted{% endif %}" id="{{ thought.uuid }}">
|
|
{% if thought.uuid == highlighted %}
|
|
{% if authenticated %}
|
|
{{ thought.get_html_content_authenticated }}
|
|
{% else %}
|
|
{{ thought.get_html_content }}
|
|
{% endif %}
|
|
{% else %}
|
|
{{ thought.html_content|safe }}
|
|
{% endif %}
|
|
</div>
|
|
{% endfor %}
|
|
|
|
<nav class="nav bottom" aria-label="History Navigation">
|
|
{% if not is_first_page %}
|
|
<span class="nav-item"><a href="?page={{ previous_page_slug }}">Newer</a></span>
|
|
{% endif %}
|
|
|
|
<span class="nav-item"><span class="current-page">{{ page.formatted_name }}</span></span>
|
|
|
|
{% if not is_last_page %}
|
|
<span class="nav-item"><a href="?page={{ next_page_slug }}">Older</a></span>
|
|
{% endif %}
|
|
</nav>
|
|
{% endblock %}
|
|
|
|
{% block scripts %}
|
|
<script>
|
|
const els = document.querySelectorAll(".thought");
|
|
|
|
for (let el of els) {
|
|
const extended = el.querySelector(".extended");
|
|
|
|
if (extended) {
|
|
//Hide extended text
|
|
extended.classList.add("hidden");
|
|
//Add button to show extended text
|
|
if (extended.childNodes.length) {
|
|
const main = el.querySelector(".main");
|
|
const showMoreButton = document.createElement("button");
|
|
showMoreButton.appendChild(document.createTextNode("Show More"));
|
|
showMoreButton.classList.add("show-more");
|
|
showMoreButton.addEventListener("click", evt => {
|
|
// Remove ourself
|
|
showMoreButton.parentNode.removeChild(showMoreButton);
|
|
// Show the extended text
|
|
extended.classList.remove("hidden");
|
|
});
|
|
main.appendChild(showMoreButton);
|
|
}
|
|
|
|
//Hydrate Show transcription button
|
|
const transcriptButton = el.querySelector(".transcript-button");
|
|
if (transcriptButton) {
|
|
const transcriptTitle = el.querySelector(".transcript-label");
|
|
const transcript = el.querySelector(".transcript");
|
|
|
|
const extendedParent = transcript.parentNode;
|
|
|
|
transcriptButton.addEventListener("click", function () {
|
|
extendedParent.appendChild(transcriptTitle);
|
|
extendedParent.appendChild(transcript);
|
|
extendedParent.removeChild(transcriptButton);
|
|
});
|
|
|
|
extendedParent.removeChild(transcriptTitle);
|
|
extendedParent.removeChild(transcript);
|
|
}
|
|
}
|
|
}
|
|
|
|
const highlighted = document.querySelector(".highlighted");
|
|
if (highlighted) {
|
|
highlighted.scrollIntoView();
|
|
const showMoreButton = highlighted.querySelector(".show-more");
|
|
if (showMoreButton) {
|
|
showMoreButton.click();
|
|
}
|
|
}
|
|
</script>
|
|
{% endblock %}
|