# HG changeset patch # User Reimar Bauer # Date 1285704725 -7200 # Node ID 32811373ffa1b42c2caca4575b506fc0039a42a3 # Parent 7a83cc907f6855d1254a94ab731854b4554539a2 action.SlideShow: feature PrintableSinglePageSlideshows implemented * "print" control on the slideshow which shows all the slides on one page * the CSS makes sure that each h1 element appears after a page break This makes it easy to deliver PDF format slides (thanks to Paul Boddie for the patch) diff -r 7a83cc907f68 -r 32811373ffa1 MoinMoin/action/SlideShow.py --- a/MoinMoin/action/SlideShow.py Fri Jul 23 09:23:59 2010 -0700 +++ b/MoinMoin/action/SlideShow.py Tue Sep 28 22:12:05 2010 +0200 @@ -8,7 +8,8 @@ @copyright: 2005 Jim Clark, 2005 Nir Soffer, 2008 MoinMoin:ThomasWaldmann, - 2009 MoinMoin:ReimarBauer + 2009 MoinMoin:ReimarBauer, + 2010 Paul Boddie @license: GNU GPL, see COPYING for details. """ @@ -168,12 +169,16 @@ # Private ---------------------------------------------------------------- def setSlideNumber(self): - try: - slideNumber = int(self.request.values.get('n', 1)) - if not 1 <= slideNumber <= len(self.page): + slideNumber = self.request.values.get('n', 1) + if slideNumber == "all": + slideNumber = None + else: + try: + slideNumber = int(slideNumber) + if not 1 <= slideNumber <= len(self.page): + slideNumber = 1 + except ValueError: slideNumber = 1 - except ValueError: - slideNumber = 1 self.slideNumber = slideNumber def createParser(self, format, text): @@ -253,7 +258,7 @@ """ Return range of slides to display, current centered """ other = self.maxSlideLinks - 1 # other slides except current first, last = self.first_slide(), self.last_slide() - start = max(first, self.slideNumber - other / 2) + start = max(first, (self.slideNumber or 1) - other / 2) end = min(start + other, last) start = max(first, end - other) return range(start, end + 1) @@ -262,10 +267,10 @@ return 1 def next_slide(self): - return min(self.slideNumber + 1, self.last_slide()) + return min((self.slideNumber or 1) + 1, self.last_slide()) def previous_slide(self): - return max(self.slideNumber - 1, self.first_slide()) + return max((self.slideNumber or 1) - 1, self.first_slide()) def last_slide(self): return max(len(self.page), 1) @@ -279,7 +284,7 @@ else: return item - def item_language_attribtues(self): + def item_language_attributes(self): return self.languageAttributes(self.request.content_lang) def item_theme_url(self): @@ -290,11 +295,23 @@ def item_title(self): return wikiutil.escape(self.page.page_name) - def item_slide_title(self): - return wikiutil.escape(self.page.titleAt(self.slideNumber)) + def item_slides(self): + if self.slideNumber is None: + slides = [] + for n in xrange(0, len(self.page)): + slides.append(slide_template % { + 'slide_title' : self.item_slide_title(n + 1), + 'slide_body' : self.item_slide_body(n + 1) + }) + return ''.join(slides) + else: + return slide_template % self - def item_slide_body(self): - text = self.page.bodyAt(self.slideNumber) + def item_slide_title(self, number=None): + return wikiutil.escape(self.page.titleAt(number or self.slideNumber)) + + def item_slide_body(self, number=None): + text = self.page.bodyAt(number or self.slideNumber) format = self.page.pi['format'] parser = self.createParser(format, text) formatter = self.createFormatter('text_html') @@ -303,6 +320,14 @@ def item_navigation_language_attributes(self): return self.languageAttributes(self.request.lang) + def item_navigation_print(self): + _ = self.request.getText + text = _('Print') + if self.slideNumber is None: + return self.disabledLink(text) + else: + return self.linkToSlide('all', text, title=_('Print slide show')) + def item_navigation_edit(self): _ = self.request.getText text = _('Edit') @@ -365,7 +390,10 @@ return wikiutil.escape(self.request.getPragma('author', defval='')) def item_counter(self): - return "%d|%d" % (self.slideNumber, self.last_slide()) + if self.slideNumber is not None: + return "%d|%d" % (self.slideNumber, self.last_slide()) + else: + return '' # This is quite stupid template, but it cleans most of the code from # html. With smarter templates, there will be no html in the action code. @@ -373,7 +401,7 @@ - + @@ -421,14 +449,11 @@ -

%(slide_title)s

- -
- %(slide_body)s -
+ %(slides)s