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

Download

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

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] (2005-04-20 13:48:58, 123.6 KB) [[attachment:MhzTheMatrix.jpg]]
  • [get | view] (2005-04-06 22:35:22, 43.7 KB) [[attachment:SlideShow-03.tar.gz]]
  • [get | view] (2005-03-31 09:50:30, 28.3 KB) [[attachment:SlideShow.tar.gz]]
  • [get | view] (2010-08-22 18:23:37, 6.8 KB) [[attachment:patch-SlideShow-print-mode-and-fixes.diff]]
 All files | Selected Files: delete move to page copy to page

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