require 'getoptlong'
require 'html_merges'
+#- install location
+$FPATH = '.'
+
#- options
$options = [
[ '--help', '-h', GetoptLong::NO_ARGUMENT, "Get help message" ],
-
+
[ '--no-check', '-n', GetoptLong::NO_ARGUMENT, "Don't check for needed external programs at startup" ],
-
+
[ '--source', '-s', GetoptLong::REQUIRED_ARGUMENT, "Directory which contains original images/videos as files or subdirs" ],
[ '--destination', '-d', GetoptLong::REQUIRED_ARGUMENT, "Directory which will contain the web-album" ],
[ '--clean', '-c', GetoptLong::NO_ARGUMENT, "Clean destination directory" ],
-
+
[ '--theme', '-t', GetoptLong::REQUIRED_ARGUMENT, "Select HTML theme to use" ],
+ [ '--size', '-z', GetoptLong::REQUIRED_ARGUMENT, "Size of images for `fullscreen' slideshow" ],
[ '--mproc', '-m', GetoptLong::REQUIRED_ARGUMENT, "Specify the number of processors for multi-processors machines" ],
]
#- default values for some globals
-$theme = 'simple'
$convert = 'convert -interlace line +profile "*"'
+$size = 'medium'
$verbose_level = 2
def usage
system("rm -rf #{$dest}")
when '--theme'
- $theme = arg
+ select_theme(arg)
+ when '--size'
+ $size = arg
when '--mproc'
$mproc = arg.to_i
if !$dest
die 'Missing --destination parameter.'
end
+
+ if !$theme
+ select_theme('simple')
+ end
+
+ size = $images_size.detect { |e| e['name'] == $size }
+ if !size
+ die "Size #{$size} not found in parameters of theme."
+ else
+ $sizeval = size['size']
+ msg 3, "Using size for fullscreen images of value: #{$sizeval}"
+ end
+end
+
+def select_theme(name)
+ $theme = name
+ themedir = "#{$FPATH}/themes/#{$theme}"
+ if !File.directory?(themedir)
+ die "Theme was not found (tried #{themedir} directory)."
+ end
+ require "#{themedir}/parameters.rb"
end
def check_installation
end
def build_html_skeleton
- theme_file = File.open("themes/#{$theme}/skeleton.html").readlines
+ theme_file = File.open("#{$FPATH}/themes/#{$theme}/skeleton.html").readlines
msg 2, "Read theme `#{$theme}'"
for line in theme_file
while line =~ /~~~(\w+)~~~/
final_images = []
images.each { |img|
dest_img = img.sub(/^#{Regexp.quote($source)}/, $dest).
- sub(/\.[^\.]+$/, '') + '-704.jpg'
+ sub(/\.[^\.]+$/, '') + "-#{$sizeval}.jpg"
final_images << File.basename(dest_img)
if !File.exists?(dest_img)
convert_options = ''
if orientation =~ /left - bottom/
convert_options += '-rotate -90 '
end
- psys("#{$convert} #{convert_options}-geometry 704x528 '#{img}' '#{dest_img}'")
+ psys("#{$convert} #{convert_options}-geometry #{$sizeval} '#{img}' '#{dest_img}'")
end
}
#- one for 1024x768 and one for 1280x1024
#- it's necessary to fit according to the typical space taken by
#- widgets defined in the skeleton of the theme
-images_size = [
+$images_size = [
{
- name => { 'en' => 'Small (for 800x600 screens)' },
- size => { '550x412' }
+ 'name' => 'small',
+ 'explanation' => { 'en' => 'Small (for 800x600 screens)' },
+ 'size' => '550x412'
},
{
- name => { 'en' => 'Medium (for 1024x768 screens)' },
- size => { '704x528' }
+ 'name' => 'medium',
+ 'explanation' => { 'en' => 'Medium (for 1024x768 screens)' },
+ 'size' => '704x528'
},
{
- name => { 'en' => 'Large (for 1280x1024 screens)' },
- size => { '880x704' }
+ 'name' => 'large',
+ 'explanation' => { 'en' => 'Large (for 1280x1024 screens)' },
+ 'size' => '880x704'
}
]