Class: PresentationMaker
- Inherits:
-
Wee::Component
- Object
- Wee::Component
- PresentationMaker
- Defined in:
- lib/wee-pm/presentation_maker.rb
Constant Summary collapse
- AREA_COLS =
90
- DEFAULT_CONVERTER =
HtmlConverter
Instance Method Summary collapse
- #add_new_slide_after ⇒ Object
-
#add_new_slide_before ⇒ Object
————————————————————————– Actions: Edit ————————————————————————–.
- #delete_current_slide ⇒ Object
-
#initialize(filename) ⇒ PresentationMaker
constructor
A new instance of PresentationMaker.
- #move_current_slide_down ⇒ Object
- #move_current_slide_up ⇒ Object
- #next_slide_or_overlay ⇒ Object
- #prev_slide_or_overlay ⇒ Object
-
#render ⇒ Object
————————————————————————– Rendering ————————————————————————–.
- #render_body ⇒ Object
- #render_navi ⇒ Object
- #render_outline ⇒ Object
- #render_slide ⇒ Object
- #render_slide_edit ⇒ Object
- #render_title_edit ⇒ Object
- #save_presentation ⇒ Object
- #select_slide(index) ⇒ Object
- #show_all_overlays ⇒ Object
-
#show_title_page ⇒ Object
————————————————————————– Actions: Show ————————————————————————–.
- #toggle_mode ⇒ Object
- #toggle_step_mode ⇒ Object
Constructor Details
#initialize(filename) ⇒ PresentationMaker
Returns a new instance of PresentationMaker.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/wee-pm/presentation_maker.rb', line 9 def initialize(filename) super() @filename = filename @presentation = if File.exists? @filename Presentation.from_string(File.read(@filename)) else Presentation.new end if @presentation..empty? @presentation. << Slide.new end @presentation..each do |sl| sl.converter = DEFAULT_CONVERTER end @edit_mode = false @show_title_page = true end |
Instance Method Details
#add_new_slide_after ⇒ Object
104 105 106 107 |
# File 'lib/wee-pm/presentation_maker.rb', line 104 def += 1 end |
#add_new_slide_before ⇒ Object
Actions: Edit
95 96 97 98 99 100 101 102 |
# File 'lib/wee-pm/presentation_maker.rb', line 95 def index = @presentation.[index,0] = Slide.new {|s| s.title = .title s.converter = DEFAULT_CONVERTER } (index) end |
#delete_current_slide ⇒ Object
109 110 111 112 113 |
# File 'lib/wee-pm/presentation_maker.rb', line 109 def return if @presentation..size <= 1 @presentation..delete_at() ([, @presentation..size-1].min) end |
#move_current_slide_down ⇒ Object
123 124 125 126 127 128 129 |
# File 'lib/wee-pm/presentation_maker.rb', line 123 def sl = @presentation. ci = return if ci >= sl.size-1 sl[ci+1], sl[ci] = sl[ci], sl[ci+1] (ci+1) end |
#move_current_slide_up ⇒ Object
115 116 117 118 119 120 121 |
# File 'lib/wee-pm/presentation_maker.rb', line 115 def sl = @presentation. ci = return if ci <= 0 sl[ci-1], sl[ci] = sl[ci], sl[ci-1] (ci-1) end |
#next_slide_or_overlay ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/wee-pm/presentation_maker.rb', line 54 def if @show_title_page @show_title_page = false (0) elsif >= . if < @presentation..size-1 ( + 1) else # TODO: show End-Box end else += 1 end unless @step_mode = . end end |
#prev_slide_or_overlay ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/wee-pm/presentation_maker.rb', line 73 def # we are already on the first page -> do nothing! return if @show_title_page if @step_mode -= 1 return if >= 0 end -= 1 if < 0 show_title_page() else () = . end end |
#render ⇒ Object
Rendering
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/wee-pm/presentation_maker.rb', line 147 def render r.html do r.head do r.title("Presentation Maker #{ @filename }") r.style(@presentation.style) if r.style(.style) end end body = r.body #if not @edit_mode # body.onclick(javascript_action {||next_slide_or_overlay}) #end body.with do if not @edit_mode page_down = r.url_for_callback(proc { () }) page_up = r.url_for_callback(proc { () }) toggle_mode_url = r.url_for_callback(proc { toggle_mode() }) toggle_step_mode_url = r.url_for_callback(proc { toggle_step_mode() }) r << %{ <script> document.onkeypress = function(ev) { switch (ev.keyCode) { case 101: /* 'e' */ document.location.href='#{ toggle_mode_url }'; return false; case 115: /* 's' */ document.location.href='#{ toggle_step_mode_url }'; return false; case 34: /* page down */ document.location.href='#{ page_down }'; return false; case 33: /* page up */ document.location.href='#{ page_up }'; return false; }; return true; }; </script> } end r.span.id("navibutton").with do r.anchor.callback { toggle_mode }.with do r.space(2) end end render_body end end end |
#render_body ⇒ Object
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 |
# File 'lib/wee-pm/presentation_maker.rb', line 368 def render_body if not @edit_mode else r.table do r.table_row do r.table_data.valign('top').with do render_navi end r.table_data.valign('top').with do end end end end end |
#render_navi ⇒ Object
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/wee-pm/presentation_maker.rb', line 235 def render_navi r.div.id('naviframe').with do r.anchor.callback{toggle_mode}.with { r.text('Hide') } r.text(" | ") r.anchor.callback { toggle_step_mode }.with do r.text('Change into Full-Slide mode') if @step_mode r.text('Change into Step mode') if !@step_mode end r.text(" | ") r.anchor.callback{save_presentation}.with { r.text('Save presentation') } r.hr r.text("Presentation: ") if @show_title_page r.text(@presentation.title) else r.anchor.callback{show_title_page}.with { r.text(@presentation.title) } end r.break render_outline r.hr if @show_title_page render_title_edit else end end end |
#render_outline ⇒ Object
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 |
# File 'lib/wee-pm/presentation_maker.rb', line 340 def render_outline r.ol { @presentation..each_with_index do |, i| r.li do if i == r.bold .title r.break (0 .. .).each do |j| if j == r.text "#{ j+1 }" else r.anchor.callback { = j }.with { r.text "#{ j+1 }" } end r.space end else r.anchor.callback { (i); () }.with { r.text .title } end end end } end |
#render_slide ⇒ Object
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'lib/wee-pm/presentation_maker.rb', line 212 def if @show_title_page r.div.id('titlepage').css_class('slide').with do r.h1.onclick(javascript_action {||}). with(@presentation.title) r.div.id('author_email').with do r.text @presentation. r.text(" (") r.anchor.href("mailto:#{ @presentation.email }").with(@presentation.email) r.text(")") end end elsif r.div.id('slides').css_class('slide'). with do r.h1.onclick(javascript_action {||}). with(.title) .render_on(r, ) end end end |
#render_slide_edit ⇒ Object
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 |
# File 'lib/wee-pm/presentation_maker.rb', line 296 def r.ul do r.li { r.text('Add new slide ') r.anchor.callback{}.with { r.text('before') }; r.text(' / ') r.anchor.callback{}.with { r.text('after') }; r.space r.text('current') } r.li { r.text('Current slide: ') r.anchor.callback{}.with { r.text('move up') }; r.text(' / ') r.anchor.callback{}.with { r.text('move down') }; r.text(' / ') r.anchor.callback{}.with { r.text('delete') } } end r.hr r.paragraph r.form do r..value('Update').callback { = . } r.space r.text "Title: " r.text_input.size(35).callback {|c| .title = c.to_s}.value(.title) r.paragraph r.text_area.cols(AREA_COLS).rows(30).callback {|c| .content = c.to_s}.with(.content) r.paragraph r.text "Annotations:" r.break r.text_area.cols(AREA_COLS).rows(10).callback {|c| .annotations = c.to_s}. with(.annotations) r.paragraph r.text "Style:" r.break r.text_area.cols(AREA_COLS).rows(10).callback {|c| .style = c.to_s}. with(.style) end end |
#render_title_edit ⇒ Object
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
# File 'lib/wee-pm/presentation_maker.rb', line 270 def render_title_edit r.form do r..value('Update') r.table.with do %w(title author email).each do |f| r.table_row.with do r.table_data("#{ f.capitalize }: ") r.table_data.with { r.text_input.size(35). callback {|c| @presentation.send("#{ f }=", c.to_s) }. value(@presentation.send("#{ f }")) } end end end # table r.paragraph r.text("Style:") r.break r.text_area.cols(AREA_COLS).rows(10).callback {|c| @presentation.style = c.to_s}. with(@presentation.style) end end |
#save_presentation ⇒ Object
131 132 133 |
# File 'lib/wee-pm/presentation_maker.rb', line 131 def save_presentation @presentation.save(@filename) end |
#select_slide(index) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/wee-pm/presentation_maker.rb', line 42 def (index) @show_title_page = false = index = @presentation.[] = 0 end |
#show_all_overlays ⇒ Object
50 51 52 |
# File 'lib/wee-pm/presentation_maker.rb', line 50 def = . end |
#show_title_page ⇒ Object
Actions: Show
37 38 39 40 |
# File 'lib/wee-pm/presentation_maker.rb', line 37 def show_title_page @show_title_page = true = = = nil end |
#toggle_mode ⇒ Object
135 136 137 |
# File 'lib/wee-pm/presentation_maker.rb', line 135 def toggle_mode @edit_mode = !@edit_mode end |
#toggle_step_mode ⇒ Object
139 140 141 |
# File 'lib/wee-pm/presentation_maker.rb', line 139 def toggle_step_mode @step_mode = !@step_mode end |