photish 0.4.0 → 0.5.0

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: 126b9558be5101767839891a8bb1f439e4ceeb4d
4
- data.tar.gz: f7f5788e4eae6c56c450f81b5079eb9747ac4660
3
+ metadata.gz: 2187730cc461f37521bd2306765d64de3a5cd48c
4
+ data.tar.gz: 4767017b8aee301d228e405fbf5617257111ed6d
5
5
  SHA512:
6
- metadata.gz: bfb7b794c442026a35bd9a2e8281068c083fd9e7bd963a0630c878683002dd13ed4b7c8f4f79ad231f565edd94ce2803b2363ac65113f2d8d9006929b24d2f48
7
- data.tar.gz: 8ad4cdffaae09e93667179b2d25b3ec6320244c6d4a582994d7bc283592dc9d7900ec64b1e22435b8458ee0466e2fb873e9635c6281f4702277fcbffe02d7891
6
+ metadata.gz: 619f637a81a664c7d6979fbac0ed998be1b29709824e049ca90f58a4fa10b8db304d862e6e2b59bab9c930c61f58b3d4d1507bf317cd6322fa97351a9a2bd20b
7
+ data.tar.gz: 63231d51f974db316a1989e995cf749bedea94486d686ad878d7b7494a1f138420d06858a9a66c614b03b2c71b6c40adb945ebc65a27cbf8ed53d1eecebe4150
@@ -0,0 +1,7 @@
1
+ backtrace.mask=true
2
+ compile.invokedynamic=true
3
+ objectspace.enabled=true
4
+ backtrace.color=true
5
+ compat.version=2.2
6
+ backtrace.style=mri
7
+ cli.debug=false
@@ -1,10 +1,4 @@
1
1
  language: ruby
2
- rvm:
3
- - 2.0
4
- - 2.1
5
- - 2.2
6
- - 2.3.0
7
- - ruby-head
8
2
  sudo: false
9
3
  before_install:
10
4
  - gem install bundler -v 1.10.6
@@ -17,3 +11,26 @@ addons:
17
11
  - libmagic-dev
18
12
  - libimage-exiftool-perl
19
13
  cache: bundler
14
+ matrix:
15
+ include:
16
+ - rvm: ruby-head
17
+ - rvm: 2.3.0
18
+ env: COVERAGE=1
19
+ - rvm: 2.2
20
+ - rvm: 2.1
21
+ - rvm: 2.0
22
+
23
+ - rvm: jruby-head
24
+ - rvm: jruby-9.0
25
+ env: SMOKE_TEST_ONLY=1
26
+
27
+ - rvm: rbx
28
+ - rvm: rbx-3.2
29
+ env: SMOKE_TEST_ONLY=1
30
+ - rvm: rbx-2
31
+ env: SMOKE_TEST_ONLY=1
32
+ fast_finish: true
33
+ allow_failures:
34
+ - rvm: ruby-head
35
+ - rvm: jruby-head
36
+ - rvm: rbx
data/Gemfile CHANGED
@@ -2,7 +2,3 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in photish.gemspec
4
4
  gemspec
