Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Adam Matoušek
BLO👏GÍ👏SEK
Commits
970382e3
Verified
Commit
970382e3
authored
Oct 15, 2022
by
Adam Matoušek
Browse files
List newest comments in the sidebar
parent
35610bab
Changes
5
Hide whitespace changes
Inline
Side-by-side
gib/main
View file @
970382e3
...
...
@@ -103,6 +103,7 @@ use transient
out generate navigation
dep templates/nav.tt
dep index
dep _comment_index
cmd $(tool) mknav
out nav.html
...
...
resources/style.css
View file @
970382e3
...
...
@@ -149,7 +149,16 @@ a:hover {
}
#navigation
li
{
list-style
:
none
;
line-height
:
2
;
line-height
:
1.6
;
overflow-wrap
:
break-word
;
}
#navigation
li
+
li
{
margin-top
:
0.5em
;
}
#navigation
.extended
li
+
li
{
margin-top
:
1em
;
}
#navigation
li
header
{
}
#navigation
li
small
{
color
:
var
(
--c-weak
);
...
...
templates/nav.tt
View file @
970382e3
...
...
@@ -7,9 +7,24 @@
<header>Škatulky</header>
[%- INCLUDE archive a=categories %]
</nav>
<nav id=latest>
<nav id=latest-comments>
<header>Nové komentáře</header>
<menu class=extended>
[%- FOREACH c IN comments %]
<li><div><a href='[% "$root/$c.article/#comment-$c.id" %]'><header>
[% c.author %]
</header>
<small>
→ <em>[% c.title %]</em><br>
<time datetime="[% isostamp(c.published) %]"> [%- datef(c.published) %]</time>
</small>
</a></div></li>
[%- END %]
</menu>
</nav>
<nav id=latest-articles>
<header>Poslední</header>
<menu>
<menu
class=extended
>
[%- FOREACH a IN latest %]
<li><div><a href="[% root %]/[% a.id %]"><header>[% a.title %]</header>
<small><time datetime="[% isostamp(a.published) %]">
...
...
tools/mkcomments
View file @
970382e3
...
...
@@ -33,7 +33,8 @@ for my $c ( sort { $a->{stamp} <=> $b->{stamp} } map load_comment($_), @commentf
else
{
push
@root_comments
,
$c
;
}
$index
.=
"
$article
\t
$c
->{id}
\n
";
$index
.=
join
"
\t
",
$article
,
@$c
{
qw/id stamp author/
};
$index
.=
"
\n
";
$comments
{
$c
->
{
id
}}
=
$c
;
}
$v
{
comments
}
=
\
@root_comments
;
...
...
tools/mknav
View file @
970382e3
...
...
@@ -8,18 +8,36 @@ use open qw/:std :encoding(utf-8)/;
use
lib
'
./tools
';
use
Blogisek
;
use
List::
Util
qw/min uniq/
;
use
File::
Slurper
qw/read_lines/
;
use
Time::
Piece
;
# Page index
my
@index
=
load_index
(
$ARGV
[
0
]
//
'
index
'
);
my
%categories
;
my
%years
;
my
%article_titles
;
foreach
(
@index
)
{
$categories
{
$_
->
{
category
}}
++
;
$years
{
$_
->
{
published
}
->
year
}
++
;
$article_titles
{
$_
->
{
id
}}
=
$_
->
{
title
};
}
# Comment index
my
@comment_index
;
for
my
$l
(
read_lines
(
"
$outdir
/_comment_index
"
)
)
{
my
%record
;
@record
{
qw/article id stamp author/
}
=
split
"
\t
",
$l
;
$record
{
published
}
=
localtime
$record
{
stamp
};
$record
{
title
}
=
$article_titles
{
$record
{
article
}};
push
@comment_index
,
\
%record
;
}
@comment_index
=
sort
{
$b
->
{
stamp
}
<=>
$a
->
{
stamp
}
}
@comment_index
;
my
%v
=
(
latest
=>
[
@index
[
0
..
min
(
2
,
$#index
)]
],
comments
=>
[
@comment_index
[
0
..
min
(
2
,
$#comment_index
)]
],
categories
=>
[
map
+
{
id
=>
$_
,
name
=>
"
/
$_
",
size
=>
$categories
{
$_
}
},
sort
keys
%categories
],
years
=>
[
map
+
{
id
=>
$_
,
name
=>
"
/
$_
",
size
=>
$years
{
$_
}
},
sort
{
$b
<=>
$a
}
keys
%years
],
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment