photish 0.3.1 → 0.3.2

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: 5f8a0b8f1e4161d340f6021e13870235e33f6023
4
- data.tar.gz: 957653b7e8c8c17beafbc7dfebf6dd6e1ed6fde6
3
+ metadata.gz: 10d4377b58ca8abfc533f024d63b08ac42ad2843
4
+ data.tar.gz: bbc4d59536dfcfe2bc92880963a32a9f77988b3e
5
5
  SHA512:
6
- metadata.gz: 47e2ba13affb3eb5598f1c5d88f4d593ebb9282aaed27b45e195ebf611fa38a12d8b7c5d9720e3c215371814fc9ee2a6c22a51d75fa0925f896003e2f24cb3ae
7
- data.tar.gz: 876a3d8d56247e9e210c9f91cc43f275c71215d24d7c83b869ec815c9bcaf5972b09c21211c46e002cad079a021d1de053c7ec371fc63fede584232a96a20e1e
6
+ metadata.gz: e1a165687012458bda29b180ea140faca11d1978d7eb9f8353c1863c95cd9aa7d761959e4c1a46c6a637e2c62e98adf860a33c6ce2ae98e0fe33f716cb180d75
7
+ data.tar.gz: b83864d828fac5f6878df88cd99061c585ba286f1b5fb809af1fc7a3ceb8486bcbd81da73c787a83090d470f1b7c2304235a1e4213892f15897b5ea22549a1d3
data/README.md CHANGED
@@ -32,7 +32,7 @@ and running:
32
32
  [Nokogiri](http://www.nokogiri.org/tutorials/installing_nokogiri.html) are
33
33
  installed (see [Dependencies](#dependencies))
34
34
  1. Install Photish `gem install photish`
35
- 1. Create a base project with `photish init`
35
+ 1. Create a base project with `photish init --example`
36
36
  1. Generate the HTML using `photish generate`
37
37
  1. Run a local HTTP server to view the site with `photish host`
38
38
  1. View your photo site at [http://localhost:9876](http://localhost:9876/)
@@ -206,6 +206,10 @@ Once you have photish installed. Get started with the following commands:
206
206
  A skeleton site can be created by running the below command inside the
207
207
  `my_new_photo_site` folder:
208
208
 
209
+ $ photish init --example
210
+
211
+ A barebones site can be created with:
212
+
209
213
  $ photish init
210
214
 
211
215
  #### Basic Photish Structure
@@ -567,10 +571,10 @@ To develop:
567
571
 
568
572
  To release:
569
573
 
574
+ $ vim lib/photish/version.rb # update version
570
575
  $ git add -p # add in changed files
571
576
  $ git commit -m 'Final commit' # finish up changes
572
577
  $ rake # ensure all tests pass
573
- $ vim lib/photish/version.rb # update version
574
578
  $ rake release # release to rubygems
575
579
 
576
580
  ## Contributing
data/TODO.md CHANGED
@@ -2,8 +2,6 @@
2
2
 
3
3
  ## In Progress
4
4
 
5
- 1. Add feature test for change and regenerate
6
-
7
5
  ## Backlog
8
6
 
9
7
  1. Plugin as a gem to deploy to github pages, netlify, amazon s3
@@ -29,6 +29,13 @@ module Photish
29
29
  Photish::Plugin::Type::Collection
30
30
  end
31
31
 
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
37
+ end
38
+
32
39
  private
33
40
 
34
41
  attr_reader :path
@@ -6,6 +6,10 @@ module Photish
6
6
  [host, url_parts].flatten.join('/')
7
7
  end
8
8
 
9
+ def url_path
10
+ url_parts.join('/')
11
+ end
12
+
9
13
  def url_parts
10
14
  base_url_parts + [url_end]
11
15
  end
@@ -6,9 +6,7 @@ module Photish
6
6
  end
7
7
 
8
8
  def record(key, file_path = nil)
9
- update do |db|
10
- db[key] = md5_of_file(file_path || key)
11
- end
9
+ db[key] = md5_of_file(file_path || key)
12
10
  end
13
11
 
14
12
  def changed?(key, file_path = nil)
@@ -16,7 +14,7 @@ module Photish
16
14
  end
17
15
 
18
16
  def flush_to_disk
19
- File.open(db_file, 'w') { |f| f.write((@db || {}).to_yaml) }
17
+ File.open(db_file, 'w') { |f| f.write((db || {}).to_yaml) }
20
18
  end
21
19
 
22
20
  private
@@ -28,23 +26,13 @@ module Photish
28
26
  end
29
27
 
30
28
  def old_md5_of_file(file_path)
31
- read_from_file[file_path]
29
+ db[file_path]
32
30
  end
33
31
 
34
- def update
35
- db = read_from_file
36
- yield(db)
37
- write_to_file(db)
38
- end
39
-
40
- def read_from_file
32
+ def db
41
33
  @db ||= File.exist?(db_file) ? YAML.load_file(db_file) : {}
42
34
  end
43
35
 
44
- def write_to_file(db)
45
- @db = db
46
- end
47
-
48
36
  def db_file
49
37
  File.join(output_dir, '.changes.yml')
50
38
  end
@@ -16,7 +16,7 @@ module Photish
16
16
  Thread.new do
17
17
  begin
18
18
  while image = image_queue.pop(true)
19
- convert(image) if changed?(output_path(image), image.path)
19
+ convert(image) if changed?(image.url_path, image.path)
20
20
  end
21
21
  rescue ThreadError => e
22
22
  log.info "Expected exception, queue is empty #{e.class} \"#{e.message}\" #{e.backtrace.join("\n")}"
@@ -47,7 +47,7 @@ module Photish
47
47
  def convert(image)
48
48
  create_parent_directories(image)
49
49
  convert_with_imagemagick(image)
50
- record(output_path(image), image.path)
50
+ record(image.url_path, image.path)
51
51
  end
52
52
 
53
53
  def convert_with_imagemagick(image)
@@ -9,6 +9,7 @@ module Photish
9
9
  end
10
10
 
11
11
  def all_for(collection)
12
+ delete_unknown_files(collection.all_url_paths)
12
13
  move_non_ignored_site_contents
13
14
 
14
15
  collection_template.render(collection)
@@ -25,6 +26,14 @@ module Photish
25
26
  :output_dir,
26
27
  :max_workers
27
28
 
29
+ def delete_unknown_files(expected_url_paths)
30
+ files_to_delete = Dir["#{output_dir}/**/*"].select do |f|
31
+ relative_file_path = f.gsub(/#{output_dir}\/?/, '')
32
+ File.file?(f) && expected_url_paths.exclude?(relative_file_path)
33
+ end
34
+ FileUtils.rm_rf(files_to_delete)
35
+ end
36
+
28
37
  def move_non_ignored_site_contents
29
38
  FileUtils.mkdir_p(output_dir)
30
39
  FileUtils.cp_r(non_ignored_site_contents, output_dir)
@@ -1,3 +1,3 @@
1
1
  module Photish
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
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.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henry Lawson