gf-ralbum 0.0.2 → 0.0.5
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.
- data/VERSION +1 -0
- data/bin/{ralbum.rb → ralbum} +1 -1
- data/example/example.sh +2 -1
- data/example/test_jalbum_phototree/jalbum-settings.jap +321 -0
- data/example/test_jalbum_phototree/src/albumfiles.txt +9 -0
- data/example/test_jalbum_phototree/src/comments.properties +0 -0
- data/example/test_jalbum_phototree/src/flowers/albumfiles.txt +14 -0
- data/example/test_jalbum_phototree/src/meta.properties +2 -0
- data/example/{test_phototree → test_rubyphoto_phototree}/album.xml +0 -0
- data/example/test_rubyphoto_phototree/flowers/IMG_1469.wt.jpg +0 -0
- data/example/test_rubyphoto_phototree/flowers/IMG_2291.jpg +0 -0
- data/example/test_rubyphoto_phototree/flowers/IMG_2598.jpg +0 -0
- data/example/test_rubyphoto_phototree/flowers/IMG_3068.jpg +0 -0
- data/example/test_rubyphoto_phototree/flowers/IMG_3323.jpg +0 -0
- data/example/test_rubyphoto_phototree/flowers/IMG_3348.jpg +0 -0
- data/example/{test_phototree → test_rubyphoto_phototree}/r_photo01.jpg +0 -0
- data/example/{test_phototree → test_rubyphoto_phototree}/r_photo01.jpg.xml +0 -0
- data/example/{test_phototree/catalog_data → test_rubyphoto_phototree/ralbum}/md5_to_key.yaml +0 -0
- data/example/{test_phototree/catalog_data → test_rubyphoto_phototree/ralbum}/md5_to_key.yaml.test +0 -0
- data/example/{test_phototree/catalog_data → test_rubyphoto_phototree/ralbum}/project.xml +206 -3
- data/example/{test_phototree → test_rubyphoto_phototree}/subalbum01/album.xml +0 -0
- data/example/{test_phototree → test_rubyphoto_phototree}/subalbum01/subalbum01_photo01.jpg +0 -0
- data/example/{test_phototree → test_rubyphoto_phototree}/subalbum01/subalbum01_photo01.jpg.xml +0 -0
- data/example/{test_phototree → test_rubyphoto_phototree}/subalbum01/subalbum01_photo02.jpg +0 -0
- data/example/{test_phototree → test_rubyphoto_phototree}/subalbum01/subalbum01_photo02.jpg.xml +0 -0
- data/example/{test_phototree → test_rubyphoto_phototree}/subalbum01/subalbum01_photo03.jpg +0 -0
- data/example/{test_phototree → test_rubyphoto_phototree}/subalbum01/subalbum01_photo03.jpg.xml +0 -0
- data/example/{test_phototree → test_rubyphoto_phototree}/subalbum01/subalbum01_photo04.jpg +0 -0
- data/example/{test_phototree → test_rubyphoto_phototree}/subalbum01/subalbum01_photo04.jpg.xml +0 -0
- data/example/{test_phototree → test_rubyphoto_phototree}/subalbum02/album.xml +0 -0
- data/example/{test_phototree → test_rubyphoto_phototree}/subalbum02/subalbum02_photo01.jpg +0 -0
- data/example/{test_phototree → test_rubyphoto_phototree}/subalbum02/subalbum02_photo01.jpg.xml +0 -0
- data/example/{test_phototree → test_rubyphoto_phototree}/subalbum02/subalbum02_photo02.jpg +0 -0
- data/example/{test_phototree → test_rubyphoto_phototree}/subalbum02/subalbum02_photo02.jpg.xml +0 -0
- data/example/{test_phototree → test_rubyphoto_phototree}/subalbum02/subalbum02_photo03.jpg +0 -0
- data/example/{test_phototree → test_rubyphoto_phototree}/subalbum02/subalbum02_photo03.jpg.xml +0 -0
- data/example/{test_phototree → test_rubyphoto_phototree}/subalbum02/subalbum02_photo04.jpg +0 -0
- data/example/{test_phototree → test_rubyphoto_phototree}/subalbum02/subalbum02_photo04.jpg.xml +0 -0
- data/example/{test_phototree → test_rubyphoto_phototree}/subalbum02/subalbum02_photo05.jpg +0 -0
- data/example/{test_phototree → test_rubyphoto_phototree}/subalbum02/subalbum02_photo05.jpg.xml +0 -0
- data/lib/ralbum.rb +9 -5
- data/lib/ralbum/album_tree/album.rb +74 -0
- data/lib/ralbum/album_tree/generate_album_tree_node_visitor.rb +73 -0
- data/lib/ralbum/album_tree/image_file.rb +88 -0
- data/lib/ralbum/{image_pool.rb → album_tree/image_pool.rb} +16 -4
- data/lib/ralbum/catalog.rb +7 -7
- data/lib/ralbum/cli/cli_ralbum.rb +66 -25
- data/lib/ralbum/image_strategies/copy_image_strategy.rb +16 -0
- data/lib/ralbum/image_strategies/linked_image_strategy.rb +18 -0
- data/lib/ralbum/image_strategies/scaled_image_strategy.rb +52 -0
- data/lib/ralbum/image_strategies/sepia_scaled_image_strategy.rb +50 -0
- data/lib/{ralbum-common → ralbum}/object_with_properties.rb +0 -0
- data/lib/{ralbum-common → ralbum}/object_with_validation.rb +0 -0
- data/lib/ralbum/photo_tree/jalbum_photo_tree.rb +83 -0
- data/lib/ralbum/photo_tree/photo_file.rb +149 -0
- data/lib/ralbum/photo_tree/photo_tree_item.rb +68 -0
- data/lib/ralbum/{photo_tree_node.rb → photo_tree/photo_tree_node.rb} +16 -13
- data/lib/ralbum/{photo_tree_builder.rb → photo_tree/rubyphoto_photo_tree.rb} +64 -46
- data/lib/ralbum/project.rb +48 -12
- data/lib/ralbum/skin.rb +34 -27
- data/lib/ralbum/skin_engine.rb +32 -17
- data/lib/ralbum/skin_engines/erb_skin_engine.rb +2 -5
- data/lib/ralbum/skin_engines/kwartz_skin_engine.rb +6 -9
- data/lib/ralbum/skin_manager.rb +11 -2
- data/lib/ralbum/skins/cgi/cgi_skin.rb +21 -23
- data/lib/ralbum/skins/cgi/res/model.rb +30 -32
- data/lib/ralbum/skins/gfold/inc/menu_bottom.html +53 -53
- data/lib/ralbum/skins/gfold/inc/menu_top.html +71 -71
- data/lib/ralbum/skins/gfold/inc/page_footer.html +28 -28
- data/lib/ralbum/skins/gfold/out/album_page.rb +316 -316
- data/lib/ralbum/skins/gfold/out/image_page.rb +231 -231
- data/lib/ralbum/skins/gfold/out/tree_page.rb +96 -96
- data/lib/ralbum/skins/gfold/res/prototype.js +3277 -3277
- data/lib/ralbum/skins/gfold/template/album_page.html +161 -161
- data/lib/ralbum/skins/gfold/template/album_page.plogic +127 -127
- data/lib/ralbum/skins/gfold/template/image_page.html +91 -91
- data/lib/ralbum/skins/gfold/template/image_page.plogic +70 -70
- data/lib/ralbum/skins/gfold/template/tree_page.html +79 -79
- data/lib/ralbum/skins/gfold/template/tree_page.plogic +45 -45
- data/lib/ralbum/skins/js/out/album_page.rb +2 -2
- data/lib/ralbum/skins/js/out/tree_page.rb +18 -17
- data/lib/ralbum/skins/js/template/album_page.html +2 -2
- data/lib/ralbum/skins/js/template/tree_page.html +1 -1
- data/lib/ralbum/skins/test_erb/template/album_page.rhtml +22 -0
- data/lib/ralbum/skins/test_erb/template/image_page.rhtml +44 -0
- data/lib/ralbum/tasks/compile_skins.rb +8 -0
- data/test/ralbum/cli/tc_cli_ralbum.rb +35 -0
- data/test/ralbum/image_strategies/tc_scaled_image_strategy.rb +18 -0
- data/test/ralbum/image_strategies/tc_sepia_scaled_image_strategy.rb +18 -0
- data/test/ralbum/photo_tree/tc_jalbum_photo_tree.rb +39 -0
- data/test/ralbum/photo_tree/tc_photo_file.rb +13 -0
- data/test/ralbum/{tc_01_photo_tree.rb → photo_tree/tc_photo_tree.rb} +10 -12
- data/test/ralbum/photo_tree/tc_rubyalbum_photo_tree.rb +20 -0
- data/test/ralbum/tc_album.rb +55 -0
- data/test/ralbum/tc_catalog.rb +8 -4
- data/test/ralbum/tc_image_pool.rb +37 -0
- data/test/ralbum/{tc_05_kwartz_skin_engine.rb → tc_kwartz_skin_engine.rb} +1 -1
- data/test/ralbum/{tc_04_skin_manager.rb → tc_skin_manager.rb} +8 -3
- data/test/ralbum/test_helper.rb +16 -1
- data/test_data/ralbum/test_data/is_test/dummy.txt +0 -0
- metadata +78 -81
- data/bin/ralbum-JPG2jpg.rb +0 -90
- data/bin/ralbum-compile_skins.rb +0 -18
- data/bin/ralbum-myconv.rb +0 -81
- data/bin/ralbum-readexif.rb +0 -18
- data/bin/ralbum-reorder.rb +0 -200
- data/lib/ralbum/album.rb +0 -66
- data/lib/ralbum/generate_album_tree_node_visitor.rb +0 -60
- data/lib/ralbum/image_file.rb +0 -81
- data/lib/ralbum/image_strategy.rb +0 -143
- data/lib/ralbum/photo_tree_item.rb +0 -89
- data/test/ralbum/cli/test_cli_ralbum.rb +0 -13
- data/test/ralbum/tc_02_photo_tree_builder.rb +0 -20
- data/test/ralbum/tc_03_album.rb +0 -42
- data/test/ralbum/tc_06_image_strategy.rb +0 -21
- data/test/test_ralbum.rb +0 -14
- data/test_data/ralbum/test_data/is_test/r_photo01_scaled.jpg +0 -0
- data/test_data/ralbum/test_data/is_test/r_photo01_sepia_scaled.jpg +0 -0
data/bin/ralbum-compile_skins.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# stdlib
|
3
|
-
require "pp"
|
4
|
-
|
5
|
-
# ralbum
|
6
|
-
$RALBUM_HOME = File.expand_path( File.join( File.dirname( __FILE__), ".." ) )
|
7
|
-
$:.unshift( File.join($RALBUM_HOME, "lib" ) )
|
8
|
-
require "common/kwartzhelper"
|
9
|
-
|
10
|
-
# html skins
|
11
|
-
%w{ gfold js cgi }.each{ |skin|
|
12
|
-
skin_dir = File.join( $RALBUM_HOME, "lib", "ralbum", "skins", skin )
|
13
|
-
skin_template_dir = File.join( skin_dir, "template" )
|
14
|
-
skin_template_include = File.join( skin_dir, "inc" )
|
15
|
-
skin_template_out = File.join( skin_dir, "out" )
|
16
|
-
compile( skin_template_dir, skin_template_include, skin_template_out )
|
17
|
-
}
|
18
|
-
|
data/bin/ralbum-myconv.rb
DELETED
@@ -1,81 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# ruby
|
4
|
-
require 'ostruct'
|
5
|
-
require 'optparse'
|
6
|
-
require 'fileutils'
|
7
|
-
|
8
|
-
# ralbums
|
9
|
-
$RALBUM_HOME = File.expand_path( File.join( File.dirname( __FILE__), ".." ) )
|
10
|
-
$:.unshift( File.join($GALLERIES_HOME, "lib" ) )
|
11
|
-
|
12
|
-
require "ralbum/recursive_run"
|
13
|
-
|
14
|
-
|
15
|
-
def run( dir )
|
16
|
-
Dir.entries(dir).each { |filename|
|
17
|
-
next unless filename =~ /\.jpg$/
|
18
|
-
next if filename =~ /.+-.+\.jpg/
|
19
|
-
|
20
|
-
new_filename =
|
21
|
-
File.basename( filename, ".jpg" ) +
|
22
|
-
"-" + $options.geometry + "_" + $options.quality + ".jpg"
|
23
|
-
|
24
|
-
inpath = dir + File::Separator + filename
|
25
|
-
outpath = dir + File::Separator + new_filename
|
26
|
-
|
27
|
-
puts "#{dir}: #{filename} -> #{new_filename}"
|
28
|
-
system("convert",
|
29
|
-
"-geometry", $options.geometry,
|
30
|
-
"-quality", $options.quality,
|
31
|
-
inpath,
|
32
|
-
outpath)
|
33
|
-
# remove exif header and comment
|
34
|
-
`jhead -de -dc #{outpath}`
|
35
|
-
}
|
36
|
-
end
|
37
|
-
|
38
|
-
|
39
|
-
$options = OpenStruct.new
|
40
|
-
$options.geometry = "1024x768"
|
41
|
-
$options.quality = "85"
|
42
|
-
$options.verbose = 0
|
43
|
-
$options.recursive = false
|
44
|
-
|
45
|
-
opts = OptionParser.new do |opts|
|
46
|
-
opts.banner = "Usage: #{File.basename($0)} "
|
47
|
-
opts.on("-f", "--force", "force the creation of directory") {
|
48
|
-
$options.force = true
|
49
|
-
}
|
50
|
-
opts.on("-v", "--verbose [NUM]", Integer, "verbosity level") { |num|
|
51
|
-
if num.nil?
|
52
|
-
$options.verbose = 1
|
53
|
-
else
|
54
|
-
$options.verbose = num
|
55
|
-
end
|
56
|
-
}
|
57
|
-
opts.on("-q", "--quality NUM", Integer, "jpeg quality") { |num|
|
58
|
-
$options.quality = num.to_s
|
59
|
-
}
|
60
|
-
opts.on("-r", "--recursive", "recursive") {
|
61
|
-
$options.recursive = true
|
62
|
-
}
|
63
|
-
opts.on("--help", "-h", "help!") {
|
64
|
-
puts opts
|
65
|
-
exit 0
|
66
|
-
}
|
67
|
-
end
|
68
|
-
opts.parse!(ARGV)
|
69
|
-
|
70
|
-
|
71
|
-
unless ARGV[0]
|
72
|
-
puts "#{File.basename __FILE__} <directory>"
|
73
|
-
puts "Create xml description file for jpg images"
|
74
|
-
exit 1
|
75
|
-
end
|
76
|
-
input_dir = ARGV[0]
|
77
|
-
if $options.recursive
|
78
|
-
recursive_run( input_dir ) { |d| run d }
|
79
|
-
else
|
80
|
-
run input_dir
|
81
|
-
end
|
data/bin/ralbum-readexif.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# ralbums
|
4
|
-
$RALBUM_HOME = File.expand_path( File.join( File.dirname( __FILE__), ".." ) )
|
5
|
-
$:.unshift( File.join($GALLERIES_HOME, "lib" ) )
|
6
|
-
|
7
|
-
# rubyalbums
|
8
|
-
require "ralbum/readexif.rb"
|
9
|
-
|
10
|
-
if ARGV.length < 1
|
11
|
-
puts "#{File.basename __FILE__} <photo>"
|
12
|
-
puts "Read exif data"
|
13
|
-
exit 1
|
14
|
-
end
|
15
|
-
|
16
|
-
r = ExifReader.new
|
17
|
-
r.read_exif( ARGV[0] )
|
18
|
-
r.print
|
data/bin/ralbum-reorder.rb
DELETED
@@ -1,200 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# ralbums
|
4
|
-
$RALBUM_HOME = File.expand_path( File.join( File.dirname( __FILE__), ".." ) )
|
5
|
-
$:.unshift( File.join($GALLERIES_HOME, "lib" ) )
|
6
|
-
|
7
|
-
# ruby
|
8
|
-
require "fileutils"
|
9
|
-
require 'optparse'
|
10
|
-
require 'ostruct'
|
11
|
-
require "rexml/document"
|
12
|
-
include REXML
|
13
|
-
|
14
|
-
# rubyalbum
|
15
|
-
require "ralbum/config"
|
16
|
-
require "ralbum/recursive_run"
|
17
|
-
|
18
|
-
|
19
|
-
#
|
20
|
-
# rename file contained in dir from oldname in newname
|
21
|
-
# return true if successfull
|
22
|
-
#
|
23
|
-
def rename( dir, old_filename, new_filename )
|
24
|
-
|
25
|
-
return true if old_filename == new_filename
|
26
|
-
#
|
27
|
-
# prevedere il caso in cui il new_file sia gia' presente
|
28
|
-
# rinominare new_file in un file temporaneo
|
29
|
-
#
|
30
|
-
old_path = dir + File::Separator + old_filename
|
31
|
-
new_path = dir + File::Separator + new_filename
|
32
|
-
|
33
|
-
if File.exist?( new_path )
|
34
|
-
return false
|
35
|
-
end
|
36
|
-
puts "in #{dir}: #{old_filename} -> #{new_filename}" if $options.ralbum_verbose > 1
|
37
|
-
FileUtils::move( old_path, new_path )
|
38
|
-
return true
|
39
|
-
end
|
40
|
-
|
41
|
-
#
|
42
|
-
# rename a set of file
|
43
|
-
# h contains h[ old_filename ] => new_filename
|
44
|
-
#
|
45
|
-
def rename_hash( dir, h )
|
46
|
-
files_renamed = true
|
47
|
-
while files_renamed and h.length > 0
|
48
|
-
files_renamed = false
|
49
|
-
delete_key = []
|
50
|
-
h.each { |old_filename, new_filename|
|
51
|
-
if rename( dir, old_filename, new_filename )
|
52
|
-
files_renamed = true
|
53
|
-
delete_key << old_filename
|
54
|
-
end
|
55
|
-
}
|
56
|
-
delete_key.each { |k| h.delete( k ) }
|
57
|
-
end
|
58
|
-
|
59
|
-
if h.length > 0
|
60
|
-
puts "WARNING: Some file are not renamed!!!!"
|
61
|
-
h.each { |old,new|
|
62
|
-
puts "#{old} => #{new}"
|
63
|
-
}
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
def run( dir )
|
70
|
-
|
71
|
-
doc = nil
|
72
|
-
xml_path = dir + File::Separator + "album.xml"
|
73
|
-
if File.exist?( xml_path )
|
74
|
-
doc = REXML::Document.new File.new( xml_path )
|
75
|
-
oldthumbnail = doc.elements["album/thumbnail"].text.to_s
|
76
|
-
puts "THUMBNAIL: " + oldthumbnail if $options.ralbum_verbose > 0
|
77
|
-
end
|
78
|
-
|
79
|
-
#
|
80
|
-
# The filename are separated in block
|
81
|
-
# the block name is the filename until the first point
|
82
|
-
# i.e.
|
83
|
-
#
|
84
|
-
# block 05_piazza:
|
85
|
-
# 05_piazza.jpg
|
86
|
-
# 05_piazza.jpg.xml
|
87
|
-
#
|
88
|
-
# block 10_piazza:
|
89
|
-
# 10_piazza.jpg.xml
|
90
|
-
# 10_piazza.e.jpg
|
91
|
-
# 10_piazza.jpg
|
92
|
-
#
|
93
|
-
blocks = { }
|
94
|
-
Dir.entries( dir ).each { |filename|
|
95
|
-
next if filename == "." or filename == ".."
|
96
|
-
md = /\A([^\.]+)\./.match( filename )
|
97
|
-
if md.nil?
|
98
|
-
puts "can't find blockname for #{filename}"
|
99
|
-
next
|
100
|
-
end
|
101
|
-
# puts md[1] + " " + md.post_match
|
102
|
-
blockname = md[ 1 ]
|
103
|
-
unless blocks.key?( blockname )
|
104
|
-
blocks[ blockname ] = []
|
105
|
-
end
|
106
|
-
blocks[ blockname ] << filename
|
107
|
-
}
|
108
|
-
|
109
|
-
# rename a block
|
110
|
-
# and build hask old_filename -> new_filename
|
111
|
-
h = {}
|
112
|
-
i = 1
|
113
|
-
blocks.keys.sort.each { |blockname|
|
114
|
-
|
115
|
-
block = blocks[ blockname ]
|
116
|
-
# don't rename block that not contain a jpg image
|
117
|
-
next unless block.find { |filename| filename =~ /\.jpg$/ }
|
118
|
-
new_blockname = sprintf( "%03d", i * $options.step ) + "_" + blockname.gsub(/^(\d)+_/, "")
|
119
|
-
if blockname != new_blockname
|
120
|
-
puts "block rename #{blockname} => #{new_blockname}" if $options.ralbum_verbose > 0
|
121
|
-
|
122
|
-
#
|
123
|
-
# creo un hashtable dal vecchio nuovo al nuovo
|
124
|
-
# e poi rinomino i file singolarmente
|
125
|
-
# puo' succedere che per qualche motivo non riesco a rinominare
|
126
|
-
# un file in un blocco anche se riesco a rinominare gli altri file
|
127
|
-
# prevedere di rinominare un blocco come operazione atomica
|
128
|
-
#
|
129
|
-
|
130
|
-
block.each { |old_filename|
|
131
|
-
new_filename = sprintf( "%03d", i * $options.step ) + "_" + old_filename.gsub(/^(\d)+_/, "")
|
132
|
-
#puts "\t #{old_filename} => #{new_filename}"
|
133
|
-
h[ old_filename ] = new_filename
|
134
|
-
}
|
135
|
-
end
|
136
|
-
i += 1
|
137
|
-
}
|
138
|
-
|
139
|
-
unless doc.nil?
|
140
|
-
newthumbnail = h[ oldthumbnail ]
|
141
|
-
if not newthumbnail.nil? and newthumbnail != oldthumbnail
|
142
|
-
puts "THUMBNAIL: #{oldthumbnail} => #{newthumbnail}" if $options.ralbum_verbose > 0
|
143
|
-
doc.elements["album/thumbnail"].text = newthumbnail
|
144
|
-
File.open( xml_path, "w" ) { |f|
|
145
|
-
doc.write( f, 0 )
|
146
|
-
}
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
rename_hash( dir, h )
|
151
|
-
|
152
|
-
end
|
153
|
-
|
154
|
-
###################################################################################
|
155
|
-
# Main
|
156
|
-
|
157
|
-
$config = Config.new
|
158
|
-
|
159
|
-
$options = OpenStruct.new
|
160
|
-
$options.force = false
|
161
|
-
$options.verbose = 0
|
162
|
-
$options.recursive = false
|
163
|
-
$options.step = 10
|
164
|
-
|
165
|
-
opts = OptionParser.new do |opts|
|
166
|
-
opts.banner =
|
167
|
-
"Usage: #{File.basename($0)} <directory>\n" +
|
168
|
-
"Rename images and xml descritors"
|
169
|
-
opts.on("-v", "--verbose [NUM]", Integer, "verbosity level") { |num|
|
170
|
-
if num.nil?
|
171
|
-
$options.verbose = 1
|
172
|
-
else
|
173
|
-
$options.verbose = num
|
174
|
-
end
|
175
|
-
}
|
176
|
-
opts.on("-r", "--recursive", "recusive in subdirectories") {
|
177
|
-
$options.recursive = true
|
178
|
-
}
|
179
|
-
opts.on("-s", "--step NUM", "step (default 10)") { |num|
|
180
|
-
$options.step = num
|
181
|
-
}
|
182
|
-
|
183
|
-
opts.on("--help", "-h", "help!") {
|
184
|
-
puts opts
|
185
|
-
exit 0
|
186
|
-
}
|
187
|
-
end
|
188
|
-
opts.parse!(ARGV)
|
189
|
-
|
190
|
-
unless ARGV[0]
|
191
|
-
puts opts
|
192
|
-
exit 1
|
193
|
-
end
|
194
|
-
|
195
|
-
input_dir = ARGV[0]
|
196
|
-
if $options.recursive
|
197
|
-
recursive_run( input_dir ) { |d| run d }
|
198
|
-
else
|
199
|
-
run input_dir
|
200
|
-
end
|
data/lib/ralbum/album.rb
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
|
3
|
-
# ralbum
|
4
|
-
require 'tree_visitor/tree_node'
|
5
|
-
|
6
|
-
#
|
7
|
-
# subalbum -> childs
|
8
|
-
# leaves -> photos o image_pools
|
9
|
-
#
|
10
|
-
class Album < TreeNode
|
11
|
-
|
12
|
-
attr_reader :key
|
13
|
-
attr_reader :description
|
14
|
-
|
15
|
-
def initialize( parent, key, title, description )
|
16
|
-
super( title, parent )
|
17
|
-
|
18
|
-
@key = key
|
19
|
-
@description = description
|
20
|
-
@defaultImagePool = nil
|
21
|
-
end
|
22
|
-
|
23
|
-
def relroot
|
24
|
-
"../" * depth
|
25
|
-
end
|
26
|
-
|
27
|
-
def relroot_with_prefix
|
28
|
-
root.prefix_path + relroot
|
29
|
-
end
|
30
|
-
|
31
|
-
def pageurl_from_root
|
32
|
-
File.join( path_from_root, "index.html" )
|
33
|
-
end
|
34
|
-
|
35
|
-
def pageurl
|
36
|
-
File.join( name, "index.html" )
|
37
|
-
end
|
38
|
-
|
39
|
-
def defaultImagePool
|
40
|
-
return @defaultImagePool unless @defaultImagePool.nil?
|
41
|
-
if leaves.length > 0
|
42
|
-
@defaultImagePool = leaves[0]
|
43
|
-
elsif childs.length > 0
|
44
|
-
@defaultImagePool = childs[0].defaultImagePool
|
45
|
-
end
|
46
|
-
if @defaultImagePool.nil?
|
47
|
-
puts "cannot determine defaultphoto for album #{title} #{reldir} #{@leaves.length} #{@childs.length}"
|
48
|
-
exit 1
|
49
|
-
end
|
50
|
-
@defaultImagePool
|
51
|
-
end
|
52
|
-
|
53
|
-
def breadcrumbs
|
54
|
-
h = { :title => name, :path => pageurl_from_root }
|
55
|
-
if parent
|
56
|
-
parent.breadcrumbs << h
|
57
|
-
else
|
58
|
-
[ h ]
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def to_s
|
63
|
-
"a: #{name.to_s}"
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
|
3
|
-
# ralbum
|
4
|
-
require 'tree_visitor/tree_node_visitor'
|
5
|
-
require 'ralbum/album'
|
6
|
-
require 'ralbum/image_pool'
|
7
|
-
require 'ralbum/image_file'
|
8
|
-
|
9
|
-
class GenerateAlbumTreeNodeVisitor
|
10
|
-
|
11
|
-
def initialize( album_dirname, catalog, image_strategies )
|
12
|
-
@album_dirname = album_dirname
|
13
|
-
@catalog = catalog
|
14
|
-
@image_strategies = image_strategies
|
15
|
-
end
|
16
|
-
|
17
|
-
def run( photoTree )
|
18
|
-
ralbum_verbose( 1, "generate albumtree" )
|
19
|
-
ralbum_verbose( 1, "create images" )
|
20
|
-
visitor = CallbackTreeNodeVisitor2.new
|
21
|
-
|
22
|
-
visitor.onEnterTreeNode { |photoNode, parentAlbumNode|
|
23
|
-
album_key = @catalog.album_key( photoNode.path_from_root )
|
24
|
-
album_title = photoNode["title"]
|
25
|
-
album_desc = photoNode["shortdesc"]
|
26
|
-
albumNode = Album.new( parentAlbumNode, album_key, album_title, album_desc )
|
27
|
-
}
|
28
|
-
|
29
|
-
visitor.onVisitLeafNode{ |photoItem, parentAlbumNode|
|
30
|
-
photo_key = @catalog.key( photoItem.md5 )
|
31
|
-
photo_title = photoItem[ "title" ]
|
32
|
-
photo_desc = photoItem[ "description" ]
|
33
|
-
imagePool = ImagePool.new( parentAlbumNode, photoItem.md5, photo_key, photo_title, photo_desc )
|
34
|
-
msg = ""
|
35
|
-
@image_strategies.each_pair {|name,image_strategy|
|
36
|
-
image_basename = @catalog.photo_file( photoItem )
|
37
|
-
inpath = photoItem.path
|
38
|
-
outdir = File.join( @album_dirname, "images_" + image_strategy.name )
|
39
|
-
outpath = File.join( outdir, image_basename )
|
40
|
-
msg += "#{name} "
|
41
|
-
if File.exist?(outpath) and File.mtime(inpath) < File.mtime(outpath)
|
42
|
-
msg += "(s) "
|
43
|
-
else
|
44
|
-
Dir.mkdir( outdir ) unless File.exist?( outdir )
|
45
|
-
msg += image_strategy.build( inpath, outpath )
|
46
|
-
end
|
47
|
-
|
48
|
-
# imagePool.thumb = ImageFile.new( imagePool, @albums_dirname, "images_100x100/" + basename )
|
49
|
-
# imagePool.defaultImageFile = ImageFile.new( imagePool, @albums_dirname, "images_640x480/" + basename, basename + ".html")
|
50
|
-
image = ImageFile.new( imagePool, outpath, image_basename + ".html" )
|
51
|
-
imagePool.image( name, image )
|
52
|
-
}
|
53
|
-
ralbum_verbose( 2, sprintf("%40s: %s \n", photoItem.basename, msg ) )
|
54
|
-
}
|
55
|
-
|
56
|
-
photoTree.accept( visitor )
|
57
|
-
visitor.root
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|