home » zplus/freepost.git
Author Nichlas Severinsen <nicsev@arkivverket.no> 2018-05-31 13:05:38
Committer Nichlas Severinsen <nicsev@arkivverket.no> 2018-05-31 13:05:38
Commit dff39df (patch)
Tree 54aa6f3
Parent(s)

Fix #73; add time tag


commits diff: fbc24e7..dff39df
12 files changed, 35 insertions, 15 deletionsdownload


Diffstat
-rwxr-xr-x date.php 21
-rwxr-xr-x template/comment.twig 2
-rwxr-xr-x template/edit_comment.twig 2
-rwxr-xr-x template/edit_post.twig 2
-rwxr-xr-x template/index.twig 2
-rwxr-xr-x template/post.twig 2
-rwxr-xr-x template/reply.twig 2
-rwxr-xr-x template/search.twig 2
-rwxr-xr-x template/user_comments.twig 2
-rwxr-xr-x template/user_posts.twig 2
-rwxr-xr-x template/user_replies.twig 2
-rwxr-xr-x twig.php 9

Diff options
View
Side
Whitespace
Context lines
Inter-hunk lines
+16/-5 M   date.php
index 41ff87e..68fd811
old size: 817B - new size: 1K
@@ -17,16 +17,27 @@ class Date
17 17 60 => 'minute',
18 18 1 => 'second');
19 19
20 - foreach ($condition as $secs => $str)
20 + foreach ($condition as $secs => $secs_as_str)
21 21 {
22 - $d = $estimate_time / $secs;
22 + $time_ago = $estimate_time / $secs;
23 23
24 - if ($d >= 1)
24 + if ($time_ago >= 1)
25 25 {
26 - $r = round ($d);
27 - return $r . ' ' . $str . ($r > 1 ? 's' : '') . ' ago';
26 + $rounded_time = round ($time_ago);
27 + return $rounded_time . ' ' . $secs_as_str . ($rounded_time > 1 ? 's' : '') . ' ago';
28 28 }
29 29 }
30 30 }
31 +
32 + public static function datetime ($datetime)
33 + {
34 + return date("Y-m-d\TH:i:s", $datetime);
35 + }
36 +
37 + public static function title ($datetime)
38 + {
39 + return date("M\\ j,\\ Y,\\ g:s\\ A\\ e", $datetime);
40 + }
41 +
31 42 }
32 43

+1/-1 M   template/comment.twig
index 4914c26..477e8c7
old size: 2K - new size: 2K
@@ -22,7 +22,7 @@
22 22 %}
23 23
24 24 {# DateTime #}
25 - <a href="{{ ('post/' ~ post.hashId ~ '#comment-' ~ comment.hashId)|docroot }}"><em>{{ comment.created|ago }}</em></a>
25 + <a href="{{ ('post/' ~ post.hashId ~ '#comment-' ~ comment.hashId)|docroot }}"><time title="{{ comment.created|title }}" datetime="{{ comment.created|datetime }}"><em> {{ comment.created|ago }} </em></time></a>
26 26
27 27 {% if user %}
28 28

+1/-1 M   template/edit_comment.twig
index 703c772..1b9d17e
old size: 978B - new size: 1K
@@ -7,7 +7,7 @@
7 7
8 8 <div class="info">
9 9 by <a href="{{ ('user/' ~ item.data.username|url_encode)|docroot }}">{{ item.data.username }}</a>
10 - <em>{{ item.data.created|ago }}</em>
10 + <time title="{{ item.data.created|title }}" datetime="{{ item.data.created|datetime }}"><em> {{ item.data.created|ago }} </em></time>
11 11 </div>
12 12
13 13 <div style="margin: 2em 0;">

+1/-1 M   template/edit_post.twig
index e88954e..4bd3a28
old size: 1K - new size: 1K
@@ -13,7 +13,7 @@
13 13 </div>
14 14 <div class="info">
15 15 by <a href="{{ ('user/' ~ item.data.username|url_encode)|docroot }}">{{ item.data.username }}</a>
16 - <em>{{ item.data.created|ago }}</em>
16 + <time title="{{ item.data.created|title }}" datetime="{{ item.data.created|datetime }}"><em> {{ item.data.created|ago }} </em></time>
17 17 </div>
18 18
19 19 <h3>Link</h3>

+1/-1 M   template/index.twig
index 359a019..45fb764
old size: 2K - new size: 2K
@@ -52,7 +52,7 @@ _\(/_ .:.*_\/_* : /\ :
52 52 } only
53 53 %}
54 54
55 - <em><a href="post/{{ post.hashId }}">{{ post.created|ago }}</a></em>
55 + <em><a href="post/{{ post.hashId }}"><time title="{{ post.created|title }}" datetime="{{ post.created|datetime }}"> {{ post.created|ago }} </time></em>
56 56 by <a href="{{ ('user/' ~ post.username|url_encode)|docroot }}">{{ post.username }}</a>
57 57
58 58 <a href="post/{{ post.hashId }}#comments">{{ post.commentsCount ? post.commentsCount }} comments</a>

