Commit a95d7eb7 authored by Luc Didry's avatar Luc Didry

Add opengraph tags + toot pages

+ update deps
+ include publish_changelog and pouet_it_from_ci gitlab-ci.yml
parent 35ab6065
Pipeline #169327 passed with stages
in 1 minute and 23 seconds
image: hatsoftwares/last:latest
stages:
- publish_changelog
- pouet_it
- pages
pages:
stage: pages
cache:
key: "last_cache"
untracked: true
......@@ -10,7 +15,7 @@ pages:
- rm -rf public
- if [[ -d last ]]; then rm -rf last/; fi
- for i in themes/*; do if [[ $i != 'themes/default' ]]; then cp -r $i last/themes; fi; done
- git clone https://framagit.org/luc/last
- git clone https://framagit.org/luc/last.git
- cp last.conf last/
- if [[ -d local ]]; then mv local last; fi
- if [[ -d cache ]]; then mv cache last; fi
......@@ -24,3 +29,10 @@ pages:
- public
only:
- master
### Publish tag changelog and create a toot
##
#
include:
- 'https://framagit.org/fiat-tux/gitlabci-snippets/raw/4e4e03322e95e9b0124c714456ebf1bdc02ad43f/publish_changelog.gitlab-ci.yml'
- 'https://framagit.org/fiat-tux/gitlabci-snippets/raw/4e4e03322e95e9b0124c714456ebf1bdc02ad43f/pouet-it-from-ci.gitlab-ci.yml'
Revision history for Last
0.6.1 2018-03-07
0.7.0 2019-09-24
- Update dependencies
- Add opengraph tags
- Add toot pages (one page per toot)
0.6.1 2018-03-07
- Fix bug in atom feed article ids
0.6.0 2018-03-07
0.6.0 2018-03-07
- Allow to merge multiple toots
- Allow to modify the content of the toot through a custom module
0.5.0 2017-12-31
0.5.0 2017-12-31
- Change CI to use the latest upstream version of Last
0.4.0 2017-10-19
0.4.0 2017-10-19
- Add timezone choice
0.3.0 2017-09-30
0.3.0 2017-09-30
- Add Markdown support (need Pandoc to work)
0.2.0 2017-09-24
0.2.0 2017-09-24
- Use API to fetch toots
- Video attachments handling
- Add attachments cache
0.1.2 2017-09-15
0.1.2 2017-09-15
- Support images on different hosts than the Mastodon pod
0.1.1 2017-06-13
0.1.1 2017-06-13
- Remove warning if no license chosen in configuration
0.1 2017-06-13
0.1 2017-06-13
- HTML page generation
- Atom feed
- Epub generation
......
......@@ -40,10 +40,11 @@ my $ua = Mojo::UserAgent->new();
my $config = $m->plugin(Config => {
file => File::Spec->catfile($Bin, 'last.conf'),
default => {
theme => 'default',
sort => 1,
license => '',
markdown => 0,
theme => 'default',
sort => 1,
license => '',
markdown => 0,
description => '',
}
});
my $theme = $config->{theme};
......@@ -183,7 +184,7 @@ $file->spurt(encode('UTF-8', $index));
my $en = c(@entries);
$en = $en->reverse unless $config->{reverse};
my $max = ($en->size < 20) ? $en->size -1 : 19;
$en = $en->slice(0 .. $max);
$en = c(@{$en->to_array}[0 .. $max]);
$en->each(
sub {
my ($e, $num) = @_;
......@@ -243,6 +244,9 @@ unless ($zip->writeToFileNamed('public/'.slugify($config->{title}).'.epub') == A
rmtree('public/epub') unless $ENV{LAST_DEBUG};
sub open_index {
my $page = shift // '/index.html';
my $description = shift;
my $file = Mojo::File->new("$Bin/themes/$theme/index.html");
my $index = Mojo::DOM->new(decode('UTF-8', $file->slurp));
$index->find('html')
......@@ -251,9 +255,32 @@ sub open_index {
$index->find('title')
->first
->content($config->{title});
$index->find('meta[name="description"]')
->first
->attr(content => $config->{description});
$index->find('meta[name="author"]')
->first
->attr(content => $config->{author});
$index->find('meta[property="og:title"]')
->first
->attr(content => $config->{title});
my $public_url = $config->{public_url};
$public_url =~ s#/$##;
$index->find('meta[property="og:url"]')
->first
->attr(content => $public_url.$page);
$index->find('meta[property="og:image"]')
->first
->attr(content => $public_url.'/img/favicon.png');
if ($description) {
$index->find('meta[property="og:description"]')
->first
->attr(content => $description);
} else {
$index->find('meta[property="og:description"]')
->first
->remove;
}
$index->find('link[rel="alternate"]')
->first
->attr(href => $url->path($url->path->merge('feed.atom'))->to_string);
......@@ -507,10 +534,34 @@ sub format_and_insert_toot {
my ($content, $i, $date, $time, $attachments, $id, $dt, $num, $attachments2) = @_;
$content =~ s#<p></p>|</br>##g;
$content =~ s#<br>#<br />#g;
my $append = "\n <article><a href=\"#$id\"><h3 id=\"$id\">$date <span style=\"font-size: 0.5em;\">$time</span></h3></a>$content$attachments<div><a href=\"$i\"><em>Source</em></a></div></article><hr>\n";
my $append = <<EOF;
<article>
<a href="$id.html">
<h2>$date <span style="font-size: 0.5em;">$time</span></h2>
</a>
$content
$attachments
<div>
<a href="$i">
<em>Source</em>
</a>
</div>
</article>
<hr>
EOF
## Insert the toot
$c->append_content($append);
## Toot page
my $description = Mojo::DOM->new($content)->all_text;
my $tpindex = open_index('/'.$id.'.html', $description);
my $tpc = $tpindex->find('#content')->first;
$tpc->append_content($append);
Mojo::File->new("public/$id.html")->spurt(encode('UTF-8', $tpindex));
## Paginate
if ($pagination && (($num % $pagination) == 0 || ($num == $urls->size))) {
my $prec = ($page == 2) ? 'index' : 'page'.($page - 1);
......@@ -529,7 +580,7 @@ sub format_and_insert_toot {
$file->spurt(encode('UTF-8', $index));
$file = Mojo::File->new("public/page$page.html");
$index = open_index();
$index = open_index('/page'.$page.'.html');
$c = $index->find('#content')->first;
$c->append_content(" <p><a href=\"".slugify($config->{title}).".epub\">Epub</a></p>\n");
}
......
This diff is collapsed.
......@@ -3,7 +3,7 @@
## Mandatory, your name
author => 'Luc Didry',
## Mandatory, the title of the page and the epub
title => 'Last: Let\'s Aggregate Superb Toots',
title => 'Last: Lets Aggregate Superb Toots',
## Mandatory, language of the toots
language => 'fr',
## Optional, sort the toots' list before fetching them
......
......@@ -3,8 +3,13 @@
<head>
<meta charset="utf-8">
<title>Your page title here :)</title>
<meta name="description" content="">
<meta name="author" content="">
<meta name="description" content="">
<meta name="author" content="">
<meta property="og:title" content="" />
<meta property="og:type" content="website" />
<meta property="og:url" content="" />
<meta property="og:image" content="/img/favicon.png" />
<meta property="og:description" content="" />
<meta name="viewport" content="width=device-width, initial-scale=1">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment