General theme: fix syntax W3C markup and add improve 'Published' date

Signed-off-by: Jesús <heckyel@hyperbola.info>
This commit is contained in:
Jesús 2020-12-30 16:17:48 -05:00
parent 056c3be3f2
commit 1f4d7cc958
No known key found for this signature in database
GPG Key ID: F6EE7BC59A315766
5 changed files with 14 additions and 5 deletions

View File

@ -2,7 +2,7 @@ function onClickReplies(e) {
var details = e.target.parentElement;
// e.preventDefault();
console.log("loading replies ..");
doXhr(details.getAttribute("src") + "&slim=1", (html) => {
doXhr(details.getAttribute("data-src") + "&slim=1", (html) => {
var div = details.querySelector(".comment_page");
div.innerHTML = html;
});
@ -14,7 +14,7 @@ window.addEventListener('DOMContentLoaded', function() {
details.addEventListener('click', onClickReplies);
details.addEventListener('auxclick', (e) => {
if (e.target.parentElement !== details) return;
if (e.button == 1) window.open(details.getAttribute("src"));
if (e.button == 1) window.open(details.getAttribute("data-src"));
});
});
});

View File

@ -12,7 +12,7 @@
<a class="author" href="{{ comment['author_url'] }}" title="{{ comment['author'] }}">{{ comment['author'] }}</a>
</address>
<a class="permalink" href="{{ comment['permalink'] }}" title="permalink">
<time datetime="2012-01-14T15:23:44+02:00">{{ comment['time_published'] }}</time>
<span>{{ comment['time_published'] }}</span>
</a>
{% if timestamp_links %}
@ -24,7 +24,7 @@
<span class="comment-likes">{{ comment['likes_text'] if comment['like_count'] else ''}}</span>
<div class="button-row">
{% if settings.use_comments_js and comment['reply_count'] %}
<details class="replies" src="{{ comment['replies_url'] }}">
<details class="replies" data-src="{{ comment['replies_url'] }}">
<summary>{{ comment['view_replies_text'] }}</summary>
<a href="{{ comment['replies_url'] }}" class="replies-open-new-tab" target="_blank">Open in new tab</a>
<div class="comment_page">loading..</div>

View File

@ -71,7 +71,7 @@
<address class="v-uploaded">Uploaded by <a href="{{ uploader_channel_url }}">{{ uploader }}</a></address>
<span class="v-views">{{ view_count }} views</span>
<time class="v-published" datetime="$upload_date">Published on {{ time_published }}</time>
<time class="v-published" datetime="{{ time_published_utc }}">Published on {{ time_published }}</time>
<span class="v-likes-dislikes">{{ like_count }} likes {{ dislike_count }} dislikes</span>
<div class="external-player-controls">

View File

@ -1,3 +1,4 @@
from datetime import datetime
import settings
import socks
import sockshandler
@ -607,3 +608,9 @@ def strip_non_ascii(string):
''' Returns the string without non ASCII characters'''
stripped = (c for c in string if 0 < ord(c) < 127)
return ''.join(stripped)
def time_utc_isoformat(string):
t = datetime.strptime(string, '%Y-%m-%d')
t = t.astimezone().isoformat()
return t

View File

@ -1,6 +1,7 @@
import youtube
from youtube import yt_app
from youtube import util, comments, local_playlist, yt_data_extract
from youtube.util import time_utc_isoformat
import settings
from flask import request
@ -491,6 +492,7 @@ def get_watch_page(video_id=None):
header_playlist_names = local_playlist.get_playlist_names(),
uploader_channel_url = ('/' + info['author_url']) if info['author_url'] else '',
time_published = info['time_published'],
time_published_utc=time_utc_isoformat(info['time_published']),
view_count = (lambda x: '{:,}'.format(x) if x is not None else "")(info.get("view_count", None)),
like_count = (lambda x: '{:,}'.format(x) if x is not None else "")(info.get("like_count", None)),
dislike_count = (lambda x: '{:,}'.format(x) if x is not None else "")(info.get("dislike_count", None)),