mirror of
https://framagit.org/fiat-tux/hat-softwares/lutim.git
synced 2026-08-07 01:12:49 +02:00
Fixes #45 + Update README.md and Changelog
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
Revision history for Lutim
|
||||
|
||||
0.5 2014-09-24
|
||||
- Add support for animated gif in Twitter cards (#45)
|
||||
- Update README.md with Twitter integration informations
|
||||
- bugfixes
|
||||
|
||||
0.4 2014-07-12
|
||||
- Webapp ! Downloadable directly from the Lutim instance
|
||||
- Configure expiration delay after uploading (#12)
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
It means Let's Upload That Image.
|
||||
|
||||
## What does it do?
|
||||
It stores images and allows you to see them, download them or use them in Twitter.
|
||||
It stores images and allows you to see them, download them or use them in Twitter. From version 0.5, the gif images can be displayed as animated gifs in Twitter, but you need a HTTPS server (Twitter requires that. Lutim detects if you have a HTTPS server and displays an static image twitter card if you don't);
|
||||
|
||||
Images are indefinitly stored unless you request that they will be deleted at first view or after 24 hours / one week / one month / one year.
|
||||
|
||||
## License
|
||||
@@ -34,17 +35,21 @@ sudo apt-get install carton
|
||||
* But, on another hand, some modules that Carton will install need to be compiled. So you will need some tools:
|
||||
|
||||
```shell
|
||||
sudo apt-get install build-essential libssl-dev
|
||||
sudo apt-get install build-essential
|
||||
```
|
||||
|
||||
### Thumbnails dependancy
|
||||
If you want to provide thumbnails of uploaded images, you have to install the *ImageMagick* image manipulation software (<http://www.imagemagick.org/>) and the Image::Magick CPAN module.
|
||||
### Thumbnails and animated gifs in Twitter dependancy
|
||||
If you want to provide thumbnails of uploaded images or have animated gifs in Twitter, you have to install the *ImageMagick* image manipulation software (<http://www.imagemagick.org/>) and the Image::Magick CPAN module.
|
||||
|
||||
On Debian, you can do:
|
||||
```shell
|
||||
sudo apt-get install perlmagick
|
||||
```
|
||||
|
||||
## Twitter integration
|
||||
If you want to share images of your Lutim instance on Twitter, you have to register your site at <https://cards-dev.twitter.com/validator>.
|
||||
|
||||
|
||||
## Installation
|
||||
After installing Carton :
|
||||
```shell
|
||||
@@ -119,6 +124,17 @@ UPDATE SQLITE_MASTER SET SQL = 'CREATE TABLE lutim ( short TEXT PRIMARY KEY, pat
|
||||
PRAGMA writable_schema = 0;
|
||||
```
|
||||
|
||||
***Warning!!!***
|
||||
|
||||
If you want to update to Lutim **0.5**, from a previous version, you'll have to modify the database.
|
||||
|
||||
```
|
||||
sqlite3 lutim.db
|
||||
PRAGMA writable_schema = 1;
|
||||
UPDATE SQLITE_MASTER SET SQL = 'CREATE TABLE lutim ( short TEXT PRIMARY KEY, path TEXT, footprint TEXT, enabled INTEGER, mediatype TEXT, filename TEXT, counter INTEGER, delete_at_first_view INTEGER, delete_at_day INTEGER, created_at INTEGER, created_by TEXT, last_access_at INTEGER, mod_token TEXT, width INTEGER, height INTEGER)' WHERE NAME = 'lutim';
|
||||
PRAGMA writable_schema = 0;
|
||||
```
|
||||
|
||||
## Reverse proxy
|
||||
You can use a reverse proxy like Nginx or Varnish (or Apache with the mod_proxy module). The web is full of tutos.
|
||||
|
||||
|
||||
+29
-3
@@ -279,9 +279,13 @@ sub add {
|
||||
my $filename = unidecode($upload->filename);
|
||||
my $ext = ($filename =~ m/([^.]+)$/)[0];
|
||||
my $path = 'files/'.$records[0]->short.'.'.$ext;
|
||||
|
||||
my ($width, $height);
|
||||
if ($im_loaded) {
|
||||
my $im = Image::Magick->new;
|
||||
my $im = Image::Magick->new;
|
||||
$im->BlobToImage($upload->slurp);
|
||||
$width = $im->Get('width');
|
||||
$height = $im->Get('height');
|
||||
$im->Resize(geometry=>'x85');
|
||||
|
||||
$thumb = 'data:'.$mediatype.';base64,';
|
||||
@@ -301,7 +305,9 @@ sub add {
|
||||
delete_at_day => ($c->param('delete-day') && $c->param('delete-day') <= $c->max_delay) ? $c->param('delete-day') : $c->max_delay,
|
||||
delete_at_first_view => ($c->param('first-view')) ? 1 : 0,
|
||||
created_at => time(),
|
||||
created_by => $ip
|
||||
created_by => $ip,
|
||||
width => $width,
|
||||
height => $height
|
||||
);
|
||||
|
||||
# Log image creation
|
||||
@@ -413,11 +419,31 @@ sub short {
|
||||
$test = 1;
|
||||
my $short = $images[0]->short;
|
||||
$short .= '/'.$key if (defined($key));
|
||||
my ($width, $height) = (340,340);
|
||||
if ($images[0]->mediatype eq 'image/gif') {
|
||||
if (defined($images[0]->width) && defined($images[0]->height)) {
|
||||
($width, $height) = ($images[0]->width, $images[0]->height);
|
||||
} elsif ($im_loaded) {
|
||||
my $upload = $c->decrypt($key, $images[0]->path);
|
||||
my $im = Image::Magick->new;
|
||||
$im->BlobToImage($upload->slurp);
|
||||
$width = $im->Get('width');
|
||||
$height = $im->Get('height');
|
||||
|
||||
$images[0]->update(
|
||||
width => $width,
|
||||
height => $height
|
||||
);
|
||||
}
|
||||
}
|
||||
return $c->render(
|
||||
template => 'twitter',
|
||||
layout => undef,
|
||||
short => $short,
|
||||
filename => $images[0]->filename
|
||||
filename => $images[0]->filename,
|
||||
mimetype => ($c->req->url->to_abs()->scheme eq 'https') ? $images[0]->mediatype : '',
|
||||
width => $width,
|
||||
height => $height
|
||||
);
|
||||
} else {
|
||||
# Delete image if needed
|
||||
|
||||
+3
-1
@@ -20,7 +20,9 @@ use ORLite {
|
||||
created_at INTEGER,
|
||||
created_by TEXT,
|
||||
last_access_at INTEGER,
|
||||
mod_token TEXT)'
|
||||
mod_token TEXT,
|
||||
width INTEGER,
|
||||
height INTEGER)'
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1,17 +1,26 @@
|
||||
% # vim:set sw=4 ts=4 sts=4 ft=html.epl expandtab:
|
||||
<!DOCTYPE html>
|
||||
<html style="height:100%;">
|
||||
<html style="max-height:100%;">
|
||||
<head>
|
||||
<title>Lutim</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" type="image/png" href="<%= url_for('/')->to_abs() %>img/favicon.png">
|
||||
<link rel="icon" type="image/png" href="<%= url_for('index')->to_abs() %>img/favicon.png">
|
||||
% if ($mimetype eq 'image/gif') {
|
||||
<meta name="twitter:card" content="player">
|
||||
<meta name="twitter:image" content="<%= url_for('index')->to_abs().$short %>">
|
||||
<meta name="twitter:player" content="<%= url_for('index')->to_abs().$short.'?t' %>">
|
||||
<meta name="twitter:title" content="<%= $filename %>">
|
||||
<meta name="twitter:player:width" content="<%= $width %>">
|
||||
<meta name="twitter:player:height" content="<%= $height %>">
|
||||
% } else {
|
||||
<meta name="twitter:card" content="photo">
|
||||
% }
|
||||
<meta name="twitter:site" content="<%= config('tweet_card_via') %>">
|
||||
<meta name="twitter:image:src" content="<%= url_for('/')->to_abs().$short %>">
|
||||
<meta name="twitter:image:src" content="<%= url_for('index')->to_abs().$short %>">
|
||||
</head>
|
||||
<body style="height: 97%;">
|
||||
<img style="max-width:100%; max-height:100%;" src="<%= url_for('/').$short %>" alt="<%= $filename %>">
|
||||
<img style="max-width:100%; max-height:100%;" src="<%= url_for('index')->to_abs().$short %>" alt="<%= $filename %>">
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user