gf-ralbum 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.
- data/LICENSE +20 -0
- data/README.rdoc +80 -0
- data/bin/ralbum-JPG2jpg.rb +90 -0
- data/bin/ralbum-compile_skins.rb +18 -0
- data/bin/ralbum-myconv.rb +81 -0
- data/bin/ralbum-readexif.rb +18 -0
- data/bin/ralbum-reorder.rb +200 -0
- data/bin/ralbum.rb +12 -0
- data/example/README.txt +8 -0
- data/example/example.sh +3 -0
- data/example/httpd.rb +35 -0
- data/example/test_phototree/album.xml +21 -0
- data/example/test_phototree/catalog_data/md5_to_key.yaml +4 -0
- data/example/test_phototree/catalog_data/md5_to_key.yaml.test +4 -0
- data/example/test_phototree/catalog_data/project.xml +329 -0
- data/example/test_phototree/r_photo01.jpg +0 -0
- data/example/test_phototree/r_photo01.jpg.xml +17 -0
- data/example/test_phototree/subalbum01/album.xml +21 -0
- data/example/test_phototree/subalbum01/subalbum01_photo01.jpg +0 -0
- data/example/test_phototree/subalbum01/subalbum01_photo01.jpg.xml +15 -0
- data/example/test_phototree/subalbum01/subalbum01_photo02.jpg +0 -0
- data/example/test_phototree/subalbum01/subalbum01_photo02.jpg.xml +15 -0
- data/example/test_phototree/subalbum01/subalbum01_photo03.jpg +0 -0
- data/example/test_phototree/subalbum01/subalbum01_photo03.jpg.xml +15 -0
- data/example/test_phototree/subalbum01/subalbum01_photo04.jpg +0 -0
- data/example/test_phototree/subalbum01/subalbum01_photo04.jpg.xml +15 -0
- data/example/test_phototree/subalbum02/album.xml +10 -0
- data/example/test_phototree/subalbum02/subalbum02_photo01.jpg +0 -0
- data/example/test_phototree/subalbum02/subalbum02_photo01.jpg.xml +15 -0
- data/example/test_phototree/subalbum02/subalbum02_photo02.jpg +0 -0
- data/example/test_phototree/subalbum02/subalbum02_photo02.jpg.xml +15 -0
- data/example/test_phototree/subalbum02/subalbum02_photo03.jpg +0 -0
- data/example/test_phototree/subalbum02/subalbum02_photo03.jpg.xml +15 -0
- data/example/test_phototree/subalbum02/subalbum02_photo04.jpg +0 -0
- data/example/test_phototree/subalbum02/subalbum02_photo04.jpg.xml +15 -0
- data/example/test_phototree/subalbum02/subalbum02_photo05.jpg +0 -0
- data/example/test_phototree/subalbum02/subalbum02_photo05.jpg.xml +15 -0
- data/lib/ralbum-common/object_with_properties.rb +14 -0
- data/lib/ralbum-common/object_with_validation.rb +50 -0
- data/lib/ralbum.rb +19 -0
- data/lib/ralbum/album.rb +66 -0
- data/lib/ralbum/catalog.rb +178 -0
- data/lib/ralbum/cli/cli_ralbum.rb +116 -0
- data/lib/ralbum/generate_album_tree_node_visitor.rb +60 -0
- data/lib/ralbum/image_file.rb +81 -0
- data/lib/ralbum/image_pool.rb +71 -0
- data/lib/ralbum/image_strategy.rb +143 -0
- data/lib/ralbum/options.rb +15 -0
- data/lib/ralbum/photo_tree_builder.rb +165 -0
- data/lib/ralbum/photo_tree_item.rb +89 -0
- data/lib/ralbum/photo_tree_node.rb +40 -0
- data/lib/ralbum/project.rb +89 -0
- data/lib/ralbum/ralbum_exception.rb +2 -0
- data/lib/ralbum/resource.rb +17 -0
- data/lib/ralbum/skin.rb +76 -0
- data/lib/ralbum/skin_engine.rb +98 -0
- data/lib/ralbum/skin_engines/erb_skin_engine.rb +35 -0
- data/lib/ralbum/skin_engines/kwartz_skin_engine.rb +54 -0
- data/lib/ralbum/skin_manager.rb +46 -0
- data/lib/ralbum/skins/cgi/cgi_skin.rb +27 -0
- data/lib/ralbum/skins/cgi/info.yml +3 -0
- data/lib/ralbum/skins/cgi/res/model.rb +235 -0
- data/lib/ralbum/skins/cgi/res/resource.rb +17 -0
- data/lib/ralbum/skins/gfold/inc/menu_bottom.html +53 -0
- data/lib/ralbum/skins/gfold/inc/menu_top.html +71 -0
- data/lib/ralbum/skins/gfold/inc/page_footer.html +28 -0
- data/lib/ralbum/skins/gfold/info.yml +3 -0
- data/lib/ralbum/skins/gfold/out/album_page.rb +316 -0
- data/lib/ralbum/skins/gfold/out/image_page.rb +231 -0
- data/lib/ralbum/skins/gfold/out/tree_page.rb +96 -0
- data/lib/ralbum/skins/gfold/res/16-arrow-down.png +0 -0
- data/lib/ralbum/skins/gfold/res/16-arrow-left.png +0 -0
- data/lib/ralbum/skins/gfold/res/16-arrow-right.png +0 -0
- data/lib/ralbum/skins/gfold/res/16-arrow-up.png +0 -0
- data/lib/ralbum/skins/gfold/res/left.gif +0 -0
- data/lib/ralbum/skins/gfold/res/prototype.js +3277 -0
- data/lib/ralbum/skins/gfold/res/right.gif +0 -0
- data/lib/ralbum/skins/gfold/res/style1.css +453 -0
- data/lib/ralbum/skins/gfold/res/style2.css +414 -0
- data/lib/ralbum/skins/gfold/res/styleswitcher.js +89 -0
- data/lib/ralbum/skins/gfold/res/top.gif +0 -0
- data/lib/ralbum/skins/gfold/res/up.gif +0 -0
- data/lib/ralbum/skins/gfold/res/valid-css.png +0 -0
- data/lib/ralbum/skins/gfold/res/valid-xhtml.png +0 -0
- data/lib/ralbum/skins/gfold/res/valid-xhtml11.png +0 -0
- data/lib/ralbum/skins/gfold/res/vcss.gif +0 -0
- data/lib/ralbum/skins/gfold/template/album_page.html +161 -0
- data/lib/ralbum/skins/gfold/template/album_page.plogic +127 -0
- data/lib/ralbum/skins/gfold/template/image_page.html +91 -0
- data/lib/ralbum/skins/gfold/template/image_page.plogic +70 -0
- data/lib/ralbum/skins/gfold/template/tree_page.html +79 -0
- data/lib/ralbum/skins/gfold/template/tree_page.plogic +45 -0
- data/lib/ralbum/skins/js/info.yml +3 -0
- data/lib/ralbum/skins/js/js_skin.rb +50 -0
- data/lib/ralbum/skins/js/out/album_page.rb +181 -0
- data/lib/ralbum/skins/js/out/slideshow_page.rb +187 -0
- data/lib/ralbum/skins/js/out/tree_page.rb +134 -0
- data/lib/ralbum/skins/js/res/left.gif +0 -0
- data/lib/ralbum/skins/js/res/right.gif +0 -0
- data/lib/ralbum/skins/js/res/style.css +76 -0
- data/lib/ralbum/skins/js/res/top.gif +0 -0
- data/lib/ralbum/skins/js/res/up.gif +0 -0
- data/lib/ralbum/skins/js/template/album_page.html +178 -0
- data/lib/ralbum/skins/js/template/album_page.plogic +88 -0
- data/lib/ralbum/skins/js/template/slideshow_page.html +169 -0
- data/lib/ralbum/skins/js/template/slideshow_page.plogic +1 -0
- data/lib/ralbum/skins/js/template/tree_page.html +118 -0
- data/lib/ralbum/skins/js/template/tree_page.plogic +43 -0
- data/lib/ralbum/skins/test_erb/info.yml +3 -0
- data/lib/ralbum/skins/test_erb/out/album_page.rb +54 -0
- data/lib/ralbum/skins/test_erb/out/image_page.rb +54 -0
- data/lib/ralbum/skins/test_kwartz/info.yml +3 -0
- data/lib/ralbum/skins/test_kwartz/out/album_page.rb +54 -0
- data/lib/ralbum/skins/test_kwartz/out/image_page.rb +54 -0
- data/lib/ralbum/skins/test_kwartz/template/album_page.html +37 -0
- data/lib/ralbum/skins/test_kwartz/template/image_page.html +37 -0
- data/test/ralbum/cli/test_cli_ralbum.rb +13 -0
- data/test/ralbum/tc_01_photo_tree.rb +37 -0
- data/test/ralbum/tc_02_photo_tree_builder.rb +20 -0
- data/test/ralbum/tc_03_album.rb +42 -0
- data/test/ralbum/tc_04_skin_manager.rb +30 -0
- data/test/ralbum/tc_05_kwartz_skin_engine.rb +50 -0
- data/test/ralbum/tc_06_image_strategy.rb +21 -0
- data/test/ralbum/tc_catalog.rb +31 -0
- data/test/ralbum/test_helper.rb +13 -0
- data/test/test_ralbum.rb +14 -0
- data/test_data/ralbum/test_data/albums_directory/gfold/album_1/img_0004.jpg.html +148 -0
- data/test_data/ralbum/test_data/albums_directory/gfold/album_1/img_0005.jpg.html +152 -0
- data/test_data/ralbum/test_data/albums_directory/gfold/album_1/img_0006.jpg.html +152 -0
- data/test_data/ralbum/test_data/albums_directory/gfold/album_1/img_0007.jpg.html +148 -0
- data/test_data/ralbum/test_data/albums_directory/gfold/album_1/index.html +195 -0
- data/test_data/ralbum/test_data/albums_directory/gfold/album_2/img_0008.jpg.html +148 -0
- data/test_data/ralbum/test_data/albums_directory/gfold/album_2/img_0009.jpg.html +152 -0
- data/test_data/ralbum/test_data/albums_directory/gfold/album_2/img_0010.jpg.html +152 -0
- data/test_data/ralbum/test_data/albums_directory/gfold/album_2/img_0011.jpg.html +152 -0
- data/test_data/ralbum/test_data/albums_directory/gfold/album_2/img_0012.jpg.html +148 -0
- data/test_data/ralbum/test_data/albums_directory/gfold/album_2/index.html +206 -0
- data/test_data/ralbum/test_data/albums_directory/gfold/img_0003.jpg.html +141 -0
- data/test_data/ralbum/test_data/albums_directory/gfold/index.html +208 -0
- data/test_data/ralbum/test_data/albums_directory/images_100x100/img_0003.jpg +0 -0
- data/test_data/ralbum/test_data/albums_directory/images_100x100/img_0004.jpg +0 -0
- data/test_data/ralbum/test_data/albums_directory/images_100x100/img_0005.jpg +0 -0
- data/test_data/ralbum/test_data/albums_directory/images_100x100/img_0006.jpg +0 -0
- data/test_data/ralbum/test_data/albums_directory/images_100x100/img_0007.jpg +0 -0
- data/test_data/ralbum/test_data/albums_directory/images_100x100/img_0008.jpg +0 -0
- data/test_data/ralbum/test_data/albums_directory/images_100x100/img_0009.jpg +0 -0
- data/test_data/ralbum/test_data/albums_directory/images_100x100/img_0010.jpg +0 -0
- data/test_data/ralbum/test_data/albums_directory/images_100x100/img_0011.jpg +0 -0
- data/test_data/ralbum/test_data/albums_directory/images_100x100/img_0012.jpg +0 -0
- data/test_data/ralbum/test_data/albums_directory/images_640x480/img_0003.jpg +0 -0
- data/test_data/ralbum/test_data/albums_directory/images_640x480/img_0004.jpg +0 -0
- data/test_data/ralbum/test_data/albums_directory/images_640x480/img_0005.jpg +0 -0
- data/test_data/ralbum/test_data/albums_directory/images_640x480/img_0006.jpg +0 -0
- data/test_data/ralbum/test_data/albums_directory/images_640x480/img_0007.jpg +0 -0
- data/test_data/ralbum/test_data/albums_directory/images_640x480/img_0008.jpg +0 -0
- data/test_data/ralbum/test_data/albums_directory/images_640x480/img_0009.jpg +0 -0
- data/test_data/ralbum/test_data/albums_directory/images_640x480/img_0010.jpg +0 -0
- data/test_data/ralbum/test_data/albums_directory/images_640x480/img_0011.jpg +0 -0
- data/test_data/ralbum/test_data/albums_directory/images_640x480/img_0012.jpg +0 -0
- data/test_data/ralbum/test_data/albums_directory/res/left.gif +0 -0
- data/test_data/ralbum/test_data/albums_directory/res/prototype.js +3277 -0
- data/test_data/ralbum/test_data/albums_directory/res/right.gif +0 -0
- data/test_data/ralbum/test_data/albums_directory/res/style1.css +453 -0
- data/test_data/ralbum/test_data/albums_directory/res/style2.css +414 -0
- data/test_data/ralbum/test_data/albums_directory/res/styleswitcher.js +89 -0
- data/test_data/ralbum/test_data/albums_directory/res/top.gif +0 -0
- data/test_data/ralbum/test_data/albums_directory/res/up.gif +0 -0
- data/test_data/ralbum/test_data/albums_directory/res/valid-css.png +0 -0
- data/test_data/ralbum/test_data/albums_directory/res/valid-xhtml.png +0 -0
- data/test_data/ralbum/test_data/albums_directory/res/valid-xhtml11.png +0 -0
- data/test_data/ralbum/test_data/albums_directory/res/vcss.gif +0 -0
- data/test_data/ralbum/test_data/albums_directory/test/album_1/img_0004.jpg.html +11 -0
- data/test_data/ralbum/test_data/albums_directory/test/album_1/img_0005.jpg.html +11 -0
- data/test_data/ralbum/test_data/albums_directory/test/album_1/img_0006.jpg.html +11 -0
- data/test_data/ralbum/test_data/albums_directory/test/album_1/img_0007.jpg.html +11 -0
- data/test_data/ralbum/test_data/albums_directory/test/album_1/index.html +13 -0
- data/test_data/ralbum/test_data/albums_directory/test/album_2/img_0008.jpg.html +11 -0
- data/test_data/ralbum/test_data/albums_directory/test/album_2/img_0009.jpg.html +11 -0
- data/test_data/ralbum/test_data/albums_directory/test/album_2/img_0010.jpg.html +11 -0
- data/test_data/ralbum/test_data/albums_directory/test/album_2/img_0011.jpg.html +11 -0
- data/test_data/ralbum/test_data/albums_directory/test/album_2/img_0012.jpg.html +11 -0
- data/test_data/ralbum/test_data/albums_directory/test/album_2/index.html +13 -0
- data/test_data/ralbum/test_data/albums_directory/test/img_0003.jpg.html +11 -0
- data/test_data/ralbum/test_data/albums_directory/test/index.html +13 -0
- 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
- metadata +276 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 gf
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
= RAlbum
|
2
|
+
|
3
|
+
I have started this personal project about two years ago. Never completed.
|
4
|
+
|
5
|
+
I wish to try ruby and ruby environment github/rubyforge/gem and I have retrieved this
|
6
|
+
old code for not start f
|
7
|
+
So if you are interested let me finish review (and rewrite) this code,
|
8
|
+
write some docs in english, ...
|
9
|
+
|
10
|
+
== DESCRIPTION:
|
11
|
+
|
12
|
+
RAlbum si basa su tre componenti
|
13
|
+
* PhotoTree e' la gerarchia di come sono organizzate le foto
|
14
|
+
in questo albero sono inserite le foto
|
15
|
+
* AlbumTree e' la gerarchia di come sono organizzate gli album
|
16
|
+
in questo albero sono inserite le immagini
|
17
|
+
* Catalog e' il database delle foto e delle immagini
|
18
|
+
|
19
|
+
Da una foto e' possibile ricavare piu' immagini p.e. la thumbnail, quella a dimensione media,
|
20
|
+
quella a dimensione piu' grande.
|
21
|
+
|
22
|
+
Un PhotoTree puo' essere ricavato dalle directory dal file-system, oppure leggendo da
|
23
|
+
un catalogo di un database di immagini come AcdSee, oppure dalle virtual directory di JAlbum
|
24
|
+
|
25
|
+
Dalle foto si ricavano le immagini. Le immagini sono le foto ridimensionate.
|
26
|
+
L'insieme delle immagini ridimensionate si chiama ImagePool
|
27
|
+
|
28
|
+
|
29
|
+
Il PhotoTree supportato ha il seguente formato
|
30
|
+
# PhotoTree
|
31
|
+
# are albums organizated into the filesystem
|
32
|
+
#
|
33
|
+
# root
|
34
|
+
# |-----alb 1
|
35
|
+
# | |---alb 1.1
|
36
|
+
# | |---alb 1.2
|
37
|
+
# | |---alb 1.2.1
|
38
|
+
# |-----alb 2
|
39
|
+
# | |--alb 2.1
|
40
|
+
#
|
41
|
+
# In every subdir there are photos
|
42
|
+
# ab x.y.z
|
43
|
+
# |---- 05_photo.jpg
|
44
|
+
# 05_photo.jpg.xml
|
45
|
+
#
|
46
|
+
|
47
|
+
|
48
|
+
Altri PhotoTree
|
49
|
+
# Web PhotoTree,
|
50
|
+
#
|
51
|
+
# it is usefull to generare a catalog of images found in web sites
|
52
|
+
#
|
53
|
+
# A Web phototree on disk is a
|
54
|
+
# root
|
55
|
+
# |
|
56
|
+
# |--website1_mirror
|
57
|
+
# | |-------- subdirs where are found images
|
58
|
+
# |--website2_mirror
|
59
|
+
# |-------- subdirs where are found images
|
60
|
+
#
|
61
|
+
|
62
|
+
|
63
|
+
== SYNOPSIS:
|
64
|
+
|
65
|
+
FIX (code sample of usage)
|
66
|
+
|
67
|
+
== REQUIREMENTS:
|
68
|
+
|
69
|
+
* ralbum-common
|
70
|
+
* rmagick
|
71
|
+
* imagesize
|
72
|
+
* kwartz
|
73
|
+
|
74
|
+
== INSTALL:
|
75
|
+
|
76
|
+
* sudo gem install ralbum
|
77
|
+
|
78
|
+
== Copyright
|
79
|
+
|
80
|
+
Copyright (c) 2009 gf. See LICENSE for details.
|
@@ -0,0 +1,90 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$RALBUM_HOME = File.expand_path( File.join( File.dirname( __FILE__), ".." ) )
|
4
|
+
$:.unshift( File.join($GALLERIES_HOME, "lib" ) )
|
5
|
+
|
6
|
+
# ruby
|
7
|
+
require 'fileutils'
|
8
|
+
require 'optparse'
|
9
|
+
require 'ostruct'
|
10
|
+
|
11
|
+
# rubyalbum
|
12
|
+
require "ralbum/config"
|
13
|
+
require "ralbum/recursive_run"
|
14
|
+
|
15
|
+
|
16
|
+
def mymove( srcpath, destpath )
|
17
|
+
if $options.usetempfile
|
18
|
+
# find a best name for tempfile
|
19
|
+
temppath = File.dirname( destpath ) + File::Separator + "tempfile"
|
20
|
+
FileUtils::move( srcpath, temppath )
|
21
|
+
FileUtils::move( temppath, destpath )
|
22
|
+
else
|
23
|
+
FileUtils::move( srcpath, destpath )
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def run( dir )
|
28
|
+
begin
|
29
|
+
Dir.entries( dir ).each { |filename|
|
30
|
+
next unless filename =~ /\.JPG$/
|
31
|
+
new_filename = filename.gsub( /\.JPG$/, ".jpg" )
|
32
|
+
inpath = dir + File::Separator + filename;
|
33
|
+
newpath = dir + File::Separator + new_filename
|
34
|
+
mymove( inpath, newpath )
|
35
|
+
puts "in #{dir}: #{filename} -> #{new_filename}"
|
36
|
+
}
|
37
|
+
rescue ArgumentError => e
|
38
|
+
puts "ERROR : " + e
|
39
|
+
puts "If you are using a fat32 filesystem try options -t"
|
40
|
+
rescue Errno::ENOENT => e
|
41
|
+
puts "ERROR : " + e
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
###################################################################################
|
46
|
+
# Main
|
47
|
+
|
48
|
+
$config = Config.new
|
49
|
+
|
50
|
+
$options = OpenStruct.new
|
51
|
+
$options.force = false
|
52
|
+
$options.verbose = 0
|
53
|
+
$options.recursive = false
|
54
|
+
$options.usetempfile = false
|
55
|
+
|
56
|
+
opts = OptionParser.new do |opts|
|
57
|
+
opts.banner =
|
58
|
+
"Usage: #{File.basename($0)} <directory>\n" +
|
59
|
+
"Rename file.JPG in file.jpg"
|
60
|
+
opts.on("-v", "--verbose [NUM]", Integer, "verbosity level") { |num|
|
61
|
+
if num.nil?
|
62
|
+
$options.verbose = 1
|
63
|
+
else
|
64
|
+
$options.verbose = num
|
65
|
+
end
|
66
|
+
}
|
67
|
+
opts.on("-r", "--recursive", "recusive in subdirectories") {
|
68
|
+
$options.recursive = true
|
69
|
+
}
|
70
|
+
opts.on("-t", "--usetempfile", "rename first to temp file and then to dest file") {
|
71
|
+
$options.usetempfile = true
|
72
|
+
}
|
73
|
+
opts.on("--help", "-h", "help!") {
|
74
|
+
puts opts
|
75
|
+
exit 0
|
76
|
+
}
|
77
|
+
end
|
78
|
+
opts.parse!(ARGV)
|
79
|
+
|
80
|
+
unless ARGV[0]
|
81
|
+
puts opts
|
82
|
+
exit 1
|
83
|
+
end
|
84
|
+
|
85
|
+
input_dir = ARGV[0]
|
86
|
+
if $options.recursive
|
87
|
+
recursive_run( input_dir ) { |d| run d }
|
88
|
+
else
|
89
|
+
run input_dir
|
90
|
+
end
|
@@ -0,0 +1,18 @@
|
|
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
|
+
|
@@ -0,0 +1,81 @@
|
|
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
|
@@ -0,0 +1,18 @@
|
|
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
|
@@ -0,0 +1,200 @@
|
|
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
|