5
-
6
- group :development do
7
- gem 'aruba', git: 'https://github.com/cucumber/aruba.git', ref: '0a3bffa'
8
- end
data/README.md CHANGED
@@ -54,6 +54,7 @@ and running:
54
54
  - [Overview](#overview)
55
55
  - [Installation](#installation)
56
56
  - [Dependencies](#dependencies)
57
+ - [Ruby Versions](#ruby-versions)
57
58
  - [Usage](#usage)
58
59
  - [Initialize](#initialize)
59
60
  - [Basic Photish Structure](#basic-photish-structure)
@@ -68,6 +69,7 @@ and running:
68
69
  - [Template Helpers](#template-helpers)
69
70
  - [Custom Rendered Content](#custom-rendered-content)
70
71
  - [Gallery Page](#gallery-page)
72
+ - [Asset Page](#asset-page)
71
73
  - [Generate](#generate)
72
74
  - [Execution Order](#execution-order)
73
75
  - [Workers and Threads](#workers-and-threads)
@@ -84,6 +86,7 @@ and running:
84
86
  - [Plugin Loading](#plugin-loading)
85
87
  - [Development](#development)
86
88
  - [Contributing](#contributing)
89
+ - [Versioning](#versioning)
87
90
  - [License](#license)
88
91
 
89
92
  ## Overview
@@ -231,6 +234,20 @@ Target OS dependencies:
231
234
  $ sudo apt-get install imagemagick
232
235
  $ sudo apt-get install libimage-exiftool-perl
233
236
 
237
+ ### Ruby Versions
238
+
239
+ Photish supports multiple ruby versions:
240
+
241
+ Ruby Version | Minimum | Maximum | Comments
242
+ ----------------------------------------- |---------|---------|---------
243
+ [MRI Ruby](https://www.ruby-lang.org/en/) | 2.0 | HEAD | Very stable, all tests pass consistently
244
+ [JRuby](http://jruby.org/) | 9.0 | HEAD | Mostly stable, smoke test passes consistently, full feature test flakey
245
+ [Rubinius](http://rubinius.com/) | 2.0 | HEAD | Mostly stable, smoke test passes consistently, full feature test flakey
246
+
247
+ The latest version and all releases of Photish are tested against the above
248
+ ruby versions in the [CI pipeline](https://travis-ci.org/henrylawson/photish).
249
+
250
+
234
251
  ## Usage
235
252
 
236
253
  Once you have photish installed. Get started with the following commands:
@@ -552,13 +569,13 @@ A gallery page is a simple way to create a custom web page within the
552
569
  collection or album of your gallery that will render within your site's [Layout
553
570
  Template](#layout-template).
554
571
 
555
- For example, if you would like to create a "more details about album" page
556
- somewhere within an album, and you would like it rendered in the [Layout
572
+ For example, if you would like to create a "more details" page somewhere within
573
+ an album, or the collection root, and you would like it rendered in the [Layout
557
574
  Template](#layout-template) to have a consistent look and feel, you can do it
558
- by creating a file a Gallery Page file such as `more-about.slim` in your
559
- album's directory. The file extension is determined using the `page_extension`
560
- [Config File Option](#config-file-option). A Gallery Page can live anywhere and
561
- you can have as many of them as you like within the `photos` directory.
575
+ by creating a Gallery Page such as `more-about.slim` anywhere in your `photos`
576
+ directory. The file extension is determined using the `page_extension` [Config
577
+ File Option](#config-file-option). A Gallery Page can live anywhere and you can
578
+ have as many of them as you like within the `photos` directory.
562
579
 
563
580
  `photos/**/*.{page_extension}`
564
581
 
@@ -574,6 +591,41 @@ As with other gallery generated content, a gallery page is accessible from the
574
591
  `all_pages` method within the [Collection](#collection-template) or
575
592
  [Album](#album-template) template.
576
593
 
594
+ ##### Asset Page
595
+
596
+ An Asset Page is a custom page that lives inside your `site` directory that
597
+ is rendered using your template engine of choice. When an Asset Page template
598
+ is rendered it is not rendered inside the site's [Layout
599
+ Template](#layout-template). Asset Page's are standalone templates. Like other
600
+ assets, they maintain the same folder structure in the `output` directory that
601
+ they have in the `site` directory. When rendered, the template is passed the
602
+ Collection model, as such they have access to all attributes that a [Collection
603
+ Template](#collection-template) does.
604
+
605
+ For example, if you would like to create an index page of all albums in your
606
+ collection you can create the following file:
607
+
608
+ `site/index/all_albums.html.{page_extension}`
609
+
610
+ ```slim
611
+ doctype html
612
+ html
613
+ head
614
+ title All Albums
615
+ body
616
+ ol
617
+ - all_albums.each do |album|
618
+ li #{album.name}
619
+ ```
620
+
621
+ When rendered, the above Asset Page will be available at
622
+ [http://localhost:9876/index/all_albums.html](http://localhost:9876/index/all_albums.html).
623
+
624
+ It is important to note that once rendered, the template extension is removed
625
+ and the basename is used for the final filename. This allows you to specify
626
+ custom extensions before the `page_extension` such as TXT or XML. In the
627
+ example above, HTML is specified.
628
+
577
629
  ### Generate
578
630
 
579
631
  The static HTML can be generated by running the below command inside the
@@ -783,6 +835,7 @@ Plugin supports:
783
835
  1. `Photish::Plugin::Type::Album`
784
836
  1. `Photish::Plugin::Type::Photo`
785
837
  1. `Photish::Plugin::Type::Image`
838
+ 1. `Photish::Plugin::Type::Page`
786
839
 
787
840
  To use the Template Helper Plugin, simply call the custom method(s) in your
788
841
  template file. For the above example, it can be used by calling the `shout`
@@ -796,8 +849,10 @@ div.my-shouting-content
796
849
 
797
850
  Some "core" Template Helper plugins available in Photish by default are:
798
851
 
799
- 1. [Breadcrumb](https://github.com/henrylawson/photish/blob/master/lib/photish/core_plugin/breadcrumb.rb)
800
- 1. [BuildUrl](https://github.com/henrylawson/photish/blob/master/lib/photish/core_plugin/build_url.rb)
852
+ 1. [Breadcrumb](https://github.com/henrylawson/photish/blob/master/lib/photish/plugin/core/breadcrumb.rb)
853
+ 1. [BuildUrl](https://github.com/henrylawson/photish/blob/master/lib/photish/plugin/core/build_url.rb)
854
+ 1. [Metadatable](https://github.com/henrylawson/photish/blob/master/lib/photish/plugin/core/metadatable.rb)
855
+ 1. [Exifable](https://github.com/henrylawson/photish/blob/master/lib/photish/plugin/core/exifable.rb)
801
856
 
802
857
  #### Deployment Engine Plugins
803
858
 
@@ -939,6 +994,10 @@ https://github.com/henrylawson/photish. This project is intended to be a safe,
939
994
  welcoming space for collaboration, and contributors are expected to adhere to
940
995
  the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
941
996
 
997
+ ## Versioning
998
+
999
+ This project follows [Semantic Versioning 2.0.0](http://semver.org/).
1000
+
942
1001
  ## License
943
1002
 
944
1003
  The gem is available as open source under the terms of the [MIT
data/Rakefile CHANGED
@@ -8,11 +8,15 @@ require 'metric_fu'
8
8
  RSpec::Core::RakeTask.new(:spec)
9
9
 
10
10
  Cucumber::Rake::Task.new(:features) do |t|
11
- t.cucumber_opts = "features --format pretty --tags ~@wip"
11
+ tags = ['']
12
+ tags << '--tags ~@wip'
13
+ tags << '--tags @smoke' if ENV['SMOKE_TEST_ONLY']
14
+ t.cucumber_opts = "features --format pretty #{tags.join(' ')}"
12
15
  end
13
16
 
14
17
  desc 'Gather code climate results'
15
18
  task :gather_coverage do
19
+ next unless ENV['COVERAGE']
16
20
  require 'simplecov'
17
21
  require 'codeclimate-test-reporter'
18
22
  CodeClimate::TestReporter::Formatter.new.format(SimpleCov.result)
data/TODO.md CHANGED
@@ -2,17 +2,16 @@
2
2
 
3
3
  ## In Progress
4
4
 
5
- 1. Create the Asset Page feature, pages in the site folder, passing collection
6
- reference
7
- 1. RCode tools
5
+ 1. A sitemap helper plugin for use in custom templates for example
6
+ `sitemap.xml`
8
7
 
9
8
  ## Backlog
10
9
 
10
+ 1. Get url by smart key
11
11
  1. Video transcoding and template rendering for videos
12
12
  1. Templates with exif data, super slow
13
13
  1. Proper asset pipeline for CSS
14
- 1. A sitemap helper plugin for use in custom templates for example
15
- `sitemap.xml`
14
+ 1. Improve the `--example` template of Photish
15
+ 1. Stabilize full tests for JRuby and Rubinius
16
16
  1. Add unit tests to classes relying on feature tests
17
17
  1. Improve metric scores from `rake stats`
18
- 1. Improve the `--example` template of Photish
@@ -0,0 +1,7 @@
1
+ backtrace.mask=true
2
+ compile.invokedynamic=true
3
+ objectspace.enabled=true
4
+ backtrace.color=true
5
+ compat.version=2.2
6
+ backtrace.style=mri
7
+ cli.debug=false
@@ -50,9 +50,10 @@ require 'photish/gallery/album'
50
50
  require 'photish/gallery/image'
51
51
  require 'photish/gallery/collection'
52
52
  require 'photish/render/template'
53
- require 'photish/render/page'
53
+ require 'photish/render/asset_page'
54
+ require 'photish/render/gallery_page'
54
55
  require 'photish/render/site'
55
- require 'photish/render/model'
56
+ require 'photish/render/gallery'
56
57
  require 'photish/render/image'
57
58
  require 'photish/cache/db_file'
58
59
  require 'photish/cache/manifest'
@@ -14,4 +14,5 @@ html
14
14
  div.footer
15
15
  | Site assets:
16
16
  == links_with_seperator([{text: 'My Custom Page', url: build_url('custom.html')},
17
+ {text: 'My Asset Page', url: build_url('map', 'site_albums.html')},
17
18
  {text: 'CSS Download', url: build_url('styles', 'basic.css')}], '|')
@@ -0,0 +1,13 @@
1
+ doctype html
2
+ html
3
+ head
4
+ title Photish asset page
5
+ link href="#{build_url('styles', 'basic.css')}" media="screen" rel="stylesheet" type="text/css"
6
+ body
7
+ div.header
8
+ a href="/"
9
+ h1 PHOTISH
10
+ div.content
11
+ ol
12
+ - all_albums.each do |album|
13
+ li #{album.name}
@@ -33,7 +33,7 @@ module Photish
33
33
 
34
34
  def self.path(output_dir, filename)
35
35
  FileUtils.mkdir_p(output_dir)
36
- path = File.join(output_dir, filename)
36
+ File.join(output_dir, filename)
37
37
  end
38
38
  end
39
39
  end
@@ -2,6 +2,18 @@ module Photish
2
2
  module CLI
3
3
  class Interface < Thor
4
4
  package_name "Photish"
5
+ map "-v" => :version
6
+ map "--version" => :version
7
+
8
+ desc "version", "Current version"
9
+ def version
10
+ puts "Photish v#{Photish::VERSION}"
11
+ end
12
+
13
+ desc "credits", "Major conritbutors"
14
+ def credits
15
+ puts "#{Photish::AUTHOR_NAME} <#{Photish::AUTHOR_EMAIL}>"
16
+ end
5
17
 
6
18
  desc "generate", "Generates the gallery static site"
7
19
  option :force, type: :boolean
@@ -22,8 +22,8 @@ module Photish
22
22
  to: :config
23
23
 
24
24
  def render_whole_site
25
- Render::Model.new(config, version_hash)
26
- .all_for(collection)
25
+ Render::Gallery.new(config, version_hash)
26
+ .all_for(collection)
27
27
  end
28
28
 
29
29
  def collection
@@ -0,0 +1,48 @@
1
+ module Photish
2
+ module Render
3
+ class AssetPage
4
+ include Log::Loggable
5
+
6
+ def initialize(collection, output_dir, site_dir)
7
+ @collection = collection
8
+ @output_dir = output_dir
9
+ @site_dir = site_dir
10
+ end
11
+
12
+ def render(page_paths)
13
+ render_all(page_paths)
14
+ end
15
+
16
+ private
17
+
18
+ attr_reader :collection,
19
+ :output_dir,
20
+ :site_dir
21
+
22
+ def render_all(page_paths)
23
+ Array(page_paths).each do |page_path|
24
+ rendered_model = render_page(page_path)
25
+ output_model_file = relative_to_output_dir(page_path)
26
+ output_model_dir = File.dirname(output_model_file)
27
+
28
+ log.debug "Rendering #{page_path} to #{output_model_file}"
29
+
30
+ FileUtils.mkdir_p(output_model_dir)
31
+ File.write(output_model_file, rendered_model)
32
+ end
33
+ end
34
+
35
+ def relative_to_output_dir(page_path)
36
+ relative_path = page_path.gsub(site_dir, '')
37
+ basename = File.basename(relative_path, File.extname(relative_path))
38
+ a = File.join(output_dir, File.dirname(relative_path), basename)
39
+ puts a
40
+ a
41
+ end
42
+
43
+ def render_page(page_path)
44
+ Tilt.new(page_path).render(collection)
45
+ end
46
+ end
47
+ end
48
+ end
@@ -1,6 +1,6 @@
1
1
  module Photish
2
2
  module Render
3
- class Model
3
+ class Gallery
4
4
  def initialize(config, version_hash)
5
5
  @config = config
6
6
  @version_hash = version_hash
@@ -48,7 +48,7 @@ module Photish
48
48
  end
49
49
 
50
50
  def page_template
51
- Page.new(layout_file, output_dir)
51
+ GalleryPage.new(layout_file, output_dir)
52
52
  end
53
53
 
54
54
  def photo_template
@@ -1,6 +1,6 @@
1
1
  module Photish
2
2
  module Render
3
- class Page
3
+ class GalleryPage
4
4
  include Log::Loggable
5
5
 
6
6
  def initialize(layout_file, output_dir)
@@ -52,12 +52,17 @@ module Photish
52
52
 
53
53
  def process_next_image(image_queue)
54
54
  image = image_queue.pop
55
- convert(image) if cache_changed?(image.url_path, image.path)
55
+ convert(image) if regenerate?(image)
56
56
  rescue Errno::ENOENT
57
57
  log.warn "Image not found #{image.path}"
58
58
  raise unless soft_failure
59
59
  end
60
60
 
61
+ def regenerate?(image)
62
+ cache_changed?(image.url_path, image.path) ||
63
+ !File.exist?(output_path(image))
64
+ end
65
+
61
66
  def to_queue(images)
62
67
  image_queue = Queue.new
63
68
  Array(images).shuffle.each { |image| image_queue << image }
@@ -10,6 +10,7 @@ module Photish
10
10
  delete_empty_folders
11
11
  move_non_ignored_site_contents
12
12
  collection_template.render(collection)
13
+ render_asset_pages(collection)
13
14
  end
14
15
 
15
16
  private
@@ -21,8 +22,21 @@ module Photish
21
22
  :output_dir,
22
23
  :worker_index,
23
24
  :url,
25
+ :page_extension,
24
26
  to: :config
25
27
 
28
+ def render_asset_pages(collection)
29
+ AssetPage.new(collection,
30
+ output_dir,
31
+ site_dir).render(asset_page_paths)
32
+ end
33
+
34
+ def asset_page_paths
35
+ Dir["#{site_dir}/**/*.#{page_extension}"].reject do |dir|
36
+ dir.include? "#{File::SEPARATOR}_"
37
+ end
38
+ end
39
+
26
40
  def move_non_ignored_site_contents
27
41
  FileUtils.mkdir_p(output_dir)
28
42
  FileUtils.cp_r(non_ignored_site_contents,
@@ -1,3 +1,5 @@
1
1
  module Photish
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
+ AUTHOR_NAME = "Henry Lawson"
4
+ AUTHOR_EMAIL = "henry.lawson@foinq.com"
3
5
  end
@@ -6,8 +6,8 @@ require 'photish/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "photish"
8
8
  spec.version = Photish::VERSION
9
- spec.authors = ["Henry Lawson"]
10
- spec.email = ["henry.lawson@foinq.com"]
9
+ spec.authors = [Photish::AUTHOR_NAME]
10
+ spec.email = [Photish::AUTHOR_EMAIL]
11
11
 
12
12
  spec.summary = %q{A static photo site generator}
13
13
  spec.description = %q{Photish is a simple, convention based (but
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
 
18
18
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
19
  spec.bindir = "exe"
20
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.executables = spec.files.grep(%r{^exe/[^\.]}) { |f| File.basename(f) }
21
21
  spec.require_paths = ["lib"]
22
22
 
23
23
  spec.required_ruby_version = '>= 2.0'
@@ -36,6 +36,7 @@ Gem::Specification.new do |spec|
36
36
  spec.add_development_dependency "anemone", "~> 0.7"
37
37
  spec.add_development_dependency "bundler", "~> 1.10"
38
38
  spec.add_development_dependency "rake", "~> 10.0"
39
+ spec.add_development_dependency "aruba"
39
40
  spec.add_development_dependency "rspec"
40
41
  spec.add_development_dependency "cucumber"
41
42
  spec.add_development_dependency "pry"
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.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henry Lawson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-03 00:00:00.000000000 Z
11
+ date: 2016-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -192,6 +192,20 @@ dependencies:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
194
  version: '10.0'
195
+ - !ruby/object:Gem::Dependency
196
+ name: aruba
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
195
209
  - !ruby/object:Gem::Dependency
196
210
  name: rspec
197
211
  requirement: !ruby/object:Gem::Requirement
@@ -331,6 +345,7 @@ files:
331
345
  - ".codeclimate.yml"
332
346
  - ".csslintrc"
333
347
  - ".gitignore"
348
+ - ".jrubyrc"
334
349
  - ".pryrc"
335
350
  - ".rspec"
336
351
  - ".rubocop.yml"
@@ -344,6 +359,7 @@ files:
344
359
  - TODO.md
345
360
  - bin/console
346
361
  - bin/setup
362
+ - exe/.jrubyrc
347
363
  - exe/photish
348
364
  - lib/photish.rb
349
365
  - lib/photish/assets/Gemfile
@@ -370,6 +386,7 @@ files:
370
386
  - lib/photish/assets/example/site/_templates/photo.slim
371
387
  - lib/photish/assets/example/site/custom.html
372
388
  - lib/photish/assets/example/site/images/crumbs.gif
389
+ - lib/photish/assets/example/site/map/site_albums.html.slim
373
390
  - lib/photish/assets/example/site/styles/basic.css
374
391
  - lib/photish/assets/gitignore
375
392
  - lib/photish/cache/db_file.rb
@@ -406,9 +423,10 @@ files:
406
423
  - lib/photish/plugin/repository.rb
407
424
  - lib/photish/plugin/type.rb
408
425
  - lib/photish/rake/task.rb
426
+ - lib/photish/render/asset_page.rb
427
+ - lib/photish/render/gallery.rb
428
+ - lib/photish/render/gallery_page.rb
409
429
  - lib/photish/render/image.rb
410
- - lib/photish/render/model.rb
411
- - lib/photish/render/page.rb
412
430
  - lib/photish/render/site.rb
413
431
  - lib/photish/render/template.rb
414
432
  - lib/photish/version.rb