added taggy things and also the date
This commit is contained in:
parent
3026a78ae0
commit
f58a8dfb8f
5
blogalba
5
blogalba
|
@ -41,9 +41,11 @@ sub readpost {
|
|||
$postm{body} = markdown($postb); undef $postb;
|
||||
if (defined $postm{date}) {
|
||||
$postm{slug} = slugify($postm{title}) unless $postm{slug}; #we allow custom slugs to be defined
|
||||
$postm{hastags} = (defined $postm{tags} and length $postm{tags})? 1 : 0;
|
||||
$postm{excerpt} = $1 if $postm{body} =~ /(<p>.*?<\/p>)/s;
|
||||
$postm{time} = str2time($postm{date});
|
||||
$postm{datetime} = timefmt($postm{date},'datetime');
|
||||
$postm{fancy} = timefmt($postm{time},'fancydate');
|
||||
$postm{permaurl} = $blog->{url}.$blog->{posturlprepend}.timefmt($postm{time},'permalink').$postm{slug};
|
||||
}
|
||||
push @posts,{%postm} if $psh==1; push @pages,{%postm} if $psh==2;return %postm;
|
||||
|
@ -60,6 +62,8 @@ sub slugify {
|
|||
sub timefmt {
|
||||
my ($epoch,$context)=@_;
|
||||
$epoch=str2time $epoch if $context eq 'readpost' or $context eq 'datetime';
|
||||
my $dsuffix = 'th'; $dsuffix = 'st' if strftime("%d",localtime $epoch) eq '01'; $dsuffix = 'nd' if strftime("%d",localtime $epoch) eq '02';
|
||||
return strftime "%A, %e$dsuffix %b. %Y", localtime $epoch if $context eq 'fancydate';
|
||||
return strftime "%Y-%m-%dT%H:%M%z",localtime $epoch if $context eq 'datetime';
|
||||
return strftime "%Y-%m",localtime $epoch if $context eq 'writepost';
|
||||
return strftime "%Y/%m/",localtime $epoch if $context eq 'permalink';
|
||||
|
@ -145,6 +149,7 @@ set server => '127.0.0.1';
|
|||
set port => 42069;
|
||||
|
||||
hook 'before' => sub {
|
||||
do_cache;
|
||||
page_init;
|
||||
};
|
||||
|
||||
|
|
|
@ -50,9 +50,10 @@
|
|||
<ul class="nav nav-stacked">
|
||||
<TMPL_IF NAME="ISPOST">
|
||||
<li><h3 class="highlight">This Post</h3></li>
|
||||
[% use date %][% dsuffix = 'th' %][% dsuffix = 'st' if page.day == 01 %][% dsuffix = 'nd' if page.day == 02 %]
|
||||
<li>Published: [% date.format(page.date, "%A, %e$dsuffix %b. %Y", 'en_GB', 1) %]</li>
|
||||
<li>Tags: [% page.tags %]</li>
|
||||
<li>Published: <TMPL_VAR NAME="fancy"></li>
|
||||
<TMPL_IF NAME="HASTAGS">
|
||||
<li>Tags: <TMPL_VAR NAME="tags"></li>
|
||||
</TMPL_IF>
|
||||
</TMPL_IF>
|
||||
<li><h3 class="highlight">Posts</h3></li>
|
||||
<TMPL_LOOP NAME="recent">
|
||||
|
|
Loading…
Reference in New Issue