photish 0.3.2 → 0.3.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: 10d4377b58ca8abfc533f024d63b08ac42ad2843
4
- data.tar.gz: bbc4d59536dfcfe2bc92880963a32a9f77988b3e
3
+ metadata.gz: 837da75e8c5426ba38888369dc28eaa433e5162c
4
+ data.tar.gz: 8678a47a42f4b7e49ec3faae98130ada68e742e6
5
5
  SHA512:
6
- metadata.gz: e1a165687012458bda29b180ea140faca11d1978d7eb9f8353c1863c95cd9aa7d761959e4c1a46c6a637e2c62e98adf860a33c6ce2ae98e0fe33f716cb180d75
7
- data.tar.gz: b83864d828fac5f6878df88cd99061c585ba286f1b5fb809af1fc7a3ceb8486bcbd81da73c787a83090d470f1b7c2304235a1e4213892f15897b5ea22549a1d3
6
+ metadata.gz: f5fb8362d0d569a7f2f7c13edcd86259112cc062714f64a30602d3d00aaf7e6efde8bf0f5753a72a7f92447702b67d823085c363e445defddee223d98341374d
7
+ data.tar.gz: e5309014399f150ee267288433e363206b6b9356c4f6c7fbe28d9a61f9cbdd00112d0cb01017a890b6e7c946bd8488d12f2f2e37a04f1ca5987cdd1d539f5bad
data/README.md CHANGED
@@ -21,6 +21,13 @@ information, Photish creates a complete static website that can be hosted on an
21
21
  [NGINX](http://nginx.org/), [Apache HTTP Server](https://httpd.apache.org/), or
22
22
  even on [Github Pages](https://pages.github.com/).
23
23
 
24
+ Photish has been created with speed and efficiency in mind. Threads are used
25
+ to parallelize image transcoding to achieve maximum utilization of your CPU
26
+ during generation. A cache file is then used to ensure that unless the image
27
+ has changed, it is not needlessly regenerated. This results in a responsive
28
+ and fast local development environment, making it easy to perfect the design
29
+ of your photo based website without having to wait for regeneration.
30
+
24
31
  ## Getting Started
25
32
 
26
33
  It is strongly recommended to read through the [Installation](#installation)
@@ -2,9 +2,7 @@ module Photish
2
2
  module Command
3
3
  class Generate < Base
4
4
  def run
5
- log_important_config_values
6
5
  load_all_plugins
7
- log_album_and_photo_names
8
6
  render_whole_site
9
7
  log.info 'Site generation completed successfully'
10
8
  end
@@ -24,19 +22,6 @@ module Photish
24
22
  Photish::Plugin::Repository.reload(log, site_dir)
25
23
  end
26
24
 
27
- def log_important_config_values
28
- log.info "Photo directory: #{photo_dir}"
29
- log.info "Site directory: #{site_dir}"
30
- log.info "Output directory: #{output_dir}"
31
- end
32
-
33
- def log_album_and_photo_names
34
- collection.albums.each do |album|
35
- log.info album.name
36
- log.info album.photos.map(&:name)
37
- end
38
- end
39
-
40
25
  def render_whole_site
41
26
  Photish::Render::Site.new(templates,
42
27
  site_dir,
@@ -30,10 +30,10 @@ module Photish
30
30
  end
31
31
 
32
32
  def all_url_paths
33
- [url_path,
34
- all_albums.map(&:url_path),
35
- all_photos.map(&:url_path),
36
- all_images.map(&:url_path)].flatten
33
+ @all_url_paths ||= [url_path,
34
+ all_albums.map(&:url_path),
35
+ all_photos.map(&:url_path),
36
+ all_images.map(&:url_path)].flatten
37
37
  end
38
38
 
39
39
  private
@@ -21,11 +21,11 @@ module Photish
21
21
  end
22
22
 
23
23
  def images
24
- qualities.map { |quality| Photish::Gallery::Image.new(self, path, quality) }
24
+ @images ||= qualities.map { |quality| Photish::Gallery::Image.new(self, path, quality) }
25
25
  end
26
26
 
27
27
  def exif
28
- MiniExiftool.new(path)
28
+ @exif ||= MiniExiftool.new(path)
29
29
  end
30
30
 
31
31
  def plugin_type
@@ -11,19 +11,19 @@ module Photish
11
11
  end
12
12
 
13
13
  def all_albums
14
- albums.map { |album| [album] + album.all_albums }
15
- .flatten
14
+ @all_albums ||= albums.map { |album| [album] + album.all_albums }
15
+ .flatten
16
16
  end
17
17
 
18
18
  def all_photos
19
- all_albums.map(&:photos)
20
- .concat(self.try(:photos) || [])
21
- .flatten
19
+ @all_photos ||= all_albums.map(&:photos)
20
+ .concat(self.try(:photos) || [])
21
+ .flatten
22
22
  end
23
23
 
24
24
  def all_images
25
- all_photos.map(&:images)
26
- .flatten
25
+ @all_images ||= all_photos.map(&:images)
26
+ .flatten
27
27
  end
28
28
  end
29
29
  end
@@ -17,7 +17,8 @@ module Photish
17
17
  end
18
18
 
19
19
  def parents_and_me
20
- [parent.try(:parents_and_me), self].flatten.compact
20
+ @parents_and_me ||= [parent.try(:parents_and_me),
21
+ self].flatten.compact
21
22
  end
22
23
 
23
24
  private
@@ -4,7 +4,7 @@ module Photish
4
4
  module Metadatable
5
5
  def metadata
6
6
  return unless File.exist?(metadata_file)
7
- RecursiveOpenStruct.new(YAML.load_file(metadata_file))
7
+ @metadata ||= RecursiveOpenStruct.new(YAML.load_file(metadata_file))
8
8
  end
9
9
 
10
10
  private
@@ -3,25 +3,25 @@ module Photish
3
3
  module Traits
4
4
  module Urlable
5
5
  def url
6
- [host, url_parts].flatten.join('/')
6
+ @url ||= [host, url_parts].flatten.join('/')
7
7
  end
8
8
 
9
9
  def url_path
10
- url_parts.join('/')
10
+ @url_path ||= url_parts.join('/')
11
11
  end
12
12
 
13
13
  def url_parts
14
- base_url_parts + [url_end]
14
+ @url_parts ||= base_url_parts + [url_end]
15
15
  end
16
16
 
17
17
  def base_url_parts
18
- parent.base_url_parts + [slugify(base_url_name)]
18
+ @base_url_parts ||= parent.base_url_parts + [slugify(base_url_name)]
19
19
  end
20
20
 
21
21
  private
22
22
 
23
23
  def host
24
- normalized_host || ''
24
+ @host ||= normalized_host || ''
25
25
  end
26
26
 
27
27
  def normalized_host
@@ -3,34 +3,43 @@ module Photish
3
3
  class ChangeManifest
4
4
  def initialize(output_dir)
5
5
  @output_dir = output_dir
6
+ @dirty = false
6
7
  end
7
8
 
8
9
  def record(key, file_path = nil)
9
- db[key] = md5_of_file(file_path || key)
10
+ @dirty = true
11
+ db[key] = checksum_of_file(file_path || key)
10
12
  end
11
13
 
12
14
  def changed?(key, file_path = nil)
13
- md5_of_file(file_path || key) != old_md5_of_file(key)
15
+ checksum_of_file(file_path || key) != old_checksum_of_file(key)
14
16
  end
15
17
 
16
18
  def flush_to_disk
19
+ return unless dirty
17
20
  File.open(db_file, 'w') { |f| f.write((db || {}).to_yaml) }
18
21
  end
19
22
 
23
+ def preload
24
+ db
25
+ end
26
+
20
27
  private
21
28
 
22
- attr_reader :output_dir
29
+ attr_reader :output_dir,
30
+ :dirty
23
31
 
24
- def md5_of_file(file_path)
32
+ def checksum_of_file(file_path)
25
33
  Digest::MD5.file(file_path).hexdigest
26
34
  end
27
-
28
- def old_md5_of_file(file_path)
35
+
36
+ def old_checksum_of_file(file_path)
29
37
  db[file_path]
30
38
  end
31
39
 
32
40
  def db
33
- @db ||= File.exist?(db_file) ? YAML.load_file(db_file) : {}
41
+ return @db if @db
42
+ @db = File.exist?(db_file) ? YAML.load_file(db_file) : {}
34
43
  end
35
44
 
36
45
  def db_file
@@ -10,8 +10,9 @@ module Photish
10
10
  def render(images)
11
11
  image_queue = to_queue(images)
12
12
 
13
- log.info "Rendering #{images.count} across #{max_workers} threads"
13
+ log.info "Rendering #{images.count} images across #{max_workers} threads"
14
14
 
15
+ change_manifest.preload
15
16
  workers = (0...max_workers).map do
16
17
  Thread.new do
17
18
  begin
@@ -1,3 +1,3 @@
1
1
  module Photish
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: photish
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henry Lawson