+1/-1 M   template/post.twig
index 6e60c4f..9c18577
old size: 2K - new size: 2K
@@ -23,7 +23,7 @@
23 23 } only
24 24 %}
25 25
26 - by <a href="{{ ('user/' ~ post.username|url_encode)|docroot }}">{{ post.username }}</a> <em>{{ post.created|ago }}</em>
26 + by <a href="{{ ('user/' ~ post.username|url_encode)|docroot }}">{{ post.username }}</a><time title="{{ post.created|title }}" datetime="{{ post.created|datetime }}"><em> {{ post.created|ago }} </em></time>
27 27 — {{ post.vote }} votes, <a href="#comments">{{ post.commentsCount }} comments</a>
28 28
29 29 {% if user and post.userId == user.id %}

+1/-1 M   template/reply.twig
index 7ff15fe..46cc10c
old size: 1K - new size: 1K
@@ -4,7 +4,7 @@
4 4 <h3>Reply to <em><a href="{{ ('user/' ~ comment.username|url_encode)|docroot }}">{{ comment.username }}</a></em></h3>
5 5
6 6 <div class="info">
7 - posted <em><a href="{{ 'post/'|docroot ~ comment.postHashId }}#comment-{{ comment.hashId }}">{{ comment.created|ago }}</a></em>
7 + posted <em><a href="{{ 'post/'|docroot ~ comment.postHashId }}#comment-{{ comment.hashId }}"><time title="{{ post.created|title }}" datetime="{{ post.created|datetime }}"> {{ comment.created|ago }} </time></a></em>
8 8 on <a href="{{ ('post/' ~ comment.postHashId)|docroot }}">{{ comment.postTitle }}</a>
9 9 </div>
10 10

+1/-1 M   template/search.twig
index 99ac99c..bb8a093
old size: 1K - new size: 1K
@@ -18,7 +18,7 @@
18 18 </div>
19 19
20 20 <div class="info">
21 - <em><a href="post/{{ post.hashId }}">{{ post.created|ago }}</a></em>
21 + <em><a href="post/{{ post.hashId }}"><time title="{{ post.created|title }}" datetime="{{ post.created|datetime }}"> {{ post.created|ago }}</time></a></em>
22 22 by <a href="{{ ('user/' ~ post.username|url_encode)|docroot }}">{{ post.username }}</a>
23 23
24 24 <a href="post/{{ post.hashId }}#comments">{{ post.commentsCount ? post.commentsCount }} comments</a>

+1/-1 M   template/user_comments.twig
index bf8097c..96e9d4c
old size: 592B - new size: 685B
@@ -11,7 +11,7 @@
11 11 <div class="info">
12 12 <a href="../post/{{ comment.postHashId }}#comment-{{ comment.hashId }}">read</a>
13 13
14 - <em>{{ comment.created|ago }}</em> on <a href="../post/{{ comment.postHashId }}">{{ comment.postTitle }}</a>
14 + <time title="{{ comment.created|title }}" datetime="{{ comment.created|datetime }}"><em> {{ comment.created|ago }} </em></time> on <a href="../post/{{ comment.postHashId }}">{{ comment.postTitle }}</a>
15 15 </div>
16 16 </div>
17 17

+1/-1 M   template/user_posts.twig
index ed7184a..b5967db
old size: 813B - new size: 900B
@@ -19,7 +19,7 @@
19 19 {# Post info #}
20 20 <div class="info">
21 21 {{ post.vote }} votes,
22 - <em>{{ post.created|ago }}</em>
22 + <time title="{{ post.created|title }}" datetime="{{ post.created|datetime }}"><em> {{ post.created|ago }} </em></time>
23 23
24 24 <a href="../post/{{ post.hashId }}">{{ post.commentsCount }} comments</a>
25 25 </div>

+1/-1 M   template/user_replies.twig
index 71a252a..aabafe9
old size: 747B - new size: 840B
@@ -12,7 +12,7 @@
12 12 <a href="../post/{{ comment.postHashId }}#comment-{{ comment.hashId }}">read</a>
13 13 <a href="../reply?comment={{ comment.hashId }}">reply</a>
14 14
15 - by <a href="../user/{{ comment.username|url_encode }}">{{ comment.username }}</a> <em>{{ comment.created|ago }}</em> on <a href="../post/{{ comment.postHashId }}">{{ comment.postTitle }}</a>
15 + by <a href="../user/{{ comment.username|url_encode }}">{{ comment.username }}</a> <time title="{{ comment.created|title }}" datetime="{{ comment.created|datetime }}"><em> {{ comment.created|ago }} </em></time> on <a href="../post/{{ comment.postHashId }}">{{ comment.postTitle }}</a>
16 16 </div>
17 17 </div>
18 18

+9/-0 M   twig.php
index f69390d..9ea3f83
old size: 2K - new size: 2K
@@ -31,6 +31,15 @@ $twig->addFilter ('ago', new Twig_Filter_Function (function ($datetime) {
31 31 return Date::ago (strtotime ($datetime));
32 32 }));
33 33
34 + $twig->addFilter ('datetime', new Twig_Filter_Function (function ($datetime) {
35 + return Date::datetime (strtotime ($datetime));
36 + }));
37 +
38 + $twig->addFilter ('title', new Twig_Filter_Function (function ($datetime) {
39 + return Date::title (strtotime ($datetime));
40 + }));
41 +
42 +
34 43 // Format Markdown to HTML
35 44 $twig->addFilter ('markdown', new Twig_Filter_Function(function ($markdown) {
36 45 $parsedown = new Parsedown ();