docgenerator 1.0.4 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (231) hide show
  1. data/lib/creole/creole2doc.rb +777 -0
  2. data/lib/creole/creole_inclusion_and_plugins.rb +236 -0
  3. data/lib/creole/creole_placeholder.rb +74 -0
  4. data/lib/creole/creole_tabular.rb +170 -0
  5. data/lib/docgenerator.rb +15 -6
  6. data/lib/docgenerator_attribute.rb +2 -2
  7. data/lib/docgenerator_characters.rb +20 -4
  8. data/lib/docgenerator_document.rb +132 -42
  9. data/lib/docgenerator_element.rb +531 -524
  10. data/lib/docgenerator_elements.rb +408 -399
  11. data/lib/docgenerator_environments.rb +28 -2
  12. data/lib/docgenerator_footnote.rb +72 -79
  13. data/lib/docgenerator_sections.rb +1 -1
  14. data/lib/docgenerator_tabular.rb +8 -3
  15. data/lib/packages/docgenerator_beamer.rb +253 -0
  16. data/lib/packages/docgenerator_scrlettr2.rb +53 -9
  17. data/lib/templates/docgenerator_template_css.rb +4 -0
  18. data/lib/wiki2doc/wiki2docgenerator.rb +1087 -970
  19. data/lib/yaml2presentation/yaml2presentation.rb +1091 -0
  20. data/self_docgenerator.rb +8 -6
  21. data/unittest/Red_Flower.jpg +0 -0
  22. data/unittest/creole1.0test.txt +128 -0
  23. data/unittest/expected/beamer_01_doc.html +1 -1
  24. data/unittest/expected/beamer_02_doc.html +1 -1
  25. data/unittest/expected/beamer_doc_html_overview_with_detailpic_and_text_doc.html +34 -0
  26. data/unittest/expected/beamer_doc_html_overview_with_detailpic_doc.html +34 -0
  27. data/unittest/expected/beamer_doc_key_doc.html +1 -1
  28. data/unittest/expected/beamer_doc_note_doc.html +1 -1
  29. data/unittest/expected/beamer_doc_pic_bottom_doc.html +1 -1
  30. data/unittest/expected/beamer_doc_pic_doc.html +1 -1
  31. data/unittest/expected/beamer_doc_pic_left_doc.html +1 -1
  32. data/unittest/expected/beamer_doc_pic_right_doc.html +1 -1
  33. data/unittest/expected/beamer_doc_pic_top_doc.html +1 -1
  34. data/unittest/expected/test_footnote.html +2 -2
  35. data/unittest/expected/test_footnote.latex +1 -1
  36. data/unittest/expected/test_footnote_group.html +3 -3
  37. data/unittest/expected/test_footnote_group.latex +2 -2
  38. data/unittest/expected_creole/test_creole.html +3 -0
  39. data/unittest/expected_creole/test_creole_characters_all.html +10 -0
  40. data/unittest/expected_creole/test_creole_characters_all.latex +20 -0
  41. data/unittest/expected_creole/test_creole_characters_special.html +10 -0
  42. data/unittest/expected_creole/test_creole_characters_special.latex +18 -0
  43. data/unittest/expected_creole/test_creole_countdown.html +3 -0
  44. data/unittest/expected_creole/test_creole_countdown.latex +4 -0
  45. data/unittest/expected_creole/test_creole_creole1.0test.html +182 -0
  46. data/unittest/expected_creole/test_creole_creole1.0test.latex +253 -0
  47. data/unittest/expected_creole/test_creole_creole1.0test.text +160 -0
  48. data/unittest/expected_creole/test_creole_footnotes.html +9 -0
  49. data/unittest/expected_creole/test_creole_footnotes.latex +14 -0
  50. data/unittest/expected_creole/test_creole_footnotes_label.html +9 -0
  51. data/unittest/expected_creole/test_creole_headings.html +17 -0
  52. data/unittest/expected_creole/test_creole_headings.latex +19 -0
  53. data/unittest/expected_creole/test_creole_headings.text +48 -0
  54. data/unittest/expected_creole/test_creole_headings.wiki +37 -0
  55. data/unittest/expected_creole/test_creole_hr.html +7 -0
  56. data/unittest/expected_creole/test_creole_hr.latex +9 -0
  57. data/unittest/expected_creole/test_creole_hr.text +4 -0
  58. data/unittest/expected_creole/test_creole_inline.html +3 -0
  59. data/unittest/expected_creole/test_creole_inline.latex +4 -0
  60. data/unittest/expected_creole/test_creole_inline.text +2 -0
  61. data/unittest/expected_creole/test_creole_inline_ruby.html +12 -0
  62. data/unittest/expected_creole/test_creole_inline_ruby.latex +20 -0
  63. data/unittest/expected_creole/test_creole_inline_ruby_raw.html +6 -0
  64. data/unittest/expected_creole/test_creole_inline_ruby_raw.latex +8 -0
  65. data/unittest/expected_creole/test_creole_input.normsource +23 -0
  66. data/unittest/expected_creole/test_creole_label.html +12 -0
  67. data/unittest/expected_creole/test_creole_label.latex +15 -0
  68. data/unittest/expected_creole/test_creole_line_break.html +6 -0
  69. data/unittest/expected_creole/test_creole_line_break.latex +8 -0
  70. data/unittest/expected_creole/test_creole_links_explicit_internal.html +6 -0
  71. data/unittest/expected_creole/test_creole_links_explicit_internal.text +4 -0
  72. data/unittest/expected_creole/test_creole_links_explicit_with_em.html +3 -0
  73. data/unittest/expected_creole/test_creole_links_explicit_with_em.latex +4 -0
  74. data/unittest/expected_creole/test_creole_links_explicit_with_em.text +2 -0
  75. data/unittest/expected_creole/test_creole_links_external.html +6 -0
  76. data/unittest/expected_creole/test_creole_links_external.latex +8 -0
  77. data/unittest/expected_creole/test_creole_links_external.text +4 -0
  78. data/unittest/expected_creole/test_creole_links_external_implicit.html +9 -0
  79. data/unittest/expected_creole/test_creole_links_external_implicit.latex +12 -0
  80. data/unittest/expected_creole/test_creole_links_external_implicit.text +6 -0
  81. data/unittest/expected_creole/test_creole_links_file.html +6 -0
  82. data/unittest/expected_creole/test_creole_links_file.latex +8 -0
  83. data/unittest/expected_creole/test_creole_links_file.text +4 -0
  84. data/unittest/expected_creole/test_creole_list_ol.html +12 -0
  85. data/unittest/expected_creole/test_creole_list_ol.latex +22 -0
  86. data/unittest/expected_creole/test_creole_list_ol_after_ul.html +12 -0
  87. data/unittest/expected_creole/test_creole_list_ol_after_ul.latex +20 -0
  88. data/unittest/expected_creole/test_creole_list_ol_after_ul.text +6 -0
  89. data/unittest/expected_creole/test_creole_list_ol_ul.html +15 -0
  90. data/unittest/expected_creole/test_creole_list_ol_ul.latex +26 -0
  91. data/unittest/expected_creole/test_creole_list_ul.html +22 -0
  92. data/unittest/expected_creole/test_creole_list_ul.latex +40 -0
  93. data/unittest/expected_creole/test_creole_list_ul.normsource +83 -0
  94. data/unittest/expected_creole/test_creole_list_ul_too_much.html +24 -0
  95. data/unittest/expected_creole/test_creole_list_ul_too_much.latex +44 -0
  96. data/unittest/expected_creole/test_creole_newline.html +9 -0
  97. data/unittest/expected_creole/test_creole_newline.latex +11 -0
  98. data/unittest/expected_creole/test_creole_newline.text +7 -0
  99. data/unittest/expected_creole/test_creole_paragraphs.html +6 -0
  100. data/unittest/expected_creole/test_creole_paragraphs.latex +8 -0
  101. data/unittest/expected_creole/test_creole_paragraphs.normsource +27 -0
  102. data/unittest/expected_creole/test_creole_paragraphs.text +4 -0
  103. data/unittest/expected_creole/test_creole_paragraphs.wiki +4 -0
  104. data/unittest/expected_creole/test_creole_paragraphs_wrap.html +5 -0
  105. data/unittest/expected_creole/test_creole_paragraphs_wrap.latex +6 -0
  106. data/unittest/expected_creole/test_creole_paragraphs_wrap.text +4 -0
  107. data/unittest/expected_creole/test_creole_paragraphs_wrap.wiki +4 -0
  108. data/unittest/expected_creole/test_creole_paragraphs_wrap0.html +9 -0
  109. data/unittest/expected_creole/test_creole_paragraphs_wrap0.latex +11 -0
  110. data/unittest/expected_creole/test_creole_paragraphs_wrap0.text +7 -0
  111. data/unittest/expected_creole/test_creole_paragraphs_wrap0.wiki +7 -0
  112. data/unittest/expected_creole/test_creole_paragraphs_wrap60.html +5 -0
  113. data/unittest/expected_creole/test_creole_paragraphs_wrap60.latex +6 -0
  114. data/unittest/expected_creole/test_creole_paragraphs_wrap60.text +4 -0
  115. data/unittest/expected_creole/test_creole_paragraphs_wrap60.wiki +4 -0
  116. data/unittest/expected_creole/test_creole_picture_link.html +6 -0
  117. data/unittest/expected_creole/test_creole_pictures.html +10 -0
  118. data/unittest/expected_creole/test_creole_pictures.latex +13 -0
  119. data/unittest/expected_creole/test_creole_pictures_css.html +3 -0
  120. data/unittest/expected_creole/test_creole_pictures_css.latex +4 -0
  121. data/unittest/expected_creole/test_creole_pictures_imgclass.html +6 -0
  122. data/unittest/expected_creole/test_creole_pictures_imgclass.latex +8 -0
  123. data/unittest/expected_creole/test_creole_placeholders_html.html +7 -0
  124. data/unittest/expected_creole/test_creole_placeholders_html.latex +8 -0
  125. data/unittest/expected_creole/test_creole_placeholders_html.text +4 -0
  126. data/unittest/expected_creole/test_creole_placeholders_latex.html +6 -0
  127. data/unittest/expected_creole/test_creole_placeholders_latex.latex +9 -0
  128. data/unittest/expected_creole/test_creole_placeholders_latex.text +4 -0
  129. data/unittest/expected_creole/test_creole_tabular.html +20 -0
  130. data/unittest/expected_creole/test_creole_tabular.latex +22 -0
  131. data/unittest/expected_creole/test_creole_tabular_creole.html +18 -0
  132. data/unittest/expected_creole/test_creole_tabular_creole.latex +19 -0
  133. data/unittest/expected_creole/test_creole_tabular_css.html +20 -0
  134. data/unittest/expected_creole/test_creole_tabular_css.latex +22 -0
  135. data/unittest/expected_creole/test_creole_toc.html +11 -0
  136. data/unittest/expected_creole/test_creole_toc.latex +22 -0
  137. data/unittest/expected_creole/test_creole_toc.text +4 -0
  138. data/unittest/expected_creole/test_creole_toc_text.html +5 -0
  139. data/unittest/expected_creole/test_creole_toc_text.latex +5 -0
  140. data/unittest/expected_creole/test_creole_ul_multiple_line.html +7 -0
  141. data/unittest/expected_creole/test_creole_ul_multiple_line.latex +14 -0
  142. data/unittest/expected_creole/test_creole_ul_with_blank.html +11 -0
  143. data/unittest/expected_creole/test_creole_ul_with_blank.latex +20 -0
  144. data/unittest/expected_creole/test_creole_ul_with_bold.creole +0 -0
  145. data/unittest/expected_creole/test_creole_ul_with_bold.html +11 -0
  146. data/unittest/expected_creole/test_creole_ul_with_bold.latex +18 -0
  147. data/unittest/expected_creole/test_creole_ul_with_bold.text +7 -0
  148. data/unittest/expected_creole/test_creole_verbatim.html +25 -0
  149. data/unittest/expected_creole/test_creole_verbatim.latex +33 -0
  150. data/unittest/expected_creole/test_creole_verbatim.text +17 -0
  151. data/unittest/expected_creole/test_creole_verbatim_inline.html +6 -0
  152. data/unittest/expected_creole/test_creole_verbatim_inline.latex +8 -0
  153. data/unittest/expected_creole/test_creole_verbatim_inline_at_start.html +6 -0
  154. data/unittest/expected_creole/test_creole_verbatim_inline_at_start.latex +8 -0
  155. data/unittest/expected_privat/test_creole_test_document.html +6 -0
  156. data/unittest/{expected → expected_wiki}/test_wiki.html +0 -0
  157. data/unittest/{expected → expected_wiki}/test_wiki.latex +0 -0
  158. data/unittest/{expected → expected_wiki}/test_wiki.text +0 -0
  159. data/unittest/{expected → expected_wiki}/test_wiki.wiki +0 -0
  160. data/unittest/{expected → expected_wiki}/test_wiki_amazon.html +0 -0
  161. data/unittest/{expected → expected_wiki}/test_wiki_description.html +0 -0
  162. data/unittest/{expected → expected_wiki}/test_wiki_description.latex +0 -0
  163. data/unittest/{expected → expected_wiki}/test_wiki_description.text +0 -0
  164. data/unittest/{expected → expected_wiki}/test_wiki_description.wiki +0 -0
  165. data/unittest/expected_wiki/test_wiki_footnote.html +8 -0
  166. data/unittest/expected_wiki/test_wiki_footnote.latex +17 -0
  167. data/unittest/{expected → expected_wiki}/test_wiki_footnote.text +2 -4
  168. data/unittest/expected_wiki/test_wiki_footnote.wiki +10 -0
  169. data/unittest/expected_wiki/test_wiki_footnote_2.html +8 -0
  170. data/unittest/expected_wiki/test_wiki_footnote_groupid.html +21 -0
  171. data/unittest/{expected → expected_wiki}/test_wiki_html_code.html +0 -0
  172. data/unittest/{expected → expected_wiki}/test_wiki_html_code.latex +0 -0
  173. data/unittest/{expected → expected_wiki}/test_wiki_html_code.text +0 -0
  174. data/unittest/{expected → expected_wiki}/test_wiki_html_code.wiki +0 -0
  175. data/unittest/{expected → expected_wiki}/test_wiki_inline.html +0 -0
  176. data/unittest/{expected → expected_wiki}/test_wiki_inline.latex +0 -0
  177. data/unittest/{expected → expected_wiki}/test_wiki_inline.text +0 -0
  178. data/unittest/{expected → expected_wiki}/test_wiki_inline.wiki +0 -0
  179. data/unittest/{expected → expected_wiki}/test_wiki_label.html +0 -0
  180. data/unittest/{expected → expected_wiki}/test_wiki_link.html +0 -0
  181. data/unittest/{expected → expected_wiki}/test_wiki_link.latex +0 -0
  182. data/unittest/{expected → expected_wiki}/test_wiki_link.log +0 -0
  183. data/unittest/{expected → expected_wiki}/test_wiki_link.wiki +0 -0
  184. data/unittest/{expected → expected_wiki}/test_wiki_list_ol.html +0 -0
  185. data/unittest/{expected → expected_wiki}/test_wiki_list_ol.latex +0 -0
  186. data/unittest/{expected → expected_wiki}/test_wiki_list_ol.text +0 -0
  187. data/unittest/{expected → expected_wiki}/test_wiki_list_ol.wiki +0 -0
  188. data/unittest/{expected → expected_wiki}/test_wiki_list_ol_after_ul.html +0 -0
  189. data/unittest/{expected → expected_wiki}/test_wiki_list_ol_after_ul.latex +0 -0
  190. data/unittest/{expected → expected_wiki}/test_wiki_list_ol_after_ul.text +0 -0
  191. data/unittest/{expected → expected_wiki}/test_wiki_list_ol_after_ul.wiki +0 -0
  192. data/unittest/{expected → expected_wiki}/test_wiki_list_ol_ul.html +0 -0
  193. data/unittest/{expected → expected_wiki}/test_wiki_list_ol_ul.latex +0 -0
  194. data/unittest/{expected → expected_wiki}/test_wiki_list_ol_ul.text +0 -0
  195. data/unittest/{expected → expected_wiki}/test_wiki_list_ol_ul.wiki +0 -0
  196. data/unittest/{expected → expected_wiki}/test_wiki_list_ul.html +0 -0
  197. data/unittest/{expected → expected_wiki}/test_wiki_list_ul.latex +0 -0
  198. data/unittest/{expected → expected_wiki}/test_wiki_list_ul.text +0 -0
  199. data/unittest/{expected → expected_wiki}/test_wiki_list_ul.wiki +0 -0
  200. data/unittest/{expected → expected_wiki}/test_wiki_list_ul_too_much.html +0 -0
  201. data/unittest/{expected → expected_wiki}/test_wiki_list_ul_too_much.latex +0 -0
  202. data/unittest/{expected → expected_wiki}/test_wiki_list_ul_too_much.text +0 -0
  203. data/unittest/{expected → expected_wiki}/test_wiki_list_ul_too_much.wiki +0 -0
  204. data/unittest/{expected → expected_wiki}/test_wiki_picture.html +0 -0
  205. data/unittest/{expected → expected_wiki}/test_wiki_picture.latex +0 -0
  206. data/unittest/{expected → expected_wiki}/test_wiki_picture_thumb.html +0 -0
  207. data/unittest/{expected → expected_wiki}/test_wiki_tab1.html +0 -0
  208. data/unittest/{expected → expected_wiki}/test_wiki_tab1.latex +0 -0
  209. data/unittest/{expected → expected_wiki}/test_wiki_tab1.wiki +0 -0
  210. data/unittest/{expected → expected_wiki}/test_wiki_textformatting.html +0 -0
  211. data/unittest/{expected → expected_wiki}/test_wiki_textformatting.latex +0 -0
  212. data/unittest/{expected → expected_wiki}/test_wiki_textformatting.text +0 -0
  213. data/unittest/{expected → expected_wiki}/test_wiki_textformatting.wiki +0 -0
  214. data/unittest/{expected → expected_wiki}/test_wiki_toc.html +0 -0
  215. data/unittest/{expected → expected_wiki}/test_wiki_toc.latex +0 -0
  216. data/unittest/{expected → expected_wiki}/test_wiki_toc.text +0 -0
  217. data/unittest/{expected → expected_wiki}/test_wiki_toc.wiki +0 -0
  218. data/unittest/{expected → expected_wiki}/test_wiki_ul_multiple_line.html +0 -0
  219. data/unittest/{expected → expected_wiki}/test_wiki_ul_multiple_line.latex +0 -0
  220. data/unittest/{expected → expected_wiki}/test_wiki_ul_multiple_line.text +0 -0
  221. data/unittest/{expected → expected_wiki}/test_wiki_ul_multiple_line.wiki +0 -0
  222. data/unittest/test_docgenerator.rb +1 -2
  223. data/unittest/unittest_creole2doc.rb +1024 -0
  224. data/unittest/unittest_docgenerator.rb +17 -8
  225. data/unittest/unittest_wiki2doc.rb +92 -88
  226. data/unittest/unittest_yaml2pres.rb +336 -0
  227. metadata +202 -70
  228. data/unittest/expected/test_wiki_footnote.html +0 -8
  229. data/unittest/expected/test_wiki_footnote.latex +0 -15
  230. data/unittest/expected/test_wiki_footnote.wiki +0 -12
  231. data/unittest/expected/test_wiki_footnote_groupid.html +0 -21
@@ -0,0 +1,1091 @@
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.