photish 0.3.4 → 0.3.5

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: 5ff58bf1d669264455034b1ea27a798ea979d2f0
4
- data.tar.gz: 6f6bb07a9b0ecd54643b9090c27336b13c0ecb09
3
+ metadata.gz: 31149e215cc2087c36f281ad5a1984ad2ce5f45b
4
+ data.tar.gz: 64ee1e2e49df780d17533a63bf3d17e8346fa7ea
5
5
  SHA512:
6
- metadata.gz: ea5d2478db86db55aca53b8fec1abe53c65d6714e6fa12bd6d3c8cd85b5f4d145183e184b4e9a10bf1a8b9cd0fd4650426ae4416f2862b7c54bae49953881663
7
- data.tar.gz: b86aa902da22f12807bdef9d26b46f7df180472268e56affc1ea9b63a7ee0c2f45fd15056a64c3a049bcb9a8acf05c6c99f54e7a3c185ce801f725f7bd72dfb6
6
+ metadata.gz: 6f9e9849870e9dcaaf562a5e5b13e6d931bddea503f00e2351958c8bbe763cbe7191c1322a0173a87cc2a02fbacb3fbf1ca6ddfe7cfc20d9e1be72f60625fe47
7
+ data.tar.gz: e937262b5fa4c831585831ff2161412bb6f50a10ca729b83513159f2bbaf28148e95a3fd58f9b21a0009b4be1782b888b55cbff71bbfc1e772df1c70bf964e6e
data/README.md CHANGED
@@ -64,6 +64,8 @@ and running:
64
64
  - [Execution Order](#execution-order)
65
65
  - [Workers and Threads](#workers-and-threads)
66
66
  - [Caching](#caching)
67
+ - [Automatic Rengeneration](#automatic-regeneration)
68
+ - [Forced Regeneration](#forced-regeneration)
67
69
  - [Host](#host)
68
70
  - [Rake Task](#rake-task)
69
71
  - [Plugins](#plugins)
@@ -294,6 +296,7 @@ url:
294
296
  base: 'subdirectory'
295
297
  workers: 4
296
298
  threads: 2
299
+ force: false
297
300
  ```
298
301
 
299
302
  The meanings and purpose of each field is defined below:
@@ -318,6 +321,7 @@ Field | Purpose
318
321
  `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`
319
322
  `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
320
323
  `threads` | the number of threads each worker should create to handle image magick transcoding
324
+ `force` | this should always be false, if true, all content will be regenerated and nothing cached
321
325
 
322
326
  #### Customizing Templates
323
327
 
@@ -473,11 +477,11 @@ The Generate command does the following:
473
477
 
474
478
  #### Workers and Threads
475
479
 
476
- In order to achieve maximum utilization of all processors on a CPU during
480
+ In order to achieve maximum utilization of all processors on a computer during
477
481
  generation, Photish has the ability to create multiple workers and threads.
478
482
 
479
483
  A worker is a spawned sub process created by the Generate command. The worker
480
- sub process is responsible for generating the HTML and Images for a sub set of
484
+ sub process is responsible for generating the HTML and Images for a subset of
481
485
  the collection.
482
486
 
483
487
  Within each worker, threads are created when calling out to the Image Magick
@@ -486,11 +490,11 @@ utilization so rather then block the whole worker, it can be more performant to
486
490
  spawn multiple Image Magick processes at once.
487
491
 
488
492
  For collections with a large number of images and HTML pages, multiple workers
489
- and threads can be used to rapidly speed up generation. However if the
490
- collection is quite small and the images are of a small size, workers and
491
- threads will increase the generation time as loading a new ruby runtime and
492
- creating multiple threads may have a higher setup time then just generating in
493
- a single ruby process.
493
+ and threads can be used to rapidly speed up generation. However, if the
494
+ collection has a small number of photos and pages, workers and threads will
495
+ increase the generation time as loading a new ruby process and creating
496
+ multiple threads may have a higher setup time then just generating everything
497
+ in a single ruby process.
494
498
 
495
499
  The number of workers and threads is configurable in the [config
496
500
  file](#config-file-options) with the `workers` and `threads` options. By
@@ -510,16 +514,25 @@ a local version of Photish with the Host command.
510
514
 
511
515
  The cache file is stored in the `output_dir` and is named `.changes.yml`.
512
516
 
513
- To do a full regeneration, simple run the Generate command with the `force`
514
- flag:
515
-
516
- $ photish generate --force
517
+ ##### Automatic Regeneration
517
518
 
518
519
  Images are regenerated when they are modified, renamed or moved.
519
520
 
520
521
  Changing the `qualities` option in the config file will also trigger a full
521
522
  regeneration of all images.
522
523
 
524
+ ##### Forced Regeneration
525
+
526
+ To do a full regeneration, run the Generate command with the `--force`
527
+ flag:
528
+
529
+ $ photish generate --force
530
+
531
+ The host command also supports the `--force` flag, to do a full regeneration
532
+ on every change:
533
+
534
+ $ photish host --force
535
+
523
536
  ### Host
524
537
 
525
538
  To test and view your changes locally, the host command can be used to run a
@@ -10,6 +10,10 @@ module Photish
10
10
  File.open(db_file(output_dir), 'w') { |f| f.write(changes.to_yaml) }
11
11
  end
12
12
 
13
+ def clear(output_dir)
14
+ FileUtils.rm_rf(db_file(output_dir))
15
+ end
16
+
13
17
  def db_file(output_dir)
14
18
  FileUtils.mkdir_p(output_dir)
15
19
  File.join(output_dir, '.changes.yml')
@@ -22,7 +26,8 @@ module Photish
22
26
 
23
27
  module_function :concat_db_files,
24
28
  :db_file,
25
- :worker_db_file
29
+ :worker_db_file,
30
+ :clear
26
31
  end
27
32
  end
28
33
  end
@@ -4,7 +4,7 @@ module Photish
4
4
  package_name "Photish"
5
5
 
6
6
  desc "generate", "Generates the gallery static site"
7
- option :worker_index, type: :numeric
7
+ option :force, type: :boolean
8
8
  def generate
9
9
  Photish::Command::Generate.new(options).execute
10
10
  end
@@ -16,6 +16,7 @@ module Photish
16
16
  end
17
17
 
18
18
  desc "host", "Serves the HTML on a HTTP server"
19
+ option :force, type: :boolean
19
20
  def host
20
21
  Photish::Command::Host.new(options).execute
21
22
  end
@@ -4,6 +4,7 @@ module Photish
4
4
  def run
5
5
  log.info "Starting generation with #{workers} workers"
6
6
 
7
+ clear_cache if force_regeneration?
7
8
  spawn_all_workers
8
9
  load_all_plugins
9
10
  wait_for_workers_to_complete
@@ -22,8 +23,17 @@ module Photish
22
23
  :qualities,
23
24
  :photish_executable,
24
25
  :workers,
26
+ :force,
25
27
  to: :config
26
28
 
29
+ def force_regeneration?
30
+ force == true
31
+ end
32
+
33
+ def clear_cache
34
+ Cache::ManifestDbFile.clear(output_dir)
35
+ end
36
+
27
37
  def load_all_plugins
28
38
  Plugin::Repository.reload(log, site_dir)
29
39
  end
@@ -10,6 +10,7 @@ module Photish
10
10
  workers: workers,
11
11
  threads: threads,
12
12
  worker_index: 0,
13
+ force: false,
13
14
  photish_executable: photish_executable,
14
15
  qualities: [
15
16
  { name: 'Original',
@@ -12,7 +12,7 @@ module Photish
12
12
  def render(images)
13
13
  log.info "Rendering #{images.count} images across #{threads} threads"
14
14
 
15
- change_manifest.preload
15
+ cache.preload
16
16
  threads = spawn_thread_instances(to_queue(images))
17
17
  threads.map(&:join)
18
18
  flush_to_disk
@@ -30,7 +30,7 @@ module Photish
30
30
  :changed?,
31
31
  :flush_to_disk,
32
32
  :preload,
33
- to: :change_manifest
33
+ to: :cache
34
34
 
35
35
  def spawn_thread_instances(image_queue)
36
36
  (0...threads).map do
@@ -74,10 +74,10 @@ module Photish
74
74
  FileUtils.mkdir_p(File.join(output_dir, image.base_url_parts))
75
75
  end
76
76
 
77
- def change_manifest
78
- @change_manifest ||= Cache::Manifest.new(output_dir,
79
- worker_index,
80
- version_hash)
77
+ def cache
78
+ @cache ||= Cache::Manifest.new(output_dir,
79
+ worker_index,
80
+ version_hash)
81
81
  end
82
82
  end
83
83
  end
@@ -1,3 +1,3 @@
1
1
  module Photish
2
- VERSION = "0.3.4"
2
+ VERSION = "0.3.5"
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.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henry Lawson