Attachment 'GoToSlide.py'
Download 1 # -*- coding: iso-8859-1 -*-
2 """
3 MoinMoin - Create an link to a slide of a SlideShow
4
5 Usage:
6
7 [[GoToSlide(text)]]
8
9 or if the text is a number use:
10
11 [[GoToSlide(,text)]]
12
13 [[GoToSlide(slide)]]
14
15 Create a link to page with ?action=SlideShow&n=slide and the text action
16
17 [[Action(slide, text)]]
18
19 Same with custom text.
20
21 @copyright: 2008 by Richard Flieger
22 @license: GNU GPL, see COPYING for details.
23 """
24
25 from MoinMoin import wikiutil
26 from MoinMoin.Page import Page
27
28 Dependencies = ["language"]
29
30
31 class Link:
32 """ Link - link to a slide of a slideshow """
33
34 arguments = ['slide', 'text']
35
36 def __init__(self, macro, args):
37 self.macro = macro
38 self.request = macro.request
39 self.args = self.getArgs(args)
40
41 def getArgs(self, string):
42 """
43 @param string: string from the wiki markup [[NewPage(string)]]
44 @rtype: dict
45 @return: dictionary with macro options
46 """
47 if not string:
48 return {}
49 args = [s.strip() for s in string.split(',')]
50 args = dict(zip(self.arguments, args))
51 return args
52
53 def renderInText(self):
54 """ Render macro in text context
55
56 The parser should decide what to do if this macro is placed in a
57 paragraph context.
58 """
59 _ = self.request.getText
60
61 # Default to show page instead of an error message (too lazy to
62 # do an error message now).
63 action = self.args.get('action', 'show')
64
65 # Use translated text or action name
66 slide = 0
67 # Escape user input
68 slide = self.args.get('slide', slide)
69 slide = wikiutil.escape(slide, 1)
70 text = self.args.get('text', slide)
71 text = _(text, formatted=False)
72 text = wikiutil.escape(text, 1)
73
74 # Create link
75 formatter = self.macro.formatter
76 page = wikiutil.quoteWikinameURL(formatter.page.page_name)
77 url = '%s?action=SlideShow&n=%s' % (page, slide)
78 link = wikiutil.link_tag(self.request, url, text=text,
79 formatter=formatter)
80 return link
81
82
83 def execute(macro, args):
84 """ Temporary glue code to use with moin current macro system """
85 return Link(macro, args).renderInText()
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.