annotate data/plugin/action/SlideShow.py @ 654:8c828d7b6cd4 tip

PDFList: check for pyPdf.utils.PdfReadError
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Wed, 07 Dec 2016 14:27:25 +0100
parents 127da830be6c
children
rev   line source
314
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
1 # -*- coding: utf-8 -*-
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
2 """
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
3 MoinMoin - SlideShow action
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
4
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
5 Treat a wiki page as a set of slides. Displays a single slide at a
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
6 time, along with a navigation aid.
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
7
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
8 A slide show page uses headings level 1 to define slides::
406
d17d73264ec5 action.SlideShow: Layout changed to show the moin logo on top right of each slide and on bottom date, author and count of slides.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 314
diff changeset
9 #pragma date Sept 04 2009
d17d73264ec5 action.SlideShow: Layout changed to show the moin logo on top right of each slide and on bottom date, author and count of slides.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 314
diff changeset
10 #pragma Your Name
314
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
11
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
12 General introduction or comments
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
13
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
14 = Slide 1 =
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
15 Slide 1 contents
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
16
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
17 = Slide 2 =
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
18 Slide 2 contents ...
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
19
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
20 Selecting SlideShow from the "More Actions" menu will display the
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
21 first slide with navigation links at the top of the screen.
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
22 Move between slides by clicking the links or with the arrow keys.
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
23
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
24 Installation:
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
25 * copy SlideShow.py to data/plugin/action/ of your wiki
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
26 * copy SlideShow.css to your theme's css/ directory
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
27 * restart moin
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
28
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
29 @copyright: 2005 Jim Clark,
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
30 2005 Nir Soffer,
406
d17d73264ec5 action.SlideShow: Layout changed to show the moin logo on top right of each slide and on bottom date, author and count of slides.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 314
diff changeset
31 2008 MoinMoin:ThomasWaldmann,
653
127da830be6c updated copyright
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 520
diff changeset
32 2009-2016 MoinMoin:ReimarBauer
314
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
33 @license: GNU GPL, see COPYING for details.
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
34 """
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
35
406
d17d73264ec5 action.SlideShow: Layout changed to show the moin logo on top right of each slide and on bottom date, author and count of slides.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 314
diff changeset
36 import re, time
314
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
37
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
38 from MoinMoin import wikiutil, i18n, error
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
39 from MoinMoin.Page import Page
520
a21974d68624 action.SlideShow: added a simple release check, because this plugin requires 1.8
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 410
diff changeset
40 from MoinMoin.version import release
314
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
41
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
42 Dependencies = ['language']
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
43
520
a21974d68624 action.SlideShow: added a simple release check, because this plugin requires 1.8
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 410
diff changeset
44 actname = __name__.split('.')[-1]
314
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
45
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
46 class Error(error.Error):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
47 """ Raised for errors in this module """
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
48
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
49 # This could be delivered in a separate plugin, but
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
50 # it is more convenient to have everything in one module.
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
51
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
52 class WikiSlideParser(object):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
53 """ Parse slides using wiki format
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
54
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
55 Typical usage::
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
56 for title, start, end in WikiSlideParser().parse(text):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
57 slides.append((title, start, end))
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
58
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
59 If you want to override this parser, you can add 'slideshow_wiki'
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
60 parser plugin, that provides a SlideParser class.
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
61 """
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
62 _heading_pattern = re.compile(r"""
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
63 # TODO: check, mhz found bug here
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
64 (?P<skip>{{{(?:.*\n)+?}}}) |
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
65 # Match headings level 1
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
66 (?P<heading>^=\s(?P<text>.*)\s=$\n?)
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
67 """, re.MULTILINE | re.UNICODE | re.VERBOSE)
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
68
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
69 def parse(self, text):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
70 """ Parse slide data in text
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
71
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
72 Wiki slides are defined by the headings, ignoring the text
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
73 before the first heading. This parser finds all headings,
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
74 skipping headings in preformatted code areas.
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
75
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
76 Returns an iterator over slide data. For each slide, a tuple
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
77 (title, bodyStart, bodyEnd) is returned. bodyStart and bodyEnd
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
78 are indexes into text.
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
79 """
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
80 matches = [match for match in self._heading_pattern.finditer(text)
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
81 if match.start('skip') == -1]
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
82
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
83 for i in range(len(matches)):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
84 title = matches[i].group('text').strip()
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
85 bodyStart = matches[i].end('heading')
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
86 try:
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
87 bodyEnd = matches[i + 1].start('heading')
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
88 except IndexError:
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
89 bodyEnd = len(text)
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
90 yield title, bodyStart, bodyEnd
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
91
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
92
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
93 class SlidePage(Page):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
94 """ A wiki page containing a slideshow
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
95
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
96 The slides are parsed according to the page #format xxx processing
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
97 instruction. This module implements only a wiki format slide parser.
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
98
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
99 To support other formats like rst, add a 'slideshow_rst' parser
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
100 plugin, providing SlideParser class, implementing the SlideParser
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
101 protocol. See WikiSlideParser for details.
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
102 """
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
103 defaultFormat = 'wiki'
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
104 defaultParser = WikiSlideParser
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
105
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
106 def __init__(self, request, name, **keywords):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
107 Page.__init__(self, request, name, **keywords)
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
108 self._slideIndex = None
406
d17d73264ec5 action.SlideShow: Layout changed to show the moin logo on top right of each slide and on bottom date, author and count of slides.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 314
diff changeset
109 self.counter = ''
314
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
110
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
111 def __len__(self):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
112 """ Return the slide count """
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
113 return len(self.slideIndex())
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
114
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
115 def isEmpty(self):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
116 return len(self) == 0
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
117
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
118 # Slide accessing methods map 1 based slides to 0 based index.
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
119
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
120 def titleAt(self, number):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
121 """ Return the title of slide number """
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
122 return self.slideIndex()[number - 1][0]
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
123
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
124 def bodyAt(self, number):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
125 """ Return the body of slide number """
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
126 start, end = self.slideIndex()[number - 1][1:]
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
127 return self.get_raw_body()[start:end]
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
128
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
129 # Private ----------------------------------------------------------------
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
130
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
131 def slideIndex(self):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
132 if self._slideIndex is None:
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
133 self.parseSlides()
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
134 return self._slideIndex
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
135
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
136 def parseSlides(self):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
137 body = self.get_raw_body()
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
138 self._slideIndex = []
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
139 parser = self.createSlideParser()
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
140 for title, bodyStart, bodyEnd in parser.parse(body):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
141 self._slideIndex.append((title, bodyStart, bodyEnd))
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
142
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
143 def createSlideParser(self):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
144 """ Import plugin and return parser class
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
145
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
146 If plugin is not found, and format is not defaultFormat, raise an error.
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
147 For defaultFormat, use builtin defaultParser in this module.
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
148 """
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
149 format = self.pi['format']
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
150 plugin = 'slideshow_' + format
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
151 try:
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
152 Parser = wikiutil.importPlugin(self.request.cfg, 'parser', plugin, 'SlideParser')
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
153 except wikiutil.PluginMissingError:
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
154 if format != self.defaultFormat:
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
155 raise Error('SlideShow does not support %s format.' % format)
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
156 Parser = self.defaultParser
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
157 return Parser()
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
158
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
159
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
160 class SlideshowAction:
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
161
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
162 name = 'SlideShow'
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
163 maxSlideLinks = 15
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
164
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
165 def __init__(self, request, pagename, template):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
166 self.request = request
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
167 self.page = SlidePage(self.request, pagename)
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
168 self.template = template
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
169
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
170 # Cache values used many times
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
171 self.pageURL = self.page.url(request)
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
172
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
173 def execute(self):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
174 _ = self.request.getText
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
175 try:
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
176 self.setSlideNumber()
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
177 self.request.emit_http_headers()
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
178 language = self.page.pi['language']
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
179 self.request.setContentLanguage(language)
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
180 self.request.write(self.template % self)
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
181 except Error, err:
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
182 self.page.send_page(self.request, msg=unicode(err))
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
183
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
184 # Private ----------------------------------------------------------------
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
185
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
186 def setSlideNumber(self):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
187 try:
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
188 slideNumber = int(self.request.form.get('n', [1])[0])
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
189 if not 1 <= slideNumber <= len(self.page):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
190 slideNumber = 1
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
191 except ValueError:
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
192 slideNumber = 1
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
193 self.slideNumber = slideNumber
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
194
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
195 def createParser(self, format, text):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
196 if format == "wiki":
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
197 format = 'text_moin_wiki'
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
198 try:
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
199 Parser = wikiutil.importPlugin(self.request.cfg, 'parser', format,
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
200 'Parser')
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
201 except wikiutil.PluginMissingError:
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
202 from MoinMoin.parser.text import Parser
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
203 parser = Parser(text, self.request)
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
204 return parser
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
205
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
206 def createFormatter(self, format):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
207 try:
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
208 Formatter = wikiutil.importPlugin(self.request.cfg, 'formatter',
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
209 format, 'Formatter')
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
210 except wikiutil.PluginMissingError:
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
211 from MoinMoin.formatter.text_plain import Formatter
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
212
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
213 formatter = Formatter(self.request)
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
214 self.request.formatter = formatter
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
215 formatter.page = self.page
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
216 return formatter
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
217
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
218 def languageAttributes(self, lang):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
219 return ' lang="%s" dir="%s"' % (lang, i18n.getDirection(lang))
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
220
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
221 def linkToPage(self, text, query='', **attributes):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
222 """ Return a link to current page """
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
223 if query:
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
224 url = '%s?%s' % (self.pageURL, query)
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
225 else:
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
226 url = self.pageURL
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
227 return self.formatLink(url, text, **attributes)
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
228
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
229 def linkToSlide(self, number, text, **attributes):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
230 """ Return a link to current page """
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
231 if number == self.slideNumber:
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
232 return self.disabledLink(text, **attributes)
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
233
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
234 url = '%s?action=%s&n=%s' % (self.pageURL, self.name, number)
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
235 return self.formatLink(url, text, **attributes)
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
236
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
237 def disabledLink(self, text, **attributes):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
238 return '<span%s>%s</span>' % (self.formatAttributes(attributes), text)
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
239
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
240 def formatLink(self, url, text, **attributes):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
241 return '<a href="%(url)s"%(attributes)s>%(text)s</a>' % {
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
242 'url': wikiutil.escape(url),
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
243 'attributes': self.formatAttributes(attributes),
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
244 'text': wikiutil.escape(text),
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
245 }
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
246
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
247 def formatAttributes(self, attributes):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
248 """ Return formatted attributes string """
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
249 formattedPairs = [' %s="%s"' % (k, v) for k, v in attributes.items()]
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
250 return ''.join(formattedPairs)
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
251
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
252 def adaptToLanguage(self, direction):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
253 # In RTL, directional items should be switched
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
254 if i18n.getDirection(self.request.lang) == 'rtl':
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
255 return not direction
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
256 return direction
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
257
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
258 def forwardIcon(self, forward=True):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
259 return [u'\u2190', u'\u2192'][self.adaptToLanguage(forward)]
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
260
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
261 def backIcon(self):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
262 return self.forwardIcon(False)
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
263
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
264 # Key codes constants
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
265 rightArrowKey = 39
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
266 leftArrowKey = 37
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
267
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
268 def slideLinksRange(self):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
269 """ Return range of slides to display, current centered """
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
270 other = self.maxSlideLinks - 1 # other slides except current
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
271 first, last = self.first_slide(), self.last_slide()
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
272 start = max(first, self.slideNumber - other / 2)
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
273 end = min(start + other, last)
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
274 start = max(first, end - other)
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
275 return range(start, end + 1)
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
276
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
277 def first_slide(self):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
278 return 1
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
279
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
280 def next_slide(self):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
281 return min(self.slideNumber + 1, self.last_slide())
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
282
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
283 def previous_slide(self):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
284 return max(self.slideNumber - 1, self.first_slide())
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
285
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
286 def last_slide(self):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
287 return max(len(self.page), 1)
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
288
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
289 # Replacing methods ------------------------------------------------------
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
290
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
291 def __getitem__(self, name):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
292 item = getattr(self, 'item_' + name)
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
293 if callable(item):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
294 return item()
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
295 else:
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
296 return item
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
297
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
298 def item_language_attribtues(self):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
299 return self.languageAttributes(self.request.content_lang)
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
300
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
301 def item_theme_url(self):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
302 return '%s/%s' % (self.request.cfg.url_prefix_static, self.request.theme.name)
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
303
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
304 item_action_name = name
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
305
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
306 def item_title(self):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
307 return wikiutil.escape(self.page.page_name)
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
308
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
309 def item_slide_title(self):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
310 return wikiutil.escape(self.page.titleAt(self.slideNumber))
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
311
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
312 def item_slide_body(self):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
313 text = self.page.bodyAt(self.slideNumber)
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
314 format = self.page.pi['format']
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
315 parser = self.createParser(format, text)
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
316 formatter = self.createFormatter('text_html')
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
317 return self.request.redirectedOutput(parser.format, formatter)
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
318
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
319 def item_navigation_language_attributes(self):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
320 return self.languageAttributes(self.request.lang)
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
321
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
322 def item_navigation_edit(self):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
323 _ = self.request.getText
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
324 text = _('Edit')
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
325 if self.request.user.may.write(self.page.page_name):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
326 return self.linkToPage(text, 'action=edit', title=_('Edit slide show'))
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
327 return self.disabledLink(text, title=_("you may need to login to edit this page"))
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
328
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
329 def item_navigation_quit(self):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
330 _ = self.request.getText
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
331 return self.linkToPage(_('Quit'), title=_('Quit slide show'))
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
332
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
333 def item_navigation_start(self):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
334 _ = self.request.getText
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
335 number = self.first_slide()
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
336 return self.linkToSlide(number, '|', title=_('Show first slide (up arrow)'))
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
337
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
338 def item_navigation_end(self):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
339 _ = self.request.getText
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
340 number = self.last_slide()
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
341 return self.linkToSlide(number, '|', title=_('Show last slide (down arrow)'))
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
342
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
343 def item_navigation_back(self):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
344 _ = self.request.getText
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
345 number = self.previous_slide()
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
346 return self.linkToSlide(number, text=self.backIcon(), title=_('Show previous slide (back arrow)'))
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
347
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
348 def item_navigation_forward(self):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
349 _ = self.request.getText
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
350 number = self.next_slide()
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
351 return self.linkToSlide(number, self.forwardIcon(), title=_('Show next slide (forward arrow)'))
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
352
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
353 def item_forward_key(self, forward=True):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
354 return (self.leftArrowKey, self.rightArrowKey)[self.adaptToLanguage(forward)]
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
355
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
356 def item_back_key(self):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
357 return self.item_forward_key(False)
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
358
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
359 def item_navigation_slides(self):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
360 items = []
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
361 for i in self.slideLinksRange():
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
362 attributes = {'title': self.page.titleAt(i)}
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
363 if i == self.slideNumber:
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
364 attributes = {'class': 'current'}
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
365 items.append(self.linkToSlide(i, i, **attributes))
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
366 items = ['<li>%s</li>' % item for item in items]
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
367 return '\n'.join(items)
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
368
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
369 def item_slide_link_base(self):
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
370 return wikiutil.escape(self.pageURL) + '?action=%s&n=' % self.name
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
371
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
372 item_next_slide = next_slide
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
373 item_previous_slide = previous_slide
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
374 item_first_slide = first_slide
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
375 item_last_slide = last_slide
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
376
406
d17d73264ec5 action.SlideShow: Layout changed to show the moin logo on top right of each slide and on bottom date, author and count of slides.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 314
diff changeset
377 def item_date(self):
410
3989be8db422 action SlideShow: pragma default changed to empty string
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 409
diff changeset
378 return wikiutil.escape(self.request.getPragma('date', defval=''))
406
d17d73264ec5 action.SlideShow: Layout changed to show the moin logo on top right of each slide and on bottom date, author and count of slides.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 314
diff changeset
379
d17d73264ec5 action.SlideShow: Layout changed to show the moin logo on top right of each slide and on bottom date, author and count of slides.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 314
diff changeset
380 def item_author(self):
410
3989be8db422 action SlideShow: pragma default changed to empty string
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 409
diff changeset
381 return wikiutil.escape(self.request.getPragma('author', defval=''))
406
d17d73264ec5 action.SlideShow: Layout changed to show the moin logo on top right of each slide and on bottom date, author and count of slides.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 314
diff changeset
382
d17d73264ec5 action.SlideShow: Layout changed to show the moin logo on top right of each slide and on bottom date, author and count of slides.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 314
diff changeset
383 def item_counter(self):
409
bb5e662eca6d action SlideShow: fixed max Slide number
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 406
diff changeset
384 return "%d|%d" % (self.slideNumber, self.last_slide())
406
d17d73264ec5 action.SlideShow: Layout changed to show the moin logo on top right of each slide and on bottom date, author and count of slides.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 314
diff changeset
385
314
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
386 # This is quite stupid template, but it cleans most of the code from
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
387 # html. With smarter templates, there will be no html in the action code.
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
388 template = """
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
389 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
390 "http://www.w3.org/TR/html4/strict.dtd">
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
391
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
392 <html%(language_attribtues)s>
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
393 <head>
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
394 <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
395 <meta name="robots" content="noindex,nofollow">
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
396 <title>%(title)s</title>
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
397
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
398 <script type="text/javascript">
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
399 function getKey(e) {
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
400 // Support multiple browsers stupidity
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
401 var key;
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
402 if (e == null) {
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
403 // IE
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
404 key = event.keyCode;
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
405 } else {
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
406 // Standards compliant
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
407 if (e.altKey || e.ctrlKey) {
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
408 return null;
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
409 }
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
410 key = e.which;
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
411 }
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
412 return key;
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
413 }
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
414
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
415 function go(slide) {
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
416 window.location="%(slide_link_base)s" + slide;
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
417 }
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
418
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
419 function onkeydown(e) {
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
420 switch(getKey(e)) {
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
421 // presenter maybe rather wants to use up/down for scrolling content!
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
422 // case 38: go('%(first_slide)s'); break; // up arrow
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
423 // case 40: go('%(last_slide)s'); break; // down arrow
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
424 case %(forward_key)s: go('%(next_slide)s'); break;
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
425 case %(back_key)s: go('%(previous_slide)s'); break;
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
426 default: return true; // pass event to browser
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
427 }
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
428 // Return false to consume the event
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
429 return false;
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
430 }
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
431
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
432 document.onkeydown = onkeydown
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
433 </script>
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
434
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
435 <link rel="stylesheet" type="text/css" charset="utf-8" media="all"
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
436 href="%(theme_url)s/css/%(action_name)s.css">
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
437 </head>
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
438
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
439 <body>
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
440 <h1>%(slide_title)s</h1>
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
441
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
442 <div id="content">
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
443 %(slide_body)s
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
444 </div>
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
445
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
446 <div id="navigation"%(navigation_language_attributes)s>
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
447 <ul>
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
448 <li>%(navigation_edit)s</li>
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
449 <li>%(navigation_quit)s</li>
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
450 <li>%(navigation_start)s</li>
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
451 <li>%(navigation_back)s</li>
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
452 %(navigation_slides)s
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
453 <li>%(navigation_forward)s</li>
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
454 <li>%(navigation_end)s</li>
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
455 </ul>
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
456 </div>
406
d17d73264ec5 action.SlideShow: Layout changed to show the moin logo on top right of each slide and on bottom date, author and count of slides.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 314
diff changeset
457 <div id="footer">
d17d73264ec5 action.SlideShow: Layout changed to show the moin logo on top right of each slide and on bottom date, author and count of slides.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 314
diff changeset
458 <ul id="date">%(date)s</ul>
d17d73264ec5 action.SlideShow: Layout changed to show the moin logo on top right of each slide and on bottom date, author and count of slides.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 314
diff changeset
459 <ul id="author">%(author)s</ul>
d17d73264ec5 action.SlideShow: Layout changed to show the moin logo on top right of each slide and on bottom date, author and count of slides.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 314
diff changeset
460 <ul id="counter">%(counter)s</ul>
d17d73264ec5 action.SlideShow: Layout changed to show the moin logo on top right of each slide and on bottom date, author and count of slides.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 314
diff changeset
461 </div>
314
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
462 <!--
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
463 <p><a href="http://validator.w3.org/check?uri=referer">
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
464 Valid HTML 4.01</a>
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
465 </p>
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
466 -->
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
467 </body>
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
468 </html>
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
469 """
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
470
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
471
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
472 def execute(pagename, request):
520
a21974d68624 action.SlideShow: added a simple release check, because this plugin requires 1.8
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 410
diff changeset
473 if not release.startswith('1.8'):
a21974d68624 action.SlideShow: added a simple release check, because this plugin requires 1.8
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 410
diff changeset
474 msg = 'This local extension action "%(action_name)s" requires moin 1.8.' % {"action_name": actname}
a21974d68624 action.SlideShow: added a simple release check, because this plugin requires 1.8
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 410
diff changeset
475 request.theme.add_msg(msg, "warning")
a21974d68624 action.SlideShow: added a simple release check, because this plugin requires 1.8
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 410
diff changeset
476 return Page(request, pagename).send_page()
314
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
477 """ Glue to current plugin system """
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
478 SlideshowAction(request, pagename, template).execute()
c1e0bb60a0c2 PEP8 clean up
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 298
diff changeset
479