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 deletions
—
download
Diffstat
Diff options
+16/-5
M date.php
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
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
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
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
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
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
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
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
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
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
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
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 ();
|