NAME
    Mojolicious::Plugin::Shotwell - View photos from Shotwell database

VERSION
    0.03

SYNOPSIS
      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

DESCRIPTION
    This plugin provides actions which can render data from a Shotwell
    <http://www.yorba.org/projects/shotwell> database:

    *   Events

        See "events" and "event".

    *   Tags

        See "tags" and "tag".

    *   Thumbnails

        See "thumb".

    *   Photos

        See "show" and "raw".

ATTRIBUTES
  cache_dir
    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' });

  dsn
    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:

      $self->register($app, { dbname => $path_to_db_file });

  sizes
    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], ... } });

ACTIONS
  events
    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.

  event
    Default route: "/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".

    JSON data:

      [
        {
          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.

  permalink
    Default route: "/:permalink".

    Will either render the same as "show" or "event", dependent on the type
    of permalink.

  permalink_delete
    Default route: "/:permalink/delete".

    Used to delete a permalink from backend.

  tags
    Default route: "/tags".

    Render data from TagTable. Data is rendered as JSON or defaults to a
    template by the name "templates/shotwell/tags.html.ep".

    JSON data:

      [
        {
          name => $str,
          url => $shotwell_tag_url,
        },
        ...
      ]

    The JSON data is also available in the template as $tags.

  tag
    Default route: "/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".

  raw
    Default route: "/raw/:id/*basename".

    Render raw photo.

  show
    Default route: "/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.

  thumb
    Default route: "/thumb/:id/*basename".

    Render photo as a thumbnail.

HELPERS
  shotwell_access_granted
      $bool = $c->shotwell_access_granted;

    Returns true if the session contains a valid permalink id.

METHODS
  register
      $self->register($app, \%config);

    Set "ATTRIBUTES" and register "ACTIONS" in the Mojolicious application.

DATABASE SCHEME
  EventTable
      id INTEGER PRIMARY KEY,
      name TEXT,
      primary_photo_id INTEGER,
      time_created INTEGER,primary_source_id TEXT,
      comment TEXT

  PhotoTable
      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

  TagTable
      id INTEGER PRIMARY KEY,
      name TEXT UNIQUE NOT NULL,
      photo_id_list TEXT,
      time_created INTEGER

AUTHOR
    Jan Henning Thorsen - "jhthorsen@cpan.org"

