photish 0.3.8 → 0.3.9

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: 8435b70f34daef14e185370d7c8ca195a75db071
4
- data.tar.gz: cac3fce5cea64da66e1b301d62ce05b9d2bfd482
3
+ metadata.gz: 8b45f6b049d2e91f129cdee867b285b823e109ac
4
+ data.tar.gz: d14a406066fce4aeeb1f7abf227004b1bef4b8cd
5
5
  SHA512:
6
- metadata.gz: 7143bed97bb665456b9a353bc9f71a063a63f34006e578221d363e36be99491d30a001428a37ea7894e76b47b0cc65c4bd8f1e1920657d6915713edf777e2cb9
7
- data.tar.gz: 63f6237a0547672589eec634fd2fab52b343b9c8c6790a5547a57db14bc65b9e9e79de24c3b4454501f168b87af555ec1e8f78737c6e8be8ec57ea13c7cad4c6
6
+ metadata.gz: 735fdef9bbe628740c2722e8ab51289cb7499ae2e13af1d21d246d20a4b7f2f0c09a07171c83c9bde61173f7eca6c1c5e0e6b061e1a4f6e78d3c70dfa56049c8
7
+ data.tar.gz: be19de1114a110b1639cbe4a3d9cef1d186768ec65f1ecd3481fe7b2c01115a35edd0d63ecc3a49b2697e733f2ddee7d8bc23c877774d2b322921a1203a4c285
data/.gitignore CHANGED
@@ -9,3 +9,7 @@ pkg
9
9
  spec/reports
10
10
  tmp
11
11
  lib/photish/assets/output
12
+
13
+ # Added these to not force others to use them.
14
+ .overcommit.yml
15
+ .rvmrc
data/.travis.yml CHANGED
@@ -1,10 +1,14 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.2
3
+ - 2.0
4
+ - 2.1
5
+ - 2.2
6
+ - 2.3.0
7
+ - ruby-head
4
8
  sudo: false
5
9
  before_install:
6
10
  - gem install bundler -v 1.10.6
7
- script: rake
11
+ script: bundle exec rake
8
12
  addons:
9
13
  code_climate:
10
14
  repo_token: ae398c193255da8c5e030cb6251f053c76757635e5215e65efa32f52d003a519
@@ -12,3 +16,4 @@ addons:
12
16
  packages:
13
17
  - libmagic-dev
14
18
  - libimage-exiftool-perl
