WhisperMaPhone/main/templates/whispermaphone/index.html

128 lines
4.8 KiB
HTML
Raw Normal View History

2020-09-06 03:12:54 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
2020-09-06 16:39:00 +00:00
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Thoughts</title>
2020-09-06 16:00:44 +00:00
2020-09-06 16:39:00 +00:00
{% load static %}
2020-11-04 18:07:06 +00:00
<link href="{% static 'main/main.css' %}" rel="stylesheet">
<link rel="icon" sizes="192x192" href="{% static 'images/favicon-192x192.png'%}">
<link rel="apple-touch-icon" href="{% static 'images/apple-touch-icon.png'%}"/>
2020-09-12 17:04:34 +00:00
<link rel="alternate" href="/feed" type="application/rss+xml" title="RSS">
2020-09-06 03:12:54 +00:00
</head>
<body>
<header>
<h1>
<span class="text">Thoughts</span>{% if authenticated %}
<a href="/post" class="text" style="border: none">Post</a>
{% endif %}</h1>
</header>
2020-09-06 04:06:16 +00:00
2020-09-06 16:00:44 +00:00
<section class="main-wrap">
{% load tz %}
2020-09-06 04:06:16 +00:00
{% for thought in thoughts %}
2020-11-22 00:05:31 +00:00
<div class="thought{% if thought.uuid == highlighted %} highlighted{% endif %}" id="{{thought.uuid}}">
2020-10-01 02:12:52 +00:00
<div class="main">
<span class="main-text text">{{thought.text}}</span>
</div>
<div class="extended-text text">{{thought.extended_text}}</div>
<div class="thought-end">
<span class="timestamp">
{% timezone thought.timezone %}
{{ thought.posted|time:"g:i a" }}
{{ thought.posted|date:"M d, Y" }},
UTC{{ thought.offset_hours }}
{% endtimezone %}
</span>
2020-10-01 02:12:52 +00:00
</div>
<hr>
2020-09-06 04:06:16 +00:00
</div>
2020-10-01 02:12:52 +00:00
{% endfor %}
2020-09-06 16:00:44 +00:00
</section>
2020-09-06 18:17:49 +00:00
<!-- <footer>Copyright Matthias @2020{% if authenticated %}-->
<!-- <a href="/post" style="color: var(&#45;&#45;text-color); margin-left: 100px; text-decoration: none">POST</a>-->
<!-- {% endif %}</footer>-->
2020-09-06 16:00:44 +00:00
<script>
const els = document.querySelectorAll(".thought");
2020-09-06 16:00:44 +00:00
for (let el of els) {
const extended = el.querySelector(".extended-text");
2020-10-01 02:12:52 +00:00
//Hide extended text
2020-09-06 17:23:30 +00:00
extended.classList.add("hidden");
2020-10-01 02:12:52 +00:00
//Add button to show extended text
2020-09-06 16:00:44 +00:00
if (extended.textContent.length) {
2020-10-01 02:12:52 +00:00
const main = el.querySelector(".main");
2020-09-06 16:00:44 +00:00
const showMoreButton = document.createElement("button");
showMoreButton.appendChild(document.createTextNode("Show More"));
2020-09-06 17:23:30 +00:00
showMoreButton.classList.add("show-more");
2020-09-06 16:00:44 +00:00
showMoreButton.addEventListener("click", evt => {
2020-10-01 02:12:52 +00:00
// Remove ourself
2020-09-06 16:00:44 +00:00
showMoreButton.parentNode.removeChild(showMoreButton);
// Show the extended text
extended.classList.remove("hidden");
})
2020-10-01 02:12:52 +00:00
main.appendChild(showMoreButton);
2020-09-06 16:00:44 +00:00
}
}
2020-11-22 00:05:31 +00:00
const highlighted = document.querySelector(".highlighted");
if (highlighted) {
highlighted.scrollIntoView();
2020-11-30 04:19:23 +00:00
const showMoreButton = highlighted.querySelector(".show-more");
2020-11-30 04:17:35 +00:00
if (showMoreButton) {
showMoreButton.click();
}
2020-11-22 00:05:31 +00:00
}
2020-09-06 16:00:44 +00:00
</script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.2.0/build/styles/tomorrow-night.min.css">
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.2.0/build/highlight.min.js"></script>
<!--Remarkable UMD bundle, includes linkify and Remarkable in the global remarkable-->
<script src="https://cdn.jsdelivr.net/npm/remarkable@2.0.1/dist/remarkable.min.js"></script>
<script>
// Remarkable ES6 module
// import { Remarkable } from "https://cdn.jsdelivr.net/npm/remarkable@2.0.1/dist/esm/index.browser.min.js";
// import { linkify } from "https://cdn.jsdelivr.net/npm/remarkable@2.0.1/dist/esm/linkify.js";
const md = new remarkable.Remarkable({
html: false, breaks: true, typographer: true,
highlight: function (str, lang) {
if (lang && hljs.getLanguage(lang)) {
return hljs.highlight(lang, str).value;
}
return hljs.highlightAuto(str).value;
}
}).use(remarkable.linkify);
// Allow data: URIs for images, from https://github.com/jonschlinkert/remarkable/issues/329
const originalLinkValidator = md.inline.validateLink;
const dataLinkRegex = /^\s*data:([a-z]+\/[a-z]+(;[a-z-]+=[a-z-]+)?)?(;base64)?,[a-z0-9!$&'',()*+,;=\-._~:@/?%\s]*\s*$/i;
md.inline.validateLink = (url) => originalLinkValidator(url) || url.match(dataLinkRegex);
for (let el of els) {
const extended = el.querySelector(".extended-text");
const mainText = el.querySelector(".main-text");
//Markdown + highlight
extended.innerHTML = md.render(extended.textContent);
mainText.innerHTML = md.render(mainText.textContent);
}
</script>
2020-09-06 03:12:54 +00:00
</body>
</html>