Add template for displaying a twitter-card compliant page

This commit is contained in:
Luc Didry
2014-02-14 15:08:47 +01:00
parent c3e15f44a1
commit 7e36a48bf6
5 changed files with 48 additions and 11 deletions
+16 -1
View File
@@ -202,6 +202,7 @@ sub startup {
$r->get('/:short' => sub {
my $c = shift;
my $short = $c->param('short');
my $touit = $c->param('t');
my $dl = (defined($c->param('dl'))) ? 'attachment' : 'inline';
my @images = LutimModel::Lutim->select('WHERE short = ? AND ENABLED = 1 AND path IS NOT NULL', $short);
@@ -222,7 +223,21 @@ sub startup {
);
return $c->redirect_to('/');
}
if($c->render_file($images[0]->filename, $images[0]->path, $images[0]->mediatype, $dl) != 500) {
my $test;
if (defined($touit)) {
$test = 1;
$c->render(
template => 'twitter',
layout => undef,
short => $images[0]->short,
filename => $images[0]->filename
);
} else {
$test = $c->render_file($images[0]->filename, $images[0]->path, $images[0]->mediatype, $dl);
}
if ($test != 500) {
# Update counter and check provisionning
$c->on(finish => sub {
# Log access
+5 -4
View File
@@ -24,13 +24,14 @@ my $inf_body = <<EOF;
EOF
our %Lexicon = (
'license' => 'License:',
'fork-me' => 'Fork me on Github !',
'share-twitter' => 'Share on Twitter',
'informations' => 'Informations',
'license' => 'License:',
'fork-me' => 'Fork me on Github !',
'share-twitter' => 'Share on Twitter',
'informations' => 'Informations',
'informations-body' => $inf_body,
'view-link' => 'View link:',
'download-link' => 'Download link:',
'twitter-link' => 'Link for put in a tweet:',
'some-bad' => 'Something bad happened',
'delete-first' => 'Delete at first view?',
'delete-day' => 'Delete after 24 hours?',
+1
View File
@@ -31,6 +31,7 @@ our %Lexicon = (
'informations-body' => $inf_body,
'view-link' => 'Lien d\'affichage :',
'download-link' => 'Lien de téléchargement :',
'twitter-link' => 'Lien pour mettre dans un tweet :',
'some-bad' => 'Un problème est survenu',
'delete-first' => 'Supprimer au premier accès ?',
'delete-day' => 'Supprimer après 24 heures ?',