19
+ cache: bundler
data/README.md CHANGED
@@ -74,9 +74,11 @@ and running:
74
74
  - [Forced Regeneration](#forced-regeneration)
75
75
  - [Crude Performance Measures](#crude-performance-measures)
76
76
  - [Host](#host)
77
+ - [Deploy](#deploy)
77
78
  - [Rake Task](#rake-task)
78
79
  - [Plugins](#plugins)
79
80
  - [Template Helper Plugins](#template-helper-plugins)
81
+ - [Deployment Engine Plugins](#deployment-engine-plugins)
80
82
  - [Plugin Loading](#plugin-loading)
81
83
  - [Development](#development)
82
84
  - [Contributing](#contributing)
@@ -195,13 +197,23 @@ photo site so you can track the version of Photish you are building with:
195
197
 
196
198
  ### Dependencies
197
199
 
198
- Photish has dependencies on certain utilities:
200
+ Photish has dependencies on certain software:
199
201
 
202
+ - [Ruby](https://www.ruby-lang.org/en/) as the utility is written in Ruby and
203
+ is a [Gem](https://www.ruby-lang.org/en/libraries/)
204
+ - [Bundler](http://bundler.io/) is not required but recommended to manage the
205
+ version, installations and updates of the Photish gem
200
206
  - [ImageMagick](http://www.imagemagick.org/script/index.php) for Image
201
207
  conversion
202
208
  - [Exiftool](http://www.sno.phy.queensu.ca/~phil/exiftool/) for image metadata
203
209
  retrieval
204
210
 
211
+ Softer dependencies:
212
+
213
+ - [Unix](http://www.unix.org/) based OS, Photish has been tested thoroughly on
214
+ Linux and MacOSX computers but theoretically should work on Windows, though
215
+ this is not tested
216
+
205
217
  **On MacOSX, using [Brew](http://brew.sh/)**
206
218
 
207
219
  $ brew install imagemagick
@@ -301,9 +313,11 @@ logging:
301
313
  url:
302
314
  host: http://mydomain.com
303
315
  base: 'subdirectory'
316
+ type: 'relative_uri'
304
317
  workers: 4
305
318
  threads: 2
306
319
  force: false
320
+ plugins: ['ssh_deploy', 'other_plugin']
307
321
  ```
308
322
 
309
323
  The meanings and purpose of each field is defined below:
@@ -326,9 +340,11 @@ Field | Purpose
326
340
  `url` | a listing of the various url options
327
341
  `url/host` | if you would like URLs generated with a specific host prefix, you can define it here, otherwise leave it as '/' or do not set this configuration at all
328
342
  `url/base` | if your website will be hosted in a sub folder and will not be accessible at the root of the host, you can specify the sub folder(s) here, this will also mean your website will be hosted in a sub folder when ran using `photish host`
343
+ `url/type` | if your website URLs require the host name in them, you can use `absolute_uri` (i.e. http://mysite.com/subdirectory/index.html), if you would prefer to generate URLs that end at the root, you can use `absolute_relative` (i.e. /subdirectory/index.html)
329
344
  `workers` | the number of workers to create, for computers with multiple processors, photish is configured by default to spawn a worker for each process, a worker is responsible for image generation and html generation, load balancing is done randomly via a simple round robin allocation
330
345
  `threads` | the number of threads each worker should create to handle image magick transcoding
331
346
  `force` | this should always be false, if true, all content will be regenerated and nothing cached
347
+ `plugins` | an array of plugin names that have been included in your Gemfile and that Photish should require into it's runtime
332
348
 
333
349
  #### Customizing Templates
334
350
 
@@ -496,9 +512,10 @@ Custom template helpers are supported through [Plugins](#plugins).
496
512
 
497
513
  By default, Photish comes with the following helpers:
498
514
 
499
- Method | Description
500
- ----------- | -----------
501
- breadcrumbs | an unordered list of pages above the current page in the hierarchy
515
+ Method | Description
516
+ ------------------- | -----------
517
+ breadcrumbs | an unordered list of pages above the current page in the hierarchy
518
+ build_url(\*pieces) | use this to ensure your URLs have the correct host name and base directory, to avoid having it hard coded in the template
502
519
 
503
520
  ### Generate
504
521
 
@@ -625,6 +642,23 @@ The local version of your website will be visible at
625
642
  The Host command will also automatically regenerate the website on startup and
626
643
  when a file is added, removed or modified in the `photo_dir` or `site_dir`.
627
644
 
645
+ ### Deploy
646
+
647
+ Photish provides a plugin type specifically for deployments, called the
648
+ [Deployment Engine](#deployment-engine-plugins). Once a deploy plugin is
649
+ configured, it can be ran by passing the deploy plugins name as a value with
650
+ the `engine` argument.
651
+
652
+ $ photish deploy --engine=name
653
+
654
+ To utilize a Deployment Engine Plugin someone in the community has written,
655
+ take a look at [Plugin Loading](#plugin-loading) for how to include it in your
656
+ site.
657
+
658
+ If you would like to write a [Deployment Engine
659
+ Plugin](#deployment-engine-plugins) instructions are available in the [plugin
660
+ section](#deployment-engine-plugins).
661
+
628
662
  ### Rake Task
629
663
 
630
664
  If you would prefer to use Photish as a task in
@@ -651,7 +685,8 @@ Photish supports extension through the creation of plugins.
651
685
 
652
686
  To create a template helper plugin you must:
653
687
 
654
- 1. Create a module in the `Photish:Plugin` module namespace
688
+ 1. Create a **Ruby module** in the `Photish::Plugin` module namespace
689
+ 1. Make the plugin available for [loading](#plugin-loading)
655
690
  1. Implement the `self.is_for?(type)` method
656
691
  1. Implement your custom helper method(s)
657
692
 
@@ -672,12 +707,8 @@ module Photish::Plugin::Shout
672
707
  "<strong>I am shouting '#{message}'!!!</strong>"
673
708
  end
674
709
  end
675
- ```
676
-
677
- If the above code is saved to `site/_plugins/shout.rb` Photish will detect the
678
- plugin ruby file at runtime and it will load and make the method available in
679
- the template.
680
710
 
711
+ ```
681
712
  A Template Helper Plugin `self.is_for?(type)` method could potentially receive
682
713
  any of the below types, simply return true for the types the Template Helper
683
714
  Plugin supports:
@@ -687,7 +718,9 @@ Plugin supports:
687
718
  1. `Photish::Plugin::Type::Photo`
688
719
  1. `Photish::Plugin::Type::Image`
689
720
 
690
- A usage example is below
721
+ To use the Template Helper Plugin, simply call the custom method(s) in your
722
+ template file. For the above example, it can be used by calling the `shout`
723
+ method in a template file:
691
724
 
692
725
  **site/_templates/photo.slim**
693
726
  ```slim
@@ -695,11 +728,65 @@ div.my-shouting-content
695
728
  == shout("HELLO")
696
729
  ```
697
730
 
731
+ Some "core" Template Helper plugins available in Photish by default are:
732
+
733
+ 1. [Breadcrumb](https://github.com/henrylawson/photish/blob/master/lib/photish/core_plugin/breadcrumb.rb)
734
+ 1. [BuildUrl](https://github.com/henrylawson/photish/blob/master/lib/photish/core_plugin/build_url.rb)
735
+
736
+ #### Deployment Engine Plugins
737
+
738
+ To create a deployment engine plugin you must:
739
+
740
+ 1. Create a **Ruby class** in the `Photish::Plugin` module namespace
741
+ 1. Make the plugin available for [loading](#plugin-loading)
742
+ 1. Implement a `self.is_for?(type)` method and respond true when it receives
743
+ the `Photish::Plugin::Type::Deploy` type
744
+ 1. Implement a `self.engine_name` method and respond with the name of the
745
+ engine, this needs to match the value the user will pass on the
746
+ [Deploy](#deploy) command
747
+ 1. Implement a constructor, it should expect two argumnets `initialize(config,
748
+ log)`, a structure representing the config file and an instance of the
749
+ logger
750
+ 1. Finally the plugin should also implement a `deploy_site` method, this method
751
+ will execute the actual deployment
752
+
753
+ A simple sample implementation is below:
754
+
755
+ **site/_plugins/my_custom_deploy.rb**
756
+ ```ruby
757
+ module Photish::Plugin::MyCustomDeploy
758
+ def initialize(config, log)
759
+ @config = config
760
+ @log = log
761
+ end
762
+
763
+ def self.is_for?(type)
764
+ Photish::Plugin::Type::Photo == type
765
+ end
766
+
767
+ def self.engine_name
768
+ 'my_custom_deploy'
769
+ end
770
+
771
+ def deploy_site
772
+ @log.info "Deploying using my plugin"
773
+ FileUtils.cp(@config.output_dir, '/srv/www')
774
+ end
775
+ end
776
+ ```
777
+
698
778
  ### Plugin Loading
699
779
 
700
- All ruby files in `site/_plugins` will be loaded into the runtime but only
701
- those in the `Photish::Plugin` namespace with a `self.is_for?(type)` method
702
- will be used by Photish as plugins.
780
+ Photish supports the following methods of Plugin loading:
781
+
782
+ 1. Automatic loading of files in the `site/_plugins` directory. This is the
783
+ most simple way and is recommended if you just want a simple helper specific
784
+ to your site.
785
+ 1. Including a Gem in your Photish site's `Gemfile` and listing the name of the
786
+ Gem in the `plugins` [Config File Option](#config-file-options). This is
787
+ recommended if you want to utilize a plugin created by someone else in the
788
+ community - rather than simple copy pasting their code to your
789
+ `site/_plugins` directory.
703
790
 
704
791
  ## Development
705
792
 
@@ -711,6 +798,7 @@ To develop:
711
798
  $ git clone git@github.com:henrylawson/photish.git
712
799
  $ cd photish
713
800
  $ ./bin/setup # installs dependencies
801
+ $ Install exiftool as detailed above.
714
802
  $ rake # runs the tests
715
803
  $ vim # open up the project and begin contributing
716
804
  $ ./bin/console # for an interactive prompt
@@ -728,10 +816,10 @@ To release:
728
816
  Bug reports and pull requests are welcome on GitHub at
729
817
  https://github.com/henrylawson/photish. This project is intended to be a safe,
730
818
  welcoming space for collaboration, and contributors are expected to adhere to
731
- the [Contributor Covenant](contributor-covenant.org) code of conduct.
819
+ the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
732
820
 
733
821
  ## License
734
822
 
735
823
  The gem is available as open source under the terms of the [MIT
736
- License](http://opensource.org/licenses/MIT).
824
+ License](https://opensource.org/licenses/MIT).
737
825
 
data/Rakefile CHANGED
@@ -26,8 +26,9 @@ end
26
26
  task :default => [:clean,
27
27
  :spec,
28
28
  :features,
29
- :gather_coverage,
30
- 'metrics:all']
29
+ :gather_coverage]
30
+
31
+ task :stats => ['metrics:all']
31
32
 
32
33
  namespace :photish do
33
34
  Photish::Rake::Task.new(:init, 'Creates a basic project') do |t|
data/TODO.md CHANGED
@@ -2,20 +2,16 @@
2
2
 
3
3
  ## In Progress
4
4
 
5
- 1. Url and base are broken during template/image creation
6
- 1. Solve problem for explicit urls mentioned in templates (that need host/base)
7
- 1. Need to have parameters to change on deploy
8
- 1. During Host command nullify url options to work on host
9
- 1. Deploy README content
10
5
  1. Extract the SSH deploy to gem
11
6
 
12
7
  ## Backlog
13
8
 
14
- 1. Empty folders exist in output dir after orig removed and regeneration has happened
9
+ 1. Dry up the SimpleCov config that is everywhere
10
+ 1. Mime-types gem required 2.0 and above, lost 1.9.x, does this matter?
11
+ 1. Need to have parameters to change on deploy
15
12
  1. Worker can die when large folders moved mid generation
16
13
  1. Changing convert items does not trigger regeneration but changing name does
17
14
  1. Templates with exif data, super slow
18
- 1. Plugin as a gem to deploy to github pages, netlify, amazon s3
19
15
  1. Custom template rendering outside of `_templates` folder using `page.{type}`
20
16
  1. Proper asset pipeline for CSS
21
17
  1. A sitemap helper plugin for use in custom templates for example
@@ -25,4 +21,4 @@
25
21
  1. Provide generic way to override config from arguments to allow for host name
26
22
  override on deploy etc.
27
23
  1. Video transcoding and template rendering
28
- 1. Demo sites with better design
24
+ 1. JRuby support, perhaps?
data/exe/photish CHANGED
@@ -3,6 +3,8 @@
3
3
  if ENV['COVERAGE']
4
4
  require 'simplecov'
5
5
  SimpleCov.command_name "photish-binary-#{Process.pid}"
6
+ SimpleCov.add_filter 'vendor'
7
+ SimpleCov.add_filter 'tmp'
6
8
  SimpleCov.root(File.join(File.expand_path(File.dirname(__FILE__)), '..'))
7
9
  end
8
10
 
@@ -1,5 +1,4 @@
1
1
  module Photish::Plugin::FooterLinks
2
-
3
2
  def self.is_for?(type)
4
3
  [
5
4
  Photish::Plugin::Type::Collection,
@@ -1,5 +1,4 @@
1
1
  class Photish::Plugin::TmpdirDeploy
2
-
3
2
  def initialize(config, log)
4
3
  @config = config
5
4
  @log = log
@@ -1,5 +1,4 @@
1
1
  module Photish::Plugin::YellLoud
2
-
3
2
  def self.is_for?(type)
4
3
  [
5
4
  Photish::Plugin::Type::Collection,
@@ -2,7 +2,7 @@ doctype html
2
2
  html
3
3
  head
4
4
  title Photish example site
5
- link href="/styles/basic.css" media="screen" rel="stylesheet" type="text/css"
5
+ link href="#{build_url('styles', 'basic.css')}" media="screen" rel="stylesheet" type="text/css"
6
6
  body
7
7
  div.header
8
8
  a href="/"
@@ -13,5 +13,5 @@ html
13
13
  == yield
14
14
  div.footer
15
15
  | Site assets:
16
- == links_with_seperator([{text: 'My Custom Page', url: '/custom.html'},
17
- {text: 'CSS Download', url: '/styles/basic.css'}], '|')
16
+ == links_with_seperator([{text: 'My Custom Page', url: build_url('custom.html')},
17
+ {text: 'CSS Download', url: build_url('styles', 'basic.css')}], '|')
@@ -7,6 +7,9 @@ module Photish
7
7
 
8
8
  return no_engine_found unless engine && engine_class
9
9
 
10
+ log.info "Regenerating site, to ensure fresh copy"
11
+ regenerate_entire_site
12
+
10
13
  log.info "Deploying with engine #{engine_class}"
11
14
  engine_class.new(config, log).deploy_site
12
15
  end
@@ -17,13 +20,17 @@ module Photish
17
20
  :site_dir,
18
21
  to: :config
19
22
 
23
+ def regenerate_entire_site
24
+ Photish::Command::Generate.new(runtime_config)
25
+ .execute
26
+ end
20
27
 
21
28
  def no_engine_found
22
29
  log.info "No engine found..."
23
30
  end
24
31
 
25
32
  def load_all_plugins
26
- Plugin::Repository.instance.reload(site_dir)
33
+ Plugin::Repository.instance.reload(config)
27
34
  end
28
35
 
29
36
  def engine_class
@@ -36,7 +36,7 @@ module Photish
36
36
  end
37
37
 
38
38
  def load_all_plugins
39
- Plugin::Repository.instance.reload(site_dir)
39
+ Plugin::Repository.instance.reload(config)
40
40
  end
41
41
 
42
42
  def spawn_all_workers
@@ -86,10 +86,14 @@ module Photish
86
86
 
87
87
  def regenerate_entire_site
88
88
  log.info "Regenerating site"
89
- Photish::Command::Generate.new(runtime_config)
89
+ Photish::Command::Generate.new(regenerate_runtime_config)
90
90
  .execute
91
91
  end
92
92
 
93
+ def regenerate_runtime_config
94
+ runtime_config.merge(url: { type: 'absolute_relative' })
95
+ end
96
+
93
97
  def queue
94
98
  @queue ||= Queue.new
95
99
  end
@@ -22,7 +22,7 @@ module Photish
22
22
 
23
23
  def load_all_plugins
24
24
  return if Plugin::Repository.instance.loaded?
25
- Plugin::Repository.instance.reload(site_dir)
25
+ Plugin::Repository.instance.reload(config)
26
26
  end
27
27
 
28
28
  def render_whole_site
@@ -15,7 +15,8 @@ module Photish
15
15
  qualities: qualities,
16
16
  templates: templates,
17
17
  logging: logging,
18
- url: url
18
+ url: url,
19
+ plugins: []
19
20
  }
20
21
  end
21
22
 
@@ -24,7 +25,8 @@ module Photish
24
25
  def url
25
26
  {
26
27
  host: '',
27
- base: nil
28
+ base: nil,
29
+ type: 'absolute_uri'
28
30
  }
29
31
  end
30
32
 
@@ -0,0 +1,35 @@
1
+ module Photish::Plugin::Breadcrumb
2
+ def self.is_for?(type)
3
+ [
4
+ Photish::Plugin::Type::Collection,
5
+ Photish::Plugin::Type::Album,
6
+ Photish::Plugin::Type::Photo
7
+ ].include?(type)
8
+ end
9
+
10
+ def breadcrumbs
11
+ html = "<ul class=\"breadcrumbs\">"
12
+ parents_and_me.each_with_index do |level, index|
13
+ html << "<li class=\"" << crumb_class(index) << "\">"
14
+ html << "<a href=\"" << level.url << "\">" << level.name << "</a>"
15
+ html << "</li>"
16
+ end
17
+ html << "</ul>"
18
+ end
19
+
20
+ def parents_and_me
21
+ @parents_and_me ||= [parent.try(:parents_and_me),
22
+ self].flatten.compact
23
+ end
24
+
25
+ private
26
+
27
+ def crumb_class(index)
28
+ crumb_class = 'breadcrumb'
29
+ crumb_class << ' crumb-' << index.to_s
30
+ crumb_class << ' crumb-first' if index == 0
31
+ crumb_class << ' crumb-last' if index == (parents_and_me.count - 1)
32
+ crumb_class << ' crumb-only' if parents_and_me.count == 1
33
+ crumb_class
34
+ end
35
+ end
@@ -0,0 +1,21 @@
1
+ module Photish::Plugin::BuildUrl
2
+ def self.is_for?(type)
3
+ [
4
+ Photish::Plugin::Type::Collection,
5
+ Photish::Plugin::Type::Album,
6
+ Photish::Plugin::Type::Photo
7
+ ].include?(type)
8
+ end
9
+
10
+ def build_url(*pieces)
11
+ url_pieces = []
12
+ url_pieces << host
13
+ url_pieces << url_info.base
14
+ url_pieces << pieces
15
+ url_pieces.flatten
16
+ .compact
17
+ .join('/')
18
+ .squeeze('/')
19
+ end
20
+ end
21
+
@@ -4,7 +4,6 @@ module Photish
4
4
  include Traits::Urlable
5
5
  include Traits::Albumable
6
6
  include Traits::Metadatable
7
- include Traits::Breadcrumbable
8
7
  include Photish::Plugin::Pluginable
9
8
 
10
9
  delegate :qualities,
@@ -4,7 +4,6 @@ module Photish
4
4
  include Traits::Urlable
5
5
  include Traits::Albumable
6
6
  include Traits::Metadatable
7
- include Traits::Breadcrumbable
8
7
  include Photish::Plugin::Pluginable
9
8
 
10
9
  attr_reader :qualities,
@@ -30,7 +29,7 @@ module Photish
30
29
  end
31
30
 
32
31
  def all_url_parts
33
- @all_url_parts ||= [url_parts,
32
+ @all_url_parts ||= [[url_parts],
34
33
  all_albums.map(&:url_parts),
35
34
  all_photos.map(&:url_parts),
36
35
  all_images.map(&:url_parts)].flatten(1)
@@ -3,7 +3,6 @@ module Photish
3
3
  class Photo
4
4
  include Traits::Urlable
5
5
  include Traits::Metadatable
6
- include Traits::Breadcrumbable
7
6
  include Photish::Plugin::Pluginable
8
7
 
9
8
  delegate :qualities,
@@ -7,7 +7,7 @@ module Photish
7
7
  end
8
8
 
9
9
  def url_path
10
- @url_path ||= url_parts.join('/')
10
+ @url_path ||= url_parts.join(File::SEPARATOR)
11
11
  end
12
12
 
13
13
  def url_parts
@@ -18,12 +18,16 @@ module Photish
18
18
  @base_url_parts ||= parent.base_url_parts + [slugify(base_url_name)]
19
19
  end
20
20
 
21
- private
22
-
23
21
  def host
24
- @host ||= url_info.host || ''
22
+ @host ||= if url_info.type == 'absolute_uri'
23
+ url_info.host || ''
24
+ else
25
+ ''
26
+ end
25
27
  end
26
28
 
29
+ private
30
+
27
31
  def slugify(word)
28
32
  CGI.escape(word.downcase.gsub(' ', '-'))
29
33
  end
@@ -4,10 +4,11 @@ module Photish
4
4
  include Singleton
5
5
  include Log::Loggable
6
6
 
7
- def reload(site_dir)
7
+ def reload(config)
8
8
  log.info "Loading plugins..."
9
9
 
10
- load_each_plugin_file(site_dir)
10
+ load_each_plugin_file(config.site_dir)
11
+ require_each_explicit_plugin(config.plugins)
11
12
  clear_plugin_cache
12
13
  load_each_plugin_constant
13
14
  end
@@ -17,8 +18,7 @@ module Photish
17
18
  end
18
19
 
19
20
  def all_plugins
20
- @all_plugins ||= constants.map { |m| constantize(m) }
21
- .reject { |m| ignored_modules.include?(m) }
21
+ @all_plugins ||= constants + sub_constants
22
22
  end
23
23
 
24
24
  def loaded?
@@ -27,6 +27,13 @@ module Photish
27
27
 
28
28
  private
29
29
 
30
+ def require_each_explicit_plugin(plugins)
31
+ plugins.each do |plugin|
32
+ log.info "Requiring config explicit plugin, #{plugin}"
33
+ require plugin
34
+ end
35
+ end
36
+
30
37
  def load_each_plugin_constant
31
38
  all_plugins.each do |plugin|
32
39
  log.info "Found plugin #{plugin}"
@@ -44,7 +51,17 @@ module Photish
44
51
  end
45
52
 
46
53
  def constants
47
- Photish::Plugin.constants
54
+ Photish::Plugin.constants.map { |m| constantize(m) }
55
+ .reject { |m| ignored_modules.include?(m) }
56
+ .select { |m| m.respond_to?(:is_for?) }
57
+ end
58
+
59
+ def sub_constants
60
+ Photish::Plugin.constants.map { |c| constantize(c) }
61
+ .reject { |m| ignored_modules.include?(m) }
62
+ .map { |c| c.constants.map { |d| constantize("#{c.name}::#{d}") } }
63
+ .flatten
64
+ .select { |m| m.respond_to?(:is_for?) }
48
65
  end
49
66
 
50
67
  def ignored_modules
@@ -7,6 +7,7 @@ module Photish
7
7
 
8
8
  def all_for(collection)
9
9
  delete_unknown_files(collection.all_url_parts)
10
+ delete_empty_folders
10
11
  move_non_ignored_site_contents
11
12
  collection_template.render(collection)
12
13
  end
@@ -19,18 +20,32 @@ module Photish
19
20
  :site_dir,
20
21
  :output_dir,
21
22
  :worker_index,
23
+ :url,
22
24
  to: :config
23
25
 
24
26
  def move_non_ignored_site_contents
25
27
  FileUtils.mkdir_p(output_dir)
26
- FileUtils.cp_r(non_ignored_site_contents, output_dir)
28
+ FileUtils.cp_r(non_ignored_site_contents,
29
+ File.join([output_dir, url.base].compact))
30
+ end
31
+
32
+ def delete_empty_folders
33
+ Dir["#{output_dir}/**/"].reverse_each do |d|
34
+ FileUtils.rm_rf(d) if empty_dir?(d)
35
+ end
36
+ end
37
+
38
+ def empty_dir?(dir)
39
+ Dir.entries(dir)
40
+ .reject { |d| File.basename(d).starts_with?('.') }
41
+ .empty?
27
42
  end
28
43
 
29
44
  def delete_unknown_files(url_parts)
30
- do_not_delete = Set.new(url_parts.map { |url| File.join(output_dir, url) }
31
- .map(&:to_s))
45
+ keep = Set.new(url_parts.map { |url| File.join(output_dir, url) }
46
+ .map(&:to_s))
32
47
  files_to_delete = Dir["#{output_dir}/**/*"].select do |f|
33
- File.file?(f) && !do_not_delete.include?(f)
48
+ File.file?(f) && !keep.include?(f)
34
49
  end
35
50
  FileUtils.rm_rf(files_to_delete)
36
51
  end
@@ -1,3 +1,3 @@
1
1
  module Photish
2
- VERSION = "0.3.8"
2
+ VERSION = "0.3.9"
3
3
  end
data/lib/photish.rb CHANGED
@@ -38,10 +38,11 @@ require 'photish/config/default_config'
38
38
  require 'photish/config/file_config'
39
39
  require 'photish/config/file_config_location'
40
40
  require 'photish/config/app_settings'
41
+ require 'photish/core_plugin/build_url'
42
+ require 'photish/core_plugin/breadcrumb'
41
43
  require 'photish/gallery/traits/urlable'
42
44
  require 'photish/gallery/traits/albumable'
43
45
  require 'photish/gallery/traits/metadatable'
44
- require 'photish/gallery/traits/breadcrumbable'
45
46
  require 'photish/gallery/photo'
46
47
  require 'photish/gallery/album'
47
48
  require 'photish/gallery/image'
data/photish.gemspec CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ["lib"]
22
22
 
23
- spec.required_ruby_version = '>= 1.9.3'
23
+ spec.required_ruby_version = '>= 2.0'
24
24
 
25
25
  spec.add_dependency "thor", "~> 0.1"
26
26
  spec.add_dependency "activesupport", "~> 4.2"
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.3.8
4
+ version: 0.3.9
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-12-26 00:00:00.000000000 Z
11
+ date: 2015-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -369,6 +369,8 @@ files:
369
369
  - lib/photish/config/default_config.rb
370
370
  - lib/photish/config/file_config.rb
371
371
  - lib/photish/config/file_config_location.rb
372
+ - lib/photish/core_plugin/breadcrumb.rb
373
+ - lib/photish/core_plugin/build_url.rb
372
374
  - lib/photish/gallery/album.rb
373
375
  - lib/photish/gallery/collection.rb
374
376
  - lib/photish/gallery/image.rb
@@ -404,7 +406,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
404
406
  requirements:
405
407
  - - ">="
406
408
  - !ruby/object:Gem::Version
407
- version: 1.9.3
409
+ version: '2.0'
408
410
  required_rubygems_version: !ruby/object:Gem::Requirement
409
411
  requirements:
410
412
  - - ">="