photish 0.3.11 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.pryrc +2 -0
- data/README.md +73 -12
- data/TODO.md +8 -8
- data/bin/console +2 -10
- data/bin/setup +0 -2
- data/lib/photish/assets/example/photos/Big Dogs/Custom Template Page.slim +5 -0
- data/lib/photish/assets/example/site/_plugins/footer_links.rb +2 -1
- data/lib/photish/assets/example/site/_plugins/tmpdir_deploy.rb +2 -2
- data/lib/photish/assets/example/site/_plugins/yell_loud.rb +2 -1
- data/lib/photish/assets/example/site/_templates/album.slim +4 -0
- data/lib/photish/cache/db_file.rb +40 -0
- data/lib/photish/cache/manifest.rb +20 -18
- data/lib/photish/cache/repository.rb +42 -0
- data/lib/photish/cli/interface.rb +4 -0
- data/lib/photish/command/base.rb +6 -2
- data/lib/photish/command/deploy.rb +4 -8
- data/lib/photish/command/generate.rb +10 -26
- data/lib/photish/command/host.rb +8 -7
- data/lib/photish/command/init.rb +1 -1
- data/lib/photish/command/worker.rb +5 -17
- data/lib/photish/config/default_config.rb +5 -3
- data/lib/photish/config/file_config.rb +19 -5
- data/lib/photish/config/settings.rb +59 -0
- data/lib/photish/gallery/album.rb +27 -14
- data/lib/photish/gallery/collection.rb +27 -13
- data/lib/photish/gallery/image.rb +5 -12
- data/lib/photish/gallery/page.rb +40 -0
- data/lib/photish/gallery/photo.rb +7 -10
- data/lib/photish/gallery/traits/albumable.rb +9 -3
- data/lib/photish/gallery/traits/fileable.rb +30 -0
- data/lib/photish/gallery/traits/urlable.rb +12 -7
- data/lib/photish/log/io.rb +20 -0
- data/lib/photish/log/loggable.rb +1 -1
- data/lib/photish/log/{log_setup.rb → setup.rb} +1 -1
- data/lib/photish/{gallery/traits/breadcrumbable.rb → plugin/core/breadcrumb.rb} +12 -3
- data/lib/photish/plugin/core/build_url.rb +26 -0
- data/lib/photish/plugin/core/exifable.rb +15 -0
- data/lib/photish/plugin/core/metadatable.rb +27 -0
- data/lib/photish/plugin/repository.rb +3 -7
- data/lib/photish/plugin/type.rb +1 -0
- data/lib/photish/render/{image_conversion.rb → image.rb} +34 -18
- data/lib/photish/render/{site_worker.rb → model.rb} +13 -12
- data/lib/photish/render/page.rb +13 -24
- data/lib/photish/render/site.rb +3 -3
- data/lib/photish/render/template.rb +59 -0
- data/lib/photish/version.rb +1 -1
- data/lib/photish.rb +14 -11
- data/photish.gemspec +1 -0
- metadata +32 -14
- data/lib/photish/cache/manifest_db_file.rb +0 -36
- data/lib/photish/config/app_settings.rb +0 -57
- data/lib/photish/config/file_config_location.rb +0 -27
- data/lib/photish/config/image_extension.rb +0 -8
- data/lib/photish/core_plugin/breadcrumb.rb +0 -35
- data/lib/photish/core_plugin/build_url.rb +0 -20
- data/lib/photish/gallery/traits/metadatable.rb +0 -30
- data/lib/photish/log/access_log.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 126b9558be5101767839891a8bb1f439e4ceeb4d
|
4
|
+
data.tar.gz: f7f5788e4eae6c56c450f81b5079eb9747ac4660
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfb7b794c442026a35bd9a2e8281068c083fd9e7bd963a0630c878683002dd13ed4b7c8f4f79ad231f565edd94ce2803b2363ac65113f2d8d9006929b24d2f48
|
7
|
+
data.tar.gz: 8ad4cdffaae09e93667179b2d25b3ec6320244c6d4a582994d7bc283592dc9d7900ec64b1e22435b8458ee0466e2fb873e9635c6281f4702277fcbffe02d7891
|
data/.pryrc
ADDED
data/README.md
CHANGED
@@ -28,11 +28,11 @@ has changed, it is not needlessly regenerated. This results in a responsive
|
|
28
28
|
and fast local development environment, making it easy to perfect the design
|
29
29
|
of your photo based website without having to wait for regeneration.
|
30
30
|
|
31
|
-
##
|
31
|
+
## Example
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
[Photish Montage](https://foinq.com/photish-montage/index.html) - A quick
|
34
|
+
mockup to show what can be done with Photish. [Source
|
35
|
+
here](https://github.com/henrylawson/photish-montage).
|
36
36
|
|
37
37
|
## Getting Started
|
38
38
|
|
@@ -66,6 +66,8 @@ and running:
|
|
66
66
|
- [Album Template](#album-template)
|
67
67
|
- [Photo Template](#photo-template)
|
68
68
|
- [Template Helpers](#template-helpers)
|
69
|
+
- [Custom Rendered Content](#custom-rendered-content)
|
70
|
+
- [Gallery Page](#gallery-page)
|
69
71
|
- [Generate](#generate)
|
70
72
|
- [Execution Order](#execution-order)
|
71
73
|
- [Workers and Threads](#workers-and-threads)
|
@@ -208,19 +210,24 @@ Photish has dependencies on certain software:
|
|
208
210
|
- [Exiftool](http://www.sno.phy.queensu.ca/~phil/exiftool/) for image metadata
|
209
211
|
retrieval
|
210
212
|
|
211
|
-
|
213
|
+
Target OS dependencies:
|
212
214
|
|
213
|
-
- [Unix](http://www.unix.org/) based
|
214
|
-
|
215
|
-
this is not tested
|
215
|
+
- [Unix](http://www.unix.org/) based operating system, Photish has been tested
|
216
|
+
thoroughly on Ubuntu and MacOSX
|
216
217
|
|
217
218
|
**On MacOSX, using [Brew](http://brew.sh/)**
|
218
219
|
|
220
|
+
$ brew install ruby
|
219
221
|
$ brew install imagemagick
|
220
222
|
$ brew install exiftool
|
223
|
+
$ gem install bundler
|
221
224
|
|
222
225
|
**On Ubuntu or Debian**
|
223
226
|
|
227
|
+
$ sudo apt-add-repository ppa:brightbox/ruby-ng
|
228
|
+
$ sudo apt-get update
|
229
|
+
$ sudo apt-get install ruby2.2
|
230
|
+
$
|
224
231
|
$ sudo apt-get install imagemagick
|
225
232
|
$ sudo apt-get install libimage-exiftool-perl
|
226
233
|
|
@@ -292,7 +299,21 @@ generated file, the generated file will clobber the asset.
|
|
292
299
|
|
293
300
|
#### Config File Options
|
294
301
|
|
295
|
-
|
302
|
+
The default way to express config is in the `config.yml` file. However config
|
303
|
+
can also be overridden using the `--config_override` flag to any of the Photish
|
304
|
+
commands. When using the `--config_override` flag, the config must be expressed
|
305
|
+
as [JSON](http://www.json.org/). For example, to override logging when calling
|
306
|
+
the Generate command, you can use:
|
307
|
+
|
308
|
+
$ photish generate --config_override='{"logging":{"colorize":false}}'
|
309
|
+
|
310
|
+
This method of config override is only recommended for cases where the value
|
311
|
+
needs to be temporarily overridden, such as during a deployment or while
|
312
|
+
debugging.
|
313
|
+
|
314
|
+
Below is a complete `config.yml` file, recommended practice is to only set the
|
315
|
+
config values you need, otherwise just use the defaults, the file can be empty
|
316
|
+
and Photish will still function:
|
296
317
|
|
297
318
|
```yaml
|
298
319
|
port: 9876
|
@@ -308,7 +329,7 @@ templates:
|
|
308
329
|
photo: photo.slim
|
309
330
|
logging:
|
310
331
|
colorize: true
|
311
|
-
level: '
|
332
|
+
level: 'debug'
|
312
333
|
output: ['stdout', 'file']
|
313
334
|
url:
|
314
335
|
host: http://mydomain.com
|
@@ -319,6 +340,7 @@ threads: 2
|
|
319
340
|
force: false
|
320
341
|
plugins: ['ssh_deploy', 'other_plugin']
|
321
342
|
image_extensions: ['jpg', 'gif']
|
343
|
+
page_extension: 'slim'
|
322
344
|
```
|
323
345
|
|
324
346
|
The meanings and purpose of each field is defined below:
|
@@ -336,7 +358,7 @@ Field | Purpose
|
|
336
358
|
`templates/photo` | the photo template file in the `site/_templates` folder, must be overridden if using a different template engine
|
337
359
|
`logging` | a listing of the various logging options
|
338
360
|
`logging/colorize` | when outputting to `STDOUT`, `true` to use color, `false` for none
|
339
|
-
`logging/level` | the default logging level, it is advised to keep this at `
|
361
|
+
`logging/level` | the default logging level, it is advised to keep this at `debug`, supported are `debug`, `info`, `warn`, `error` and `fatal`
|
340
362
|
`logging/output` | the appenders for the logger, `stdout` goes to `STDOUT`, `file` goes to `log/photish.log`
|
341
363
|
`url` | a listing of the various url options
|
342
364
|
`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
|
@@ -347,6 +369,7 @@ Field | Purpose
|
|
347
369
|
`force` | this should always be false, if true, all content will be regenerated and nothing cached
|
348
370
|
`plugins` | an array of plugin names that have been included in your Gemfile and that Photish should require into it's runtime
|
349
371
|
`image_extensions` | by default, Photish obtains a list of supported image format extensions from ImageMagick, however if you choose too, you can explicitly list the extensions that Photish should use to find images
|
372
|
+
`page_extension` | the extension of **Pages** files that will live amongst the photo collection
|
350
373
|
|
351
374
|
#### Customizing Templates
|
352
375
|
|
@@ -407,6 +430,7 @@ albums | an array of child [Albums](https://github.com/henrylawson/
|
|
407
430
|
all_albums | an array of all child [Albums](https://github.com/henrylawson/photish/blob/master/lib/photish/gallery/album.rb)
|
408
431
|
all_photos | an array of all child [Photos](https://github.com/henrylawson/photish/blob/master/lib/photish/gallery/photo.rb)
|
409
432
|
all_images | an array of all child [Images](https://github.com/henrylawson/photish/blob/master/lib/photish/gallery/image.rb)
|
433
|
+
all_pages | an array of all child [Pages](https://github.com/henrylawson/photish/blob/master/lib/photish/gallery/page.rb)
|
410
434
|
|
411
435
|
##### Album Template
|
412
436
|
|
@@ -442,6 +466,7 @@ albums | an array of child [Albums](https://github.com/henrylawson/
|
|
442
466
|
all_albums | an array of all child [Albums](https://github.com/henrylawson/photish/blob/master/lib/photish/gallery/album.rb)
|
443
467
|
all_photos | an array of all child [Photos](https://github.com/henrylawson/photish/blob/master/lib/photish/gallery/photo.rb)
|
444
468
|
all_images | an array of all child [Images](https://github.com/henrylawson/photish/blob/master/lib/photish/gallery/image.rb)
|
469
|
+
all_pages | an array of all child [Pages](https://github.com/henrylawson/photish/blob/master/lib/photish/gallery/page.rb)
|
445
470
|
|
446
471
|
##### Photo Template
|
447
472
|
|
@@ -519,6 +544,36 @@ Method | Description
|
|
519
544
|
breadcrumbs | an unordered list of pages above the current page in the hierarchy
|
520
545
|
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
|
521
546
|
|
547
|
+
#### Custom Rendered Content
|
548
|
+
|
549
|
+
##### Gallery Page
|
550
|
+
|
551
|
+
A gallery page is a simple way to create a custom web page within the
|
552
|
+
collection or album of your gallery that will render within your site's [Layout
|
553
|
+
Template](#layout-template).
|
554
|
+
|
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
|
557
|
+
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.
|
562
|
+
|
563
|
+
`photos/**/*.{page_extension}`
|
564
|
+
|
565
|
+
```slim
|
566
|
+
div.more-about-album
|
567
|
+
h2 The More Details Page
|
568
|
+
p Lorem ipsum...
|
569
|
+
p Lorem ipsum...
|
570
|
+
p Lorem ipsum...
|
571
|
+
```
|
572
|
+
|
573
|
+
As with other gallery generated content, a gallery page is accessible from the
|
574
|
+
`all_pages` method within the [Collection](#collection-template) or
|
575
|
+
[Album](#album-template) template.
|
576
|
+
|
522
577
|
### Generate
|
523
578
|
|
524
579
|
The static HTML can be generated by running the below command inside the
|
@@ -644,6 +699,12 @@ The local version of your website will be visible at
|
|
644
699
|
The Host command will also automatically regenerate the website on startup and
|
645
700
|
when a file is added, removed or modified in the `photo_dir` or `site_dir`.
|
646
701
|
|
702
|
+
Note, when running in this mode any Image Conversion errors are swallowed and
|
703
|
+
logged. This is done as it is quite common for image files to be moved while
|
704
|
+
conversion is in progress. Rather then terminate the Host, the file move is
|
705
|
+
recorded and regeneration will be triggered once the current generation
|
706
|
+
completes.
|
707
|
+
|
647
708
|
### Deploy
|
648
709
|
|
649
710
|
Photish provides a plugin type specifically for deployments, called the
|
@@ -777,7 +838,7 @@ module Photish::Plugin::MyCustomDeploy
|
|
777
838
|
end
|
778
839
|
|
779
840
|
def deploy_site
|
780
|
-
@log.
|
841
|
+
@log.debug "Deploying using my plugin"
|
781
842
|
FileUtils.cp(@config.output_dir, '/srv/www')
|
782
843
|
end
|
783
844
|
end
|
data/TODO.md
CHANGED
@@ -2,17 +2,17 @@
|
|
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
|
8
|
+
|
5
9
|
## Backlog
|
6
10
|
|
7
|
-
1.
|
8
|
-
1. Changing convert items does not trigger regeneration but changing name does
|
11
|
+
1. Video transcoding and template rendering for videos
|
9
12
|
1. Templates with exif data, super slow
|
10
|
-
1. Custom template rendering outside of `_templates` folder using `page.{type}`
|
11
13
|
1. Proper asset pipeline for CSS
|
12
14
|
1. A sitemap helper plugin for use in custom templates for example
|
13
15
|
`sitemap.xml`
|
14
|
-
1.
|
15
|
-
1.
|
16
|
-
1.
|
17
|
-
override on deploy etc.
|
18
|
-
1. Video transcoding and template rendering
|
16
|
+
1. Add unit tests to classes relying on feature tests
|
17
|
+
1. Improve metric scores from `rake stats`
|
18
|
+
1. Improve the `--example` template of Photish
|
data/bin/console
CHANGED
@@ -2,13 +2,5 @@
|
|
2
2
|
|
3
3
|
require "bundler/setup"
|
4
4
|
require "photish"
|
5
|
-
|
6
|
-
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start
|
5
|
+
require "pry"
|
6
|
+
Pry.start
|
data/bin/setup
CHANGED
@@ -6,5 +6,3 @@ command -v convert >/dev/null 2>&1 || { echo >&2 "imagemagick required. run \"br
|
|
6
6
|
command -v exiftool >/dev/null 2>&1 || { echo >&2 "exiftool required. run \"brew install exiftool\""; exit 1; }
|
7
7
|
|
8
8
|
bundle install
|
9
|
-
|
10
|
-
# Do any other automated setup that you need to do here
|
@@ -8,8 +8,8 @@ class Photish::Plugin::TmpdirDeploy
|
|
8
8
|
tmpdir = Dir.mktmpdir
|
9
9
|
FileUtils.cp_r(config.output_dir, tmpdir)
|
10
10
|
|
11
|
-
log.
|
12
|
-
log.
|
11
|
+
log.debug "Static site deployed to directory: #{tmpdir}"
|
12
|
+
log.debug "Deployment to tmpdir successful"
|
13
13
|
end
|
14
14
|
|
15
15
|
private
|
@@ -7,6 +7,10 @@ div.album
|
|
7
7
|
div.album-photo
|
8
8
|
a href=photo.url title=photo.name
|
9
9
|
img src=photo.images.find{ |i|i.quality_name=='Low' }.url alt=photo.name
|
10
|
+
div.album-pages
|
11
|
+
- pages.each do |page|
|
12
|
+
div.album-page
|
13
|
+
a href=page.url title=page.name #{page.name}
|
10
14
|
|
11
15
|
div.sub-albums
|
12
16
|
- albums.each do |album|
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Photish
|
2
|
+
module Cache
|
3
|
+
class DbFile
|
4
|
+
def self.new_master(output_dir)
|
5
|
+
new(path(output_dir, '.changes.yml'))
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.new_worker(output_dir, index)
|
9
|
+
new(path(output_dir, ".changes.#{index}.yml"))
|
10
|
+
end
|
11
|
+
|
12
|
+
def write(hash)
|
13
|
+
File.open(file, 'w') do
|
14
|
+
|f| f.write(hash.to_yaml)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def read
|
19
|
+
File.exist?(file) ? YAML.load_file(file) : {}
|
20
|
+
end
|
21
|
+
|
22
|
+
def clear
|
23
|
+
FileUtils.rm_rf(file)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
attr_reader :file
|
29
|
+
|
30
|
+
def initialize(file)
|
31
|
+
@file = file
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.path(output_dir, filename)
|
35
|
+
FileUtils.mkdir_p(output_dir)
|
36
|
+
path = File.join(output_dir, filename)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -1,8 +1,9 @@
|
|
1
1
|
module Photish
|
2
2
|
module Cache
|
3
3
|
class Manifest
|
4
|
-
def initialize(output_dir, worker_index, version_hash)
|
4
|
+
def initialize(output_dir, workers, worker_index, version_hash)
|
5
5
|
@output_dir = output_dir
|
6
|
+
@workers = workers
|
6
7
|
@worker_index = worker_index
|
7
8
|
@version_hash = version_hash
|
8
9
|
@cache = {}
|
@@ -12,23 +13,21 @@ module Photish
|
|
12
13
|
def record(key, file_path = nil)
|
13
14
|
checksum = checksum_of_file(file_path || key)
|
14
15
|
worker_db[key] = checksum
|
15
|
-
|
16
|
+
master_db[key] = checksum
|
16
17
|
end
|
17
18
|
|
18
19
|
def changed?(key, file_path = nil)
|
19
20
|
checksum = checksum_of_file(file_path || key)
|
20
21
|
worker_db[key] = checksum
|
21
|
-
checksum !=
|
22
|
+
checksum != master_db[key]
|
22
23
|
end
|
23
24
|
|
24
25
|
def flush_to_disk
|
25
|
-
|
26
|
-
|f| f.write(worker_db.to_yaml)
|
27
|
-
end
|
26
|
+
worker_db_file(worker_index).write(worker_db)
|
28
27
|
end
|
29
28
|
|
30
|
-
def
|
31
|
-
|
29
|
+
def load_from_disk
|
30
|
+
master_db
|
32
31
|
end
|
33
32
|
|
34
33
|
private
|
@@ -37,26 +36,29 @@ module Photish
|
|
37
36
|
:cache,
|
38
37
|
:version_hash,
|
39
38
|
:worker_index,
|
40
|
-
:worker_db
|
39
|
+
:worker_db,
|
40
|
+
:workers
|
41
41
|
|
42
|
-
delegate :
|
42
|
+
delegate :master_db_file,
|
43
43
|
:worker_db_file,
|
44
|
-
to: :
|
44
|
+
to: :repository
|
45
45
|
|
46
46
|
def checksum_of_file(file_path)
|
47
47
|
cache.fetch(file_path.hash) do |key|
|
48
|
-
cache[key] =
|
49
|
-
Digest::MD5.file(file_path).hexdigest
|
48
|
+
cache[key] = hash(file_path)
|
50
49
|
end
|
51
50
|
end
|
52
51
|
|
53
|
-
def
|
54
|
-
|
55
|
-
|
52
|
+
def hash(file_path)
|
53
|
+
version_hash.to_s + Digest::MD5.file(file_path).hexdigest
|
54
|
+
end
|
55
|
+
|
56
|
+
def master_db
|
57
|
+
@master_db ||= master_db_file.read
|
56
58
|
end
|
57
59
|
|
58
|
-
def
|
59
|
-
|
60
|
+
def repository
|
61
|
+
@repository ||= Repository.new(output_dir, workers)
|
60
62
|
end
|
61
63
|
end
|
62
64
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Photish
|
2
|
+
module Cache
|
3
|
+
class Repository
|
4
|
+
def initialize(output_dir, workers)
|
5
|
+
@output_dir = output_dir
|
6
|
+
@workers = workers
|
7
|
+
@worker_db_file_cache = {}
|
8
|
+
end
|
9
|
+
|
10
|
+
delegate :clear,
|
11
|
+
to: :master_db_file,
|
12
|
+
prefix: true
|
13
|
+
|
14
|
+
def concat_worker_db_files
|
15
|
+
master_db_file.write(accumulate_changes)
|
16
|
+
end
|
17
|
+
|
18
|
+
def master_db_file
|
19
|
+
@master_db_file ||= DbFile.new_master(output_dir)
|
20
|
+
end
|
21
|
+
|
22
|
+
def worker_db_file(index)
|
23
|
+
worker_db_file_cache.fetch(index) do
|
24
|
+
DbFile.new_worker(output_dir, index)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
attr_reader :output_dir,
|
31
|
+
:workers,
|
32
|
+
:worker_db_file_cache
|
33
|
+
|
34
|
+
def accumulate_changes
|
35
|
+
(1..workers).inject({}) do |accumulator, worker_index|
|
36
|
+
db_file = worker_db_file(worker_index)
|
37
|
+
accumulator.merge(db_file.read)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -5,6 +5,7 @@ module Photish
|
|
5
5
|
|
6
6
|
desc "generate", "Generates the gallery static site"
|
7
7
|
option :force, type: :boolean
|
8
|
+
option :config_override, type: :string
|
8
9
|
def generate
|
9
10
|
Photish::Command::Generate.new(options).execute
|
10
11
|
end
|
@@ -17,18 +18,21 @@ module Photish
|
|
17
18
|
|
18
19
|
desc "host", "Serves the HTML on a HTTP server"
|
19
20
|
option :force, type: :boolean
|
21
|
+
option :config_override, type: :string
|
20
22
|
def host
|
21
23
|
Photish::Command::Host.new(options).execute
|
22
24
|
end
|
23
25
|
|
24
26
|
desc "init", "Creates a basic Photish site structure"
|
25
27
|
option :example, type: :boolean
|
28
|
+
option :config_override, type: :string
|
26
29
|
def init
|
27
30
|
Photish::Command::Init.new(options).execute
|
28
31
|
end
|
29
32
|
|
30
33
|
desc "deploy", "Deploys the static site, using the specified engine"
|
31
34
|
method_option :engine, required: true
|
35
|
+
option :config_override, type: :string
|
32
36
|
def deploy
|
33
37
|
Photish::Command::Deploy.new(options).execute
|
34
38
|
end
|
data/lib/photish/command/base.rb
CHANGED
@@ -23,14 +23,18 @@ module Photish
|
|
23
23
|
:version_hash,
|
24
24
|
to: :app_settings
|
25
25
|
|
26
|
+
def load_all_plugins
|
27
|
+
Plugin::Repository.instance.reload(config)
|
28
|
+
end
|
29
|
+
|
26
30
|
private
|
27
31
|
|
28
32
|
def app_settings
|
29
|
-
@app_settings ||= Config::
|
33
|
+
@app_settings ||= Config::Settings.new(runtime_config)
|
30
34
|
end
|
31
35
|
|
32
36
|
def setup_logging
|
33
|
-
Log::
|
37
|
+
Log::Setup.instance.configure(config.logging)
|
34
38
|
end
|
35
39
|
end
|
36
40
|
end
|
@@ -3,14 +3,14 @@ module Photish
|
|
3
3
|
class Deploy < Base
|
4
4
|
def run
|
5
5
|
load_all_plugins
|
6
|
-
log.
|
6
|
+
log.debug "Requested engine: #{engine}"
|
7
7
|
|
8
8
|
return no_engine_found unless engine && engine_class
|
9
9
|
|
10
|
-
log.
|
10
|
+
log.debug "Regenerating site, to ensure fresh copy"
|
11
11
|
regenerate_entire_site
|
12
12
|
|
13
|
-
log.
|
13
|
+
log.debug "Deploying with engine #{engine_class}"
|
14
14
|
engine_class.new(config, log).deploy_site
|
15
15
|
end
|
16
16
|
|
@@ -26,11 +26,7 @@ module Photish
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def no_engine_found
|
29
|
-
log.
|
30
|
-
end
|
31
|
-
|
32
|
-
def load_all_plugins
|
33
|
-
Plugin::Repository.instance.reload(config)
|
29
|
+
log.debug "No engine found..."
|
34
30
|
end
|
35
31
|
|
36
32
|
def engine_class
|
@@ -2,44 +2,35 @@ module Photish
|
|
2
2
|
module Command
|
3
3
|
class Generate < Base
|
4
4
|
def run
|
5
|
-
log.
|
5
|
+
log.debug "Generating with #{workers} workers and #{threads} threads"
|
6
6
|
|
7
|
-
|
7
|
+
master_db_file_clear if force_regeneration?
|
8
8
|
spawn_all_workers
|
9
9
|
load_all_plugins
|
10
10
|
wait_for_workers_to_complete
|
11
|
-
|
11
|
+
concat_worker_db_files
|
12
12
|
perform_serial_generation
|
13
13
|
|
14
|
-
log.
|
14
|
+
log.debug "Generation completed successfully"
|
15
15
|
end
|
16
16
|
|
17
17
|
private
|
18
18
|
|
19
19
|
delegate :output_dir,
|
20
|
-
:photo_dir,
|
21
|
-
:url,
|
22
|
-
:site_dir,
|
23
|
-
:qualities,
|
24
20
|
:photish_executable,
|
25
21
|
:workers,
|
26
22
|
:force,
|
27
23
|
:threads,
|
28
|
-
:image_extensions,
|
29
24
|
to: :config
|
30
25
|
|
31
|
-
delegate :
|
32
|
-
:
|
33
|
-
to: :
|
26
|
+
delegate :concat_worker_db_files,
|
27
|
+
:master_db_file_clear,
|
28
|
+
to: :cache_repository
|
34
29
|
|
35
30
|
def force_regeneration?
|
36
31
|
force == true
|
37
32
|
end
|
38
33
|
|
39
|
-
def load_all_plugins
|
40
|
-
Plugin::Repository.instance.reload(config)
|
41
|
-
end
|
42
|
-
|
43
34
|
def spawn_all_workers
|
44
35
|
return single_worker if one_worker?
|
45
36
|
@spawned_processes ||= (1..workers).map do |index|
|
@@ -68,14 +59,7 @@ module Photish
|
|
68
59
|
end
|
69
60
|
|
70
61
|
def collection
|
71
|
-
@collection ||= Gallery::Collection.new(
|
72
|
-
qualities_mapped,
|
73
|
-
url,
|
74
|
-
image_extensions)
|
75
|
-
end
|
76
|
-
|
77
|
-
def qualities_mapped
|
78
|
-
qualities.map { |quality| OpenStruct.new(quality) }
|
62
|
+
@collection ||= Gallery::Collection.new(config)
|
79
63
|
end
|
80
64
|
|
81
65
|
def worker_command(worker_index)
|
@@ -84,8 +68,8 @@ module Photish
|
|
84
68
|
"--worker_index=#{worker_index}"].join(' ')
|
85
69
|
end
|
86
70
|
|
87
|
-
def
|
88
|
-
Cache::
|
71
|
+
def cache_repository
|
72
|
+
Cache::Repository.new(output_dir, workers)
|
89
73
|
end
|
90
74
|
end
|
91
75
|
end
|