photish 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 86c9bceeb05e4c52b9e06582cf5d47332d7338c1
4
- data.tar.gz: 9f69c399a197274f8383c927ff7be19f08915080
3
+ metadata.gz: c712dc33fcb4d3676a75f2d0db5ff195d262dda8
4
+ data.tar.gz: 079592c5851be9fc41fe1ac3303140f518189b62
5
5
  SHA512:
6
- metadata.gz: 174364ba192d4f23e91ae45fd6cb26741e1806f15b27f5a6f20dfa1ab285e71e4ea01eb6dd7b65f0ce635beaeb1f2f208b16ef8697e600c32f505dd1af96d6a3
7
- data.tar.gz: a0002e4bd187e082e354e0135b787eb05f24a14cab3197dc48bd815d0278565b0da81d68eb721940a363c1ce4cb0fe3adebeb0cb450b11171d519afdae636e97
6
+ metadata.gz: 387946be6d365bbd64b5a4890e07177f9ec4d2142252139b362ceebe2361811b9f9fed4d3ac87b2e392e64a9847fb1c56c82ca0cff9963e034c288ea31ade62d
7
+ data.tar.gz: 197d39dc376c55ad3c1b4528383f44d90598934483cc350803381289804435bf406d0438468c0f1552bbd5c3a284c1e5ec0a6b37c47d165ffb5269e4cfbe4e1d
data/README.md CHANGED
@@ -15,6 +15,28 @@ information, Photish creates a complete static website that can be hosted on an
15
15
  [NGINX](http://nginx.org/), [Apache HTTP Server](https://httpd.apache.org/), or
16
16
  even on [Github Pages](https://pages.github.com/).
17
17
 
18
+ ## Table of Contents
19
+
20
+ - [Overview](#overview)
21
+ - [Installation](#installation)
22
+ - [Usage](#usage)
23
+ - [Initialize](#initialize)
24
+ - [Basic Photish Structure](#basic-photish-structure)
25
+ - [Template Engines](#template-engines)
26
+ - [Site Assets](#site-assets)
27
+ - [Config File Options](#config-file-options)
28
+ - [Customizing Templates](#customizing-templates)
29
+ - [Layout Template](#layout-template)
30
+ - [Collection Template](#collection-template)
31
+ - [Album Template](#album-template)
32
+ - [Photo Template](#photo-template)
33
+ - [Generate](#generate)
34
+ - [Execution Order](#execution-order)
35
+ - [Host](#host)
36
+ - [Development](#development)
37
+ - [Contributing](#contributing)
38
+ - [License](#license)
39
+
18
40
  ## Overview
19
41
 
20
42
  Photish turns this:
@@ -159,7 +181,7 @@ the file extension of the template engine you prefer
159
181
  1. Update `config.yml` to reference your newly created template files
160
182
  1. Re write the basic template code in your chosen language
161
183
 
162
- #### Site Assets, CSS, Images, JavaScript
184
+ #### Site Assets
163
185
 
164
186
  Any content not starting with an `_` (underscore) in the `site` folder will be
165
187
  copied to the `output` folder.
data/TODO.md CHANGED
@@ -2,17 +2,11 @@
2
2
 
3
3
  ## Must Have
4
4
 
5
- 1. `init` command to get started
5
+ 1. Make the assets stuff smaller, prettier HTML/CSS design
6
6
 
7
7
  ## Might Have
8
8
 
9
9
  1. `deploy` to deploy to github pages
10
- 1. Exception and error handling to have clearer errors
11
- 1. Startup bash script should install image magick, libmagic, exiftool
12
- 1. README table of contents
13
-
14
- ## Potential Features
15
-
16
10
  1. A sitemap helper
17
11
  1. A breadcrumb helper
18
12
  1. Relative/absolute with/without hostname URLs (for different host envs) with view helper
data/bin/setup CHANGED
@@ -2,6 +2,9 @@
2
2
  set -euo pipefail
3
3
  IFS=$'\n\t'
4
4
 
5
+ command -v convert >/dev/null 2>&1 || { echo >&2 "imagemagick required. run \"brew install imagemagick\""; exit 1; }
6
+ command -v exiftool >/dev/null 2>&1 || { echo >&2 "exiftool required. run \"brew install exiftool\""; exit 1; }
7
+
5
8
  bundle install
6
9
 
7
10
  # Do any other automated setup that you need to do here
@@ -1,7 +1,7 @@
1
1
  require 'thor'
2
- require 'photish/generation'
3
- require 'photish/host'
4
- require 'photish/init'
2
+ require 'photish/command/generation'
3
+ require 'photish/command/host'
4
+ require 'photish/command/init'
5
5
 
6
6
  module Photish
7
7
  class CLI < Thor
@@ -9,17 +9,17 @@ module Photish
9
9
 
10
10
  desc "generate", "Generates the gallery static site"
11
11
  def generate
12
- Photish::Generation.new(options).execute
12
+ Command::Generation.new(options).execute
13
13
  end
14
14
 
15
15
  desc "host", "Serves the HTML on a HTTP server at http://localhost:9876/"
16
16
  def host
17
- Photish::Host.new(options).execute
17
+ Command::Host.new(options).execute
18
18
  end
19
19
 
20
20
  desc "init", "Creates a basic Photish site sctructure"
21
21
  def init
22
- Photish::Init.new(options).execute
22
+ Command::Init.new(options).execute
23
23
  end
24
24
  end
25
25
  end
@@ -0,0 +1,73 @@
1
+ require 'photish/log/logger'
2
+ require 'photish/config/app_settings'
3
+ require 'photish/gallery/collection'
4
+ require 'photish/render/site'
5
+
6
+ module Photish
7
+ module Command
8
+ class Generation
9
+ include ::Photish::Log::Logger
10
+
11
+ def initialize(runtime_config)
12
+ @config = Photish::Config::AppSettings.new(runtime_config)
13
+ .config
14
+ end
15
+
16
+ def execute
17
+ log_important_config_values
18
+ log_album_and_photo_names
19
+ render_whole_site
20
+ log 'Site generation completed successfully'
21
+ end
22
+
23
+ private
24
+
25
+ attr_reader :config
26
+
27
+ def log_important_config_values
28
+ log "Photo directory: #{photo_dir}"
29
+ log "Site directory: #{site_dir}"
30
+ log "Output directory: #{output_dir}"
31
+ end
32
+
33
+ def log_album_and_photo_names
34
+ collection.albums.each do |album|
35
+ log album.name
36
+ log album.photos.map(&:name)
37
+ end
38
+ end
39
+
40
+ def render_whole_site
41
+ Photish::Render::Site.new(templates,
42
+ site_dir,
43
+ output_dir)
44
+ .all_for(collection)
45
+ end
46
+
47
+ def photo_dir
48
+ config.val(:photo_dir)
49
+ end
50
+
51
+ def output_dir
52
+ config.val(:output_dir)
53
+ end
54
+
55
+ def site_dir
56
+ config.val(:site_dir)
57
+ end
58
+
59
+ def collection
60
+ @collection ||= Gallery::Collection.new(photo_dir, qualities)
61
+ end
62
+
63
+ def qualities
64
+ config.val(:qualities)
65
+ .map { |quality| OpenStruct.new(quality) }
66
+ end
67
+
68
+ def templates
69
+ OpenStruct.new(config.val(:templates))
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,38 @@
1
+ require 'photish/log/logger'
2
+ require 'webrick'
3
+
4
+ module Photish
5
+ module Command
6
+ class Host
7
+ include ::Photish::Log::Logger
8
+
9
+ def initialize(runtime_config)
10
+ @config = Photish::Config::AppSettings.new(runtime_config)
11
+ .config
12
+ end
13
+
14
+ def execute
15
+ trap 'INT' do server.shutdown end
16
+ server.start
17
+ log "Site is running at 0.0.0.0:#{port}"
18
+ end
19
+
20
+ private
21
+
22
+ attr_reader :config
23
+
24
+ def server
25
+ @server ||= WEBrick::HTTPServer.new(Port: port,
26
+ DocumentRoot: output_dir)
27
+ end
28
+
29
+ def port
30
+ config.val(:port)
31
+ end
32
+
33
+ def output_dir
34
+ config.val(:output_dir)
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,40 @@
1
+ require 'photish/log/logger'
2
+
3
+ module Photish
4
+ module Command
5
+ class Init
6
+ include ::Photish::Log::Logger
7
+
8
+ def initialize(runtime_config)
9
+ @runtime_config = runtime_config
10
+ end
11
+
12
+ def execute
13
+ FileUtils.cp_r(config_file, Dir.pwd)
14
+ FileUtils.cp_r(photos_dir, Dir.pwd)
15
+ FileUtils.cp_r(site_dir, Dir.pwd)
16
+ log "Photish site initiated successfully"
17
+ end
18
+
19
+ private
20
+
21
+ attr_reader :runtime_config
22
+
23
+ def config_file
24
+ asset_path('config.yml')
25
+ end
26
+
27
+ def photos_dir
28
+ asset_path('photos')
29
+ end
30
+
31
+ def site_dir
32
+ asset_path('site')
33
+ end
34
+
35
+ def asset_path(*path)
36
+ File.join(File.dirname(__FILE__), '..', 'assets', path)
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,11 @@
1
+ require 'colorize'
2
+
3
+ module Photish
4
+ module Log
5
+ module Logger
6
+ def log(message)
7
+ puts "#{Time.now.iso8601.colorize(:blue)} => #{message.to_s.colorize(:green)}"
8
+ end
9
+ end
10
+ end
11
+ end
@@ -4,7 +4,7 @@ module Photish
4
4
  module Render
5
5
  class ImageConversion
6
6
 
7
- include Photish::Log
7
+ include Photish::Log::Logger
8
8
 
9
9
  def initialize(output_dir)
10
10
  @output_dir = output_dir
@@ -4,7 +4,7 @@ module Photish
4
4
  module Render
5
5
  class Page
6
6
 
7
- include Photish::Log
7
+ include Photish::Log::Logger
8
8
 
9
9
  def initialize(layout_file, template_file, output_dir)
10
10
  @layout_file = layout_file
@@ -1,3 +1,3 @@
1
1
  module Photish
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -31,6 +31,7 @@ Gem::Specification.new do |spec|
31
31
  spec.add_dependency "anemone", "~> 0.7"
32
32
  spec.add_dependency "mini_exiftool", "~> 2.5"
33
33
  spec.add_dependency "recursive-open-struct", "~> 0.6"
34
+ spec.add_dependency "colorize", "~> 0.7"
34
35
 
35
36
  spec.add_development_dependency "bundler", "~> 1.10"
36
37
  spec.add_development_dependency "rake", "~> 10.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: photish
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henry Lawson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-11-23 00:00:00.000000000 Z
11
+ date: 2015-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -136,6 +136,20 @@ dependencies:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0.6'
139
+ - !ruby/object:Gem::Dependency
140
+ name: colorize
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '0.7'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '0.7'
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: bundler
141
155
  requirement: !ruby/object:Gem::Requirement
@@ -274,6 +288,9 @@ files:
274
288
  - lib/photish/assets/site/custom.html
275
289
  - lib/photish/assets/site/styles/basic.css
276
290
  - lib/photish/cli.rb
291
+ - lib/photish/command/generation.rb
292
+ - lib/photish/command/host.rb
293
+ - lib/photish/command/init.rb
277
294
  - lib/photish/config/app_settings.rb
278
295
  - lib/photish/config/default_config.rb
279
296
  - lib/photish/config/file_config.rb
@@ -286,10 +303,7 @@ files:
286
303
  - lib/photish/gallery/traits/albumable.rb
287
304
  - lib/photish/gallery/traits/metadatable.rb
288
305
  - lib/photish/gallery/traits/urlable.rb
289
- - lib/photish/generation.rb
290
- - lib/photish/host.rb
291
- - lib/photish/init.rb
292
- - lib/photish/log.rb
306
+ - lib/photish/log/logger.rb
293
307
  - lib/photish/render/image_conversion.rb
294
308
  - lib/photish/render/page.rb
295
309
  - lib/photish/render/site.rb
@@ -1,71 +0,0 @@
1
- require 'photish/log'
2
- require 'photish/config/app_settings'
3
- require 'photish/gallery/collection'
4
- require 'photish/render/site'
5
-
6
- module Photish
7
- class Generation
8
- include Photish::Log
9
-
10
- def initialize(runtime_config)
11
- @config = Photish::Config::AppSettings.new(runtime_config)
12
- .config
13
- end
14
-
15
- def execute
16
- log_important_config_values
17
- log_album_and_photo_names
18
- render_whole_site
19
- log 'Site generation completed successfully'
20
- end
21
-
22
- private
23
-
24
- attr_reader :config
25
-
26
- def log_important_config_values
27
- log "Photo directory: #{photo_dir}"
28
- log "Site directory: #{site_dir}"
29
- log "Output directory: #{output_dir}"
30
- end
31
-
32
- def log_album_and_photo_names
33
- collection.albums.each do |album|
34
- log album.name
35
- log album.photos.map(&:name)
36
- end
37
- end
38
-
39
- def render_whole_site
40
- Photish::Render::Site.new(templates,
41
- site_dir,
42
- output_dir)
43
- .all_for(collection)
44
- end
45
-
46
- def photo_dir
47
- config.val(:photo_dir)
48
- end
49
-
50
- def output_dir
51
- config.val(:output_dir)
52
- end
53
-
54
- def site_dir
55
- config.val(:site_dir)
56
- end
57
-
58
- def collection
59
- @collection ||= Gallery::Collection.new(photo_dir, qualities)
60
- end
61
-
62
- def qualities
63
- config.val(:qualities)
64
- .map { |quality| OpenStruct.new(quality) }
65
- end
66
-
67
- def templates
68
- OpenStruct.new(config.val(:templates))
69
- end
70
- end
71
- end
@@ -1,35 +0,0 @@
1
- require 'webrick'
2
-
3
- module Photish
4
- class Host
5
- include Photish::Log
6
-
7
- def initialize(runtime_config)
8
- @config = Photish::Config::AppSettings.new(runtime_config)
9
- .config
10
- end
11
-
12
- def execute
13
- trap 'INT' do server.shutdown end
14
- server.start
15
- log "Site is running at 0.0.0.0:#{port}"
16
- end
17
-
18
- private
19
-
20
- attr_reader :config
21
-
22
- def server
23
- @server ||= WEBrick::HTTPServer.new(Port: port,
24
- DocumentRoot: output_dir)
25
- end
26
-
27
- def port
28
- config.val(:port)
29
- end
30
-
31
- def output_dir
32
- config.val(:output_dir)
33
- end
34
- end
35
- end
@@ -1,36 +0,0 @@
1
- module Photish
2
- class Init
3
- include Photish::Log
4
-
5
- def initialize(runtime_config)
6
- @runtime_config = runtime_config
7
- end
8
-
9
- def execute
10
- FileUtils.cp_r(config_file, Dir.pwd)
11
- FileUtils.cp_r(photos_dir, Dir.pwd)
12
- FileUtils.cp_r(site_dir, Dir.pwd)
13
- log "Photish site initiated successfully"
14
- end
15
-
16
- private
17
-
18
- attr_reader :runtime_config
19
-
20
- def config_file
21
- asset_path('config.yml')
22
- end
23
-
24
- def photos_dir
25
- asset_path('photos')
26
- end
27
-
28
- def site_dir
29
- asset_path('site')
30
- end
31
-
32
- def asset_path(*path)
33
- File.join(File.dirname(__FILE__), 'assets', path)
34
- end
35
- end
36
- end
@@ -1,7 +0,0 @@
1
- module Photish
2
- module Log
3
- def log(message)
4
- puts "#{Time.now.iso8601} => #{message}"
5
- end
6
- end
7
- end