mirror of
https://code.castopod.org/adaures/castopod
synced 2025-06-05 08:52:00 +00:00
feat: make displayed publication time as relative time using @github/time-elements
This commit is contained in:
parent
0e14eb4d3f
commit
230e139e43
@ -514,3 +514,24 @@ if (! function_exists('audio_player')) {
|
|||||||
CODE_SAMPLE;
|
CODE_SAMPLE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
if (! function_exists('relative_time')) {
|
||||||
|
function relative_time(Time $time, string $class = ''): string
|
||||||
|
{
|
||||||
|
$translatedDate = lang('Common.mediumDate', [$time]);
|
||||||
|
$datetime = $time->toDateTimeString();
|
||||||
|
|
||||||
|
return <<<CODE_SAMPLE
|
||||||
|
<time-ago class="${class}" datetime="${datetime}">
|
||||||
|
<time
|
||||||
|
itemprop="published"
|
||||||
|
datetime="${datetime}"
|
||||||
|
title="${time}">${translatedDate}</time>
|
||||||
|
</time-ago>
|
||||||
|
CODE_SAMPLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import "@github/markdown-toolbar-element";
|
import "@github/markdown-toolbar-element";
|
||||||
|
import "@github/time-elements";
|
||||||
import ClientTimezone from "./modules/ClientTimezone";
|
import ClientTimezone from "./modules/ClientTimezone";
|
||||||
import Clipboard from "./modules/Clipboard";
|
import Clipboard from "./modules/Clipboard";
|
||||||
import DateTimePicker from "./modules/DateTimePicker";
|
import DateTimePicker from "./modules/DateTimePicker";
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import "@github/time-elements";
|
||||||
import Dropdown from "./modules/Dropdown";
|
import Dropdown from "./modules/Dropdown";
|
||||||
import Time from "./modules/Time";
|
import Time from "./modules/Time";
|
||||||
import Toggler from "./modules/Toggler";
|
import Toggler from "./modules/Toggler";
|
||||||
|
@ -42,12 +42,7 @@
|
|||||||
<span class="text-sm text-gray-500 truncate">@<?= $podcast
|
<span class="text-sm text-gray-500 truncate">@<?= $podcast
|
||||||
->actor->username ?></span>
|
->actor->username ?></span>
|
||||||
</p>
|
</p>
|
||||||
<time class="text-xs text-gray-500" itemprop="published" datetime="<?= $status->published_at->format(
|
<?= relative_time($status->published_at, 'text-xs text-gray-500') ?>
|
||||||
DateTime::ATOM,
|
|
||||||
) ?>" title="<?= $status->published_at ?>"><?= lang(
|
|
||||||
'Common.mediumDate',
|
|
||||||
[$status->published_at],
|
|
||||||
) ?></time>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="px-4 mb-2">
|
<div class="px-4 mb-2">
|
||||||
@ -78,13 +73,7 @@
|
|||||||
) ?>
|
) ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-xs text-gray-600">
|
<div class="text-xs text-gray-600">
|
||||||
<time itemprop="published" datetime="<?= $episode->published_at->format(
|
<?= relative_time($episode->published_at) ?>
|
||||||
DateTime::ATOM,
|
|
||||||
) ?>" title="<?= $episode->published_at ?>">
|
|
||||||
<?= lang('Common.mediumDate', [
|
|
||||||
$episode->published_at,
|
|
||||||
]) ?>
|
|
||||||
</time>
|
|
||||||
<span class="mx-1">•</span>
|
<span class="mx-1">•</span>
|
||||||
<time datetime="PT<?= $episode->audio_file_duration ?>S">
|
<time datetime="PT<?= $episode->audio_file_duration ?>S">
|
||||||
<?= format_duration($episode->audio_file_duration) ?>
|
<?= format_duration($episode->audio_file_duration) ?>
|
||||||
|
@ -21,11 +21,7 @@
|
|||||||
<span class="mx-1">-</span>
|
<span class="mx-1">-</span>
|
||||||
<?= $episode->title ?>
|
<?= $episode->title ?>
|
||||||
</h2>
|
</h2>
|
||||||
<time class="text-xs whitespace-nowrap" itemprop="published" datetime="<?= $episode->published_at->format(DateTime::ATOM,) ?>" title="<?= $episode->published_at ?>">
|
<?= relative_time($episode->published_at, 'text-xs whitespace-nowrap') ?>
|
||||||
<?= lang('Common.mediumDate', [
|
|
||||||
$episode->published_at,
|
|
||||||
]) ?>
|
|
||||||
</time>
|
|
||||||
</a>
|
</a>
|
||||||
<div class="flex mt-auto gap-x-4">
|
<div class="flex mt-auto gap-x-4">
|
||||||
<?= play_episode_button($episode->id, $episode->image->thumbnail_url, $episode->title, $podcast->title, $episode->audio_file_web_url, $episode->audio_file_mimetype, 'mt-auto') ?>
|
<?= play_episode_button($episode->id, $episode->image->thumbnail_url, $episode->title, $podcast->title, $episode->audio_file_web_url, $episode->audio_file_mimetype, 'mt-auto') ?>
|
||||||
|
@ -19,13 +19,7 @@
|
|||||||
<span class="mx-1">-</span>
|
<span class="mx-1">-</span>
|
||||||
<?= $episode->title ?>
|
<?= $episode->title ?>
|
||||||
</div>
|
</div>
|
||||||
<time
|
<?= relative_time($episode->published_at, 'text-xs whitespace-nowrap') ?>
|
||||||
class="text-xs"
|
|
||||||
itemprop="published"
|
|
||||||
datetime="<?= $episode->published_at->format(DateTime::ATOM) ?>"
|
|
||||||
title="<?= $episode->published_at ?>">
|
|
||||||
<?= lang('Common.mediumDate', [$episode->published_at]) ?>
|
|
||||||
</time>
|
|
||||||
</a>
|
</a>
|
||||||
<?= play_episode_button($episode->id, $episode->image->thumbnail_url, $episode->title, $podcast->title, $episode->audio_file_web_url, $episode->audio_file_mimetype, 'mt-auto') ?>
|
<?= play_episode_button($episode->id, $episode->image->thumbnail_url, $episode->title, $podcast->title, $episode->audio_file_web_url, $episode->audio_file_mimetype, 'mt-auto') ?>
|
||||||
</div>
|
</div>
|
||||||
|
@ -25,11 +25,7 @@
|
|||||||
</a>
|
</a>
|
||||||
<a href="<?= route_to('status', $podcast->handle, $status->id) ?>"
|
<a href="<?= route_to('status', $podcast->handle, $status->id) ?>"
|
||||||
class="text-xs text-gray-500">
|
class="text-xs text-gray-500">
|
||||||
<time
|
<?= relative_time($status->published_at) ?>
|
||||||
itemprop="published"
|
|
||||||
datetime="<?= $status->published_at->format(DateTime::ATOM) ?>"
|
|
||||||
title="<?= $status->published_at ?>"
|
|
||||||
><?= lang('Common.mediumDate', [$status->published_at]) ?></time>
|
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
@ -25,11 +25,7 @@
|
|||||||
</a>
|
</a>
|
||||||
<a href="<?= route_to('status', $podcast->handle, $status->id) ?>"
|
<a href="<?= route_to('status', $podcast->handle, $status->id) ?>"
|
||||||
class="text-xs text-gray-500">
|
class="text-xs text-gray-500">
|
||||||
<time
|
<?= relative_time($status->published_at) ?>
|
||||||
itemprop="published"
|
|
||||||
datetime="<?= $status->published_at->format(DateTime::ATOM) ?>"
|
|
||||||
title="<?= $status->published_at ?>"
|
|
||||||
><?= lang('Common.mediumDate', [$status->published_at]) ?></time>
|
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
@ -11,12 +11,7 @@
|
|||||||
->display_name ?><span class="ml-1 text-sm font-normal text-gray-600">@<?= $reply
|
->display_name ?><span class="ml-1 text-sm font-normal text-gray-600">@<?= $reply
|
||||||
->actor->username .
|
->actor->username .
|
||||||
($reply->actor->is_local ? '' : '@' . $reply->actor->domain) ?></span></a>
|
($reply->actor->is_local ? '' : '@' . $reply->actor->domain) ?></span></a>
|
||||||
<time
|
<?= relative_time($status->published_at, 'flex-shrink-0 ml-auto text-xs text-gray-600') ?>
|
||||||
class="flex-shrink-0 ml-auto text-xs text-gray-600"
|
|
||||||
itemprop="published"
|
|
||||||
datetime="<?= $reply->published_at->format(DateTime::ATOM) ?>"
|
|
||||||
title="<?= $reply->published_at ?>"
|
|
||||||
><?= lang('Common.mediumDate', [$reply->published_at]) ?></time>
|
|
||||||
</header>
|
</header>
|
||||||
<p class="mb-2 status-content"><?= $reply->message_html ?></p>
|
<p class="mb-2 status-content"><?= $reply->message_html ?></p>
|
||||||
<?php if ($reply->has_preview_card): ?>
|
<?php if ($reply->has_preview_card): ?>
|
||||||
|
@ -11,12 +11,7 @@
|
|||||||
->display_name ?><span class="ml-1 text-sm font-normal text-gray-600">@<?= $reply
|
->display_name ?><span class="ml-1 text-sm font-normal text-gray-600">@<?= $reply
|
||||||
->actor->username .
|
->actor->username .
|
||||||
($reply->actor->is_local ? '' : '@' . $reply->actor->domain) ?></span></a>
|
($reply->actor->is_local ? '' : '@' . $reply->actor->domain) ?></span></a>
|
||||||
<time
|
<?= relative_time($status->published_at, 'flex-shrink-0 ml-auto text-xs text-gray-600') ?>
|
||||||
class="flex-shrink-0 ml-auto text-xs text-gray-600"
|
|
||||||
itemprop="published"
|
|
||||||
datetime="<?= $reply->published_at->format(DateTime::ATOM) ?>"
|
|
||||||
title="<?= $reply->published_at ?>"
|
|
||||||
><?= lang('Common.mediumDate', [$reply->published_at]) ?></time>
|
|
||||||
</header>
|
</header>
|
||||||
<p class="mb-2 status-content"><?= $reply->message_html ?></p>
|
<p class="mb-2 status-content"><?= $reply->message_html ?></p>
|
||||||
<?php if ($reply->has_preview_card): ?>
|
<?php if ($reply->has_preview_card): ?>
|
||||||
|
@ -18,11 +18,7 @@
|
|||||||
</a>
|
</a>
|
||||||
<a href="<?= route_to('status', $podcast->handle, $status->id) ?>"
|
<a href="<?= route_to('status', $podcast->handle, $status->id) ?>"
|
||||||
class="text-xs text-gray-500">
|
class="text-xs text-gray-500">
|
||||||
<time
|
<?= relative_time($status->published_at) ?>
|
||||||
itemprop="published"
|
|
||||||
datetime="<?= $status->published_at->format(DateTime::ATOM) ?>"
|
|
||||||
title="<?= $status->published_at ?>"
|
|
||||||
><?= lang('Common.mediumDate', [$status->published_at]) ?></time>
|
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
@ -18,11 +18,7 @@
|
|||||||
</a>
|
</a>
|
||||||
<a href="<?= route_to('status', $podcast->handle, $status->id) ?>"
|
<a href="<?= route_to('status', $podcast->handle, $status->id) ?>"
|
||||||
class="text-xs text-gray-500">
|
class="text-xs text-gray-500">
|
||||||
<time
|
<?= relative_time($status->published_at) ?>
|
||||||
itemprop="published"
|
|
||||||
datetime="<?= $status->published_at->format(DateTime::ATOM) ?>"
|
|
||||||
title="<?= $status->published_at ?>"
|
|
||||||
><?= lang('Common.mediumDate', [$status->published_at]) ?></time>
|
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
@ -59,13 +59,7 @@
|
|||||||
'text-gray-700',
|
'text-gray-700',
|
||||||
) ?>
|
) ?>
|
||||||
<div class="mb-4 text-xs">
|
<div class="mb-4 text-xs">
|
||||||
<time pubdate datetime="<?= $episode->published_at->format(
|
<?= relative_time($episode->published_at) ?>
|
||||||
DateTime::ATOM,
|
|
||||||
) ?>" title="<?= $episode->published_at ?>">
|
|
||||||
<?= lang('Common.mediumDate', [
|
|
||||||
$episode->published_at,
|
|
||||||
]) ?>
|
|
||||||
</time>
|
|
||||||
<span class="mx-1">•</span>
|
<span class="mx-1">•</span>
|
||||||
<time datetime="PT<?= $episode->audio_file_duration ?>S">
|
<time datetime="PT<?= $episode->audio_file_duration ?>S">
|
||||||
<?= format_duration($episode->audio_file_duration) ?>
|
<?= format_duration($episode->audio_file_duration) ?>
|
||||||
|
@ -59,13 +59,7 @@
|
|||||||
'text-gray-700',
|
'text-gray-700',
|
||||||
) ?>
|
) ?>
|
||||||
<div class="mb-4 text-xs">
|
<div class="mb-4 text-xs">
|
||||||
<time pubdate datetime="<?= $episode->published_at->format(
|
<?= relative_time($episode->published_at) ?>
|
||||||
DateTime::ATOM,
|
|
||||||
) ?>" title="<?= $episode->published_at ?>">
|
|
||||||
<?= lang('Common.mediumDate', [
|
|
||||||
$episode->published_at,
|
|
||||||
]) ?>
|
|
||||||
</time>
|
|
||||||
<span class="mx-1">•</span>
|
<span class="mx-1">•</span>
|
||||||
<time datetime="PT<?= $episode->audio_file_duration ?>S">
|
<time datetime="PT<?= $episode->audio_file_duration ?>S">
|
||||||
<?= format_duration($episode->audio_file_duration) ?>
|
<?= format_duration($episode->audio_file_duration) ?>
|
||||||
|
11
package-lock.json
generated
11
package-lock.json
generated
@ -12,6 +12,7 @@
|
|||||||
"@amcharts/amcharts4": "^4.10.20",
|
"@amcharts/amcharts4": "^4.10.20",
|
||||||
"@amcharts/amcharts4-geodata": "^4.1.21",
|
"@amcharts/amcharts4-geodata": "^4.1.21",
|
||||||
"@github/markdown-toolbar-element": "^1.5.1",
|
"@github/markdown-toolbar-element": "^1.5.1",
|
||||||
|
"@github/time-elements": "^3.1.2",
|
||||||
"@popperjs/core": "^2.9.2",
|
"@popperjs/core": "^2.9.2",
|
||||||
"@vime/core": "^5.0.33",
|
"@vime/core": "^5.0.33",
|
||||||
"choices.js": "^9.0.1",
|
"choices.js": "^9.0.1",
|
||||||
@ -1039,6 +1040,11 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@github/markdown-toolbar-element/-/markdown-toolbar-element-1.5.3.tgz",
|
"resolved": "https://registry.npmjs.org/@github/markdown-toolbar-element/-/markdown-toolbar-element-1.5.3.tgz",
|
||||||
"integrity": "sha512-fNgAuHBWWzqxMvkTMM7ijqPryLmnPVOi4OWp8YyUC74YgtJCRvQyL7gl9SzNLMXmGQxiRVIYbUJxa61X1oRObw=="
|
"integrity": "sha512-fNgAuHBWWzqxMvkTMM7ijqPryLmnPVOi4OWp8YyUC74YgtJCRvQyL7gl9SzNLMXmGQxiRVIYbUJxa61X1oRObw=="
|
||||||
},
|
},
|
||||||
|
"node_modules/@github/time-elements": {
|
||||||
|
"version": "3.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@github/time-elements/-/time-elements-3.1.2.tgz",
|
||||||
|
"integrity": "sha512-YVtZVLBikP6I7na22kfB9PKIseISwX41MFJ7lPuNz1VVH2IR5cpRRU6F1X6kcchPChljuvMUR4OiwMWHOJQ8kQ=="
|
||||||
|
},
|
||||||
"node_modules/@humanwhocodes/config-array": {
|
"node_modules/@humanwhocodes/config-array": {
|
||||||
"version": "0.5.0",
|
"version": "0.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.5.0.tgz",
|
||||||
@ -20246,6 +20252,11 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@github/markdown-toolbar-element/-/markdown-toolbar-element-1.5.3.tgz",
|
"resolved": "https://registry.npmjs.org/@github/markdown-toolbar-element/-/markdown-toolbar-element-1.5.3.tgz",
|
||||||
"integrity": "sha512-fNgAuHBWWzqxMvkTMM7ijqPryLmnPVOi4OWp8YyUC74YgtJCRvQyL7gl9SzNLMXmGQxiRVIYbUJxa61X1oRObw=="
|
"integrity": "sha512-fNgAuHBWWzqxMvkTMM7ijqPryLmnPVOi4OWp8YyUC74YgtJCRvQyL7gl9SzNLMXmGQxiRVIYbUJxa61X1oRObw=="
|
||||||
},
|
},
|
||||||
|
"@github/time-elements": {
|
||||||
|
"version": "3.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@github/time-elements/-/time-elements-3.1.2.tgz",
|
||||||
|
"integrity": "sha512-YVtZVLBikP6I7na22kfB9PKIseISwX41MFJ7lPuNz1VVH2IR5cpRRU6F1X6kcchPChljuvMUR4OiwMWHOJQ8kQ=="
|
||||||
|
},
|
||||||
"@humanwhocodes/config-array": {
|
"@humanwhocodes/config-array": {
|
||||||
"version": "0.5.0",
|
"version": "0.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.5.0.tgz",
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
"@amcharts/amcharts4-geodata": "^4.1.21",
|
"@amcharts/amcharts4-geodata": "^4.1.21",
|
||||||
"@amcharts/amcharts4": "^4.10.20",
|
"@amcharts/amcharts4": "^4.10.20",
|
||||||
"@github/markdown-toolbar-element": "^1.5.1",
|
"@github/markdown-toolbar-element": "^1.5.1",
|
||||||
|
"@github/time-elements": "^3.1.2",
|
||||||
"@popperjs/core": "^2.9.2",
|
"@popperjs/core": "^2.9.2",
|
||||||
"@vime/core": "^5.0.33",
|
"@vime/core": "^5.0.33",
|
||||||
"choices.js": "^9.0.1",
|
"choices.js": "^9.0.1",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user