annotate MoinMoin/action/SlideShow.py @ 5945:d73431c6d2c9

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