ralber 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/ralber.rb +1 -1
- data/lib/ralber/album.rb +13 -0
- data/lib/ralber/image.rb +27 -4
- data/lib/ralber/publisher.rb +5 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 529c57628e4ae4b6c145a5cbfca4d79f045261b5
|
4
|
+
data.tar.gz: f9df5763a02617c6371b48e7c2b7ecac97d85528
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74d83d3d557a627ec15ab9ed6aaf0dc085af092eb89fe2a4e0990de528038f9a0e60cae855983186d69216be516da8dfb4bdd5d48e92c5052eeb861e592c3a56
|
7
|
+
data.tar.gz: 14f949a4115dabd6d51e223d4e86dec357571c64a66dc2616c4031c5dd5ef64a1a3e93fe49d8d279fc54111d66d830236d87362750f888816c1ff3952d711331
|
data/bin/ralber.rb
CHANGED
@@ -10,7 +10,7 @@ require 'ralber/commands/create_command'
|
|
10
10
|
require 'ralber/commands/publish_command'
|
11
11
|
require 'ralber/commands/update_command'
|
12
12
|
|
13
|
-
program :version, '0.0.
|
13
|
+
program :version, '0.0.2'
|
14
14
|
program :description, 'A static web album generator'
|
15
15
|
|
16
16
|
command :create do |c|
|
data/lib/ralber/album.rb
CHANGED
@@ -209,7 +209,20 @@ module Ralber
|
|
209
209
|
rescue
|
210
210
|
end
|
211
211
|
end
|
212
|
+
|
213
|
+
self.clear_unused_config
|
212
214
|
self.write_albuminfo
|
213
215
|
end
|
216
|
+
|
217
|
+
def clear_unused_config
|
218
|
+
configs = Dir.glob(File.join(File.dirname(self.json_path),'*.json')).map {|f| File.basename(f)}
|
219
|
+
configs.delete('album.json')
|
220
|
+
@images.each {|img|
|
221
|
+
configs.delete(File.basename(img.json_path))
|
222
|
+
}
|
223
|
+
configs.each {|conf|
|
224
|
+
File.delete(File.join(File.dirname(self.json_path),conf))
|
225
|
+
}
|
226
|
+
end
|
214
227
|
end
|
215
228
|
end
|
data/lib/ralber/image.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'bundler/setup'
|
3
|
-
|
3
|
+
require 'digest'
|
4
4
|
require 'json'
|
5
5
|
require 'rmagick'
|
6
6
|
|
@@ -11,7 +11,7 @@ module Ralber
|
|
11
11
|
# functions like thumbs etc.
|
12
12
|
class Image
|
13
13
|
attr :path
|
14
|
-
attr_reader :title, :type, :description, :width, :height
|
14
|
+
#attr_reader :title, :type, :description, :width, :height, :published_md5
|
15
15
|
|
16
16
|
def initialize(path)
|
17
17
|
raise StandardError, "File does not exits" if not File.exists?(path)
|
@@ -34,6 +34,9 @@ module Ralber
|
|
34
34
|
def height
|
35
35
|
@image_info['height']
|
36
36
|
end
|
37
|
+
def published_md5
|
38
|
+
@image_info['published_md5']
|
39
|
+
end
|
37
40
|
|
38
41
|
##
|
39
42
|
# creates the initial image.json file, extracting the metadata
|
@@ -46,6 +49,7 @@ module Ralber
|
|
46
49
|
@image_info['type'] = type
|
47
50
|
@image_info['width'] = meta[:width]
|
48
51
|
@image_info['height'] = meta[:height]
|
52
|
+
@image_info['published_md5'] = meta[:published_md5]
|
49
53
|
|
50
54
|
self.write_imageinfo
|
51
55
|
end
|
@@ -69,7 +73,8 @@ module Ralber
|
|
69
73
|
"type" => nil,
|
70
74
|
"description" => '',
|
71
75
|
"width" => 0,
|
72
|
-
"height" => 0
|
76
|
+
"height" => 0,
|
77
|
+
"published_md5" => ''
|
73
78
|
}
|
74
79
|
end
|
75
80
|
|
@@ -87,6 +92,7 @@ module Ralber
|
|
87
92
|
(info['type'] = data['type'].to_sym) if data.key?('type')
|
88
93
|
(info['width'] = data['width']) if data.key?('width')
|
89
94
|
(info['height'] = data['height']) if data.key?('height')
|
95
|
+
(info['published_md5'] = data['published_md5']) if data.key?('published_md5')
|
90
96
|
end
|
91
97
|
rescue
|
92
98
|
end
|
@@ -112,7 +118,8 @@ module Ralber
|
|
112
118
|
{
|
113
119
|
:width => img.columns,
|
114
120
|
:height => img.rows,
|
115
|
-
:type => self.map_type(img.format)
|
121
|
+
:type => self.map_type(img.format),
|
122
|
+
:published_md5 => ''
|
116
123
|
}
|
117
124
|
end
|
118
125
|
|
@@ -151,5 +158,21 @@ module Ralber
|
|
151
158
|
end
|
152
159
|
return name
|
153
160
|
end
|
161
|
+
|
162
|
+
def calc_md5
|
163
|
+
if not @md5_calculated
|
164
|
+
@md5_calculated = Digest::MD5.file(@path).hexdigest
|
165
|
+
end
|
166
|
+
return @md5_calculated
|
167
|
+
end
|
168
|
+
|
169
|
+
def has_changed
|
170
|
+
self.calc_md5() != self.published_md5
|
171
|
+
end
|
172
|
+
|
173
|
+
def update_md5
|
174
|
+
@image_info['published_md5'] = self.calc_md5
|
175
|
+
self.write_imageinfo
|
176
|
+
end
|
154
177
|
end
|
155
178
|
end
|
data/lib/ralber/publisher.rb
CHANGED
@@ -44,6 +44,10 @@ module Ralber
|
|
44
44
|
destdir = File.join(path,imgdir,name)
|
45
45
|
self.create_images(destdir,conf,name )
|
46
46
|
}
|
47
|
+
@album.images.each {|img|
|
48
|
+
self.inform_listeners(:image_update_md5, "Updating MD5 information for #{File.basename(img.path)}")
|
49
|
+
img.update_md5
|
50
|
+
}
|
47
51
|
end
|
48
52
|
|
49
53
|
def publish_index_to(path)
|
@@ -126,7 +130,7 @@ module Ralber
|
|
126
130
|
info = self.image_info(img,name)
|
127
131
|
format = (conf['format']).to_sym if conf['format']
|
128
132
|
destfile = File.join(destdir,img.get_resized_name(img.path,format))
|
129
|
-
if (File.exists?(destfile) && @force != true)
|
133
|
+
if (File.exists?(destfile) && @force != true && (not img.has_changed()))
|
130
134
|
self.inform_listeners(:create_resized_version, "Skipping #{name}: #{info['rel_path']}, File exists");
|
131
135
|
else
|
132
136
|
self.ensure_path(destdir)
|