Attachment 'patch-SlideShow-print-mode.diff'

Download

   1 diff -r fd9387911e26 -r 0a1aaf70fd91 MoinMoin/action/SlideShow.py
   2 --- a/MoinMoin/action/SlideShow.py	Mon Sep 27 19:43:20 2010 +0200
   3 +++ b/MoinMoin/action/SlideShow.py	Mon Sep 27 19:45:27 2010 +0200
   4 @@ -169,12 +169,16 @@
   5      # Private ----------------------------------------------------------------
   6  
   7      def setSlideNumber(self):
   8 -        try:
   9 -            slideNumber = int(self.request.values.get('n', 1))
  10 -            if not 1 <= slideNumber <= len(self.page):
  11 +        slideNumber = self.request.values.get('n', 1)
  12 +        if slideNumber == "all":
  13 +            slideNumber = None
  14 +        else:
  15 +            try:
  16 +                slideNumber = int(slideNumber)
  17 +                if not 1 <= slideNumber <= len(self.page):
  18 +                    slideNumber = 1
  19 +            except ValueError:
  20                  slideNumber = 1
  21 -        except ValueError:
  22 -            slideNumber = 1
  23          self.slideNumber = slideNumber
  24  
  25      def createParser(self, format, text):
  26 @@ -254,7 +258,7 @@
  27          """ Return range of slides to display, current centered """
  28          other = self.maxSlideLinks - 1 # other slides except current
  29          first, last = self.first_slide(), self.last_slide()
  30 -        start = max(first, self.slideNumber - other / 2)
  31 +        start = max(first, (self.slideNumber or 1) - other / 2)
  32          end = min(start + other, last)
  33          start = max(first, end - other)
  34          return range(start, end + 1)
  35 @@ -263,10 +267,10 @@
  36          return 1
  37  
  38      def next_slide(self):
  39 -        return min(self.slideNumber + 1, self.last_slide())
  40 +        return min((self.slideNumber or 1) + 1, self.last_slide())
  41  
  42      def previous_slide(self):
  43 -        return max(self.slideNumber - 1, self.first_slide())
  44 +        return max((self.slideNumber or 1) - 1, self.first_slide())
  45  
  46      def last_slide(self):
  47          return max(len(self.page), 1)
  48 @@ -280,7 +284,7 @@
  49          else:
  50              return item
  51  
  52 -    def item_language_attribtues(self):
  53 +    def item_language_attributes(self):
  54          return self.languageAttributes(self.request.content_lang)
  55  
  56      def item_theme_url(self):
  57 @@ -291,11 +295,23 @@
  58      def item_title(self):
  59          return wikiutil.escape(self.page.page_name)
  60  
  61 -    def item_slide_title(self):
  62 -        return wikiutil.escape(self.page.titleAt(self.slideNumber))
  63 +    def item_slides(self):
  64 +        if self.slideNumber is None:
  65 +            slides = []
  66 +            for n in xrange(0, len(self.page)):
  67 +                slides.append(slide_template % {
  68 +                    'slide_title' : self.item_slide_title(n + 1),
  69 +                    'slide_body' : self.item_slide_body(n + 1)
  70 +                    })
  71 +            return ''.join(slides)
  72 +        else:
  73 +            return slide_template % self
  74  
  75 -    def item_slide_body(self):
  76 -        text = self.page.bodyAt(self.slideNumber)
  77 +    def item_slide_title(self, number=None):
  78 +        return wikiutil.escape(self.page.titleAt(number or self.slideNumber))
  79 +
  80 +    def item_slide_body(self, number=None):
  81 +        text = self.page.bodyAt(number or self.slideNumber)
  82          format = self.page.pi['format']
  83          parser = self.createParser(format, text)
  84          formatter = self.createFormatter('text_html')
  85 @@ -303,6 +319,14 @@
  86  
  87      def item_navigation_language_attributes(self):
  88          return self.languageAttributes(self.request.lang)
  89 +
  90 +    def item_navigation_print(self):
  91 +        _ = self.request.getText
  92 +        text = _('Print')
  93 +        if self.slideNumber is None:
  94 +            return self.disabledLink(text)
  95 +        else:
  96 +            return self.linkToSlide('all', text, title=_('Print slide show'))
  97  
  98      def item_navigation_edit(self):
  99          _ = self.request.getText
 100 @@ -366,7 +390,10 @@
 101          return wikiutil.escape(self.request.getPragma('author', defval=''))
 102  
 103      def item_counter(self):
 104 -        return "%d|%d" % (self.slideNumber, self.last_slide())
 105 +        if self.slideNumber is not None:
 106 +            return "%d|%d" % (self.slideNumber, self.last_slide())
 107 +        else:
 108 +            return ''
 109  
 110  # This is quite stupid template, but it cleans most of the code from
 111  # html. With smarter templates, there will be no html in the action code.
 112 @@ -374,7 +401,7 @@
 113  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
 114      "http://www.w3.org/TR/html4/strict.dtd">
 115  
 116 -<html%(language_attribtues)s>
 117 +<html%(language_attributes)s>
 118  <head>
 119      <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
 120      <meta name="robots" content="noindex,nofollow">
 121 @@ -422,14 +449,11 @@
 122  </head>
 123  
 124  <body>
 125 -    <h1>%(slide_title)s</h1>
 126 -
 127 -    <div id="content">
 128 -        %(slide_body)s
 129 -    </div>
 130 +    %(slides)s
 131  
 132      <div id="navigation"%(navigation_language_attributes)s>
 133          <ul>
 134 +            <li>%(navigation_print)s</li>
 135              <li>%(navigation_edit)s</li>
 136              <li>%(navigation_quit)s</li>
 137              <li>%(navigation_start)s</li>
 138 @@ -440,9 +464,11 @@
 139          </ul>
 140      </div>
 141      <div id="footer">
 142 -    <ul id="date">%(date)s</ul>
 143 -    <ul id="author">%(author)s</ul>
 144 -    <ul id="counter">%(counter)s</ul>
 145 +    <ul>
 146 +    <li id="date">%(date)s</li>
 147 +    <li id="author">%(author)s</li>
 148 +    <li id="counter">%(counter)s</li>
 149 +    </ul>
 150      </div>
 151  <!--
 152      <p><a href="http://validator.w3.org/check?uri=referer">
 153 @@ -453,6 +479,13 @@
 154  </html>
 155  """
 156  
 157 +slide_template = """
 158 +    <h1>%(slide_title)s</h1>
 159 +
 160 +    <div id="content">
 161 +        %(slide_body)s
 162 +    </div>
 163 +"""
 164  
 165  def execute(pagename, request):
 166      """ Glue to current plugin system """
 167 diff -r fd9387911e26 -r 0a1aaf70fd91 MoinMoin/web/static/htdocs/modernized/css/SlideShow.css
 168 --- a/MoinMoin/web/static/htdocs/modernized/css/SlideShow.css	Mon Sep 27 19:43:20 2010 +0200
 169 +++ b/MoinMoin/web/static/htdocs/modernized/css/SlideShow.css	Mon Sep 27 19:45:27 2010 +0200
 170 @@ -4,6 +4,7 @@
 171   * Copy SlideShow.css to your theme's css/ directory.
 172   *
 173   * copyright: 2008 Thomas Waldmann
 174 + * copyright: 2010 Paul Boddie
 175   * license: GNU GPL, see COPYING for details
 176   */
 177  
 178 @@ -18,7 +19,7 @@
 179  
 180  body {
 181      margin: 1em;
 182 -    padding: 20px;
 183 +    padding-top: 20px;
 184  }
 185  
 186  /* Slide heading */
 187 @@ -176,6 +177,20 @@
 188  
 189  @media print {
 190      #navigation {
 191 -    display: none;
 192 +        display: none;
 193 +    }
 194 +
 195 +    h1 {
 196 +        page-break-before: always; /* show slides on separate pages */
 197 +    }
 198 +
 199 +    pre {
 200 +        white-space: pre-wrap;
 201      }
 202  }
 203 +
 204 +/* Make tables more presentable. */
 205 +
 206 +td p {
 207 +    margin: 0.5em;
 208 +}
 209 

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2010-09-26 23:24:37, 6.8 KB) [[attachment:patch-SlideShow-print-mode-and-fixes-1.9.diff]]
  • [get | view] (2010-08-27 17:56:28, 6.8 KB) [[attachment:patch-SlideShow-print-mode-and-fixes.diff]]
  • [get | view] (2010-09-27 17:49:44, 6.3 KB) [[attachment:patch-SlideShow-print-mode.diff]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.