html2slideshow 2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/html2slideshow +27 -0
- data/doc/changes.txt +162 -0
- data/doc/license.txt +674 -0
- data/lib/LANG +1 -0
- data/lib/about.rb +57 -0
- data/lib/argparser.rb +143 -0
- data/lib/completable.rb +157 -0
- data/lib/configurator.rb +155 -0
- data/lib/copyright.txt +22 -0
- data/lib/extstring.rb +75 -0
- data/lib/file_checking.rb +153 -0
- data/lib/html2slideshow.cfg +22 -0
- data/lib/html2slideshow.rb +132 -0
- data/lib/htmlbuilder.rb +267 -0
- data/lib/icons/failure.png +0 -0
- data/lib/icons/howto.png +0 -0
- data/lib/icons/logo.png +0 -0
- data/lib/icons/message.png +0 -0
- data/lib/icons/options.png +0 -0
- data/lib/icons/question.png +0 -0
- data/lib/icons/success.png +0 -0
- data/lib/image.rb +62 -0
- data/lib/list_fields.rb +34 -0
- data/lib/log.conf +60 -0
- data/lib/logging.rb +194 -0
- data/lib/slideshow_css.rb +248 -0
- data/lib/slideshow_images/downCursor.png +0 -0
- data/lib/slideshow_images/leftArrow.png +0 -0
- data/lib/slideshow_images/olive.png +0 -0
- data/lib/slideshow_images/pause.png +0 -0
- data/lib/slideshow_images/rightArrow.png +0 -0
- data/lib/slideshow_images/sizeMedium.png +0 -0
- data/lib/slideshow_images/sizeNormal.png +0 -0
- data/lib/slideshow_images/sizeSmall.png +0 -0
- data/lib/slideshow_images/start.png +0 -0
- data/lib/slideshow_images/stop.png +0 -0
- data/lib/slideshow_images/toggle.png +0 -0
- data/lib/slideshow_images/upCursor.png +0 -0
- data/lib/slideshow_js.rb +390 -0
- data/lib/slideshow_template.rb +194 -0
- data/lib/sourcefile.rb +191 -0
- data/lib/translating.rb +90 -0
- data/lib/translations +354 -0
- metadata +86 -0
@@ -0,0 +1,153 @@
|
|
1
|
+
#encoding: UTF-8
|
2
|
+
=begin
|
3
|
+
/***************************************************************************
|
4
|
+
* ©2011-2021 Michael Uplawski <michael.uplawski@uplawski.eu> *
|
5
|
+
* *
|
6
|
+
* This program is free software; you can redistribute it and/or modify *
|
7
|
+
* it under the terms of the GNU General Public License as published by *
|
8
|
+
* the Free Software Foundation; either version 3 of the License, or *
|
9
|
+
* (at your option) any later version. *
|
10
|
+
* *
|
11
|
+
* This program is distributed in the hope that it will be useful, *
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
14
|
+
* GNU General Public License for more details. *
|
15
|
+
* *
|
16
|
+
* You should have received a copy of the GNU General Public License *
|
17
|
+
* along with this program; if not, write to the *
|
18
|
+
* Free Software Foundation, Inc., *
|
19
|
+
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
20
|
+
***************************************************************************/
|
21
|
+
=end
|
22
|
+
|
23
|
+
require 'filemagic'
|
24
|
+
|
25
|
+
=begin
|
26
|
+
A module to facilitate frequently occuring checks on
|
27
|
+
file-system objects
|
28
|
+
=end
|
29
|
+
module File_Checking
|
30
|
+
|
31
|
+
@@last_mime_type = nil
|
32
|
+
|
33
|
+
@@text_messages = {
|
34
|
+
:exist? => "does not exist!",
|
35
|
+
:exist => "does not exist!",
|
36
|
+
:readable? => "is not readable!",
|
37
|
+
:readable => "is not readable!",
|
38
|
+
:executable? => "is not executable!",
|
39
|
+
:executable => "is not executable!",
|
40
|
+
:writable? => "is not writable!",
|
41
|
+
:writable => "is not writable!",
|
42
|
+
:directory? => "is not a directory!",
|
43
|
+
:directory => "is not a directory!",
|
44
|
+
:file? => "is not a file!",
|
45
|
+
:file => "is not a file!",
|
46
|
+
# different thing
|
47
|
+
:type => "is not of the sought file-type (not '%s', but '%s')!",
|
48
|
+
:mime => "does not have the sought mime-type (not '%s', but '%s')!",
|
49
|
+
}
|
50
|
+
|
51
|
+
def self::last_mime_type
|
52
|
+
@@last_mime_type
|
53
|
+
end
|
54
|
+
|
55
|
+
# Checks if the file with the name from the first
|
56
|
+
# parameter has the properties, listed in the second.
|
57
|
+
# The messages parameter is an array of one or several
|
58
|
+
# of :exist?, :readable?, :writable?, :directory? or
|
59
|
+
# their string-representations, respectively.
|
60
|
+
# Returns nil in case of success, otherwise an
|
61
|
+
# informative message, describing the first negative
|
62
|
+
# test-result.
|
63
|
+
def file_check(file, *messages)
|
64
|
+
File_Checking.file_check(file, *messages)
|
65
|
+
end
|
66
|
+
|
67
|
+
# Checks if the file with the name from the first
|
68
|
+
# parameter has the properties, listed in the second.
|
69
|
+
# The messages parameter is an array of one or all
|
70
|
+
# of :exist?, :readable?, :writable?, :directory? or
|
71
|
+
# their string-representations, respectively.
|
72
|
+
# Returns nil in case of success, otherwise an
|
73
|
+
# informative message, describing the first negative
|
74
|
+
# test-result.
|
75
|
+
def self.file_check(file, *messages)
|
76
|
+
if !File.exist?(file)
|
77
|
+
return file.dup << ' ' << ' does not exist!'
|
78
|
+
end
|
79
|
+
msg = nil
|
80
|
+
if(file && messages.respond_to?(:to_ary) && !messages.empty?)
|
81
|
+
messages.each do |k|
|
82
|
+
if( k != :mime && k != :type)
|
83
|
+
if(! k.to_s.end_with?('?'))
|
84
|
+
k = (k.to_s << '?').to_sym
|
85
|
+
end
|
86
|
+
@log.debug ('checking ' << k.to_s) if @log
|
87
|
+
if(msg == nil && File.respond_to?(k) && ! File.send(k, file.to_s))
|
88
|
+
msg = "#{file} #{@@text_messages[k.to_sym]}"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
msg
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.mime_check(file, mime_type_s)
|
97
|
+
if !File.exist?(file)
|
98
|
+
return file.dup << ' ' << ' does not exist!'
|
99
|
+
end
|
100
|
+
|
101
|
+
fm = FileMagic.mime
|
102
|
+
if (!File.directory?(file) )
|
103
|
+
begin
|
104
|
+
fd = fm.fd(File.new(file) ).split(';')[0]
|
105
|
+
rescue Exception => ex
|
106
|
+
@@last_mime_type = nil
|
107
|
+
return ex.message
|
108
|
+
end
|
109
|
+
@@last_mime_type = fd
|
110
|
+
# list of mime_types
|
111
|
+
if mime_type_s.respond_to?(:to_ary)
|
112
|
+
format = mime_type_s.detect {|f| fd == f.strip}
|
113
|
+
if !format
|
114
|
+
return file.dup << ' is of none of the supported mime-types, but ' << fd
|
115
|
+
end
|
116
|
+
# one mime_type only
|
117
|
+
elsif fd != mime_type.strip
|
118
|
+
return file.dup << ' ' << (@@text_messages[:mime] %[mime_type, fd])
|
119
|
+
end
|
120
|
+
else
|
121
|
+
@@last_mime_type = "inode/directory"
|
122
|
+
return file.dup << " is a directory!"
|
123
|
+
end
|
124
|
+
return nil
|
125
|
+
end
|
126
|
+
|
127
|
+
def self.magic_check(file, magic)
|
128
|
+
if !File.exist?(file)
|
129
|
+
return file.dup << ' ' << ' does not exist!'
|
130
|
+
end
|
131
|
+
fm = FileMagic.fm
|
132
|
+
fd = fm.fd(File.new(file) ).split(';')[0]
|
133
|
+
if fd != magic.strip
|
134
|
+
return file.dup << ' ' << (@@text_messages[:type] %[magic, fd])
|
135
|
+
end
|
136
|
+
return nil
|
137
|
+
end
|
138
|
+
|
139
|
+
end # module
|
140
|
+
|
141
|
+
=begin
|
142
|
+
# example
|
143
|
+
|
144
|
+
include File_Checking
|
145
|
+
msg = file_check('some_file.txt', [:exist?, :readable?, 'writable'])
|
146
|
+
# same as
|
147
|
+
# msg = file_check('some_file.txt', [:exist, :readable, 'writable?'])
|
148
|
+
|
149
|
+
msg ||= magic_check('some_file.txt', 'OpenDocument Text')
|
150
|
+
msg ||= mime_check('some_file.txt', 'application/vnd.oasis.opendocument.text')
|
151
|
+
puts msg if msg
|
152
|
+
=end
|
153
|
+
# E O F
|
@@ -0,0 +1,22 @@
|
|
1
|
+
---
|
2
|
+
:recursive: true
|
3
|
+
:source: "/local_data/Photos/Chez_Fares_Mai_2022/"
|
4
|
+
:target: "/local_data/Photos/Chez_Fares_Mai_2022/slide show"
|
5
|
+
:image_types:
|
6
|
+
- jpg
|
7
|
+
- JPG
|
8
|
+
- jpeg
|
9
|
+
- JPEG
|
10
|
+
- WEBP
|
11
|
+
- webp
|
12
|
+
:source_type: files
|
13
|
+
:file_pattern: ".*"
|
14
|
+
:merge: false
|
15
|
+
:title: Broyage
|
16
|
+
:log: "/tmp/test.log"
|
17
|
+
:debug: true
|
18
|
+
:scale_medium: '800'
|
19
|
+
:scale_small: '500'
|
20
|
+
:browser: qutebrowser
|
21
|
+
:date: '2022-05-22 20:57:10 +0200'
|
22
|
+
:suffix:
|
@@ -0,0 +1,132 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#encoding: UTF-8
|
3
|
+
|
4
|
+
=begin
|
5
|
+
/***************************************************************************
|
6
|
+
* Copyright © 2008-2017, Michael Uplawski <michael.uplawski@uplawski.eu> *
|
7
|
+
* *
|
8
|
+
* This program is free software; you can redistribute it and/or modify *
|
9
|
+
* it under the terms of the GNU General Public License as published by *
|
10
|
+
* the Free Software Foundation; either version 3 of the License, or *
|
11
|
+
* (at your option) any later version. *
|
12
|
+
* *
|
13
|
+
* This program is distributed in the hope that it will be useful, *
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
16
|
+
* GNU General Public License for more details. *
|
17
|
+
* *
|
18
|
+
* You should have received a copy of the GNU General Public License *
|
19
|
+
* along with this program; if not, write to the *
|
20
|
+
* Free Software Foundation, Inc., *
|
21
|
+
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
22
|
+
***************************************************************************/
|
23
|
+
=end
|
24
|
+
|
25
|
+
require_relative 'argparser'
|
26
|
+
require_relative 'sourcefile'
|
27
|
+
require_relative 'file_checking'
|
28
|
+
require_relative 'htmlbuilder'
|
29
|
+
require_relative 'configurator'
|
30
|
+
require_relative 'extstring'
|
31
|
+
require_relative 'logging'
|
32
|
+
require 'singleton'
|
33
|
+
|
34
|
+
=begin
|
35
|
+
The SlideShowGenerator class provides the main routine to start
|
36
|
+
the slideshow-generation.
|
37
|
+
Alternatively a commandline parameter -g or --generic can be
|
38
|
+
used to write a generic configuration file, which can be used
|
39
|
+
to alter the program output in later runs of the generator.
|
40
|
+
See Argparser for details on commandline parameters.
|
41
|
+
=end
|
42
|
+
class SlideShowGenerator
|
43
|
+
include Singleton
|
44
|
+
|
45
|
+
self::extend(Logging)
|
46
|
+
@@log = self::init_logger()
|
47
|
+
|
48
|
+
def initialize
|
49
|
+
@log = @@log
|
50
|
+
end
|
51
|
+
|
52
|
+
# The original console-version works with this method
|
53
|
+
def generate(args)
|
54
|
+
message = nil
|
55
|
+
options = ArgParser.parse(args)
|
56
|
+
@log.level = Logger::INFO if !options.debug
|
57
|
+
@log.debug('Log-level is ' << @log.level.to_s)
|
58
|
+
|
59
|
+
@log.debug("options are " + options.to_s)
|
60
|
+
unless options.generic
|
61
|
+
pwd = Dir.pwd()
|
62
|
+
if(options.source && !options.source.empty?)
|
63
|
+
message = File_Checking.file_check(options.source, [:exist?, :readable?, :writable?, :directory?])
|
64
|
+
if(message)
|
65
|
+
message = sprintf( trl("Source-directory") << ": %s" , message)
|
66
|
+
else
|
67
|
+
Dir.chdir(options.source)
|
68
|
+
|
69
|
+
if('files' == options.source_type)
|
70
|
+
read_dir(options)
|
71
|
+
else
|
72
|
+
read_html(options)
|
73
|
+
end
|
74
|
+
Dir.chdir(pwd)
|
75
|
+
end
|
76
|
+
else
|
77
|
+
message = trl('No source-directory given!')
|
78
|
+
end
|
79
|
+
else
|
80
|
+
message = Configurator.write_configuration(options.generic)
|
81
|
+
end
|
82
|
+
message if message
|
83
|
+
end
|
84
|
+
|
85
|
+
# read from DIR
|
86
|
+
def read_dir(options)
|
87
|
+
@log.debug('reading files from souce-directory')
|
88
|
+
if(!options.formats || options.formats.empty?)
|
89
|
+
options.formats = %w[jpg JPG jpeg JPEG webp]
|
90
|
+
@log.debug("no image types chosen, looking for JPEGs and WebP")
|
91
|
+
end
|
92
|
+
@log.debug('working on directory ' + Dir.pwd)
|
93
|
+
source = SourceFile.new(Dir.pwd, options)
|
94
|
+
HtmlBuilder.new(source, options)
|
95
|
+
end
|
96
|
+
|
97
|
+
# read from html
|
98
|
+
def read_html(options)
|
99
|
+
@log.debug('reading references from html')
|
100
|
+
htmlfiles = Dir.glob("{*.htm,*.html}")
|
101
|
+
if(htmlfiles && !htmlfiles.empty?)
|
102
|
+
htmlfiles.each do |sf|
|
103
|
+
@log.debug('working on file ' + sf)
|
104
|
+
source = SourceFile.new(sf, options)
|
105
|
+
HtmlBuilder.new(source, options)
|
106
|
+
end
|
107
|
+
else
|
108
|
+
@log.error("NO source-files in %s! Check source-directory!" %options.source)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
#
|
112
|
+
# main routine.
|
113
|
+
def run()
|
114
|
+
|
115
|
+
message = generate(ARGV)
|
116
|
+
if message
|
117
|
+
@log.error message
|
118
|
+
@log.debug('returning nil')
|
119
|
+
nil
|
120
|
+
else
|
121
|
+
msg = trl('DONE')
|
122
|
+
puts "-" * msg.length << "\n" << msg
|
123
|
+
@log.debug('returning true')
|
124
|
+
true
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
if __FILE__ == $0
|
130
|
+
SlideShowGenerator.instance().run()
|
131
|
+
end
|
132
|
+
|
data/lib/htmlbuilder.rb
ADDED
@@ -0,0 +1,267 @@
|
|
1
|
+
#encoding: UTF-8
|
2
|
+
=begin
|
3
|
+
/***************************************************************************
|
4
|
+
* Copyright © 2008-2012, Michael Uplawski <michael.uplawski@uplawski.eu> *
|
5
|
+
* *
|
6
|
+
* This program is free software; you can redistribute it and/or modify *
|
7
|
+
* it under the terms of the GNU General Public License as published by *
|
8
|
+
* the Free Software Foundation; either version 3 of the License, or *
|
9
|
+
* (at your option) any later version. *
|
10
|
+
* *
|
11
|
+
* This program is distributed in the hope that it will be useful, *
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
14
|
+
* GNU General Public License for more details. *
|
15
|
+
* *
|
16
|
+
* You should have received a copy of the GNU General Public License *
|
17
|
+
* along with this program; if not, write to the *
|
18
|
+
* Free Software Foundation, Inc., *
|
19
|
+
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
20
|
+
***************************************************************************/
|
21
|
+
=end
|
22
|
+
|
23
|
+
RD = File.expand_path(File.dirname(__FILE__) ) + File::Separator if !defined?(RD)
|
24
|
+
|
25
|
+
require_relative 'sourcefile'
|
26
|
+
require_relative 'file_checking'
|
27
|
+
require_relative 'slideshow_template'
|
28
|
+
require_relative 'slideshow_css'
|
29
|
+
require_relative 'slideshow_js'
|
30
|
+
require 'yaml'
|
31
|
+
require 'date'
|
32
|
+
require_relative 'completable'
|
33
|
+
require 'fileutils'
|
34
|
+
require_relative 'configurator'
|
35
|
+
require_relative 'logging'
|
36
|
+
|
37
|
+
FS = File::Separator
|
38
|
+
|
39
|
+
=begin
|
40
|
+
This class writes the final slide-show
|
41
|
+
pages.
|
42
|
+
=end
|
43
|
+
class HtmlBuilder
|
44
|
+
self::extend(Logging)
|
45
|
+
@@log = init_logger
|
46
|
+
@@count_tag = "<span id=\"lastImage\" style=\"display:none\">"
|
47
|
+
@@span_close = "</span>"
|
48
|
+
|
49
|
+
include File_Checking
|
50
|
+
|
51
|
+
def initialize(sourcefile, options)
|
52
|
+
@log = @@log
|
53
|
+
@log.debug(format("source: %s", sourcefile.to_s))
|
54
|
+
@log.debug(format("options: %s", options.to_s))
|
55
|
+
@configurator = Configurator.new(options)
|
56
|
+
@source = sourcefile
|
57
|
+
@target_dir = nil
|
58
|
+
@substitutions = {
|
59
|
+
'title' => @source.title,
|
60
|
+
'javaScript' => 'slideshow.js',
|
61
|
+
'css' => 'slideshow.css',
|
62
|
+
'NoJsUrl' => 'index.html',
|
63
|
+
'NoJsTitle' => trl('Back to the welcome page'),
|
64
|
+
'NoJsName' => trl('welcome page'),
|
65
|
+
'heading1' => @source.title,
|
66
|
+
'nullImageUrl' => 'images/olive.png',
|
67
|
+
'pxMedium' => format("%spx", @configurator.scale_medium || '500'),
|
68
|
+
'pxSmall' => format("%spx", @configurator.scale_small || '300'),
|
69
|
+
'ImgReferences' => format_references
|
70
|
+
}
|
71
|
+
|
72
|
+
@log.debug(format("substitutions are %s", @substitutions))
|
73
|
+
msg = create_slideshow if @substitutions['ImgReferences']
|
74
|
+
@log.debug(msg) if msg
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def format_references()
|
80
|
+
images = @source.images
|
81
|
+
size = images.size
|
82
|
+
refs = images.collect {|im| im.reference}
|
83
|
+
references = nil
|
84
|
+
|
85
|
+
if(size > 1)
|
86
|
+
@log.debug('configurator sais target = ' << @configurator.target)
|
87
|
+
sd = @configurator.target.sub(@configurator.source, '').strip()
|
88
|
+
references = @@count_tag + size.to_s + @@span_close
|
89
|
+
if @configurator.target != "./"
|
90
|
+
dpfx = '../'
|
91
|
+
end
|
92
|
+
images.each_with_index do |image, index|
|
93
|
+
image_url = nil
|
94
|
+
references += "<span style=\"display:none;\" id=\"image#{index}\""
|
95
|
+
if(@source.title)
|
96
|
+
references << " title=\"" << @source.title << "\">"
|
97
|
+
else
|
98
|
+
references << ">"
|
99
|
+
end
|
100
|
+
references << format("%s%s", dpfx, image.reference) << @@span_close
|
101
|
+
end
|
102
|
+
end
|
103
|
+
references
|
104
|
+
end
|
105
|
+
|
106
|
+
def create_slideshow()
|
107
|
+
template_file, msg = template()
|
108
|
+
@log.debug("template_file is #{template_file}")
|
109
|
+
if(!msg)
|
110
|
+
slideshow_file, msg = target_file()
|
111
|
+
if(!msg)
|
112
|
+
@log.debug("writing slide-show to #{slideshow_file}")
|
113
|
+
File.delete(slideshow_file) if File.exist?(slideshow_file)
|
114
|
+
File.open(slideshow_file, 'w') do |slf|
|
115
|
+
File.open(template_file, 'r') do |tpf|
|
116
|
+
tpf.extend(Completable)
|
117
|
+
tpf.field_delimiter = "%-"
|
118
|
+
fc, msg = tpf.complete(@substitutions) do |chunk|
|
119
|
+
slf << chunk
|
120
|
+
end
|
121
|
+
@log.debug("field-count is #{fc}")
|
122
|
+
msg = "Success: replaced #{fc} fields." if (fc && fc > 0)
|
123
|
+
summary = tpf.summary
|
124
|
+
msg += "\nfound: #{summary.fields_found.inspect}"
|
125
|
+
msg += "\nmissed: #{summary.fields_missing.join(', ')}"
|
126
|
+
end
|
127
|
+
end
|
128
|
+
msg = put_js
|
129
|
+
msg = put_css if !msg
|
130
|
+
msg = put_icons if !msg
|
131
|
+
else
|
132
|
+
msg = "Cannot write slideshow to #{slideshow_file} (#{msg.to_s})"
|
133
|
+
end
|
134
|
+
else
|
135
|
+
msg = "Cannot create template-file (#{msg.to_s})"
|
136
|
+
end
|
137
|
+
return msg
|
138
|
+
end
|
139
|
+
|
140
|
+
def put_icons
|
141
|
+
tdir, msg = target_dir
|
142
|
+
if(!msg)
|
143
|
+
icons_dir = tdir + FS + 'images'
|
144
|
+
Dir.mkdir(icons_dir) if (!File.exist?(icons_dir))
|
145
|
+
icons_source = RD + FS + 'slideshow_images' + FS
|
146
|
+
icons = Dir.new(icons_source).collect{|i| (icons_source + i) if( i.end_with?('.png'))}.compact!
|
147
|
+
FileUtils.cp(icons, icons_dir)
|
148
|
+
@log.debug("copied icons into #{icons_dir}")
|
149
|
+
else
|
150
|
+
return msg
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
|
155
|
+
def put_css
|
156
|
+
tdir, msg = target_dir
|
157
|
+
if(!msg)
|
158
|
+
css_file = tdir + File::Separator + 'slideshow.css'
|
159
|
+
if(!File.exist?(css_file))
|
160
|
+
css_dir = File.dirname(css_file)
|
161
|
+
Dir.mkdir(css_dir) if (!File.exist?(css_dir))
|
162
|
+
msg = file_check(css_dir, [:exist?, :writable?, :directory?])
|
163
|
+
if(!msg)
|
164
|
+
File.open(css_file, File::CREAT|File::WRONLY) do |slf|
|
165
|
+
slf.write($SLIDESHOW_CSS)
|
166
|
+
@log.debug("wrote css-file to #{css_file}")
|
167
|
+
end
|
168
|
+
else
|
169
|
+
return msg
|
170
|
+
end
|
171
|
+
end
|
172
|
+
return nil
|
173
|
+
else
|
174
|
+
return msg
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
def put_js
|
179
|
+
tdir, msg = target_dir
|
180
|
+
if(!msg)
|
181
|
+
js_file = tdir + File::Separator + 'slideshow.js'
|
182
|
+
if(!File.exist?(js_file))
|
183
|
+
js_dir = File.dirname(js_file)
|
184
|
+
Dir.mkdir(js_dir) if (!File.exist?(js_dir))
|
185
|
+
msg = file_check(js_dir, [:exist?, :writable?, :directory?])
|
186
|
+
if(!msg)
|
187
|
+
File.open(js_file, File::CREAT|File::WRONLY) do |slf|
|
188
|
+
slf.write($JAVASCRIPT)
|
189
|
+
@log.debug("wrote js-file to #{js_file}")
|
190
|
+
end
|
191
|
+
else
|
192
|
+
return msg
|
193
|
+
end
|
194
|
+
end
|
195
|
+
return nil
|
196
|
+
else
|
197
|
+
return msg
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
def template
|
202
|
+
msg = nil
|
203
|
+
template_file = nil
|
204
|
+
tdir, msg = target_dir
|
205
|
+
if(!msg)
|
206
|
+
template_file = tdir + File::Separator + 'template.html'
|
207
|
+
if(!File.exist?('template_file'))
|
208
|
+
template_dir = File.dirname(template_file)
|
209
|
+
Dir.mkdir(template_dir) if (!File.exist?(template_dir))
|
210
|
+
msg = file_check(template_dir, [:exist?, :writable?, :directory?])
|
211
|
+
if(!msg)
|
212
|
+
# avoid trailing garbage when overwriting old templates
|
213
|
+
File.delete(template_file) if File.exist?(template_file)
|
214
|
+
File.open(template_file, File::CREAT|File::WRONLY) do |slf|
|
215
|
+
slf.write($TEMPLATE)
|
216
|
+
@log.debug("wrote template-file to #{template_file}")
|
217
|
+
end
|
218
|
+
end
|
219
|
+
else
|
220
|
+
@log.debug('template is already available')
|
221
|
+
end
|
222
|
+
end
|
223
|
+
return template_file, msg
|
224
|
+
end
|
225
|
+
|
226
|
+
def target_dir
|
227
|
+
return @target_dir if @target_dir
|
228
|
+
path = @configurator.target
|
229
|
+
Dir.mkdir(path) if(!File.exist?(path))
|
230
|
+
msg = file_check(path, [:exist?, :writable?, :directory?])
|
231
|
+
if(!msg)
|
232
|
+
@target_dir = String.new(path)
|
233
|
+
@target_dir.freeze
|
234
|
+
@log.debug("target dir is #{@target_dir}")
|
235
|
+
return path, nil
|
236
|
+
else
|
237
|
+
return nil, msg
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
def target_file
|
242
|
+
td, msg = target_dir
|
243
|
+
@log.debug('writing file to ' + target_dir)
|
244
|
+
@log.debug(format("title from configuration: %s", @configurator.title))
|
245
|
+
path = ''
|
246
|
+
if(!msg)
|
247
|
+
tf = ''
|
248
|
+
if(@configurator.title && !@configurator.title.empty?)
|
249
|
+
tf = @configurator.title.strip
|
250
|
+
@log.debug('tf ex configurator.title: ' + tf)
|
251
|
+
elsif(@source.title)
|
252
|
+
tf = @source.title.gsub('/', '-')
|
253
|
+
@log.debug('tf ex source.title: ' + tf)
|
254
|
+
else
|
255
|
+
tf = @source.file_name.strip
|
256
|
+
tf << @configurator.suffix
|
257
|
+
@log.debug('tf ex source.file_name: ' + tf)
|
258
|
+
end
|
259
|
+
path << td.strip << FS << tf
|
260
|
+
path << @source.file_ext
|
261
|
+
@log.debug("\tfile is " + path)
|
262
|
+
return path, nil
|
263
|
+
else
|
264
|
+
return nil, msg
|
265
|
+
end
|
266
|
+
end
|
267
|
+
end
|
Binary file
|
data/lib/icons/howto.png
ADDED
Binary file
|
data/lib/icons/logo.png
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/lib/image.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
#encoding: UTF-8
|
2
|
+
=begin
|
3
|
+
/***************************************************************************
|
4
|
+
* Copyright © 2008-2012, Michael Uplawski <michael.uplawski@uplawski.eu> *
|
5
|
+
* *
|
6
|
+
* This program is free software; you can redistribute it and/or modify *
|
7
|
+
* it under the terms of the GNU General Public License as published by *
|
8
|
+
* the Free Software Foundation; either version 3 of the License, or *
|
9
|
+
* (at your option) any later version. *
|
10
|
+
* *
|
11
|
+
* This program is distributed in the hope that it will be useful, *
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
14
|
+
* GNU General Public License for more details. *
|
15
|
+
* *
|
16
|
+
* You should have received a copy of the GNU General Public License *
|
17
|
+
* along with this program; if not, write to the *
|
18
|
+
* Free Software Foundation, Inc., *
|
19
|
+
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
20
|
+
***************************************************************************/
|
21
|
+
=end
|
22
|
+
require_relative 'file_checking'
|
23
|
+
require_relative 'logging'
|
24
|
+
|
25
|
+
=begin
|
26
|
+
An object of this class represents 1 picture file.
|
27
|
+
=end
|
28
|
+
class Image
|
29
|
+
extend Logging
|
30
|
+
|
31
|
+
@@log = init_logger(STDOUT)
|
32
|
+
|
33
|
+
attr_reader :reference
|
34
|
+
|
35
|
+
# string representations of supported image formats
|
36
|
+
FORMATS = { :jpg => 'image/jpeg',
|
37
|
+
:webp => 'image/webp',
|
38
|
+
:png => 'image/png',
|
39
|
+
:gif => 'image/gif',
|
40
|
+
:svg => 'image/svg'}
|
41
|
+
|
42
|
+
|
43
|
+
def self::supported?(image, formats)
|
44
|
+
@log.debug('formats is ' << formats.to_s)
|
45
|
+
msg = File_Checking::mime_check(image, FORMATS.values)
|
46
|
+
@@log.info(image.dup << ' ' << trl("is not supported, wrong mime-type") << ': ' << File_Checking.last_mime_type.to_s) if msg
|
47
|
+
if !msg
|
48
|
+
if !formats.include?(File_Checking.last_mime_type)
|
49
|
+
msg = image.dup << ' ' << trl("is not in one of the requested file types") << ' (' << formats.join(', ') << ')'
|
50
|
+
@@log.info(msg)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
return msg
|
54
|
+
end
|
55
|
+
|
56
|
+
def initialize(path_url)
|
57
|
+
@log = @@log
|
58
|
+
@reference = path_url
|
59
|
+
|
60
|
+
@log.debug('new Image instance : ' << @reference)
|
61
|
+
end
|
62
|
+
end
|
data/lib/list_fields.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
#encoding: UTF-8
|
2
|
+
=begin
|
3
|
+
/***************************************************************************
|
4
|
+
* Copyright © 2008-2012, Michael Uplawski <michael.uplawski@uplawski.eu> *
|
5
|
+
* *
|
6
|
+
* This program is free software; you can redistribute it and/or modify *
|
7
|
+
* it under the terms of the GNU General Public License as published by *
|
8
|
+
* the Free Software Foundation; either version 3 of the License, or *
|
9
|
+
* (at your option) any later version. *
|
10
|
+
* *
|
11
|
+
* This program is distributed in the hope that it will be useful, *
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
14
|
+
* GNU General Public License for more details. *
|
15
|
+
* *
|
16
|
+
* You should have received a copy of the GNU General Public License *
|
17
|
+
* along with this program; if not, write to the *
|
18
|
+
* Free Software Foundation, Inc., *
|
19
|
+
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
20
|
+
***************************************************************************/
|
21
|
+
=end
|
22
|
+
|
23
|
+
# Unused in the html2slideshow program. This will just
|
24
|
+
# create a list of fields, recognized by a certain delimeter
|
25
|
+
# (here: %- -%).
|
26
|
+
|
27
|
+
File.open('slideshow_template.rb', 'r') do |tp|
|
28
|
+
File.open('/tmp/listFields.txt', 'w') do |list|
|
29
|
+
while tp.gets('-%')
|
30
|
+
m = $_.match("%-(.*)-%")
|
31
|
+
list.puts( m[0]) if m
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|