Mojolicious::Plugin::Shotwell - View photos from Shotwell database
0.05
use Mojolicious::Lite; # allow /shotwell/... resources to be protected by login my $protected = under '/shotwell' => sub { my $c = shift; return 1 if $c->session('username') or $c->shotwell_access_granted; $c->render('login'); return 0; }; plugin shotwell => { dbname => '/home/username/.local/share/shotwell/data/photo.db', routes => { default => $protected, permalink => app->routes->get('/:permalink'), # not protected } }; app->start;
This module can also be tested from command line if you have the defaults set up:
$ perl -Mojo -e'plugin "shotwell"; app->start' daemon
This plugin provides actions which can render data from a Shotwell database:
Events
See "events" and "event".
Tags
See "tags" and "tag".
Thumbnails
See "thumb".
Photos
See "show" and "raw".
Path to where all the scaled/rotated images gets stored. Defaults to "/tmp/shotwell". This can be overridden in "register":
$self->register($app, { cache_dir => '/some/path' });
Returns argument for "connect" in DBI. Default is
dbi:SQLite:dbname=$HOME/.local/share/shotwell/data/photo.db
$HOME is the HOME environment variable. The default dsn can be overridden by either giving "dsn" or "dbname" to "register". Example:
$HOME
HOME
$self->register($app, { dbname => $path_to_db_file });
The size of the photos generated by "raw" and "thumb". Default is:
{ inline => [ 1024, 0 ], # 0 = scale thumb => [ 100, 100 ], }
This can be overridden in "register":
$self->register($app, { sizes => { thumb => [200, 200], ... } });
Default route: /.
/
Render data from EventTable. Data is rendered as JSON or defaults to a template by the name "templates/shotwell/events.html.ep".
JSON data:
[ { id => $int, name => $str, time_created => $epoch, url => $shotwell_event_url, }, ... ]
The JSON data is also available in the template as $events.
$events
Default route: /event/:id/:name.
/event/:id/:name
Render photos from PhotoTable, by a given event id. Data is rendered as JSON or defaults to a template by the name "templates/shotwell/event.html.ep".
[ { id => $int, size => $int, title => $str, raw => $shotwell_raw_url, thumb => $shotwell_thumb_url, url => $shotwell_show_url, }, ... ]
The JSON data is also available in the template as $photos.
$photos
Default route: /:permalink.
/:permalink
Will either render the same as "show" or "event", dependent on the type of permalink.
Default route: /:permalink/delete.
/:permalink/delete
Used to delete a permalink from backend.
Default route: /tags.
/tags
Render data from TagTable. Data is rendered as JSON or defaults to a template by the name "templates/shotwell/tags.html.ep".
[ { name => $str, url => $shotwell_tag_url, }, ... ]
The JSON data is also available in the template as $tags.
$tags
Default route: /tag/:name.
/tag/:name
Render photos from PhotoTable, by a given tag name. Data is rendered as JSON or defaults to a template by the name "templates/shotwell/tag.html.ep".
The JSON data is the same as for "event".
Default route: /raw/:id/*basename.
/raw/:id/*basename
Render raw photo.
Default route: /show/:id/*basename.
/show/:id/*basename
Render a template with an photo inside. The name of the template is "templates/shotwell/show.html.ep".
The stash data is the same as one element described for "event" JSON data.
Default route: /thumb/:id/*basename.
/thumb/:id/*basename
Render photo as a thumbnail.
$bool = $c->shotwell_access_granted;
Returns true if the session contains a valid permalink id.
$self->register($app, \%config);
Set "ATTRIBUTES" and register "ACTIONS" in the Mojolicious application.
id INTEGER PRIMARY KEY, name TEXT, primary_photo_id INTEGER, time_created INTEGER,primary_source_id TEXT, comment TEXT
id INTEGER PRIMARY KEY, filename TEXT UNIQUE NOT NULL, width INTEGER, height INTEGER, filesize INTEGER, timestamp INTEGER, exposure_time INTEGER, orientation INTEGER, original_orientation INTEGER, import_id INTEGER, event_id INTEGER, transformations TEXT, md5 TEXT, thumbnail_md5 TEXT, exif_md5 TEXT, time_created INTEGER, flags INTEGER DEFAULT 0, rating INTEGER DEFAULT 0, file_format INTEGER DEFAULT 0, title TEXT, backlinks TEXT, time_reimported INTEGER, editable_id INTEGER DEFAULT -1, metadata_dirty INTEGER DEFAULT 0, developer TEXT, develop_shotwell_id INTEGER DEFAULT -1, develop_camera_id INTEGER DEFAULT -1, develop_embedded_id INTEGER DEFAULT -1, comment TEXT
id INTEGER PRIMARY KEY, name TEXT UNIQUE NOT NULL, photo_id_list TEXT, time_created INTEGER
Jan Henning Thorsen - jhthorsen@cpan.org
jhthorsen@cpan.org
To install Mojolicious::Plugin::Shotwell, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojolicious::Plugin::Shotwell
CPAN shell
perl -MCPAN -e shell install Mojolicious::Plugin::Shotwell
For more information on module installation, please visit the detailed CPAN module installation guide.