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