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
File without changes
|
File without changes
|
data/example/{test_phototree → test_rubyphoto_phototree}/subalbum01/subalbum01_photo01.jpg.xml
RENAMED
File without changes
|
File without changes
|
data/example/{test_phototree → test_rubyphoto_phototree}/subalbum01/subalbum01_photo02.jpg.xml
RENAMED
File without changes
|
File without changes
|
data/example/{test_phototree → test_rubyphoto_phototree}/subalbum01/subalbum01_photo03.jpg.xml
RENAMED
File without changes
|
File without changes
|
data/example/{test_phototree → test_rubyphoto_phototree}/subalbum01/subalbum01_photo04.jpg.xml
RENAMED
File without changes
|
File without changes
|
File without changes
|
data/example/{test_phototree → test_rubyphoto_phototree}/subalbum02/subalbum02_photo01.jpg.xml
RENAMED
File without changes
|
File without changes
|
data/example/{test_phototree → test_rubyphoto_phototree}/subalbum02/subalbum02_photo02.jpg.xml
RENAMED
File without changes
|
File without changes
|
data/example/{test_phototree → test_rubyphoto_phototree}/subalbum02/subalbum02_photo03.jpg.xml
RENAMED
File without changes
|
File without changes
|
data/example/{test_phototree → test_rubyphoto_phototree}/subalbum02/subalbum02_photo04.jpg.xml
RENAMED
File without changes
|
File without changes
|
data/example/{test_phototree → test_rubyphoto_phototree}/subalbum02/subalbum02_photo05.jpg.xml
RENAMED
File without changes
|
data/lib/ralbum.rb
CHANGED
@@ -1,19 +1,23 @@
|
|
1
1
|
class Ralbum
|
2
|
-
VERSION = '0.0.
|
2
|
+
VERSION = '0.0.5'
|
3
3
|
end
|
4
4
|
|
5
5
|
#
|
6
6
|
# Check dependecies
|
7
7
|
#
|
8
8
|
require 'rubygems'
|
9
|
+
|
10
|
+
|
11
|
+
# gem 'treevisitor', '~> 3.0'
|
12
|
+
|
9
13
|
begin
|
10
|
-
require '
|
14
|
+
require 'treevisitor'
|
11
15
|
rescue LoadError
|
12
|
-
abort '
|
16
|
+
abort 'treevisitor gem required!!'
|
13
17
|
end
|
14
18
|
|
15
19
|
begin
|
16
|
-
require '
|
20
|
+
require 'RMagick'
|
17
21
|
rescue LoadError
|
18
|
-
abort '
|
22
|
+
abort 'rmagick required!!'
|
19
23
|
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# treevisitor
|
2
|
+
require 'treevisitor/tree_node'
|
3
|
+
|
4
|
+
#
|
5
|
+
# subalbum -> childs
|
6
|
+
# leaves -> photos o image_pools
|
7
|
+
#
|
8
|
+
class Album < TreeNode
|
9
|
+
|
10
|
+
attr_reader :key
|
11
|
+
attr_reader :description
|
12
|
+
|
13
|
+
def initialize( parent, key, title, description )
|
14
|
+
super( title, parent )
|
15
|
+
|
16
|
+
@key = key
|
17
|
+
@description = description
|
18
|
+
@default_image_pool = nil
|
19
|
+
end
|
20
|
+
|
21
|
+
############################################################################
|
22
|
+
# paths
|
23
|
+
#
|
24
|
+
|
25
|
+
def relroot
|
26
|
+
"../" * depth
|
27
|
+
end
|
28
|
+
|
29
|
+
def relroot_with_prefix
|
30
|
+
if root.prefix_path
|
31
|
+
root.prefix_path + relroot
|
32
|
+
else
|
33
|
+
relroot
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def page_url_from_root
|
38
|
+
File.join( path, "index.html" )
|
39
|
+
end
|
40
|
+
|
41
|
+
def page_url
|
42
|
+
File.join( name, "index.html" )
|
43
|
+
end
|
44
|
+
|
45
|
+
def breadcrumbs
|
46
|
+
h = { :title => name, :path => page_url_from_root }
|
47
|
+
if parent
|
48
|
+
parent.breadcrumbs << h
|
49
|
+
else
|
50
|
+
[ h ]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
###########################################################################
|
55
|
+
|
56
|
+
def default_image_pool
|
57
|
+
return @default_image_pool unless @default_image_pool.nil?
|
58
|
+
if leaves.length > 0
|
59
|
+
@default_image_pool = leaves[0]
|
60
|
+
elsif childs.length > 0
|
61
|
+
@default_image_pool = childs[0].default_image_pool
|
62
|
+
end
|
63
|
+
if @default_image_pool.nil?
|
64
|
+
msg = "cannot determine defaultphoto for album #{title} #{reldir} #{@leaves.length} #{@childs.length}"
|
65
|
+
raise msg
|
66
|
+
end
|
67
|
+
@default_image_pool
|
68
|
+
end
|
69
|
+
|
70
|
+
def to_s
|
71
|
+
"a: #{name.to_s}"
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
#treevisitor
|
2
|
+
require 'treevisitor/tree_node_visitor'
|
3
|
+
require 'treevisitor/visitors/callback_tree_node_visitor2'
|
4
|
+
|
5
|
+
# ralbum
|
6
|
+
require 'ralbum/album_tree/album'
|
7
|
+
require 'ralbum/album_tree/image_pool'
|
8
|
+
require 'ralbum/album_tree/image_file'
|
9
|
+
|
10
|
+
|
11
|
+
class GenerateAlbumTreeNodeVisitor < CallbackTreeNodeVisitor2
|
12
|
+
|
13
|
+
def initialize( album_dirname, catalog, image_strategies )
|
14
|
+
super()
|
15
|
+
@album_dirname = album_dirname
|
16
|
+
@catalog = catalog
|
17
|
+
@image_strategies = image_strategies
|
18
|
+
|
19
|
+
# TODO: eliminare le seguenti chiamate, trovare il visitor giusto da cui ereditare
|
20
|
+
on_enter_tree_node do |photo_tree_node, parentAlbumNode|
|
21
|
+
_on_enter_tree_node photo_tree_node, parentAlbumNode
|
22
|
+
end
|
23
|
+
|
24
|
+
on_visit_leaf_node do |photo_item, parent_album_node|
|
25
|
+
_on_visit_leaf_node photo_item, parent_album_node
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def run( photo_tree )
|
30
|
+
ralbum_verbose( 1, "generate albumtree" )
|
31
|
+
ralbum_verbose( 1, "create images" )
|
32
|
+
photo_tree.accept( self )
|
33
|
+
root
|
34
|
+
end
|
35
|
+
|
36
|
+
def _on_enter_tree_node(photo_tree_node, parent_album_node)
|
37
|
+
album_key = @catalog.album_key( photo_tree_node.path )
|
38
|
+
album_title = photo_tree_node.name # instead of photo_tree_node["title"]
|
39
|
+
album_desc = photo_tree_node["shortdesc"]
|
40
|
+
albumNode = Album.new( parent_album_node, album_key, album_title, album_desc )
|
41
|
+
end
|
42
|
+
|
43
|
+
def _on_visit_leaf_node(photo_item, parent_album_node)
|
44
|
+
photo_key = @catalog.key( photo_item.photo_file.md5 )
|
45
|
+
photo_title = photo_item.title
|
46
|
+
photo_desc = photo_item.description
|
47
|
+
image_pool = ImagePool.new( parent_album_node, photo_item.photo_file.md5, photo_key, photo_title, photo_desc )
|
48
|
+
msg = ""
|
49
|
+
|
50
|
+
@image_strategies.each_pair {|name,image_strategy|
|
51
|
+
image_basename = @catalog.photo_file( photo_item )
|
52
|
+
|
53
|
+
inpath = photo_item.photo_file.path
|
54
|
+
|
55
|
+
outdir = File.join( @album_dirname, "images_" + image_strategy.name )
|
56
|
+
outpath = File.join( outdir, image_basename )
|
57
|
+
msg += "#{name} "
|
58
|
+
if File.exist?(outpath) and File.mtime(inpath) < File.mtime(outpath)
|
59
|
+
msg += "(s) "
|
60
|
+
else
|
61
|
+
Dir.mkdir( outdir ) unless File.exist?( outdir )
|
62
|
+
msg += image_strategy.build( inpath, outpath )
|
63
|
+
end
|
64
|
+
|
65
|
+
src_url = File.join(image_pool.relroot_with_prefix, "images_" + image_strategy.name, image_basename)
|
66
|
+
image = ImageFile.new( image_pool, outpath, src_url, image_basename + ".html" )
|
67
|
+
|
68
|
+
image_pool.image( name, image )
|
69
|
+
}
|
70
|
+
ralbum_verbose( 2, sprintf("%40s: %s \n", photo_item.basename, msg ) )
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# gems
|
2
|
+
require 'rubygems'
|
3
|
+
require 'RMagick'
|
4
|
+
|
5
|
+
class ImageFile
|
6
|
+
|
7
|
+
attr_reader :image_pool
|
8
|
+
|
9
|
+
# properties of image
|
10
|
+
attr_reader :size
|
11
|
+
attr_reader :width
|
12
|
+
attr_reader :height
|
13
|
+
|
14
|
+
#
|
15
|
+
# page_url is the url of html page relative to the webroot f.e. "img_88.html"
|
16
|
+
# used to link html pages
|
17
|
+
# url is the name of image f.e. "img_88.jpg"
|
18
|
+
# used in the src=<...> of the image tag
|
19
|
+
#
|
20
|
+
def initialize( image_pool, local_path, src_url, page_url )
|
21
|
+
@image_pool = image_pool
|
22
|
+
@src_url = src_url
|
23
|
+
@page_url = page_url
|
24
|
+
|
25
|
+
if not File.exist?(local_path)
|
26
|
+
raise RAlbumException.new "file '#{local_path}' not exist"
|
27
|
+
end
|
28
|
+
if File.directory?(local_path)
|
29
|
+
raise RAlbumException.new "expected '#{local_path}' as file but it is a directory"
|
30
|
+
end
|
31
|
+
|
32
|
+
image = Magick::Image::read(local_path).first
|
33
|
+
@width = image.columns
|
34
|
+
@height = image.rows
|
35
|
+
@size = image.filesize / 1024
|
36
|
+
end
|
37
|
+
|
38
|
+
#############################################################################
|
39
|
+
# properties
|
40
|
+
#
|
41
|
+
def name
|
42
|
+
@image_pool.name
|
43
|
+
end
|
44
|
+
|
45
|
+
def description
|
46
|
+
@image_pool.description
|
47
|
+
end
|
48
|
+
|
49
|
+
#############################################################################
|
50
|
+
# paths
|
51
|
+
|
52
|
+
attr_reader :src_url # path where is the image
|
53
|
+
attr_reader :page_url # url of html page displaying the image
|
54
|
+
|
55
|
+
def page_url_from_root
|
56
|
+
@image_pool.path + "/" + page_url
|
57
|
+
end
|
58
|
+
|
59
|
+
def relroot
|
60
|
+
@image_pool.relroot
|
61
|
+
end
|
62
|
+
|
63
|
+
def relroot_with_prefix
|
64
|
+
@image_pool.relroot_with_prefix
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
def breadcrumbs
|
69
|
+
@image_pool.breadcrumbs
|
70
|
+
end
|
71
|
+
|
72
|
+
def prev_page_url
|
73
|
+
if @image_pool.prev
|
74
|
+
@image_pool.prev.default_image_file.page_url
|
75
|
+
else
|
76
|
+
nil
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def next_page_url
|
81
|
+
if @image_pool.next
|
82
|
+
@image_pool.next.default_image_file.page_url
|
83
|
+
else
|
84
|
+
nil
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# ralbum
|
2
|
-
require '
|
2
|
+
require 'treevisitor/leaf_node'
|
3
3
|
|
4
4
|
#
|
5
5
|
# ImagePool e' creata da una PhotoItem identificata da un md5
|
@@ -33,7 +33,10 @@ class ImagePool < LeafNode
|
|
33
33
|
|
34
34
|
@images = {}
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
|
+
############################################################################
|
38
|
+
# paths
|
39
|
+
|
37
40
|
def relroot
|
38
41
|
parent.relroot
|
39
42
|
end
|
@@ -45,7 +48,10 @@ class ImagePool < LeafNode
|
|
45
48
|
def breadcrumbs
|
46
49
|
parent.breadcrumbs
|
47
50
|
end
|
48
|
-
|
51
|
+
|
52
|
+
############################################################################
|
53
|
+
# images management
|
54
|
+
|
49
55
|
def image( type, image_file = nil)
|
50
56
|
if image_file
|
51
57
|
@images[ type ] = image_file
|
@@ -57,10 +63,16 @@ class ImagePool < LeafNode
|
|
57
63
|
res
|
58
64
|
end
|
59
65
|
|
60
|
-
def
|
66
|
+
def default_image_file
|
61
67
|
image("default")
|
62
68
|
end
|
63
69
|
|
70
|
+
def thumb
|
71
|
+
image("thumb")
|
72
|
+
end
|
73
|
+
|
74
|
+
############################################################################
|
75
|
+
|
64
76
|
def to_s
|
65
77
|
str = "ip: #{name.to_s} -#{@images.length}-"
|
66
78
|
@images.each_key { |key| str += key.to_s }
|
data/lib/ralbum/catalog.rb
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
# stlib
|
2
|
-
require 'singleton'
|
3
2
|
require 'yaml'
|
4
3
|
|
5
4
|
# ralbums
|
6
|
-
require 'ralbum/
|
7
|
-
require 'ralbum/
|
8
|
-
|
5
|
+
require 'ralbum/ralbum_exception'
|
6
|
+
require 'ralbum/album_tree/image_pool'
|
9
7
|
|
10
8
|
#
|
11
9
|
# All photos are stored here by md5
|
12
10
|
#
|
13
11
|
class Catalog
|
14
12
|
|
13
|
+
DEFAULT_CATALOG_DIRNAME = "ralbum"
|
14
|
+
|
15
15
|
attr_reader :catalog_dirname
|
16
16
|
|
17
17
|
def initialize( catalog_dirname )
|
18
18
|
@catalog_dir = catalog_dirname
|
19
19
|
if not FileTest.directory?( catalog_dirname )
|
20
|
-
raise "Catog.init: catalog directory '#{catalog_dir}' not exists"
|
20
|
+
raise RAlbumException.new, "Catog.init: catalog directory '#{@catalog_dir}' not exists"
|
21
21
|
end
|
22
22
|
|
23
23
|
@md5_to_key = {}
|
@@ -43,8 +43,8 @@ class Catalog
|
|
43
43
|
sprintf("%04d", k )
|
44
44
|
end
|
45
45
|
|
46
|
-
def photo_file(
|
47
|
-
"img_" + key(
|
46
|
+
def photo_file( photo_tree_item )
|
47
|
+
"img_" + key( photo_tree_item.photo_file.md5.to_s ) + ".jpg"
|
48
48
|
end
|
49
49
|
|
50
50
|
def album_key( reldir )
|
@@ -3,19 +3,13 @@ require 'rubygems'
|
|
3
3
|
require 'digest/md5'
|
4
4
|
require 'rexml/document'
|
5
5
|
require 'yaml'
|
6
|
-
require 'pp'
|
7
6
|
require 'optparse'
|
8
7
|
require 'ostruct'
|
9
8
|
require 'fileutils'
|
10
9
|
|
11
10
|
# ralbum
|
12
|
-
require '
|
13
|
-
require 'tree_visitor/tree_node_visitor'
|
11
|
+
require 'ralbum'
|
14
12
|
require 'ralbum/options'
|
15
|
-
require 'ralbum/photo_tree_builder'
|
16
|
-
require 'ralbum/catalog'
|
17
|
-
require 'ralbum/generate_album_tree_node_visitor'
|
18
|
-
require 'ralbum/skin_manager'
|
19
13
|
require 'ralbum/project'
|
20
14
|
|
21
15
|
class CliRAlbum
|
@@ -28,22 +22,36 @@ class CliRAlbum
|
|
28
22
|
|
29
23
|
skin_manager = SkinManager.new
|
30
24
|
|
25
|
+
### common
|
31
26
|
$options = OpenStruct.new
|
32
|
-
$options.force = false
|
33
27
|
$options.verbose = 0
|
34
|
-
|
35
|
-
$options.
|
28
|
+
### input
|
29
|
+
$options.photo_tree_type = "rubyphoto"
|
30
|
+
### output
|
31
|
+
$options.force = false
|
36
32
|
$options.skins = [ "gfold" ]
|
37
33
|
$options.inctemplate = nil
|
34
|
+
### debug
|
35
|
+
$options.debug_photo_tree = false
|
36
|
+
$options.debug_album_tree = false
|
38
37
|
|
39
38
|
options = OptionParser.new do |opts|
|
40
39
|
opts.banner =
|
41
40
|
"Usage: #{File.basename($0)} <photo tree directory> <album tree directory>\n" +
|
42
41
|
"Create albums from a phototree"
|
43
42
|
|
44
|
-
|
45
|
-
|
43
|
+
##### common options
|
44
|
+
opts.separator ""
|
45
|
+
opts.separator "common options:"
|
46
|
+
opts.on("--help", "-h", "help!") {
|
47
|
+
puts opts
|
48
|
+
return 0
|
46
49
|
}
|
50
|
+
opts.on("--version", "Show the version") do
|
51
|
+
puts "ralbum version #{Ralbum::VERSION}"
|
52
|
+
return 0
|
53
|
+
end
|
54
|
+
|
47
55
|
opts.on("-v", "--verbose [NUM]", Integer, "verbosity level") { |num|
|
48
56
|
if num.nil?
|
49
57
|
$options.verbose = 1
|
@@ -51,13 +59,29 @@ class CliRAlbum
|
|
51
59
|
$options.verbose = num
|
52
60
|
end
|
53
61
|
}
|
54
|
-
opts.on("-i", "--ifilter STRING", String, "input filter (phototree)" ) { |arg|
|
55
|
-
$options.inputfilter = arg
|
56
|
-
}
|
57
62
|
opts.on("-l", "--list-skins", "show a list of skins") { |arg|
|
58
63
|
puts "Available skins:"
|
59
64
|
puts skin_manager.describe_skins
|
60
|
-
|
65
|
+
return 0
|
66
|
+
}
|
67
|
+
|
68
|
+
##### input options
|
69
|
+
opts.separator ""
|
70
|
+
opts.separator "input options:"
|
71
|
+
|
72
|
+
algos = %w[rubyphoto jalbum]
|
73
|
+
algo_aliases = { "r" => "rubyphoto", "j" => "jalbum" }
|
74
|
+
algo_list = (algo_aliases.keys + algos).join(',')
|
75
|
+
opts.on("-i", "--ifilter ALGO", algos, algo_aliases, "input filter (phototree)"," (#{algo_list})") do |algo|
|
76
|
+
$options.photo_tree_type = algo
|
77
|
+
end
|
78
|
+
|
79
|
+
##### output options
|
80
|
+
opts.separator ""
|
81
|
+
opts.separator "output options:"
|
82
|
+
|
83
|
+
opts.on("-f", "--force", "force the creation of directory") {
|
84
|
+
$options.force = true
|
61
85
|
}
|
62
86
|
opts.on("-s", "--skin x,y,z", Array, "skin(s)") { |arg|
|
63
87
|
$options.skins = arg
|
@@ -65,16 +89,27 @@ class CliRAlbum
|
|
65
89
|
opts.on("--inc STRING", String, "includes kwarts template" ) { |arg|
|
66
90
|
$options.inctemplate = arg
|
67
91
|
}
|
68
|
-
|
69
|
-
|
70
|
-
|
92
|
+
|
93
|
+
##### debug options
|
94
|
+
opts.separator ""
|
95
|
+
opts.separator "debug options:"
|
96
|
+
opts.on("--debug-photo-tree") {
|
97
|
+
$options.debug_photo_tree = true
|
98
|
+
}
|
99
|
+
opts.on("--debug-album-tree") {
|
100
|
+
$options.debug_album_tree = true
|
71
101
|
}
|
72
102
|
end
|
73
103
|
options.parse!(argv)
|
74
104
|
|
105
|
+
if ARGV.length < 1
|
106
|
+
puts "missing source (photo tree) directory. Use --help for a list of options"
|
107
|
+
return 1
|
108
|
+
end
|
109
|
+
|
75
110
|
if ARGV.length < 2
|
76
|
-
puts options
|
77
|
-
|
111
|
+
puts "missing destination (album_tree) directory. Use --help for a list of options"
|
112
|
+
return 1
|
78
113
|
end
|
79
114
|
|
80
115
|
phototree_dirname = argv[0]
|
@@ -84,13 +119,13 @@ class CliRAlbum
|
|
84
119
|
$options.skins.each do |skin_name|
|
85
120
|
unless skin_manager.has_skin?(skin_name)
|
86
121
|
puts "skin: #{skin_name} not exists"
|
87
|
-
|
122
|
+
return 1
|
88
123
|
end
|
89
124
|
end
|
90
125
|
|
91
126
|
if not File.directory?( phototree_dirname )
|
92
127
|
puts "phototree_dir '#{phototree_dirname}' not exists or is not a directory"
|
93
|
-
|
128
|
+
return 1
|
94
129
|
end
|
95
130
|
|
96
131
|
if not File.directory?( album_dirname )
|
@@ -100,17 +135,23 @@ class CliRAlbum
|
|
100
135
|
else
|
101
136
|
puts "albums_dir '#{album_dirname}' not exists or is not a directory"
|
102
137
|
puts "use -f to force the creation of directory"
|
103
|
-
|
138
|
+
return 1
|
104
139
|
end
|
105
140
|
end
|
106
141
|
|
107
142
|
phototree_dirname = File.expand_path( phototree_dirname )
|
108
143
|
album_dirname = File.expand_path( album_dirname )
|
109
144
|
project = Project.new(skin_manager)
|
145
|
+
### input
|
110
146
|
project.phototree_dirname = phototree_dirname
|
147
|
+
project.photo_tree_type = $options.photo_tree_type
|
148
|
+
### output
|
111
149
|
project.album_dirname = album_dirname
|
112
150
|
project.skin_names = $options.skins
|
113
|
-
|
151
|
+
### debug
|
152
|
+
project.debug_photo_tree = $options.debug_photo_tree
|
153
|
+
project.debug_album_tree = $options.debug_album_tree
|
154
|
+
return project.run
|
114
155
|
end
|
115
156
|
|
116
157
|
end
|