Attachment 'modern_cms15.py'
Download 1 """
2 Modern based cms theme
3 ======================
4
5 If you want to use a wiki as a tool to create a regular site easily,
6 this theme is for you. The wiki looks like a plain site to visitors or
7 users without edit rights, and a wiki to users with edits rights.
8
9 This is also a replacement for the readonly theme that was part of release 1.2.
10
11
12 Problems
13 --------
14 Some actions are not available for visitors:
15
16 - Show Raw Text
17 - Show Print Preview
18 - Show Like Pages
19 - Show Local Site Map
20 - Delete Cache
21
22 Most of these are not really needed for a visitor. Print style sheet is
23 used transparently when you print a page. Like Pages and Local Site Map
24 should be available, but are not really needed if you have a good
25 search.
26
27 Missing page will suggest visitors to create a new page, but they will
28 always fail because they don't have acl rights. This should be fixed in
29 other place.
30
31
32 Install
33 -------
34
35 1. Put in your wiki/data/plugin/theme/
36
37 2. Prevent visitors from writing using acl::
38
39 acl_rights_before = (u"WikiAdmin:read,write,delete,revert,admin "
40 u"EditorsGroup:read,write,delete,revert ")
41 acl_rights_default = u"All:read "
42
43 Remember that some ACL you put on a page will override the default ACL!
44
45 3. Make it the default and only theme on your site::
46
47 theme_default = 'modern_cms'
48 theme_force = True
49
50
51 Compatibility
52 --------------
53 Tested with release 1.5.1, should work with any 1.5 release.
54
55
56 Legal
57 -----
58 @copyright (c) 2005 Nir Soffer <nirs@freeshell.org>
59 @copyright (c) 2006 Thomas Waldmann
60 @license: GNU GPL, see COPYING for details
61
62 """
63
64 from MoinMoin.theme import modern
65
66 class Theme(modern.Theme):
67
68 name = "modern" # uses "modern" CSS and images
69
70 def shouldShowEditbar(self, page):
71 """ Hide the edit bar if you can't edit """
72 if self.request.user.may.write(page.page_name):
73 return modern.Theme.shouldShowEditbar(self, page)
74 return False
75
76 def pageLastName(self, name):
77 """ This should be in the Page class, but its not """
78 return name[name.rfind('/') + 1:]
79
80 def shortenPagename(self, name):
81 """ Shorten page names
82
83 This is a modified copy from theme/__init__.py. Modified to
84 show only the last name of a page, even if there is room for
85 the full name.
86 """
87 name = self.pageLastName(name)
88 maxLength = self.maxPagenameLength()
89 if len(name) > maxLength:
90 half, left = divmod(maxLength - 3, 2)
91 name = u'%s...%s' % (name[:half + left], name[-half:])
92 return name
93
94 def footer(self, d, **keywords):
95 """ same as modern footer, but no pageinfo """
96 page = d['page']
97 html = [
98 # End of page
99 self.endPage(),
100
101 # Pre footer custom html (not recommended!)
102 self.emit_custom_html(self.cfg.page_footer1),
103
104 # Footer
105 u'<div id="footer">',
106 self.editbar(d),
107 self.credits(d),
108 self.showversion(d, **keywords),
109 u'</div>',
110
111 # Post footer custom html
112 self.emit_custom_html(self.cfg.page_footer2),
113 ]
114 return u'\n'.join(html)
115
116 def execute(request):
117 return Theme(request)
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.