docgenerator 1.1.1 → 1.2.1
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/examples/docgenerator_example.rb +34 -17
- data/examples/docgenerator_example_footnote.rb +82 -61
- data/examples/docgenerator_example_list.rb +24 -18
- data/examples/docgenerator_example_restrictions.rb +17 -27
- data/examples/docgenerator_example_tabular.rb +20 -20
- data/examples/docgenerator_example_tripfalls.rb +28 -20
- data/examples/results/readme +1 -0
- data/examples/results_expected/docgenerator_example.html +39 -0
- data/examples/results_expected/docgenerator_example.pdf +0 -0
- data/examples/results_expected/docgenerator_example.tex +56 -0
- data/examples/results_expected/docgenerator_example_footnote.html +40 -0
- data/examples/results_expected/docgenerator_example_footnote.pdf +0 -0
- data/examples/results_expected/docgenerator_example_footnote.tex +50 -0
- data/examples/results_expected/docgenerator_example_list.html +18 -0
- data/examples/results_expected/docgenerator_example_list.pdf +0 -0
- data/examples/results_expected/docgenerator_example_list.tex +46 -0
- data/examples/results_expected/docgenerator_example_restrictions.html +22 -0
- data/examples/results_expected/docgenerator_example_restrictions.pdf +0 -0
- data/examples/results_expected/docgenerator_example_restrictions.tex +31 -0
- data/examples/results_expected/docgenerator_example_tabular.html +37 -0
- data/examples/results_expected/docgenerator_example_tabular.pdf +0 -0
- data/examples/results_expected/docgenerator_example_tabular.tex +41 -0
- data/examples/results_expected/docgenerator_example_tripfalls.html +27 -0
- data/examples/results_expected/docgenerator_example_tripfalls.pdf +0 -0
- data/examples/results_expected/docgenerator_example_tripfalls.tex +31 -0
- data/lib/creole/creole2doc.rb +291 -140
- data/lib/creole/creole_inclusion_and_plugins.rb +142 -39
- data/lib/creole/creole_placeholder.rb +92 -30
- data/lib/creole/creole_tabular.rb +119 -20
- data/lib/docgenerator.rb +209 -118
- data/lib/{docgenerator_attribute.rb → docgenerator/attribute.rb} +2 -1
- data/lib/{docgenerator_characters.rb → docgenerator/characters.rb} +75 -6
- data/lib/{docgenerator_css.rb → docgenerator/css.rb} +0 -0
- data/lib/docgenerator/document.rb +588 -0
- data/lib/{docgenerator_element.rb → docgenerator/element.rb} +52 -80
- data/lib/{docgenerator_elements.rb → docgenerator/elements.rb} +43 -17
- data/lib/{docgenerator_environments.rb → docgenerator/environments.rb} +20 -6
- data/lib/{docgenerator_footnote.rb → docgenerator/footnote.rb} +22 -18
- data/lib/{docgenerator_lists.rb → docgenerator/lists.rb} +17 -1
- data/lib/{docgenerator_sections.rb → docgenerator/sections.rb} +9 -1
- data/lib/docgenerator/standard.rb +81 -0
- data/lib/{docgenerator_tabular.rb → docgenerator/tabular.rb} +9 -5
- data/lib/packages/docgenerator_listings.rb +9 -5
- data/lib/packages/docgenerator_pdfpages.rb +17 -11
- data/lib/packages/docgenerator_url.rb +0 -2
- data/lib/templates/docgenerator_template.rb +66 -29
- data/lib/templates/docgenerator_template.yaml +18 -0
- data/lib/wiki2doc/wiki2docgenerator.rb +6 -2
- data/readme.rd +132 -0
- data/unittest/expected/test_document_usepackage_undefined.log +2 -0
- data/unittest/expected/test_enumerate.context +4 -0
- data/unittest/expected/test_footnote.html +4 -4
- data/unittest/expected/test_footnote.latex +4 -4
- data/unittest/expected/test_footnote_group.html +6 -6
- data/unittest/expected/test_footnote_group.latex +6 -6
- data/unittest/expected/test_href.html +2 -2
- data/unittest/expected/test_href.latex +2 -2
- data/unittest/expected/test_href.text +2 -2
- data/unittest/expected/test_itemize.context +4 -0
- data/unittest/expected/test_runtex.stdout +3 -0
- data/unittest/expected/test_runtex_2.stdout +3 -0
- data/unittest/expected/test_section.context +20 -0
- data/unittest/expected/test_tabular.html +2 -2
- data/unittest/expected/test_verbatim.html +3 -0
- data/unittest/expected/test_verbatim.latex +4 -0
- data/unittest/expected/test_verbatim_array.html +1 -0
- data/unittest/expected/test_verbatim_array.latex +2 -0
- data/unittest/expected_creole/test_creole_characters_all.html +12 -5
- data/unittest/expected_creole/test_creole_characters_all.latex +20 -6
- data/unittest/expected_creole/test_creole_comment.context +11 -0
- data/unittest/expected_creole/test_creole_comment.creole +12 -0
- data/unittest/expected_creole/test_creole_comment.html +9 -0
- data/unittest/expected_creole/test_creole_comment.latex +11 -0
- data/unittest/expected_creole/test_creole_creole1.0test.html +3 -3
- data/unittest/expected_creole/test_creole_creole1.0test.latex +3 -3
- data/unittest/expected_creole/test_creole_creole1.0test.text +4 -4
- data/unittest/expected_creole/test_creole_ignore.html +3 -0
- data/unittest/expected_creole/test_creole_ignore.latex +4 -0
- data/unittest/expected_creole/test_creole_ignore.text +2 -0
- data/unittest/expected_creole/test_creole_input.normsource +12 -12
- data/unittest/expected_creole/test_creole_input_file_simple.html +15 -0
- data/unittest/expected_creole/test_creole_input_file_simple_readlines.html +15 -0
- data/unittest/expected_creole/test_creole_links_external_implicit.html +2 -2
- data/unittest/expected_creole/test_creole_links_external_implicit.latex +2 -2
- data/unittest/expected_creole/test_creole_links_external_implicit.text +2 -2
- data/unittest/expected_creole/test_creole_links_implicit_end.creole +4 -0
- data/unittest/expected_creole/test_creole_links_implicit_end.html +3 -0
- data/unittest/expected_creole/test_creole_links_implicit_end.latex +4 -0
- data/unittest/expected_creole/test_creole_list_ul.normsource +42 -42
- data/unittest/expected_creole/test_creole_mix_titles_list.html +10 -0
- data/unittest/expected_creole/test_creole_mix_titles_list.latex +18 -0
- data/unittest/expected_creole/test_creole_mix_titles_list.text +12 -0
- data/unittest/expected_creole/test_creole_paragraphs.normsource +15 -15
- data/unittest/expected_creole/test_creole_pictures_css.html +4 -1
- data/unittest/expected_creole/test_creole_pictures_css.latex +5 -1
- data/unittest/expected_creole/test_creole_pictures_longdesc.html +3 -0
- data/unittest/expected_creole/test_creole_pictures_width.html +3 -0
- data/unittest/expected_creole/test_creole_pictures_width.latex +4 -0
- data/unittest/expected_creole/test_creole_short_html.html +3 -0
- data/unittest/expected_creole/test_creole_short_html.latex +4 -0
- data/unittest/expected_creole/test_creole_short_html.text +2 -0
- data/unittest/expected_creole/test_creole_shy.creole +6 -0
- data/unittest/expected_creole/test_creole_shy.html +6 -0
- data/unittest/expected_creole/test_creole_shy.latex +8 -0
- data/unittest/expected_creole/test_creole_shy.text +4 -0
- data/unittest/expected_creole/test_creole_tabular_with_cell_option.html +20 -0
- data/unittest/expected_creole/test_creole_toc.html +3 -1
- data/unittest/expected_creole/test_creole_toc.latex +1 -1
- data/unittest/expected_creole/test_creole_toc.text +1 -1
- data/unittest/expected_creole/test_creole_toc_level.html +7 -0
- data/unittest/expected_creole/test_creole_toc_level.latex +10 -0
- data/unittest/expected_creole/test_creole_toc_level.text +3 -0
- data/unittest/expected_creole/test_creole_toc_level_text.html +8 -0
- data/unittest/expected_creole/test_creole_toc_level_text.latex +9 -0
- data/unittest/expected_creole/test_creole_verbatim.html +1 -1
- data/unittest/expected_creole/test_creole_verbatim.latex +1 -1
- data/unittest/expected_creole/test_creole_verbatim.text +1 -1
- data/unittest/expected_creole/test_creole_verbatim_inline.html +1 -1
- data/unittest/expected_creole/test_creole_verbatim_inline.latex +1 -1
- data/unittest/expected_wiki/test_wiki_description.html +5 -5
- data/unittest/expected_wiki/test_wiki_description.latex +5 -5
- data/unittest/expected_wiki/test_wiki_description.text +5 -5
- data/unittest/expected_wiki/test_wiki_description.wiki +5 -5
- data/unittest/test_rakefile_docgenerator.rb +43 -0
- data/unittest/unittest_creole2doc.rb +415 -27
- data/unittest/unittest_docgenerator.rb +256 -23
- data/unittest/unittest_docgenerator_runtex.rb +83 -0
- data/unittest/unittest_versions.rb +44 -0
- data/unittest/unittest_wiki2doc.rb +28 -27
- metadata +473 -106
- data/lib/docgenerator_document.rb +0 -525
- data/lib/packages/docgenerator_beamer.rb +0 -253
- data/lib/yaml2presentation/yaml2presentation.rb +0 -1091
- data/unittest/expected/beamer_01_article.tex +0 -13
- data/unittest/expected/beamer_01_attachment.tex +0 -15
- data/unittest/expected/beamer_01_doc.html +0 -13
- data/unittest/expected/beamer_01_doc.tex +0 -18
- data/unittest/expected/beamer_01_notes_only.tex +0 -13
- data/unittest/expected/beamer_01_notes_onlyslideswithnotes.tex +0 -13
- data/unittest/expected/beamer_01_notes_show.tex +0 -13
- data/unittest/expected/beamer_01_presentation.tex +0 -13
- data/unittest/expected/beamer_02_doc.html +0 -29
- data/unittest/expected/beamer_02_doc.tex +0 -34
- data/unittest/expected/beamer_block.html +0 -1
- data/unittest/expected/beamer_block.latex +0 -1
- data/unittest/expected/beamer_doc_fragile_doc.tex +0 -33
- data/unittest/expected/beamer_doc_html_overview_with_detailpic_and_text_doc.html +0 -34
- data/unittest/expected/beamer_doc_html_overview_with_detailpic_doc.html +0 -34
- data/unittest/expected/beamer_doc_key_doc.html +0 -20
- data/unittest/expected/beamer_doc_key_doc.tex +0 -29
- data/unittest/expected/beamer_doc_note_doc.html +0 -30
- data/unittest/expected/beamer_doc_note_doc.tex +0 -37
- data/unittest/expected/beamer_doc_pic_bottom_doc.html +0 -24
- data/unittest/expected/beamer_doc_pic_doc.html +0 -24
- data/unittest/expected/beamer_doc_pic_doc.tex +0 -28
- data/unittest/expected/beamer_doc_pic_left_doc.html +0 -24
- data/unittest/expected/beamer_doc_pic_left_doc.tex +0 -28
- data/unittest/expected/beamer_doc_pic_ratio_doc.tex +0 -29
- data/unittest/expected/beamer_doc_pic_right_doc.html +0 -24
- data/unittest/expected/beamer_doc_pic_right_doc.tex +0 -28
- data/unittest/expected/beamer_doc_pic_top_doc.html +0 -24
- data/unittest/expected/beamer_frame.html +0 -5
- data/unittest/expected/beamer_frame.tex +0 -11
- data/unittest/expected/beamer_frame_fragile.tex +0 -7
- data/unittest/expected/beamer_frame_id.html +0 -1
- data/unittest/expected/beamer_frame_id.tex +0 -4
- data/unittest/expected/beamer_framepic.html +0 -5
- data/unittest/expected/beamer_framepic.latex +0 -1
- data/unittest/expected/beamer_framepic_link.html +0 -5
- data/unittest/expected/beamer_framepic_link.latex +0 -1
- data/unittest/expected/beamer_frametitle.html +0 -1
- data/unittest/expected/beamer_frametitle.latex +0 -1
- data/unittest/expected/beamer_note.html +0 -1
- data/unittest/expected/beamer_note.latex +0 -1
- data/unittest/expected_privat/test_creole_test_document.html +0 -6
- data/unittest/expected_wiki/test_wiki_amazon.html +0 -10
- data/unittest/expected_wiki/test_wiki_link.log +0 -3
- data/unittest/test_docgenerator.rb +0 -107
- data/unittest/unittest_yaml2pres.rb +0 -336
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
#
|
|
2
|
-
# The text 'Beamer' must be part of this template.
|
|
3
|
-
# Without it, the title-Class will not use the short version for title.#
|
|
4
|
-
#
|
|
5
|
-
DocumentTemplate.new(:beamer, :latex, %q|<<prefix>>
|
|
6
|
-
% ----------------------------------------------------------------
|
|
7
|
-
% For Usage with Beamer
|
|
8
|
-
% ----------------------------------------------------------------
|
|
9
|
-
<<head>>
|
|
10
|
-
% ----------------------------------------------------------------
|
|
11
|
-
\begin{document}
|
|
12
|
-
<<body>>
|
|
13
|
-
\end{document}
|
|
14
|
-
% ----------------------------------------------------------------
|
|
15
|
-
|.gsub(/^\s*/, ''))
|
|
16
|
-
DocumentTemplate.new(:beamerhead, :latex, %q|<<prefix>>
|
|
17
|
-
\documentclass[<<classoptions>>]{beamer}
|
|
18
|
-
%<<theme>>
|
|
19
|
-
\usepackage{babel}
|
|
20
|
-
\usepackage[ansinew]{inputenc}
|
|
21
|
-
\usepackage{beamertool}
|
|
22
|
-
\usepackage{hyperref}
|
|
23
|
-
% ----------------------------------------------------------------
|
|
24
|
-
<<head>>
|
|
25
|
-
|.gsub(/^\s*/, ''))
|
|
26
|
-
[
|
|
27
|
-
:beamerthemebars, :beamerthemeboxes, :beamerthemeclassic,
|
|
28
|
-
:beamerthemelined, :beamerthemeplain, :beamerthemesidebar,
|
|
29
|
-
:beamerthemesidebardark, :beamerthemesidebardarktab,
|
|
30
|
-
:beamerthemesidebartab, :beamerthemesplit,
|
|
31
|
-
:beamerthemesplitcondensed, :beamerthemetree,
|
|
32
|
-
:beamerthemevcd,
|
|
33
|
-
:beamerthemegemeinschaftsauto
|
|
34
|
-
].each{ |theme|
|
|
35
|
-
DocumentTemplate.new(theme, :latex, DocumentTemplate[:beamerhead].template.sub(/%<<theme>>/, "\\usepackage{#{theme}}"))
|
|
36
|
-
}
|
|
37
|
-
DocumentTemplate.new(:beamerarticle, :latex, %q|<<prefix>>
|
|
38
|
-
\documentclass[class=scrartcl,<<classoptions>>]{beamer}
|
|
39
|
-
\usepackage{babel}
|
|
40
|
-
\usepackage{beamerbasearticle}
|
|
41
|
-
\usepackage[article]{beamertool}
|
|
42
|
-
\usepackage[ansinew]{inputenc}
|
|
43
|
-
\usepackage{hyperref}
|
|
44
|
-
% ----------------------------------------------------------------
|
|
45
|
-
<<head>>
|
|
46
|
-
|.gsub(/^\s*/, ''))
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
#Define TeX-Kommands
|
|
50
|
-
|
|
51
|
-
#frame -- environment.
|
|
52
|
-
#options
|
|
53
|
-
#~ Element.create( :frame, {}, true, {
|
|
54
|
-
#~ :latex => '#{linebreak(@crbefore)}\frame{#{@content}}#{linebreak(@crafter)}'
|
|
55
|
-
#~ } )
|
|
56
|
-
|
|
57
|
-
class Frame < Element
|
|
58
|
-
add_attributes( {
|
|
59
|
-
:options => Attribute.create( [ :latex ], [nil, 'fragile', 't', 'b'] ),
|
|
60
|
-
}.update( HTML_ATTR_ALL ) )
|
|
61
|
-
Element.add( [:frame], Frame)
|
|
62
|
-
#Returns a div-element.
|
|
63
|
-
#The class for the css is set to 'frame' (if not defined before).
|
|
64
|
-
def htmltag( )
|
|
65
|
-
if @attr[:class].content.empty?
|
|
66
|
-
@attr[:class] << :frame
|
|
67
|
-
end
|
|
68
|
-
'div'
|
|
69
|
-
end
|
|
70
|
-
def to_latex( options = {} )
|
|
71
|
-
option = "[#{@attr[:options].content.join(',')}]"
|
|
72
|
-
option = nil if option == '[]'
|
|
73
|
-
label = nil
|
|
74
|
-
label = element(:label,{:name => @attr[:id]}).cr.to_latex(options) unless @attr[:id].content.empty?
|
|
75
|
-
#~ return "#{linebreak(@crbefore)}\\frame#{option}{\n#{@content}}#{linebreak(@crafter)}"
|
|
76
|
-
return "#{linebreak(@crbefore)}\\begin{frame}#{option}\n#{label}#{@content.to_latex(options)}\n\\end{frame}#{linebreak(@crafter)}"
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
#
|
|
81
|
-
#Frametitle.
|
|
82
|
-
#Can be changed by
|
|
83
|
-
# Element.get( :frametitle ).class_eval( "def htmltag(); 'h4'; end")
|
|
84
|
-
Element.create( :frametitle, { }, true, {
|
|
85
|
-
:latex => '#{linebreak(@crbefore)}\frametitle{#{@content}}#{linebreak(@crafter)}',
|
|
86
|
-
:htmltag => 'p', #'h4',
|
|
87
|
-
:html => '#{linebreak(@crbefore)}<#{htmltag} class = "frametitle">#{@content}</#{htmltag}>#{linebreak(@crafter)}',
|
|
88
|
-
} )
|
|
89
|
-
|
|
90
|
-
Element.create( :block, {
|
|
91
|
-
:title => Attribute.create( [ :latex ] ),
|
|
92
|
-
}, true, {
|
|
93
|
-
:latex => '#{linebreak(@crbefore)}' + '\begin{block}{#{@attr[:title]}}' + '#{linebreak(@crmid)}' + '#{@content}\end{block}' + '#{linebreak(@crafter)}'
|
|
94
|
-
} )
|
|
95
|
-
|
|
96
|
-
#
|
|
97
|
-
# Notes in Beamer.
|
|
98
|
-
#
|
|
99
|
-
Element.create( :note, { }, true, {
|
|
100
|
-
:latex => '#{linebreak(@crbefore)}\note{#{@content}}#{linebreak(@crafter)}',
|
|
101
|
-
:htmltag => 'p', #'h4',
|
|
102
|
-
:html => '#{linebreak(@crbefore)}<#{htmltag} class = "note">#{@content}</#{htmltag}>#{linebreak(@crafter)}',
|
|
103
|
-
} )
|
|
104
|
-
|
|
105
|
-
#\framePic{filename}{
|
|
106
|
-
# description
|
|
107
|
-
#}
|
|
108
|
-
#~ Element.create( :framepic, { :file => Attribute.create( [ :required ] ),
|
|
109
|
-
#~ :link => Attribute.create( )
|
|
110
|
-
#~ }, true, {
|
|
111
|
-
#~ :latex => '\framePic{#{@attr[:file]}}{#{@content}}'
|
|
112
|
-
#~ } )
|
|
113
|
-
|
|
114
|
-
Element.create( :institute, {
|
|
115
|
-
}, true, {
|
|
116
|
-
:latex => '#{linebreak(@crbefore)}' + '\institute{#{@content}}' + '#{linebreak(@crafter)}'
|
|
117
|
-
} )
|
|
118
|
-
|
|
119
|
-
Element.create( :subtitle, {
|
|
120
|
-
}, true, {
|
|
121
|
-
:latex => '#{linebreak(@crbefore)}' + '\subtitle{#{@content}}' + '#{linebreak(@crafter)}'
|
|
122
|
-
} )
|
|
123
|
-
|
|
124
|
-
begin
|
|
125
|
-
#define Knut::Picture
|
|
126
|
-
require 'knut_picture'
|
|
127
|
-
rescue
|
|
128
|
-
#Define Knut::Picture with reduced functionality
|
|
129
|
-
module Knut
|
|
130
|
-
class Picture
|
|
131
|
-
def initialize( filename )
|
|
132
|
-
@filename = filename
|
|
133
|
-
@basename = File.basename(@filename)
|
|
134
|
-
@dir = File.dirname(@filename)
|
|
135
|
-
if ! File.exists?( @filename )
|
|
136
|
-
puts "#{self.class}: #{@filename} not found"
|
|
137
|
-
else
|
|
138
|
-
@size = File.size(@filename)
|
|
139
|
-
@sizekb = @size / 1024
|
|
140
|
-
end
|
|
141
|
-
end
|
|
142
|
-
#Filename including the path
|
|
143
|
-
attr_reader :filename
|
|
144
|
-
#Directory of the picture
|
|
145
|
-
attr_reader :dir
|
|
146
|
-
attr_reader :basename
|
|
147
|
-
def tech_description()
|
|
148
|
-
"#{@basename} (#{@sizekb}KB)"
|
|
149
|
-
end
|
|
150
|
-
end
|
|
151
|
-
end
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
class Framepic < Element
|
|
155
|
-
Element.add( [:framepic], Framepic)
|
|
156
|
-
add_attributes( {
|
|
157
|
-
:file => Attribute.create( [ :required ] ),
|
|
158
|
-
:link => Attribute.create( [ :latex ]), #Hyperlink
|
|
159
|
-
}.update( HTML_ATTR_ALL ) )
|
|
160
|
-
#container for the picture
|
|
161
|
-
def picture()
|
|
162
|
-
@picture = Knut::Picture.new( @attr[:file].content.first ) if ! @picture
|
|
163
|
-
@picture
|
|
164
|
-
end
|
|
165
|
-
attr_accessor :div_css
|
|
166
|
-
attr_accessor :img_css
|
|
167
|
-
attr_accessor :div_class
|
|
168
|
-
attr_accessor :img_class
|
|
169
|
-
attr_accessor :picwithname
|
|
170
|
-
def to_html( options = {})
|
|
171
|
-
html = [] #element(:div, {:class => :framepic })
|
|
172
|
-
#~ if @attr[:link].content.size > 0
|
|
173
|
-
#~ html << "[#{@attr[:link]}]"
|
|
174
|
-
#~ end
|
|
175
|
-
|
|
176
|
-
html << div_img = element(:div ).CR
|
|
177
|
-
if self.picture.href
|
|
178
|
-
div_img << element(:a, { :href => self.picture.href },
|
|
179
|
-
img = element(:img )
|
|
180
|
-
)
|
|
181
|
-
else
|
|
182
|
-
div_img << img = element(:img )
|
|
183
|
-
end
|
|
184
|
-
if self.picture.thumbname and self.picture.usethumb?
|
|
185
|
-
img[:src] << self.picture.thumbname
|
|
186
|
-
else
|
|
187
|
-
img[:src] << self.picture.filename
|
|
188
|
-
end
|
|
189
|
-
@div_css = CSS.new() if ! @div_css
|
|
190
|
-
div_img[:class] << @div_class if @div_class
|
|
191
|
-
div_img[:style] << @div_css
|
|
192
|
-
div_img[:align] << 'center' if div_img[:align].content.empty?
|
|
193
|
-
img[:class] << @img_class if @img_class
|
|
194
|
-
img[:style] << @img_css if @img_css
|
|
195
|
-
if picwithname
|
|
196
|
-
div_img << element(:br ).cr
|
|
197
|
-
div_img << element(:footnotesize, {}, self.picture.tech_description)
|
|
198
|
-
end
|
|
199
|
-
html << @content
|
|
200
|
-
return html.to_html(options)
|
|
201
|
-
end
|
|
202
|
-
def to_latex( options = {} )
|
|
203
|
-
result = ""
|
|
204
|
-
result << "\n" if @crbefore
|
|
205
|
-
result << "\\framePic"
|
|
206
|
-
if self.div_css #Check alignment
|
|
207
|
-
case self.div_css[:float]
|
|
208
|
-
when nil, 'left' #standard
|
|
209
|
-
when 'right'
|
|
210
|
-
result << "[right]"
|
|
211
|
-
else
|
|
212
|
-
puts "#{__FILE__}##{__LINE__}: Undefined float '#{self.div_css[:float]}' for TeX"
|
|
213
|
-
end
|
|
214
|
-
end
|
|
215
|
-
result << "{#{self.picture.filename}}"
|
|
216
|
-
if @attr[:link].content.size > 0
|
|
217
|
-
result << "[#{@attr[:link]}]"
|
|
218
|
-
end
|
|
219
|
-
result << "{"
|
|
220
|
-
result << "\n" if @crmid
|
|
221
|
-
result << "#{@content.to_latex(options)}"
|
|
222
|
-
result << "\n" if @crmid
|
|
223
|
-
result << "}"
|
|
224
|
-
result << "\n" if @crafter
|
|
225
|
-
return result
|
|
226
|
-
end
|
|
227
|
-
end
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
Element.create( :includegraphicsJustified, {}, true, {
|
|
231
|
-
:latex => '\includegraphicsJustified{#{@content}}',
|
|
232
|
-
:html => '<img src = "#{@content}" style = "max-width: 80%" />',
|
|
233
|
-
} )
|
|
234
|
-
|
|
235
|
-
#fixme --> docgenerator_color ?
|
|
236
|
-
class Textcolor < Element
|
|
237
|
-
Element.add( [:textcolor], Textcolor)
|
|
238
|
-
add_attributes( { :mode => Attribute.create( [ :required ], [:rgb] ),
|
|
239
|
-
:color => Attribute.create( [ :required ], [String] ),
|
|
240
|
-
} )
|
|
241
|
-
def to_latex( options = {})
|
|
242
|
-
result = ""
|
|
243
|
-
result << "\n" if @crbefore
|
|
244
|
-
result << "\\textcolor[#{attr[:mode]}]{#{@attr[:color]}}"
|
|
245
|
-
result << "\n" if @crmid
|
|
246
|
-
result << "{"
|
|
247
|
-
result << "#{@content.to_latex(options)}"
|
|
248
|
-
result << "\n" if @crmid
|
|
249
|
-
result << "}"
|
|
250
|
-
result << "\n" if @crafter
|
|
251
|
-
return result
|
|
252
|
-
end
|
|
253
|
-
end
|
|
@@ -1,1091 +0,0 @@
|
|
|
1
|
-
#~ fixmes:
|
|
2
|
-
#~ Frame: puts in log umsetzte
|
|
3
|
-
|
|
4
|
-
#~ require 'docgenerator'
|
|
5
|
-
require 'wiki2doc/wiki2docgenerator.rb'
|
|
6
|
-
require 'creole/creole2doc.rb'
|
|
7
|
-
require 'packages/docgenerator_beamer.rb'
|
|
8
|
-
require 'yaml'
|
|
9
|
-
|
|
10
|
-
#Analyse Wiki-text inside a frame.
|
|
11
|
-
class WikiFrame < Wikitext
|
|
12
|
-
def wiki_macro( macro, parameters )
|
|
13
|
-
case macro
|
|
14
|
-
#Special feature, requires additional scripts.
|
|
15
|
-
when 'note'
|
|
16
|
-
element(:note,{}, parameters)
|
|
17
|
-
when 'rail'
|
|
18
|
-
raise "require rails parts" if ! Rail_diagramm
|
|
19
|
-
Rail_diagramm[parameters.to_sym]
|
|
20
|
-
else
|
|
21
|
-
super(macro, parameters)
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
#Redefinition of docgenerator-Frame class (or better extension.)
|
|
27
|
-
#
|
|
28
|
-
#Generell Problems:
|
|
29
|
-
#-no lists outside a frame for LaTeX-Output
|
|
30
|
-
#-frames with verbatim must contain the option ''fragile''
|
|
31
|
-
class Frame
|
|
32
|
-
attr_accessor :title
|
|
33
|
-
attr_accessor :html_link
|
|
34
|
-
#Filename of a preview thumb
|
|
35
|
-
attr_reader :thumb
|
|
36
|
-
attr_accessor :framepic
|
|
37
|
-
attr_accessor :picname
|
|
38
|
-
attr_accessor :key
|
|
39
|
-
#Settings of Presentation
|
|
40
|
-
#contains things like "picwithframe"
|
|
41
|
-
attr_accessor :settings
|
|
42
|
-
#Presentation, where frame is part of.
|
|
43
|
-
#Used to add detail pages of pictures
|
|
44
|
-
attr_accessor :presentation
|
|
45
|
-
|
|
46
|
-
#Add a picture to the frame
|
|
47
|
-
def pic=( picname )
|
|
48
|
-
if ! File.exist?(picname)
|
|
49
|
-
@log.error("Picture #{picname} missing") if @log.error?
|
|
50
|
-
end
|
|
51
|
-
@picname = picname
|
|
52
|
-
self << @framepic = Framepic.new( { :file => picname } )
|
|
53
|
-
@framepic.picture.thumbname = @thumb if @thumb
|
|
54
|
-
return @framepic
|
|
55
|
-
end
|
|
56
|
-
#Add a picture with link to a 'fullpage-mode'.
|
|
57
|
-
def picfull=( picname )
|
|
58
|
-
self.pic= picname
|
|
59
|
-
if self.presentation
|
|
60
|
-
self.presentation.attachment << picname
|
|
61
|
-
@framepic[:link] << "pic:#{picname}"
|
|
62
|
-
end
|
|
63
|
-
#not really functional. Is set later again with beamer_save
|
|
64
|
-
@framepic.picwithname = @settings[:picwithname]
|
|
65
|
-
end
|
|
66
|
-
#Add a picture in 'fullpage-mode'.
|
|
67
|
-
def piconly=( picname )
|
|
68
|
-
if ! File.exist?(picname)
|
|
69
|
-
@log.warn("Picture #{picname} missing")if @log.warn?
|
|
70
|
-
end
|
|
71
|
-
@picname = picname
|
|
72
|
-
self << element(:includegraphicsJustified, {}, picname)
|
|
73
|
-
#~ return @framepic
|
|
74
|
-
end
|
|
75
|
-
def thumb=( thumbname )
|
|
76
|
-
raise "Thumb without picture (#{title}" if ! @framepic
|
|
77
|
-
if ! File.exist?(thumbname)
|
|
78
|
-
@log.warn("Thumb #{thumbname} missing") if @log.warn?
|
|
79
|
-
end
|
|
80
|
-
@thumb = thumbname
|
|
81
|
-
@framepic.picture.thumbname = thumbname if @framepic.picture
|
|
82
|
-
end #Add option.
|
|
83
|
-
|
|
84
|
-
#CSS-options for surrounding div
|
|
85
|
-
def pos=( pos )
|
|
86
|
-
if ! @framepic
|
|
87
|
-
@log.warn("Set pos #{pos} for undefined picture in #{@title}") if @log.warn?
|
|
88
|
-
return false
|
|
89
|
-
end
|
|
90
|
-
@framepic.div_css = CSS.new() if ! @framepic.div_css
|
|
91
|
-
case pos
|
|
92
|
-
when 'left', 'right'
|
|
93
|
-
@framepic.div_css[:float] = pos
|
|
94
|
-
@framepic.div_css[:padding] = '10px'
|
|
95
|
-
when 'top', 'bottom'
|
|
96
|
-
@framepic.div_css[:float] = 'none'
|
|
97
|
-
else
|
|
98
|
-
@log.warn("Undefined option #{pos} in #{@title}") if @log.warn?
|
|
99
|
-
end
|
|
100
|
-
end #pos=
|
|
101
|
-
#Set picture width
|
|
102
|
-
def picwidth= (width )
|
|
103
|
-
if ! @framepic
|
|
104
|
-
@log.warn("Set width for undefined picture in #{@title}") if @log.warn?
|
|
105
|
-
return false
|
|
106
|
-
end
|
|
107
|
-
@framepic.img_css = CSS.new() if ! @framepic.img_css
|
|
108
|
-
@framepic.img_css[:width] = width
|
|
109
|
-
end
|
|
110
|
-
def framepicratio=( value )
|
|
111
|
-
vals = value.strip.split(/[,;]/)
|
|
112
|
-
vals.each{|val|
|
|
113
|
-
case val
|
|
114
|
-
when /\d*\.\d+/
|
|
115
|
-
else
|
|
116
|
-
@log.warn("Wrong ratio #{val} given with #{value}") if @log.warn?
|
|
117
|
-
end
|
|
118
|
-
}
|
|
119
|
-
@framepicratio = "\\framepicratio{#{vals[0]}}{#{vals[1]}}\n"
|
|
120
|
-
end
|
|
121
|
-
def img_class=( value )
|
|
122
|
-
if ! @framepic
|
|
123
|
-
@log.warn("Set width for undefined picture in #{@title}") if @log.warn?
|
|
124
|
-
return false
|
|
125
|
-
end
|
|
126
|
-
@framepic.img_class = value
|
|
127
|
-
end
|
|
128
|
-
#Set CSS-class for the div
|
|
129
|
-
def html_class=( value )
|
|
130
|
-
if ! @framepic
|
|
131
|
-
@log.warn("Set #{key} for undefined picture in #{@title}") if @log.warn?
|
|
132
|
-
return false
|
|
133
|
-
end
|
|
134
|
-
@framepic.div_class = value
|
|
135
|
-
end
|
|
136
|
-
def fragile=( value );
|
|
137
|
-
self[:options] << 'fragile'
|
|
138
|
-
end
|
|
139
|
-
#Alignment top/bottom of page
|
|
140
|
-
def alignment= (value)
|
|
141
|
-
case value
|
|
142
|
-
when 't', 'b'
|
|
143
|
-
self[:options] << value
|
|
144
|
-
else
|
|
145
|
-
@log.warn("Undefined alignment #{value} (allowed: t/b)" ) if @log.warn?
|
|
146
|
-
end
|
|
147
|
-
end
|
|
148
|
-
#If there is a pic, move the content of the frame to the content of the pic.
|
|
149
|
-
def rearrange_content()
|
|
150
|
-
newcontent = []
|
|
151
|
-
@content.each{|e|
|
|
152
|
-
if e.is_a?(:framepic) or e.is_a?(:frametitle)
|
|
153
|
-
newcontent << e
|
|
154
|
-
else
|
|
155
|
-
@framepic << e
|
|
156
|
-
end
|
|
157
|
-
}
|
|
158
|
-
return newcontent
|
|
159
|
-
end
|
|
160
|
-
def to_doc(target, options = {})
|
|
161
|
-
if self.key and @attr[:id].content.empty?
|
|
162
|
-
@attr[:id] << self.key
|
|
163
|
-
end
|
|
164
|
-
super
|
|
165
|
-
end
|
|
166
|
-
#Store old logic of to_latex
|
|
167
|
-
alias :old_to_latex :to_latex
|
|
168
|
-
#Move content into TeX-Macro.
|
|
169
|
-
#Not nice, but so we can use << in frame and don't need an additional step.
|
|
170
|
-
def to_latex(options = {})
|
|
171
|
-
@content = rearrange_content() if @framepic
|
|
172
|
-
@content.unshift(@framepicratio) if @framepicratio
|
|
173
|
-
old_to_latex(options)
|
|
174
|
-
end
|
|
175
|
-
#~ def to_html(options = {})
|
|
176
|
-
#~ if self.key and @attr[:id].content.empty?
|
|
177
|
-
#~ @attr[:id] << self.key
|
|
178
|
-
#~ end
|
|
179
|
-
#~ super
|
|
180
|
-
#~ end
|
|
181
|
-
end #Frame
|
|
182
|
-
|
|
183
|
-
#Class to create
|
|
184
|
-
#-Presentation (Using beamer-class for LaTeX)
|
|
185
|
-
#
|
|
186
|
-
class Presentation
|
|
187
|
-
#Little elp for me.
|
|
188
|
-
#Avoid the automatic generation of TeX-Entries
|
|
189
|
-
EMPTYBIBTEX = "\n%BibTeX-Entry>\n%BibTeX-Entry<\n"
|
|
190
|
-
#
|
|
191
|
-
#Defaults settings for Presentation, used in Presentation#save_beamer.
|
|
192
|
-
#
|
|
193
|
-
DEF_SETTINGS = {
|
|
194
|
-
#Values for Document
|
|
195
|
-
:template => :emptyTemplate,
|
|
196
|
-
:splitscreen => nil,
|
|
197
|
-
:language => ['ngerman'], #Default
|
|
198
|
-
:author => nil,
|
|
199
|
-
:defaultoptions => {}, #Defaults for each frame
|
|
200
|
-
:wikiframe => WikiFrame, #Wiki-type
|
|
201
|
-
#~ :shortauthor => nil,
|
|
202
|
-
:institute => nil,
|
|
203
|
-
:date => nil,
|
|
204
|
-
:shorttitle => nil,
|
|
205
|
-
:subtitle => nil, #used for beamer
|
|
206
|
-
:logo => nil,
|
|
207
|
-
:maketitle => nil,
|
|
208
|
-
:maketoc => nil,
|
|
209
|
-
:keywords => nil, #copied to @keywords
|
|
210
|
-
:description=> nil, #copied to @description
|
|
211
|
-
:id => nil, #copied to @description
|
|
212
|
-
:altlang => nil, #copied to @description
|
|
213
|
-
#Outputs (true, nil)
|
|
214
|
-
:presentation => false,
|
|
215
|
-
:beamer_article => false,
|
|
216
|
-
:beamer_notes => false, #one value of BEAMER_NOTES
|
|
217
|
-
:beamer_include=> false,
|
|
218
|
-
:html => false,#valid parameter: true, :overview_with_singlepages, :with_detailpic :with_detailpic_and_text
|
|
219
|
-
:pdftk => false,#Additional pdftk-process
|
|
220
|
-
#Options for TeX
|
|
221
|
-
:runtex => false,
|
|
222
|
-
:fullpage => false,
|
|
223
|
-
#Picture name under picture
|
|
224
|
-
:picwithname => false,
|
|
225
|
-
:classoption => [],
|
|
226
|
-
:log => Log4r::Logger.new( 'presentation', Log4r::WARN ),
|
|
227
|
-
#Valid keys - suppress the "Unknown key"-Warning for additional keys.
|
|
228
|
-
:valid_keys => []
|
|
229
|
-
}
|
|
230
|
-
DEF_SETTINGS[:log].outputters = Log4r::StdoutOutputter.new('Presentation')
|
|
231
|
-
|
|
232
|
-
#show - Include notes in the output file. Normal slides are also included.
|
|
233
|
-
#only - Include only the notes in the output file and suppresses all frames.
|
|
234
|
-
#onlyslideswithnotes - This includes all notes and those slides that contain a \note.
|
|
235
|
-
BEAMER_NOTES = [
|
|
236
|
-
'show', #Normal presentation, including notes pages
|
|
237
|
-
'only', #only notes pages
|
|
238
|
-
'onlyslideswithnotes', #Normal page and notes page, only pages with comments
|
|
239
|
-
]
|
|
240
|
-
#Option splitscreen/Taking Advantage of Multiple Screens
|
|
241
|
-
BEAMER_SPLIT_POSITIONS = [
|
|
242
|
-
'right',
|
|
243
|
-
'left',
|
|
244
|
-
'top',
|
|
245
|
-
'bottom',
|
|
246
|
-
]
|
|
247
|
-
#Define a presentation/picture galery
|
|
248
|
-
def initialize( title, settings = {})
|
|
249
|
-
@title = title
|
|
250
|
-
@settings = DEF_SETTINGS.merge(settings)
|
|
251
|
-
|
|
252
|
-
@log = @settings[:log]
|
|
253
|
-
@log.info("Build Presentation #{title}") if @log.info?
|
|
254
|
-
|
|
255
|
-
@head = []
|
|
256
|
-
@attachment = []
|
|
257
|
-
@content = []
|
|
258
|
-
@frames = [] #u.a. f�r Navigation
|
|
259
|
-
@bibtex = nil
|
|
260
|
-
@description = @settings[:description]
|
|
261
|
-
@keywords = @settings[:keywords]
|
|
262
|
-
#~ log.level = Log4r::ERROR
|
|
263
|
-
#~ log.level = Log4r::DEBUG
|
|
264
|
-
#~ log.outputters = Log4r::StdoutOutputter.new('test_document_toc')
|
|
265
|
-
|
|
266
|
-
if ! [WikiFrame, Creole].include?(@settings[:wikiframe])
|
|
267
|
-
@log.error("Wrong type for wikiframe (#{@settings[:wikiframe]})") if @log.error?
|
|
268
|
-
end
|
|
269
|
-
|
|
270
|
-
end
|
|
271
|
-
attr_accessor :title
|
|
272
|
-
#Some global settings.
|
|
273
|
-
#Can be set via macros in WikiPresentation.
|
|
274
|
-
#Allowed values, see method check_settings
|
|
275
|
-
attr_reader :settings
|
|
276
|
-
#Attachments.
|
|
277
|
-
#Contains "big" pictures
|
|
278
|
-
attr_accessor :attachment
|
|
279
|
-
#Additional heading information.
|
|
280
|
-
#Is a list.
|
|
281
|
-
attr_reader :head
|
|
282
|
-
#Definition for a bibtex-entry
|
|
283
|
-
attr_accessor :bibtex
|
|
284
|
-
attr_accessor :keywords
|
|
285
|
-
attr_accessor :description
|
|
286
|
-
#Logger for the presentation
|
|
287
|
-
attr_reader :log
|
|
288
|
-
|
|
289
|
-
#Allowed keys and methods to be called.
|
|
290
|
-
#:main is a dummy method
|
|
291
|
-
KEYS = {
|
|
292
|
-
'section' => :main,
|
|
293
|
-
'sectionshort' => :main,
|
|
294
|
-
'subsection' => :main,
|
|
295
|
-
'subsectionshort'=> :main,
|
|
296
|
-
'title' => :main,
|
|
297
|
-
'wiki' => :main,
|
|
298
|
-
'notes' => :main,
|
|
299
|
-
'restrict' => :main, #Allowed values: :latex, :html
|
|
300
|
-
'thumb' => :thumb=,
|
|
301
|
-
'pic' => :pic=,
|
|
302
|
-
'pic*' => :picfull=,
|
|
303
|
-
'PIC' => :piconly=,
|
|
304
|
-
'picwidth' => :picwidth=,
|
|
305
|
-
'pos' => :pos=,
|
|
306
|
-
'alignment' => :alignment=,
|
|
307
|
-
'fragile' => :fragile=,
|
|
308
|
-
'key' => :key=,
|
|
309
|
-
'html_class'=> :html_class=,
|
|
310
|
-
'img_class' => :img_class=,
|
|
311
|
-
'framepicratio' => :framepicratio=,
|
|
312
|
-
}
|
|
313
|
-
#Add contents to Presentation.
|
|
314
|
-
#fixme2yaml
|
|
315
|
-
def <<(input)
|
|
316
|
-
data = input
|
|
317
|
-
data = YAML.load(input) if input.is_a?( String ) or input.is_a?( File )
|
|
318
|
-
data = [data] if input.is_a?( Hash )
|
|
319
|
-
raise "Wrong datatype in Presentation << (#{input.class}, converted to #{data.class}" if ! data.is_a?(Array)
|
|
320
|
-
|
|
321
|
-
data.each{|properties|
|
|
322
|
-
props = @settings[:defaultoptions].merge(properties)
|
|
323
|
-
if props['section']
|
|
324
|
-
@content << element(:section, {}, props['section']).cr
|
|
325
|
-
if props['sectionshort']
|
|
326
|
-
@content.last[:short] << props['sectionshort']
|
|
327
|
-
end
|
|
328
|
-
end
|
|
329
|
-
if props['subsection']
|
|
330
|
-
@content << element(:subsection, {}, props['subsection']).cr
|
|
331
|
-
if props['subsectionshort']
|
|
332
|
-
@content.last[:short] << props['subsectionshort']
|
|
333
|
-
end
|
|
334
|
-
end
|
|
335
|
-
|
|
336
|
-
#Add in frames
|
|
337
|
-
@content << frame = element(:frame, :log => @log).CR
|
|
338
|
-
@frames << frame
|
|
339
|
-
frame.presentation = self
|
|
340
|
-
frame.settings = @settings
|
|
341
|
-
frame.restrict_to(props['restrict']) if props['restrict']
|
|
342
|
-
if props['title']
|
|
343
|
-
frame.title = props['title']
|
|
344
|
-
frame << element(:frametitle, {}, frame.title ).cr
|
|
345
|
-
else
|
|
346
|
-
@log.error("No title available(#{props.inspect})") if @log.error?
|
|
347
|
-
end
|
|
348
|
-
#Call methods for settings.
|
|
349
|
-
#The sequence is important (thumb, pos... requires a pic.
|
|
350
|
-
[ "pic", "pic*", "PIC", "thumb",
|
|
351
|
-
"pos", "picwidth",
|
|
352
|
-
"fragile", "alignment",
|
|
353
|
-
"key",
|
|
354
|
-
"html_class", "img_class",
|
|
355
|
-
"framepicratio"
|
|
356
|
-
].each{|key|
|
|
357
|
-
if props[key]
|
|
358
|
-
frame.send( KEYS[key], props[key] )
|
|
359
|
-
end
|
|
360
|
-
}
|
|
361
|
-
frame << @settings[:wikiframe].new(:content => props['wiki']) if props['wiki']
|
|
362
|
-
if props['notes']
|
|
363
|
-
frame << element(:note,{},
|
|
364
|
-
@settings[:wikiframe].new(:content => props['notes'])
|
|
365
|
-
)
|
|
366
|
-
end
|
|
367
|
-
|
|
368
|
-
#Check for unknown parameters (Typo?)
|
|
369
|
-
(props.keys - KEYS.keys - @settings[:valid_keys]).each{|key|
|
|
370
|
-
@log.warn("Unknown key '#{key}' in #{props.inspect}") if @log.warn?
|
|
371
|
-
}
|
|
372
|
-
@content << element(:newline, {:clear=>'all'}).restrict_to(:html).cr
|
|
373
|
-
}
|
|
374
|
-
return self
|
|
375
|
-
end
|
|
376
|
-
|
|
377
|
-
#The result are different files:
|
|
378
|
-
#-The presentation content (beamer_include)
|
|
379
|
-
#-The article version
|
|
380
|
-
#-the beamer version
|
|
381
|
-
#-the notes version
|
|
382
|
-
#-the HTML version
|
|
383
|
-
#The flags are used to write "true" to the documentsettings.
|
|
384
|
-
#-runtex (:pdflualatex, :latex, :pdflatex, :xelatex)
|
|
385
|
-
#-fullpage
|
|
386
|
-
def save( filename, *args )
|
|
387
|
-
settings = DEF_SETTINGS.dup.update(@settings)
|
|
388
|
-
args.flatten.each{|arg|
|
|
389
|
-
if arg.is_a?(Hash) #max. einmal, letzte Element
|
|
390
|
-
settings.update(arg)
|
|
391
|
-
else
|
|
392
|
-
settings[arg] = true
|
|
393
|
-
end
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
#check settings
|
|
397
|
-
settings[:beamer_include] = ( settings[:presentation] or settings[:beamer_article] or settings[:beamer_notes] )
|
|
398
|
-
if ! (settings.keys - DEF_SETTINGS.keys).empty?
|
|
399
|
-
puts "Undefined setting #{(settings.keys - DEF_SETTINGS.keys ).inspect}"
|
|
400
|
-
end
|
|
401
|
-
@content.each{|frame|
|
|
402
|
-
next if ! frame.is_a?(Frame)
|
|
403
|
-
frame.settings = settings
|
|
404
|
-
frame.framepic.picwithname = settings[:picwithname] if settings[:picwithname] and frame.framepic
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
#fixme: Parameter zum setzen.
|
|
408
|
-
overwrite = true
|
|
409
|
-
|
|
410
|
-
dir = File.dirname(filename) + '/'
|
|
411
|
-
filename_base = File.basename(filename, '.tex')
|
|
412
|
-
|
|
413
|
-
filename_html = "#{filename_base}.html"
|
|
414
|
-
filename_tex = "#{filename_base}.tex"
|
|
415
|
-
filename_pres = "#{filename_base}_screen.tex"
|
|
416
|
-
filename_artcl = "#{filename_base}_print.tex"
|
|
417
|
-
filename_note = "#{filename_base}_notes.tex"
|
|
418
|
-
filename_att = "#{filename_base}_attachment.tex"
|
|
419
|
-
|
|
420
|
-
settings[:filename_att] = filename_att
|
|
421
|
-
document = build_document(settings)
|
|
422
|
-
attachment = build_attachment_doc(settings) if @attachment.size > 0
|
|
423
|
-
|
|
424
|
-
presentation = nil
|
|
425
|
-
presentation = build_presentation(filename, settings) if settings[:presentation]
|
|
426
|
-
|
|
427
|
-
article = nil
|
|
428
|
-
article = build_article(filename, settings) if settings[:beamer_article]
|
|
429
|
-
|
|
430
|
-
notes = nil
|
|
431
|
-
notes = build_notes(filename, settings) if settings[:beamer_notes]
|
|
432
|
-
|
|
433
|
-
#Save HTML
|
|
434
|
-
#~ Parameter zum einstellen:
|
|
435
|
-
#~ �bersicht mit
|
|
436
|
-
#~ -text
|
|
437
|
-
#~ -bild
|
|
438
|
-
#~ -link zu detail
|
|
439
|
-
#~ detail mit
|
|
440
|
-
#~ -bild
|
|
441
|
-
#~ -text
|
|
442
|
-
#~ -Aufbau Filename
|
|
443
|
-
case settings[:html]
|
|
444
|
-
#Overview contains the title and a link to the detail page
|
|
445
|
-
when :overview_with_singlepages
|
|
446
|
-
html_overview = build_html_overview_with_singlepages(dir, filename_html, settings)
|
|
447
|
-
html_overview.save( dir + filename_html, :overwrite => overwrite )
|
|
448
|
-
#Overview containes picture-thumb and text.
|
|
449
|
-
#The thumb is linked to a html with picture
|
|
450
|
-
when :with_detailpic, :with_detailpic_and_text
|
|
451
|
-
#Build all picture-HTMLS, named with numbers
|
|
452
|
-
build_html_with_detailpic(filename_html, settings)
|
|
453
|
-
document.save( dir + filename_html, :overwrite => overwrite )
|
|
454
|
-
when true
|
|
455
|
-
document.save( dir + filename_html, :overwrite => overwrite )
|
|
456
|
-
when false #No action
|
|
457
|
-
else
|
|
458
|
-
@log.error("Unknown feature for :html (#{@option[:html]}, #{__FILE__}##{__LINE__})") if @log.error?
|
|
459
|
-
end
|
|
460
|
-
|
|
461
|
-
#Save TeX/Beamer-class
|
|
462
|
-
changed = false
|
|
463
|
-
changed = true if document.save( dir + filename_tex, :overwrite => overwrite ) if settings[:beamer_include]
|
|
464
|
-
changed = true if presentation.save( dir + filename_pres, :overwrite => overwrite ) if presentation
|
|
465
|
-
changed = true if article.save( dir + filename_artcl, :overwrite => overwrite ) if article
|
|
466
|
-
changed = true if notes.save( dir + filename_note, :overwrite => overwrite ) if notes
|
|
467
|
-
changed = true if attachment.save( dir + filename_att, :overwrite => overwrite ) if attachment
|
|
468
|
-
|
|
469
|
-
if settings[:runtex]
|
|
470
|
-
if changed
|
|
471
|
-
Document.runtex( filename_pres, settings[:runtex] ) if presentation
|
|
472
|
-
Document.runtex( filename_artcl, settings[:runtex] ) if article
|
|
473
|
-
Document.runtex( filename_note, settings[:runtex] ) if notes
|
|
474
|
-
else
|
|
475
|
-
@log.info('No TeX-call (no change in documents)') if @log.info?
|
|
476
|
-
end
|
|
477
|
-
end #runtex
|
|
478
|
-
if pdftk = settings[:pdftk]
|
|
479
|
-
pdftk_base = filename_pres.gsub(/\.tex/, '')
|
|
480
|
-
call_pdftk( "#{pdftk_base}.pdf", "#{pdftk_base}2.pdf", settings[:pdftk])
|
|
481
|
-
end
|
|
482
|
-
end #save_beamer
|
|
483
|
-
#
|
|
484
|
-
#Build the content of the presentation.
|
|
485
|
-
#Will be included to the different main documents.
|
|
486
|
-
def build_document(settings)
|
|
487
|
-
|
|
488
|
-
document = Document.new(
|
|
489
|
-
:template => :beamer,
|
|
490
|
-
:title => title,
|
|
491
|
-
:shorttitle => settings[:shorttitle],
|
|
492
|
-
:log => @log
|
|
493
|
-
)
|
|
494
|
-
document.description = @description
|
|
495
|
-
document.keywords = @keywords
|
|
496
|
-
if @bibtex
|
|
497
|
-
document.head << EMPTYBIBTEX.sub(/>\n/, ">\n%#{@bibtex.gsub(/\n/, "\n%")}\n")
|
|
498
|
-
else #Avoid the automatic generation of BibTeX-Entries
|
|
499
|
-
document.head << element(:span,{},EMPTYBIBTEX).restrict_to(:latex)
|
|
500
|
-
end
|
|
501
|
-
|
|
502
|
-
if settings[:author].respond_to?(:join)
|
|
503
|
-
document.author = settings[:author].join(', ')
|
|
504
|
-
elsif settings[:author]
|
|
505
|
-
document.author = settings[:author]
|
|
506
|
-
end
|
|
507
|
-
document.head<< element(:institute, {}, settings[:institute]) if settings[:institute]
|
|
508
|
-
document.date = settings[:date] if settings[:date]
|
|
509
|
-
#~ document.logo = settings[:logo] if settings[:logo]
|
|
510
|
-
[ :id, :altlang ].each{|setting|
|
|
511
|
-
document.meta( setting, settings[setting]) if settings[setting]
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
document.head << element(:subtitle, {}, settings[:subtitle]).restrict_to(:latex) if settings[:subtitle]
|
|
515
|
-
|
|
516
|
-
document.body << element(:maketitle).cr if settings[:maketitle]
|
|
517
|
-
case settings[:maketoc]
|
|
518
|
-
when true
|
|
519
|
-
document.body << element(:tableofcontents).cr
|
|
520
|
-
when :article
|
|
521
|
-
document.body << [
|
|
522
|
-
'\only<article>{',
|
|
523
|
-
element(:tableofcontents),
|
|
524
|
-
"}\n"
|
|
525
|
-
]
|
|
526
|
-
end #settings[:maketoc]
|
|
527
|
-
document.body << @content
|
|
528
|
-
|
|
529
|
-
#Collection of attachments
|
|
530
|
-
if @attachment.size > 0
|
|
531
|
-
document.body << element(:span,{},[ '\only<presentation>{',
|
|
532
|
-
%q|
|
|
533
|
-
\appendix
|
|
534
|
-
|.gsub(/^\t*/, ''),
|
|
535
|
-
element(:input,{}, settings[:filename_att] ).cr,
|
|
536
|
-
'}%Big Pictures' ]
|
|
537
|
-
).restrict_to(:latex)
|
|
538
|
-
end
|
|
539
|
-
return document
|
|
540
|
-
end #build_document
|
|
541
|
-
#
|
|
542
|
-
#Build the include to be attached at the end.
|
|
543
|
-
#This document contains the full-page pictures.
|
|
544
|
-
def build_attachment_doc(settings)
|
|
545
|
-
attachment = Document.new(:template => :include, :log => @log)
|
|
546
|
-
attachment.head << EMPTYBIBTEX
|
|
547
|
-
attachment.body << %q|
|
|
548
|
-
%
|
|
549
|
-
% Big Pictures / Plainframes
|
|
550
|
-
\section{Enlarged Pictures}%\frame{\sectionpage}
|
|
551
|
-
|
|
552
|
-
\usebackgroundtemplate{}
|
|
553
|
-
|.gsub(/^\t*/, '')
|
|
554
|
-
@attachment.each{|picname|
|
|
555
|
-
attachment.body << <<-FRAME
|
|
556
|
-
\\frame<handout:0>[plain]{%\\frametitle{#{picname}}
|
|
557
|
-
\\hypertarget{pic:#{picname}}{}
|
|
558
|
-
\\includegraphicsJustified{#{picname}}
|
|
559
|
-
}
|
|
560
|
-
FRAME
|
|
561
|
-
}
|
|
562
|
-
return attachment
|
|
563
|
-
end #build_attachment_doc
|
|
564
|
-
#
|
|
565
|
-
#Build the main-tex-document for presentation.
|
|
566
|
-
def build_presentation(filename, settings)
|
|
567
|
-
presentation = Document.new( :template => @settings[:template], :log => @log )
|
|
568
|
-
if settings[:language].respond_to?(:join)
|
|
569
|
-
presentation.language = settings[:language].join(',')
|
|
570
|
-
elsif !settings[:language]
|
|
571
|
-
presentation.language = 'ngerman'
|
|
572
|
-
else
|
|
573
|
-
presentation.language = settings[:language]
|
|
574
|
-
end
|
|
575
|
-
presentation.add_option(:picwithname) if settings[:picwithname]
|
|
576
|
-
presentation.add_option( settings[:classoption] ) if settings[:classoption]
|
|
577
|
-
|
|
578
|
-
#~ @classoptions.each{|opt| presentation.add_option( opt ) }
|
|
579
|
-
presentation.head << EMPTYBIBTEX
|
|
580
|
-
|
|
581
|
-
if settings[:fullpage]
|
|
582
|
-
presentation.head << "\\hypersetup{\n"
|
|
583
|
-
presentation.head << "\tpdfpagemode=FullScreen,\n"
|
|
584
|
-
presentation.head << "}\n"
|
|
585
|
-
end
|
|
586
|
-
presentation.head << @head
|
|
587
|
-
|
|
588
|
-
presentation.head << element(:input, {}, filename).cr
|
|
589
|
-
presentation
|
|
590
|
-
end #def build_presentation
|
|
591
|
-
#
|
|
592
|
-
#Build the main-tex-document for article.
|
|
593
|
-
def build_article(filename, settings)
|
|
594
|
-
if @settings[:template].to_s =~ /festo/i
|
|
595
|
-
article = Document.new( :template => :beamerFestoarticle, :log => @log )
|
|
596
|
-
else
|
|
597
|
-
article = Document.new( :template => :beamerarticle, :log => @log )
|
|
598
|
-
end
|
|
599
|
-
article.head << EMPTYBIBTEX
|
|
600
|
-
article.head << @head
|
|
601
|
-
|
|
602
|
-
article.head << "\\input{#{filename}}\n"
|
|
603
|
-
article.language = settings[:language].join(',')
|
|
604
|
-
article.add_option(:picwithname) if settings[:picwithname]
|
|
605
|
-
article.add_option( settings[:classoption] ) if settings[:classoption]
|
|
606
|
-
return article
|
|
607
|
-
end #build_article
|
|
608
|
-
#
|
|
609
|
-
#Build the main-tex-document for notes.
|
|
610
|
-
#
|
|
611
|
-
#The following settings are possible:
|
|
612
|
-
#- show - Include notes in the output file. Normal slides are also included.
|
|
613
|
-
#- only - Include only the notes in the output file and suppresses all frames.
|
|
614
|
-
#- onlyslideswithnotes - This includes all notes and those slides that contain a \note.
|
|
615
|
-
def build_notes(filename, settings)
|
|
616
|
-
settings[:beamer_notes] = 'only' if settings[:beamer_notes] == true
|
|
617
|
-
if ! BEAMER_NOTES.include?(settings[:beamer_notes])
|
|
618
|
-
@log.error("Beamer_Notes settings: unknown #{settings[:beamer_notes].inspect} - use #{BEAMER_NOTES.inspect}") if @log.error?
|
|
619
|
-
end
|
|
620
|
-
|
|
621
|
-
#~ notes = Document.new( :template => DocumentTemplate[settings[:template]].sub(/<<classoptions>>/, "notes=#{settings[:beamer_notes]},<<classoptions>>") )
|
|
622
|
-
notes = Document.new( :template => DocumentTemplate[settings[:template]], :log => @log )
|
|
623
|
-
notes.add_option("notes=#{settings[:beamer_notes]}")
|
|
624
|
-
notes.head << EMPTYBIBTEX
|
|
625
|
-
notes.head << @head
|
|
626
|
-
|
|
627
|
-
if settings[:splitscreen]
|
|
628
|
-
if ! BEAMER_SPLIT_POSITIONS.include?(settings[:splitscreen])
|
|
629
|
-
@log.error("Undefined option for splitscreen, use 'right'. (allowed: #{BEAMER_SPLIT_POSITIONS.inspect})") if @log.error?
|
|
630
|
-
settings[:splitscreen] = 'right'
|
|
631
|
-
end
|
|
632
|
-
if settings[:beamer_notes] != 'show'
|
|
633
|
-
@log.info("Use splitscreen without all frames") if @log.info?
|
|
634
|
-
end
|
|
635
|
-
notes.head << <<SPLITSCREEN
|
|
636
|
-
\\usepackage{pgfpages}
|
|
637
|
-
\\setbeameroption{show notes on second screen=#{settings[:splitscreen]}}
|
|
638
|
-
SPLITSCREEN
|
|
639
|
-
end
|
|
640
|
-
|
|
641
|
-
notes.head << "\\input{#{filename}}\n"
|
|
642
|
-
notes.language = settings[:language].join(',')
|
|
643
|
-
notes.add_option(:picwithname) if settings[:picwithname]
|
|
644
|
-
notes.add_option( settings[:classoption] ) if settings[:classoption]
|
|
645
|
-
return notes
|
|
646
|
-
end #build_notes
|
|
647
|
-
#Overview contains the title and a link to the detail page
|
|
648
|
-
def build_html_overview_with_singlepages(dir, filename_html, settings)
|
|
649
|
-
#Links needed for navigation
|
|
650
|
-
@frames.each_with_index{|frame,count|
|
|
651
|
-
if frame.key
|
|
652
|
-
frame.html_link = filename_html.sub(/\.htm/, "_#{frame.key}.htm" )
|
|
653
|
-
else
|
|
654
|
-
frame.html_link = filename_html.sub(/\.htm/, "_#{count}.htm" )
|
|
655
|
-
end
|
|
656
|
-
}
|
|
657
|
-
#Build single files.
|
|
658
|
-
Knut::Picture.usethumbs = false
|
|
659
|
-
@frames.each_with_index{|frame,count|
|
|
660
|
-
singleframe = Document.new()
|
|
661
|
-
singleframe.title = frame.title
|
|
662
|
-
singleframe.body << html_navigation( count, filename_html )
|
|
663
|
-
singleframe.body << frame
|
|
664
|
-
singleframe.body << html_navigation( count, filename_html )
|
|
665
|
-
singleframe.save( dir + frame.html_link, :overwrite => true )
|
|
666
|
-
}
|
|
667
|
-
Knut::Picture.usethumbs = true
|
|
668
|
-
#Build main-File
|
|
669
|
-
html_overview = Document.new( :log => @log)
|
|
670
|
-
html_overview.title = title
|
|
671
|
-
html_overview.description = @description
|
|
672
|
-
html_overview.keywords = @keywords
|
|
673
|
-
[ :shorttitle, :id, :altlang ].each{|setting|
|
|
674
|
-
html_overview.meta( setting, settings[setting]) if settings[setting]
|
|
675
|
-
}
|
|
676
|
-
@content.each{|frame|
|
|
677
|
-
if frame.is_a?(Frame)
|
|
678
|
-
html_overview.body << element(:p,{},[
|
|
679
|
-
element(:Rightarrow),
|
|
680
|
-
preview = element(:a,{:href=>frame.html_link}, frame.title)
|
|
681
|
-
]).cr
|
|
682
|
-
#Add thumb
|
|
683
|
-
if frame.thumb
|
|
684
|
-
preview << element(:br )
|
|
685
|
-
preview << element(:img,{ :src =>frame.thumb} )
|
|
686
|
-
end
|
|
687
|
-
else
|
|
688
|
-
html_overview.body << frame
|
|
689
|
-
end
|
|
690
|
-
}
|
|
691
|
-
return html_overview
|
|
692
|
-
end #build_html_overview_with_singlepages
|
|
693
|
-
#Build all picture-HTMLS, named with numbers
|
|
694
|
-
def build_html_with_detailpic(filename_html, settings)
|
|
695
|
-
@frames.each_with_index{|frame,count|
|
|
696
|
-
filename = frame.title
|
|
697
|
-
if frame.framepic
|
|
698
|
-
filename = File.basename(frame.framepic.picture.filename, '.jpg')
|
|
699
|
-
#~ filename.gsub!(/\.(jpg|png)/i, '')
|
|
700
|
-
frame.framepic.picture.href = "./#{filename}.html"
|
|
701
|
-
frame.framepic.picture.title = frame.title
|
|
702
|
-
end
|
|
703
|
-
frame.html_link = "#{filename}.html"
|
|
704
|
-
}
|
|
705
|
-
#Save all HTML for Pictures
|
|
706
|
-
@frames.each_with_index{|frame,count|
|
|
707
|
-
next if ! frame.framepic
|
|
708
|
-
post = []
|
|
709
|
-
case settings[:html]
|
|
710
|
-
# only navigation
|
|
711
|
-
when :with_detailpic
|
|
712
|
-
post << html_navigation( count, filename_html )
|
|
713
|
-
# complete content added (Preview + Text
|
|
714
|
-
when :with_detailpic_and_text
|
|
715
|
-
frame.content.each{|c|
|
|
716
|
-
#0=Titel
|
|
717
|
-
#1=framepic
|
|
718
|
-
#2=Description in Array
|
|
719
|
-
case c
|
|
720
|
-
when Framepic, element(:frametitle).class
|
|
721
|
-
when Array, WikiFrame, Creole
|
|
722
|
-
post << c
|
|
723
|
-
else
|
|
724
|
-
#~ puts #{__FILE__}##{__LINE__} c.class, c.inspect
|
|
725
|
-
end
|
|
726
|
-
}
|
|
727
|
-
post << html_navigation( count, filename_html )
|
|
728
|
-
end
|
|
729
|
-
|
|
730
|
-
frame.framepic.picture.html(
|
|
731
|
-
:filename => frame.html_link,
|
|
732
|
-
:id => settings[:id] ? "#{File.basename(frame.html_link, 'html')}#{settings[:id]}" : nil,
|
|
733
|
-
:altlang => settings[:altlang] ? "#{File.basename(frame.html_link, 'html')}#{settings[:altlang]}" : nil,
|
|
734
|
-
:pre => html_navigation( count, filename_html ),
|
|
735
|
-
:post => post
|
|
736
|
-
)
|
|
737
|
-
}
|
|
738
|
-
end #build_html_with_detailpic
|
|
739
|
-
alias :save_beamer :save
|
|
740
|
-
#
|
|
741
|
-
def call_pdftk(source, output, pdftksettings)
|
|
742
|
-
(pdftksettings.keys - [:owner_pw, :user_pw, :allow] ).each{|opt|
|
|
743
|
-
puts "PDFTK: Undefined option #{opt.inspect}"
|
|
744
|
-
}
|
|
745
|
-
pdftkcmd = ["pdftk #{source}"]
|
|
746
|
-
#~ pdftk << "output #{pdftk_base}_save.pdf"
|
|
747
|
-
pdftkcmd << "output #{output}"
|
|
748
|
-
pdftkcmd << "owner_pw #{pdftksettings[:owner_pw]}" if pdftksettings[:owner_pw]
|
|
749
|
-
pdftkcmd << "user_pw #{pdftksettings[:user_pw]}" if pdftksettings[:user_pw]
|
|
750
|
-
if pdftksettings[:allow]
|
|
751
|
-
([pdftksettings[:allow]].flatten - [
|
|
752
|
-
'Printing', 'DegradedPrinting',
|
|
753
|
-
'ModifyContents', # Also allows Assembly
|
|
754
|
-
'Assembly',
|
|
755
|
-
'CopyContents', #Also allows ScreenReaders
|
|
756
|
-
'ScreenReaders',
|
|
757
|
-
'ModifyAnnotations', #Also allows FillIn
|
|
758
|
-
'FillIn',
|
|
759
|
-
'AllFeatures',
|
|
760
|
-
]).each{|opt|
|
|
761
|
-
puts "PDFTK/allow: Undefined option #{opt.inspect}"
|
|
762
|
-
}
|
|
763
|
-
pdftkcmd << "allow"
|
|
764
|
-
pdftkcmd << pdftksettings[:allow]
|
|
765
|
-
end
|
|
766
|
-
pdftkcmd << "dont_ask"
|
|
767
|
-
pdftkcmd << "verbose"
|
|
768
|
-
puts pdftkcmd.join(" ")
|
|
769
|
-
system(pdftkcmd.join(" "))
|
|
770
|
-
end #call_pdftk
|
|
771
|
-
|
|
772
|
-
#Return a HTML-element with links to pre- and successor
|
|
773
|
-
# <= ^ =>
|
|
774
|
-
#
|
|
775
|
-
def html_navigation( count, filename_html )
|
|
776
|
-
nav = element(:div, { :style => CSS.new( :text_align => 'center', :clear=>'both' )})
|
|
777
|
-
if @frames[count - 1] and count > 0
|
|
778
|
-
nav << element(:a, { :href=> @frames[count - 1].html_link }, element(:Leftarrow)).cr
|
|
779
|
-
end
|
|
780
|
-
nav << element(:a, { :href=> filename_html }, element(:Uparrow)).cr
|
|
781
|
-
if @frames[count + 1]
|
|
782
|
-
nav << element(:a, { :href=> @frames[count + 1].html_link }, element(:Rightarrow)).cr
|
|
783
|
-
end
|
|
784
|
-
return nav
|
|
785
|
-
end
|
|
786
|
-
#Return all used pics.
|
|
787
|
-
#Can be used to detect new/obsolete pictures in a directory.
|
|
788
|
-
def used_pics()
|
|
789
|
-
pics = []
|
|
790
|
-
@frames.each{|frame|
|
|
791
|
-
#~ if frame.framepic
|
|
792
|
-
#~ pics << frame.framepic.picture.filename
|
|
793
|
-
#~ end
|
|
794
|
-
if frame.picname
|
|
795
|
-
pics << frame.picname
|
|
796
|
-
end
|
|
797
|
-
}
|
|
798
|
-
return pics
|
|
799
|
-
end
|
|
800
|
-
end
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
#
|
|
804
|
-
#Read pictures and build yaml-Template.
|
|
805
|
-
def dir2yaml( pattern, defaults = ''
|
|
806
|
-
#~ <<-DEFAULTS
|
|
807
|
-
#~ picwidth: 100%
|
|
808
|
-
#~ option: left
|
|
809
|
-
#~ list:
|
|
810
|
-
#~ # - Punkt 1
|
|
811
|
-
#~ DEFAULTS
|
|
812
|
-
)
|
|
813
|
-
defaults.gsub!(/^\s*/, ' ')
|
|
814
|
-
files2yaml(Dir[pattern])
|
|
815
|
-
end #dir2yaml
|
|
816
|
-
def files2yaml( files, defaults = '')
|
|
817
|
-
yaml = []
|
|
818
|
-
files.each{|f|
|
|
819
|
-
yaml << '-'
|
|
820
|
-
yaml << "\tpic: #{f}"
|
|
821
|
-
yaml << "\ttitle: #{f.gsub(/_|\.png|\.jpg/, ' ')}" if /title:/ !~ defaults
|
|
822
|
-
yaml << "\twiki: |\n\t\t#~ content" if /wiki:/ !~ defaults
|
|
823
|
-
yaml << defaults
|
|
824
|
-
|
|
825
|
-
}
|
|
826
|
-
return yaml.join("\n")
|
|
827
|
-
end
|
|
828
|
-
|
|
829
|
-
#Get something and build the data.
|
|
830
|
-
#input can be:
|
|
831
|
-
#-A file -> read it
|
|
832
|
-
#-A string -> call YAML
|
|
833
|
-
#-Else: I expect a valid array/hash
|
|
834
|
-
def prepare_data( input )
|
|
835
|
-
data = input
|
|
836
|
-
lineno = 0
|
|
837
|
-
if input.is_a?(File)
|
|
838
|
-
#This is normally DATA, so we start with an offset.
|
|
839
|
-
lineno = input.lineno
|
|
840
|
-
input = input.readlines.to_s
|
|
841
|
-
end
|
|
842
|
-
if input.is_a?(String)
|
|
843
|
-
begin
|
|
844
|
-
data = YAML.load( input.gsub(/\t/, ' ') )
|
|
845
|
-
rescue ArgumentError
|
|
846
|
-
if /syntax error on line (.*), col/ =~ $!.to_s
|
|
847
|
-
lineno += $1.to_i
|
|
848
|
-
raise "Error in YAML-Input (Line #{lineno}?)"
|
|
849
|
-
end
|
|
850
|
-
raise "Error in YAML-Input: #{$!}"
|
|
851
|
-
raise "Error in YAML-Input: #{$!}\n#{input}"
|
|
852
|
-
end
|
|
853
|
-
end
|
|
854
|
-
return data
|
|
855
|
-
end
|
|
856
|
-
#Takes the yaml-data and make some corrections on it.
|
|
857
|
-
#
|
|
858
|
-
#Example:
|
|
859
|
-
#Add a thumb on each value
|
|
860
|
-
# puts yaml2yaml(DATA, Proc.new{|y|
|
|
861
|
-
# y['thumb'] = "thumb_#{y['pic']}"
|
|
862
|
-
# y
|
|
863
|
-
# }).to_yaml
|
|
864
|
-
#Problem: Umlaute are converted
|
|
865
|
-
def yaml2yaml( input, corrections )
|
|
866
|
-
data = prepare_data( input ) #Array of hashes
|
|
867
|
-
puts "yaml2yaml: No Proc-element given" if ! corrections.is_a?(Proc)
|
|
868
|
-
|
|
869
|
-
newdata = []
|
|
870
|
-
data.each{|props|
|
|
871
|
-
if ! props.is_a?(Hash)
|
|
872
|
-
raise "yaml2pres: props is no Hash (#{props.inspect})"
|
|
873
|
-
next
|
|
874
|
-
end
|
|
875
|
-
|
|
876
|
-
newdata << corrections.call( props )
|
|
877
|
-
}
|
|
878
|
-
newdata
|
|
879
|
-
end
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
if __FILE__ == $0
|
|
885
|
-
<<TEMPLATE
|
|
886
|
-
require 'C:/usr/Script/MyScripts' if File.exist?('C:/usr/Script/MyScripts.rb')
|
|
887
|
-
require 'yaml2presentation'
|
|
888
|
-
|
|
889
|
-
#~ Dir['*.JPG'].each{|f| Knut::Picture.new(f).mk_thumb }
|
|
890
|
-
#~ Dir['*.jpg'].each{|f| Knut::Picture.new(f).mk_thumb }
|
|
891
|
-
TEMPLATE
|
|
892
|
-
|
|
893
|
-
pres = Presentation.new( 'Pr�sentationen mit yaml2presentation.rb',
|
|
894
|
-
:template => :beamerthemetree
|
|
895
|
-
)
|
|
896
|
-
pres.settings[:shorttitle] = 'yaml2presentation.rb'
|
|
897
|
-
pres.settings[:author] = 'Knut Lickert'
|
|
898
|
-
pres.settings[:date] = Date.today
|
|
899
|
-
#~ pres.settings[:language] << 'Sprache'
|
|
900
|
-
#~ pres.settings[:subtitle] = ''
|
|
901
|
-
pres.head << <<HEADER
|
|
902
|
-
\\AtBeginSection[] % Do nothing for \\section*
|
|
903
|
-
{
|
|
904
|
-
\\frame<beamer>{\\tableofcontents[current]}
|
|
905
|
-
}
|
|
906
|
-
|
|
907
|
-
\\AtBeginSubsection[]
|
|
908
|
-
{
|
|
909
|
-
\\frame<beamer>{\\tableofcontents[currentsection,currentsubsection]}
|
|
910
|
-
}
|
|
911
|
-
HEADER
|
|
912
|
-
|
|
913
|
-
pres << DATA.readlines.to_s.gsub(/\t/, ' ')
|
|
914
|
-
puts pres.build_presentation('XX',{}).to_latex(:log=>pres.log)
|
|
915
|
-
|
|
916
|
-
pres.save('doc_yaml2presentation',
|
|
917
|
-
#~ :presentation => true,
|
|
918
|
-
#~ :pdftk => {
|
|
919
|
-
#~ :owner_pw => 'pw',
|
|
920
|
-
#~ :user_pw => 'pw2',
|
|
921
|
-
#~ :allow => [
|
|
922
|
-
#~ 'CopyContents',
|
|
923
|
-
#~ 'Printing',
|
|
924
|
-
#~ ]
|
|
925
|
-
#~ },
|
|
926
|
-
#~ :beamer_article => true,
|
|
927
|
-
:beamer_notes => 'show', #/ 'only' / 'onlyslideswithnotes'
|
|
928
|
-
#~ :splitscreen => 'bottom'
|
|
929
|
-
#~ :splitscreen => 'right'
|
|
930
|
-
#~ :html => true, #:overview_with_singlepages :with_detailpic
|
|
931
|
-
:runtex => true, #:fullpage => true,
|
|
932
|
-
#~ :picwithname => true,
|
|
933
|
-
:maketitle => true,
|
|
934
|
-
:maketoc => true
|
|
935
|
-
)
|
|
936
|
-
|
|
937
|
-
end
|
|
938
|
-
|
|
939
|
-
#~ -
|
|
940
|
-
#~ section: �berschrift
|
|
941
|
-
#~ subsection: �berschrift 2
|
|
942
|
-
#~ title: Titel
|
|
943
|
-
#~ key: key
|
|
944
|
-
#~ pic: test.jpg
|
|
945
|
-
#~ pic*: test.jpg
|
|
946
|
-
#~ picwidth: 12px
|
|
947
|
-
#~ thumb: thumb.png
|
|
948
|
-
#~ fragile: true
|
|
949
|
-
#~ alignment: t
|
|
950
|
-
#~ pos: left
|
|
951
|
-
#~ wiki: |
|
|
952
|
-
#~ Vorher
|
|
953
|
-
#~ *punkt 1
|
|
954
|
-
#~ *Punkt 2
|
|
955
|
-
#~ Nachher
|
|
956
|
-
#~ notes: |
|
|
957
|
-
#~ Notizen
|
|
958
|
-
|
|
959
|
-
__END__
|
|
960
|
-
-
|
|
961
|
-
section: Grunds�tzliche Idee
|
|
962
|
-
title: Einleitung
|
|
963
|
-
wiki: |
|
|
964
|
-
Yaml-Syntax zur Erstellung
|
|
965
|
-
*Beamer-Pr�sentation (LaTeX) (Ersatz mkpres.rb)
|
|
966
|
-
*Webgalerie (HTML) (Ersatz web-gallery.rb)
|
|
967
|
-
Darstellung eines Frames wahlweise:
|
|
968
|
-
*Links ein Bild, rechts kurze Beschreibung
|
|
969
|
-
*Rechts ein Bild, links kurze Beschreibung
|
|
970
|
-
*Nur Text
|
|
971
|
-
-
|
|
972
|
-
section: Features
|
|
973
|
-
subsection: HTML-Galerie
|
|
974
|
-
title: HTML-Galerie
|
|
975
|
-
wiki: |
|
|
976
|
-
*Thumb/Kurzfassung
|
|
977
|
-
*Langfassung auf Detailseite
|
|
978
|
-
-
|
|
979
|
-
subsection: TeX/Beamer.sty
|
|
980
|
-
title: TeX/Beamer
|
|
981
|
-
#~ pic: c:/usr/wwwHostEurope/Stummfilm/source/Tonfilm_Kitsch.jpg
|
|
982
|
-
pos: right
|
|
983
|
-
wiki: |
|
|
984
|
-
*Text in Wiki-Notation
|
|
985
|
-
*Link auf Detailbild am Ende
|
|
986
|
-
-
|
|
987
|
-
section: Parameter
|
|
988
|
-
subsection: Gliederung
|
|
989
|
-
title: Gliederung
|
|
990
|
-
wiki: |
|
|
991
|
-
Parameter f�r Gliederungen:
|
|
992
|
-
*section
|
|
993
|
-
**sectionshort
|
|
994
|
-
*subsection
|
|
995
|
-
**subsectionshort
|
|
996
|
-
Jeweils in Frames integriert
|
|
997
|
-
-
|
|
998
|
-
subsection: Optionen zum Frame
|
|
999
|
-
title: Optionen zum Frame
|
|
1000
|
-
fragile: true
|
|
1001
|
-
wiki: |
|
|
1002
|
-
Bsp:
|
|
1003
|
-
title: Titel
|
|
1004
|
-
key: key
|
|
1005
|
-
*title: Titel des Frames
|
|
1006
|
-
*key: Optional, f�r label/Link genutzt
|
|
1007
|
-
-
|
|
1008
|
-
subsection: Optionen zum Text
|
|
1009
|
-
title: Optionen zum Text
|
|
1010
|
-
fragile: true
|
|
1011
|
-
wiki: |
|
|
1012
|
-
Bsp:
|
|
1013
|
-
fragile: true
|
|
1014
|
-
wiki: |
|
|
1015
|
-
Vorher
|
|
1016
|
-
*punkt 1
|
|
1017
|
-
*Punkt 2
|
|
1018
|
-
Nachher
|
|
1019
|
-
notes: |
|
|
1020
|
-
Notizen
|
|
1021
|
-
|
|
1022
|
-
*notes: Anmerkungen zum Frame (LaTeX)
|
|
1023
|
-
*fragile: LaTeX, falls Wiki verbatim-Text enth�lt.
|
|
1024
|
-
-
|
|
1025
|
-
subsection: Optionen von Bildern
|
|
1026
|
-
title: Bild einf�gen
|
|
1027
|
-
fragile: true
|
|
1028
|
-
wiki: |
|
|
1029
|
-
Bsp:
|
|
1030
|
-
pic: test.jpg
|
|
1031
|
-
pic*: test.jpg
|
|
1032
|
-
PIC: test.jpg
|
|
1033
|
-
thumb: thumb.png
|
|
1034
|
-
*pic: Bildadresse
|
|
1035
|
-
*pic*: Bild mit Link zu Bild in Fullpage am Dokumentende
|
|
1036
|
-
*PIC: Bild in Fullpage
|
|
1037
|
-
*thumb: Vorlage f�r ''pic*'' (sinnvoll f�r HTML)
|
|
1038
|
-
-
|
|
1039
|
-
title: Bildoptionen
|
|
1040
|
-
fragile: true
|
|
1041
|
-
wiki: |
|
|
1042
|
-
Bsp:
|
|
1043
|
-
href: http://...
|
|
1044
|
-
picwidth: 12px
|
|
1045
|
-
alignment: t
|
|
1046
|
-
html_class: xx
|
|
1047
|
-
img_class: xx
|
|
1048
|
-
*href: Link auf externe Adresse
|
|
1049
|
-
*alt (HTML)
|
|
1050
|
-
*html\_class (HTML)
|
|
1051
|
-
*img\_class (HTML)
|
|
1052
|
-
|
|
1053
|
-
-
|
|
1054
|
-
title: Bildposition
|
|
1055
|
-
fragile: true
|
|
1056
|
-
wiki: |
|
|
1057
|
-
Bsp:
|
|
1058
|
-
pos: left
|
|
1059
|
-
Bildposition relativ zum Text
|
|
1060
|
-
*'''left'''
|
|
1061
|
-
*right
|
|
1062
|
-
*top
|
|
1063
|
-
*bottom
|
|
1064
|
-
Anordnung des Bildes. F�r TeX nur links.
|
|
1065
|
-
-
|
|
1066
|
-
title: Bild/Textverh�ltnis
|
|
1067
|
-
fragile: true
|
|
1068
|
-
wiki: |
|
|
1069
|
-
Nur f�r LaTeX.
|
|
1070
|
-
|
|
1071
|
-
Bsp:
|
|
1072
|
-
framepicratio: 0.25;0.5
|
|
1073
|
-
Bildgr��e und Textgr��e im Verh�ltnis zur Textbreite.
|
|
1074
|
-
-
|
|
1075
|
-
subsection: Weitere Optionen
|
|
1076
|
-
title: Option Restrict
|
|
1077
|
-
wiki: |
|
|
1078
|
-
Werte f�r restrict
|
|
1079
|
-
*:latex
|
|
1080
|
-
*:html
|
|
1081
|
-
Ausgabe auf ein Format begrenzen.
|
|
1082
|
-
-
|
|
1083
|
-
title: Option pdftk
|
|
1084
|
-
wiki: |
|
|
1085
|
-
Mit der Option ''pdftk'' wird mittels pdftk eine zweite
|
|
1086
|
-
Screen-Version erzeugt.
|
|
1087
|
-
|
|
1088
|
-
Optionen:
|
|
1089
|
-
*owner\_pw
|
|
1090
|
-
*user\_pw
|
|
1091
|
-
*allow: Ausnahmen f�r Verbote, wenn Passwort gesetzt.
|