Private
Public Access
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fd68400822 |
No files matched your search
@@ -0,0 +1,41 @@
|
||||
(function () {
|
||||
// Everything is stored and server-rendered in UTC (config.settings.base
|
||||
// TIME_ZONE) — these <time datetime="..."> elements carry that UTC
|
||||
// instant plus a UTC-formatted fallback as their initial text, and this
|
||||
// reformats them using the browser's own timezone, client-side, so the
|
||||
// server never needs to know (or guess) where the viewer actually is.
|
||||
var SHORT_OPTIONS = { hour: "numeric", minute: "2-digit" };
|
||||
var LONG_OPTIONS = {
|
||||
year: "numeric",
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
};
|
||||
|
||||
function localizeTimesWithin(root) {
|
||||
if (!root || typeof root.querySelectorAll !== "function") return;
|
||||
root.querySelectorAll("time[data-local-format]").forEach(function (el) {
|
||||
var iso = el.getAttribute("datetime");
|
||||
if (!iso) return;
|
||||
var date = new Date(iso);
|
||||
if (isNaN(date.getTime())) return;
|
||||
var options = el.dataset.localFormat === "short" ? SHORT_OPTIONS : LONG_OPTIONS;
|
||||
try {
|
||||
el.textContent = date.toLocaleString(undefined, options);
|
||||
} catch (e) {
|
||||
/* Intl unavailable or threw — leave the server-rendered UTC text as-is */
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
localizeTimesWithin(document);
|
||||
|
||||
// Article rows/content are frequently swapped in by htmx (pagination,
|
||||
// the inline expand-article view, the dashboard's retry action) without
|
||||
// a full page load, so every swap needs the same pass over just the
|
||||
// new content.
|
||||
document.body.addEventListener("htmx:afterSwap", function (event) {
|
||||
localizeTimesWithin(event.target);
|
||||
});
|
||||
})();
|
||||
@@ -53,6 +53,7 @@
|
||||
{% endif %}
|
||||
|
||||
<script src="{% static 'js/stream.js' %}" defer></script>
|
||||
<script src="{% static 'js/localize-times.js' %}" defer></script>
|
||||
{% if user.is_authenticated %}
|
||||
<script src="{% static 'js/theme.js' %}" defer></script>
|
||||
<script src="{% static 'js/sidebar-state.js' %}" defer></script>
|
||||
|
||||
@@ -31,7 +31,13 @@
|
||||
<td>{{ feed.subscriber_count }}</td>
|
||||
<td>{{ feed.get_last_fetch_status_display }}</td>
|
||||
<td>{{ feed.fetch_error_count }}</td>
|
||||
<td>{{ feed.last_fetched_at|default:"never" }}</td>
|
||||
<td>
|
||||
{% if feed.last_fetched_at %}
|
||||
<time datetime="{{ feed.last_fetched_at|date:"c" }}" data-local-format="long">{{ feed.last_fetched_at|date:"M j, Y H:i" }}</time>
|
||||
{% else %}
|
||||
never
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ feed.last_error_message|default:"—" }}</td>
|
||||
<td>
|
||||
<form method="post" action="{% url 'core:retry_feed' feed.id %}">
|
||||
|
||||
@@ -2,7 +2,10 @@
|
||||
<h2 class="article-content-title">{{ article.title|default:"(untitled)" }}</h2>
|
||||
<p class="article-meta">
|
||||
{% if article.feed.favicon_url %}<img src="{{ article.feed.favicon_url }}" alt="" class="feed-favicon">{% endif %}
|
||||
{{ article.feed.title }} · {{ article.published_at|date:"M j, Y H:i" }}
|
||||
{{ article.feed.title }}
|
||||
{% if article.published_at %}
|
||||
· <time datetime="{{ article.published_at|date:"c" }}" data-local-format="long">{{ article.published_at|date:"M j, Y H:i" }}</time>
|
||||
{% endif %}
|
||||
{% if article.author %} · {{ article.author }}{% endif %}
|
||||
{% if article.link %} · <a href="{{ article.link }}" target="_blank" rel="noopener noreferrer">Original ↗</a>{% endif %}
|
||||
</p>
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
<a href="{% url 'reader:article_detail' article.pk %}" class="article-title"
|
||||
data-inline-url="{% url 'reader:article_inline' article.pk %}"
|
||||
onclick="return toggleArticle(event, {{ article.pk }})">{{ article.title|default:"(untitled)" }}</a>
|
||||
<span class="article-time">{{ article.published_at|date:"g:i A" }}</span>
|
||||
{% if article.published_at %}
|
||||
<time class="article-time" datetime="{{ article.published_at|date:"c" }}" data-local-format="short">{{ article.published_at|date:"g:i A" }}</time>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div id="article-body-{{ article.pk }}" class="article-inline-body" hidden></div>
|
||||
</li>
|
||||
Reference in new issue
Block a user