annotate MoinMoin/themes/__init__.py @ 2590:92a9c6ef1ec7

reduce number of warning and error messages when running "m docs"
author RogerHaase <haaserd@gmail.com>
date Wed, 02 Apr 2014 15:04:19 -0700
parents ee404f81afe9
children 2003e3685733
rev   line source
26
4cd8edde9e94 automatically transform module docstrings, moving legal stuff to comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 24
diff changeset
1 # Copyright: 2003-2010 MoinMoin:ThomasWaldmann
4cd8edde9e94 automatically transform module docstrings, moving legal stuff to comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 24
diff changeset
2 # Copyright: 2008 MoinMoin:RadomirDopieralski
4cd8edde9e94 automatically transform module docstrings, moving legal stuff to comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 24
diff changeset
3 # Copyright: 2010 MoinMoin:DiogenesAugusto
4cd8edde9e94 automatically transform module docstrings, moving legal stuff to comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 24
diff changeset
4 # License: GNU GPL v2 (or any later version), see LICENSE.txt for details.
4cd8edde9e94 automatically transform module docstrings, moving legal stuff to comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 24
diff changeset
5
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
6 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
7 MoinMoin - Theme Support
26
4cd8edde9e94 automatically transform module docstrings, moving legal stuff to comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 24
diff changeset
8 """
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
9
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
10
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
11 import urllib
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
12
1144
9ab81e421631 Use dumps() for json escaping
Sam Toyer <samATqxcvDOTnet>
parents: 1142
diff changeset
13 from json import dumps
1123
ebc4f8213e74 Add a flat subitem index for show item view.
Sam Toyer <samATqxcvDOTnet>
parents: 1110
diff changeset
14
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
15 from flask import current_app as app
109
e4c332436733 remove flask monkeypatch, use 'from flask import g as flaskg'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 106
diff changeset
16 from flask import g as flaskg
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
17 from flask import url_for, request
1767
54be46b8a0b4 flask ext import change
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1764
diff changeset
18 from flask.ext.themes import get_theme, render_theme_template
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
19
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
20 from MoinMoin import log
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
21 logging = log.getLogger(__name__)
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
22
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
23 from MoinMoin.i18n import _, L_, N_
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
24 from MoinMoin import wikiutil, user
2226
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
25 from MoinMoin.constants.keys import USERID, ADDRESS, HOSTNAME, REVID, ITEMID, NAME_EXACT
2292
7b7e07bb6f8a Removed linking of all view to home.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2282
diff changeset
26 from MoinMoin.constants.namespaces import NAMESPACE_DEFAULT, NAMESPACE_USERPROFILES, NAMESPACE_ALL
1227
18cb4213fc4d Always show search box in layout.html
Sam Toyer <samATqxcvDOTnet>
parents: 1145
diff changeset
27 from MoinMoin.search import SearchForm
2226
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
28 from MoinMoin.util.interwiki import split_interwiki, getInterwikiHome, is_local_wiki, is_known_wiki, url_for_item, CompositeName, split_fqname
174
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 150
diff changeset
29 from MoinMoin.util.crypto import cache_key
248
1a1dab306214 move the flatland form html generator to the global environment
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 216
diff changeset
30 from MoinMoin.util.forms import make_generator
1764
19b19d4d9291 Add a @timed decorator.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1726
diff changeset
31 from MoinMoin.util.clock import timed
1801
f6afb9aeb861 Replace CONTENTTYPE_GROUPS with information collected in content_registry.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1800
diff changeset
32 from MoinMoin.util.mime import Type
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
33
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
34
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
35 def get_current_theme():
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
36 # this might be called at a time when flaskg.user is not setup yet:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
37 u = getattr(flaskg, 'user', None)
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
38 if u and u.theme_name is not None:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
39 theme_name = u.theme_name
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
40 else:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
41 theme_name = app.cfg.theme_default
104
9ca492c52070 use default theme if we cannot get the one that was requested (instead of crashing)
MattMaker <trip@entropyreductionservices.com>
parents: 64
diff changeset
42 try:
9ca492c52070 use default theme if we cannot get the one that was requested (instead of crashing)
MattMaker <trip@entropyreductionservices.com>
parents: 64
diff changeset
43 return get_theme(theme_name)
9ca492c52070 use default theme if we cannot get the one that was requested (instead of crashing)
MattMaker <trip@entropyreductionservices.com>
parents: 64
diff changeset
44 except KeyError:
1975
384555088cab lots of pep8 fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1974
diff changeset
45 logging.warning("Theme {0!r} was not found; using default of {1!r} instead.".format(
384555088cab lots of pep8 fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1974
diff changeset
46 theme_name, app.cfg.theme_default))
104
9ca492c52070 use default theme if we cannot get the one that was requested (instead of crashing)
MattMaker <trip@entropyreductionservices.com>
parents: 64
diff changeset
47 theme_name = app.cfg.theme_default
9ca492c52070 use default theme if we cannot get the one that was requested (instead of crashing)
MattMaker <trip@entropyreductionservices.com>
parents: 64
diff changeset
48 return get_theme(theme_name)
9ca492c52070 use default theme if we cannot get the one that was requested (instead of crashing)
MattMaker <trip@entropyreductionservices.com>
parents: 64
diff changeset
49
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
50
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
51 def render_template(template, **context):
1764
19b19d4d9291 Add a @timed decorator.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1726
diff changeset
52 return render_theme_template(get_current_theme(), template, **context)
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
53
1975
384555088cab lots of pep8 fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1974
diff changeset
54
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
55 def themed_error(e):
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
56 item_name = request.view_args.get('item_name', u'')
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
57 if e.code == 403:
1907
7324a1d71443 simplify and standardize headings and page titles on user and admin pages
Roger Haase <crosseyedpenguin@yahoo.com>
parents: 1885
diff changeset
58 title = L_('Access Denied')
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
59 description = L_('You are not allowed to access this resource.')
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
60 else:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
61 # if we have no special code, we just return the HTTPException instance
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
62 return e
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
63 content = render_template('error.html',
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
64 item_name=item_name,
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
65 title=title, description=description)
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
66 return content, e.code
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
67
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
68
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
69 class ThemeSupport(object):
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
70 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
71 Support code for template feeding.
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
72 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
73 def __init__(self, cfg):
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
74 self.cfg = cfg
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
75 self.user = flaskg.user
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
76 self.storage = flaskg.storage
1975
384555088cab lots of pep8 fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1974
diff changeset
77 self.ui_lang = 'en' # XXX
384555088cab lots of pep8 fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1974
diff changeset
78 self.ui_dir = 'ltr' # XXX
384555088cab lots of pep8 fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1974
diff changeset
79 self.content_lang = flaskg.content_lang # XXX
384555088cab lots of pep8 fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1974
diff changeset
80 self.content_dir = 'ltr' # XXX
384555088cab lots of pep8 fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1974
diff changeset
81 self.meta_items = [] # list of (name, content) for html head <meta>
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
82
2395
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
83 def get_action_tabs(self, item_name, current_endpoint):
2489
d29bfd06cd8c Fixes the global index view, issue with checking existence of empty string
sharky93 <rishabhr123@gmail.com>
parents: 2482
diff changeset
84
d29bfd06cd8c Fixes the global index view, issue with checking existence of empty string
sharky93 <rishabhr123@gmail.com>
parents: 2482
diff changeset
85 if item_name in ['@NONAMEGIVEN', '']:
d29bfd06cd8c Fixes the global index view, issue with checking existence of empty string
sharky93 <rishabhr123@gmail.com>
parents: 2482
diff changeset
86 return []
d29bfd06cd8c Fixes the global index view, issue with checking existence of empty string
sharky93 <rishabhr123@gmail.com>
parents: 2482
diff changeset
87
d29bfd06cd8c Fixes the global index view, issue with checking existence of empty string
sharky93 <rishabhr123@gmail.com>
parents: 2482
diff changeset
88 exists = flaskg.storage.has_item(item_name)
2492
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
89
2395
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
90 navtabs_endpoints = ['frontend.show_item', 'frontend.history',
2492
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
91 'frontend.show_item_meta', 'frontend.highlight_item', 'frontend.backrefs',
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
92 'frontend.index', 'frontend.sitemap', 'frontend.similar_names', ]
2489
d29bfd06cd8c Fixes the global index view, issue with checking existence of empty string
sharky93 <rishabhr123@gmail.com>
parents: 2482
diff changeset
93
2380
7df17df524e7 adds helper function to render action tabs
sharky93 <rishabhr123@gmail.com>
parents: 2328
diff changeset
94 if self.user.may.write(item_name):
2395
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
95 navtabs_endpoints.append('frontend.modify_item')
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
96
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
97 icon = self.get_endpoint_iconmap()
2489
d29bfd06cd8c Fixes the global index view, issue with checking existence of empty string
sharky93 <rishabhr123@gmail.com>
parents: 2482
diff changeset
98
2395
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
99 navtabs = []
2492
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
100 spl_active = [('frontend.history', 'frontend.diff'), ]
2395
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
101
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
102 for endpoint, label, title, check_exists in app.cfg.item_views:
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
103 if endpoint not in app.cfg.endpoints_excluded:
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
104 if not check_exists or exists:
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
105 if endpoint in navtabs_endpoints:
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
106
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
107 iconcls = icon[endpoint]
2459
a66fcc5ce02b fixes doubleclick to edit, adds linkcls to navtabs for rendering a class for the hyperlink
sharky93 <rishabhr123@gmail.com>
parents: 2457
diff changeset
108 linkcls = None
2492
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
109
2395
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
110 if endpoint == 'special.comments':
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
111 maincls = "moin-toggle-comments-button"
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
112 href = "#"
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
113 elif endpoint == 'special.transclusions':
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
114 maincls = "moin-transclusions-button"
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
115 href = "#"
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
116 else:
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
117 maincls = None
2457
17a40164f8b4 fixes rendering of class in tabs, adds markup support for double click to edit JS
sharky93 <rishabhr123@gmail.com>
parents: 2454
diff changeset
118 # special case for modify item link, this depends on the double click to edit JS
17a40164f8b4 fixes rendering of class in tabs, adds markup support for double click to edit JS
sharky93 <rishabhr123@gmail.com>
parents: 2454
diff changeset
119 if endpoint == 'frontend.modify_item':
2459
a66fcc5ce02b fixes doubleclick to edit, adds linkcls to navtabs for rendering a class for the hyperlink
sharky93 <rishabhr123@gmail.com>
parents: 2457
diff changeset
120 linkcls = "moin-modify-button"
2395
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
121 href = url_for(endpoint, item_name=item_name)
2396
35b64d97bd9c Fixes #39, by making the history tab active for diff views
sharky93 <rishabhr123@gmail.com>
parents: 2395
diff changeset
122 if endpoint == current_endpoint or (endpoint, current_endpoint) in spl_active:
2459
a66fcc5ce02b fixes doubleclick to edit, adds linkcls to navtabs for rendering a class for the hyperlink
sharky93 <rishabhr123@gmail.com>
parents: 2457
diff changeset
123 maincls = "active"
2395
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
124
2459
a66fcc5ce02b fixes doubleclick to edit, adds linkcls to navtabs for rendering a class for the hyperlink
sharky93 <rishabhr123@gmail.com>
parents: 2457
diff changeset
125 navtabs.append((endpoint, href, maincls, iconcls, linkcls, title, label))
2380
7df17df524e7 adds helper function to render action tabs
sharky93 <rishabhr123@gmail.com>
parents: 2328
diff changeset
126 return navtabs
7df17df524e7 adds helper function to render action tabs
sharky93 <rishabhr123@gmail.com>
parents: 2328
diff changeset
127
2381
aa19b1b69b5c adds helper function to render the local panel
sharky93 <rishabhr123@gmail.com>
parents: 2380
diff changeset
128 def get_local_panel(self, item_name):
2489
d29bfd06cd8c Fixes the global index view, issue with checking existence of empty string
sharky93 <rishabhr123@gmail.com>
parents: 2482
diff changeset
129
d29bfd06cd8c Fixes the global index view, issue with checking existence of empty string
sharky93 <rishabhr123@gmail.com>
parents: 2482
diff changeset
130 if item_name in ['@NONAMEGIVEN', '']:
d29bfd06cd8c Fixes the global index view, issue with checking existence of empty string
sharky93 <rishabhr123@gmail.com>
parents: 2482
diff changeset
131 return [], [], []
d29bfd06cd8c Fixes the global index view, issue with checking existence of empty string
sharky93 <rishabhr123@gmail.com>
parents: 2482
diff changeset
132
d29bfd06cd8c Fixes the global index view, issue with checking existence of empty string
sharky93 <rishabhr123@gmail.com>
parents: 2482
diff changeset
133 exists = flaskg.storage.has_item(item_name)
d29bfd06cd8c Fixes the global index view, issue with checking existence of empty string
sharky93 <rishabhr123@gmail.com>
parents: 2482
diff changeset
134
2491
8f054781b48a more defensive checking for item existence, improved generation of current_url, pep8 fixes remain
sharky93 <rishabhr123@gmail.com>
parents: 2489
diff changeset
135 if not exists:
8f054781b48a more defensive checking for item existence, improved generation of current_url, pep8 fixes remain
sharky93 <rishabhr123@gmail.com>
parents: 2489
diff changeset
136 return [], [], []
8f054781b48a more defensive checking for item existence, improved generation of current_url, pep8 fixes remain
sharky93 <rishabhr123@gmail.com>
parents: 2489
diff changeset
137
2393
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
138 user_actions_endpoints = ['frontend.quicklink_item', 'frontend.subscribe_item', ]
2450
1691455778f1 moves Item Navigation to the left, SiteMap and ItemIndex to the tabs
sharky93 <rishabhr123@gmail.com>
parents: 2448
diff changeset
139 item_navigation_endpoints = ['special.supplementation']
2393
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
140 item_actions_endpoints = ['frontend.rename_item', 'frontend.delete_item', 'frontend.destroy_item',
2492
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
141 'frontend.download_item',
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
142 'frontend.copy_item', ] if self.user.may.write(item_name) else []
2393
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
143
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
144 user_actions = []
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
145 item_navigation = []
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
146 item_actions = []
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
147
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
148 icon = self.get_endpoint_iconmap()
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
149
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
150 for endpoint, label, title, check_exists in app.cfg.item_views:
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
151 if endpoint not in app.cfg.endpoints_excluded:
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
152 if not check_exists or exists:
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
153 if endpoint in user_actions_endpoints:
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
154 if flaskg.user.valid:
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
155 href = url_for(endpoint, item_name=item_name)
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
156 iconcls = icon[endpoint]
2589
ee404f81afe9 fix new pep8 errors generated after pep8 is upgraded to 1.5.1
RogerHaase <haaserd@gmail.com>
parents: 2548
diff changeset
157 # endpoint = iconcls = label = None
2393
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
158
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
159 if endpoint == 'frontend.quicklink_item':
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
160 if not flaskg.user.is_quicklinked_to([item_name]):
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
161 label = _('Add Link')
2480
a17476268e7a refined macro for hyperlink and local panel, the sidebar links are not red when the page doesn't exist
sharky93 <rishabhr123@gmail.com>
parents: 2459
diff changeset
162 user_actions.append((endpoint, href, iconcls, label, title, True))
2393
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
163 elif endpoint == 'frontend.subscribe_item':
2548
07f3ccfdea45 fixes Issue #397: AttributeError after login 'list' object has no attribute 'meta'
hellboy2k8 <shailrishabh@gmail.com>
parents: 2519
diff changeset
164 from MoinMoin.items import Item
07f3ccfdea45 fixes Issue #397: AttributeError after login 'list' object has no attribute 'meta'
hellboy2k8 <shailrishabh@gmail.com>
parents: 2519
diff changeset
165 item = Item.create(item_name)
07f3ccfdea45 fixes Issue #397: AttributeError after login 'list' object has no attribute 'meta'
hellboy2k8 <shailrishabh@gmail.com>
parents: 2519
diff changeset
166 if flaskg.user.is_subscribed_to(item):
2393
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
167 label = _('Unsubscribe')
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
168 else:
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
169 label = _('Subscribe')
2480
a17476268e7a refined macro for hyperlink and local panel, the sidebar links are not red when the page doesn't exist
sharky93 <rishabhr123@gmail.com>
parents: 2459
diff changeset
170 user_actions.append((endpoint, href, iconcls, label, title, True))
2393
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
171
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
172 elif endpoint in item_actions_endpoints:
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
173
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
174 iconcls = icon[endpoint]
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
175
2448
7fb6bff63aa0 fixes #64, discussion moved under item_navigation
sharky93 <rishabhr123@gmail.com>
parents: 2446
diff changeset
176 href = url_for(endpoint, item_name=item_name)
2480
a17476268e7a refined macro for hyperlink and local panel, the sidebar links are not red when the page doesn't exist
sharky93 <rishabhr123@gmail.com>
parents: 2459
diff changeset
177 item_actions.append((endpoint, href, iconcls, label, title, True))
2448
7fb6bff63aa0 fixes #64, discussion moved under item_navigation
sharky93 <rishabhr123@gmail.com>
parents: 2446
diff changeset
178
7fb6bff63aa0 fixes #64, discussion moved under item_navigation
sharky93 <rishabhr123@gmail.com>
parents: 2446
diff changeset
179 elif endpoint in item_navigation_endpoints:
7fb6bff63aa0 fixes #64, discussion moved under item_navigation
sharky93 <rishabhr123@gmail.com>
parents: 2446
diff changeset
180
7fb6bff63aa0 fixes #64, discussion moved under item_navigation
sharky93 <rishabhr123@gmail.com>
parents: 2446
diff changeset
181 iconcls = icon[endpoint]
2492
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
182
2393
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
183 if endpoint == 'special.supplementation':
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
184 for sub_item_name in app.cfg.supplementation_item_names:
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
185 current_sub = item_name.rsplit('/', 1)[-1]
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
186 if current_sub not in app.cfg.supplementation_item_names:
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
187 supp_name = '%s/%s' % (item_name, sub_item_name)
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
188 if flaskg.storage.has_item(supp_name) or flaskg.user.may.write(supp_name):
2482
f50f7d1cbf14 Fixes non-display of delete, destroy, other item actions, variable value was being overwritten
sharky93 <rishabhr123@gmail.com>
parents: 2480
diff changeset
189 subitem_exists = self.storage.has_item(supp_name)
2393
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
190 href = url_for('frontend.show_item', item_name=supp_name)
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
191 label = _(sub_item_name)
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
192 title = None
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
193
2482
f50f7d1cbf14 Fixes non-display of delete, destroy, other item actions, variable value was being overwritten
sharky93 <rishabhr123@gmail.com>
parents: 2480
diff changeset
194 item_navigation.append((endpoint, href, iconcls, label, title, subitem_exists))
2393
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
195 else:
2492
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
196 href = url_for(endpoint, item_name=item_name)
2480
a17476268e7a refined macro for hyperlink and local panel, the sidebar links are not red when the page doesn't exist
sharky93 <rishabhr123@gmail.com>
parents: 2459
diff changeset
197 item_navigation.append((endpoint, href, iconcls, label, title, True))
2393
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
198
2381
aa19b1b69b5c adds helper function to render the local panel
sharky93 <rishabhr123@gmail.com>
parents: 2380
diff changeset
199 return user_actions, item_navigation, item_actions
aa19b1b69b5c adds helper function to render the local panel
sharky93 <rishabhr123@gmail.com>
parents: 2380
diff changeset
200
2387
9bf41329f031 icon dict to map endpoints with icon retrieved from helper functions
sharky93 <rishabhr123@gmail.com>
parents: 2381
diff changeset
201 def get_endpoint_iconmap(self):
2492
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
202 icon = {'frontend.quicklink_item': "icon-star-empty",
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
203 'frontend.subscribe_item': "icon-envelope",
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
204 'frontend.index': "icon-list-alt",
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
205 'frontend.sitemap': "icon-sitemap",
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
206 'frontend.rename_item': "icon-tag",
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
207 'frontend.delete_item': "icon-trash",
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
208 'frontend.destroy_item': "icon-fire",
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
209 'frontend.similar_names': "icon-search",
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
210 'frontend.download_item': "icon-download-alt",
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
211 'frontend.copy_item': "icon-comment",
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
212 'special.supplementation': "icon-comments",
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
213 'frontend.show_item': "icon-eye-open",
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
214 'frontend.modify_item': "icon-pencil",
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
215 'frontend.history': "icon-time",
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
216 'frontend.show_item_meta': "icon-wrench",
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
217 'frontend.highlight_item': "icon-code",
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
218 'frontend.backrefs': "icon-share",
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
219 'special.comments': "icon-comment",
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
220 'special.transclusions': "icon-edit", }
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
221 return icon
2387
9bf41329f031 icon dict to map endpoints with icon retrieved from helper functions
sharky93 <rishabhr123@gmail.com>
parents: 2381
diff changeset
222
2226
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
223 def location_breadcrumbs(self, fqname):
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
224 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
225 Assemble the location using breadcrumbs (was: title)
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
226
38
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
227 :rtype: list
2226
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
228 :returns: location breadcrumbs items in tuple (segment_name, fq_name, exists)
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
229 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
230 breadcrumbs = []
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
231 current_item = ''
2226
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
232 if not isinstance(fqname, CompositeName):
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
233 fqname = split_fqname(fqname)
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
234 if fqname.field != NAME_EXACT:
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
235 return [(fqname, fqname, bool(self.storage.get_item(**fqname.query)))]
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
236 namespace = fqname.namespace
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
237 fq_current = CompositeName(u'', NAME_EXACT, namespace)
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
238 fq_segment = CompositeName(u'', NAME_EXACT, namespace or '~')
2252
ecd43cdbb9b6 breadcrubms now show up titles properly.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2236
diff changeset
239 breadcrumbs.append((fq_segment, fq_current, False))
2226
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
240 item_name = fqname.value
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
241 if not item_name:
2252
ecd43cdbb9b6 breadcrubms now show up titles properly.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2236
diff changeset
242 return breadcrumbs
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
243 for segment in item_name.split('/'):
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
244 current_item += segment
2226
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
245 fq_current = CompositeName(namespace, NAME_EXACT, current_item)
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
246 fq_segment = CompositeName(namespace, NAME_EXACT, segment)
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
247 breadcrumbs.append((fq_segment, fq_current, bool(self.storage.get_item(**fq_current.query))))
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
248 current_item += '/'
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
249 return breadcrumbs
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
250
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
251 def path_breadcrumbs(self):
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
252 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
253 Assemble the path breadcrumbs (a.k.a.: trail)
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
254
38
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
255 :rtype: list
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
256 :returns: path breadcrumbs items in tuple (wiki_name, item_name, url, exists, err)
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
257 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
258 user = self.user
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
259 breadcrumbs = []
1281
0a70177ce4de user: changed method names for better PEP8 compliance
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1278
diff changeset
260 trail = user.get_trail()
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
261 for interwiki_item_name in trail:
2217
431815d4f4a6 Fixed interwiki patch to deal with new composite name.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2117
diff changeset
262 wiki_name, namespace, field, item_name = split_interwiki(interwiki_item_name)
2226
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
263 fqname = CompositeName(namespace, field, item_name)
313
8fa4a76d71ff cleanup interwiki code, new easier/more powerful functions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 248
diff changeset
264 err = not is_known_wiki(wiki_name)
2226
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
265 href = url_for_item(wiki_name=wiki_name, **fqname.split)
313
8fa4a76d71ff cleanup interwiki code, new easier/more powerful functions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 248
diff changeset
266 if is_local_wiki(wiki_name):
2226
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
267 exists = bool(self.storage.get_item(**fqname.query))
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
268 wiki_name = '' # means "this wiki" for the theme code
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
269 else:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
270 exists = True # we can't detect existance of remote items
2226
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
271 if item_name:
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
272 breadcrumbs.append((wiki_name, fqname, href, exists, err))
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
273 return breadcrumbs
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
274
2263
6dd5af01d54d Sub-items pannel now has fqname support.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2253
diff changeset
275 def subitem_index(self, fqname):
1123
ebc4f8213e74 Add a flat subitem index for show item view.
Sam Toyer <samATqxcvDOTnet>
parents: 1110
diff changeset
276 """
2263
6dd5af01d54d Sub-items pannel now has fqname support.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2253
diff changeset
277 Get a list of subitems for the given fqname
1123
ebc4f8213e74 Add a flat subitem index for show item view.
Sam Toyer <samATqxcvDOTnet>
parents: 1110
diff changeset
278
ebc4f8213e74 Add a flat subitem index for show item view.
Sam Toyer <samATqxcvDOTnet>
parents: 1110
diff changeset
279 :rtype: list
ebc4f8213e74 Add a flat subitem index for show item view.
Sam Toyer <samATqxcvDOTnet>
parents: 1110
diff changeset
280 :returns: list of item tuples (item_name, item_title, item_mime_type, has_children)
ebc4f8213e74 Add a flat subitem index for show item view.
Sam Toyer <samATqxcvDOTnet>
parents: 1110
diff changeset
281 """
ebc4f8213e74 Add a flat subitem index for show item view.
Sam Toyer <samATqxcvDOTnet>
parents: 1110
diff changeset
282 from MoinMoin.items import Item
2263
6dd5af01d54d Sub-items pannel now has fqname support.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2253
diff changeset
283 if not isinstance(fqname, CompositeName):
6dd5af01d54d Sub-items pannel now has fqname support.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2253
diff changeset
284 fqname = split_fqname(fqname)
6dd5af01d54d Sub-items pannel now has fqname support.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2253
diff changeset
285 item = Item.create(fqname.fullname)
1800
54062fc0ca97 Separate "directory" and "file" items in the index view.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1767
diff changeset
286 return item.get_mixed_index()
1123
ebc4f8213e74 Add a flat subitem index for show item view.
Sam Toyer <samATqxcvDOTnet>
parents: 1110
diff changeset
287
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
288 def userhome(self):
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
289 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
290 Assemble arguments used to build user homepage link
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
291
38
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
292 :rtype: tuple
1063
ee71ed6e97c6 change user.aliasname to user.display_name
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 969
diff changeset
293 :returns: arguments of user homepage link in tuple (wiki_href, display_name, title, exists)
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
294 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
295 user = self.user
1286
d2704c2a8d39 meta NAME and User.name is always a list of unicode names
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1283
diff changeset
296 name = user.name0
1063
ee71ed6e97c6 change user.aliasname to user.display_name
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 969
diff changeset
297 display_name = user.display_name or name
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
298 wikiname, itemname = getInterwikiHome(name)
1832
ff503e7ea7a0 merged default into namespaces branch, some stuff XXX BROKEN
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1315 1801
diff changeset
299 title = u"{0} @ {1}".format(display_name, wikiname)
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
300 # link to (interwiki) user homepage
313
8fa4a76d71ff cleanup interwiki code, new easier/more powerful functions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 248
diff changeset
301 if is_local_wiki(wikiname):
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
302 exists = self.storage.has_item(itemname)
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
303 else:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
304 # We cannot check if wiki pages exists in remote wikis
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
305 exists = True
2279
49bc6f85f918 Fixed pep8 errors.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2273
diff changeset
306 wiki_href = url_for_item(itemname, wiki_name=wikiname, namespace=NAMESPACE_USERPROFILES)
1063
ee71ed6e97c6 change user.aliasname to user.display_name
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 969
diff changeset
307 return wiki_href, display_name, title, exists
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
308
63
14832b8cc7ed navibar/split_navilink: remove i18n support (was used for cfg.navibar)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 38
diff changeset
309 def split_navilink(self, text):
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
310 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
311 Split navibar links into pagename, link to page
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
312
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
313 Admin or user might want to use shorter navibar items by using
63
14832b8cc7ed navibar/split_navilink: remove i18n support (was used for cfg.navibar)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 38
diff changeset
314 the [[page|title]] or [[url|title]] syntax.
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
315
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
316 Supported syntax:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
317 * PageName
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
318 * WikiName:PageName
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
319 * wiki:WikiName:PageName
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
320 * url
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
321 * all targets as seen above with title: [[target|title]]
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
322
38
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
323 :param text: the text used in config or user preferences
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
324 :rtype: tuple
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
325 :returns: pagename or url, link to page or url
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
326 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
327 title = None
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
328 wiki_local = '' # means local wiki
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
329
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
330 # Handle [[pagename|title]] or [[url|title]] formats
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
331 if text.startswith('[[') and text.endswith(']]'):
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
332 text = text[2:-2]
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
333 try:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
334 target, title = text.split('|', 1)
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
335 target = target.strip()
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
336 title = title.strip()
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
337 except (ValueError, TypeError):
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
338 # Just use the text as is.
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
339 target = text.strip()
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
340 else:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
341 target = text
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
342
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
343 if wikiutil.is_URL(target):
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
344 if not title:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
345 title = target
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
346 return target, title, wiki_local
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
347
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
348 # remove wiki: url prefix
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
349 if target.startswith("wiki:"):
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
350 target = target[5:]
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
351
2217
431815d4f4a6 Fixed interwiki patch to deal with new composite name.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2117
diff changeset
352 wiki_name, namespace, field, item_name = split_interwiki(target)
316
4ee796d759bf use url_for_item where appropriate (in py code, no template changes yet)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 313
diff changeset
353 if wiki_name == 'Self':
4ee796d759bf use url_for_item where appropriate (in py code, no template changes yet)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 313
diff changeset
354 wiki_name = ''
2217
431815d4f4a6 Fixed interwiki patch to deal with new composite name.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2117
diff changeset
355 href = url_for_item(item_name, namespace=namespace, wiki_name=wiki_name, field=field)
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
356 if not title:
2230
f2bd327932fb Fixes #6. Quicklinks now use abbreviated fqnames.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2226
diff changeset
357 title = shorten_fqname(CompositeName(namespace, field, item_name))
316
4ee796d759bf use url_for_item where appropriate (in py code, no template changes yet)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 313
diff changeset
358 return href, title, wiki_name
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
359
1764
19b19d4d9291 Add a @timed decorator.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1726
diff changeset
360 @timed()
2282
5c424120a253 Fixed #21, now links in navbar link to current namespace.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2279
diff changeset
361 def navibar(self, fqname):
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
362 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
363 Assemble the navibar
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
364
38
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
365 :rtype: list
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
366 :returns: list of tuples (css_class, url, link_text, title)
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
367 """
2282
5c424120a253 Fixed #21, now links in navbar link to current namespace.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2279
diff changeset
368 if not isinstance(fqname, CompositeName):
5c424120a253 Fixed #21, now links in navbar link to current namespace.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2279
diff changeset
369 fqname = split_fqname(fqname)
5c424120a253 Fixed #21, now links in navbar link to current namespace.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2279
diff changeset
370 item_name = fqname.value
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
371 current = item_name
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
372 # Process config navi_bar
2043
423d8d791cc9 Fix for Issue#291, home link now coloured as should be
sharky93 <rishabhr123@gmail.com>
parents: 2011
diff changeset
373 items = []
423d8d791cc9 Fix for Issue#291, home link now coloured as should be
sharky93 <rishabhr123@gmail.com>
parents: 2011
diff changeset
374 for cls, endpoint, args, link_text, title in self.cfg.navi_bar:
423d8d791cc9 Fix for Issue#291, home link now coloured as should be
sharky93 <rishabhr123@gmail.com>
parents: 2011
diff changeset
375 if endpoint == "frontend.show_root":
423d8d791cc9 Fix for Issue#291, home link now coloured as should be
sharky93 <rishabhr123@gmail.com>
parents: 2011
diff changeset
376 endpoint = "frontend.show_item"
2282
5c424120a253 Fixed #21, now links in navbar link to current namespace.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2279
diff changeset
377 root_fqname = fqname.get_root_fqname()
2292
7b7e07bb6f8a Removed linking of all view to home.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2282
diff changeset
378 default_root = app.cfg.root_mapping.get(NAMESPACE_DEFAULT, app.cfg.default_root)
7b7e07bb6f8a Removed linking of all view to home.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2282
diff changeset
379 args['item_name'] = root_fqname.fullname if fqname.namespace != NAMESPACE_ALL else default_root
2282
5c424120a253 Fixed #21, now links in navbar link to current namespace.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2279
diff changeset
380 elif endpoint in ["frontend.global_history", "frontend.global_tags"]:
5c424120a253 Fixed #21, now links in navbar link to current namespace.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2279
diff changeset
381 args['namespace'] = fqname.namespace
5c424120a253 Fixed #21, now links in navbar link to current namespace.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2279
diff changeset
382 elif endpoint == "frontend.index":
5c424120a253 Fixed #21, now links in navbar link to current namespace.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2279
diff changeset
383 args['item_name'] = fqname.namespace
2043
423d8d791cc9 Fix for Issue#291, home link now coloured as should be
sharky93 <rishabhr123@gmail.com>
parents: 2011
diff changeset
384 items.append((cls, url_for(endpoint, **args), link_text, title))
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
385
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
386 # Add user links to wiki links.
1278
2c58cbcfeabe quicklinks/subscribed_items: use attributes directly, simplify code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1227
diff changeset
387 for text in self.user.quicklinks:
63
14832b8cc7ed navibar/split_navilink: remove i18n support (was used for cfg.navibar)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 38
diff changeset
388 url, link_text, title = self.split_navilink(text)
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
389 items.append(('userlink', url, link_text, title))
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
390
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
391 # Add sister pages (see http://usemod.com/cgi-bin/mb.pl?SisterSitesImplementationGuide )
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
392 for sistername, sisterurl in self.cfg.sistersites:
313
8fa4a76d71ff cleanup interwiki code, new easier/more powerful functions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 248
diff changeset
393 if is_local_wiki(sistername):
1885
063c879ef79b sistersites: fix tuple member count
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1801
diff changeset
394 items.append(('sisterwiki current', sisterurl, sistername, ''))
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
395 else:
174
e8f61cbd661b modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 150
diff changeset
396 cid = cache_key(usage="SisterSites", sistername=sistername)
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
397 sisteritems = app.cache.get(cid)
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
398 if sisteritems is None:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
399 uo = urllib.URLopener()
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
400 uo.version = 'MoinMoin SisterItem list fetcher 1.0'
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
401 try:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
402 sisteritems = {}
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
403 f = uo.open(sisterurl)
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
404 for line in f:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
405 line = line.strip()
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
406 try:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
407 item_url, item_name = line.split(' ', 1)
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
408 sisteritems[item_name.decode('utf-8')] = item_url
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
409 except:
1975
384555088cab lots of pep8 fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1974
diff changeset
410 pass # ignore invalid lines
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
411 f.close()
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
412 app.cache.set(cid, sisteritems)
1414
614005b5edb3 fixed some .format() unicode issues, partially fixing bug #124
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1397
diff changeset
413 logging.info("Site: {0!r} Status: Updated. Pages: {1}".format(sistername, len(sisteritems)))
135
75312c9b94e3 use except...as syntax, use raise Exception(...) syntax, fix some imports
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 126
diff changeset
414 except IOError as err:
1975
384555088cab lots of pep8 fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1974
diff changeset
415 (title, code, msg, headers) = err.args # code e.g. 304
1414
614005b5edb3 fixed some .format() unicode issues, partially fixing bug #124
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1397
diff changeset
416 logging.warning("Site: {0!r} Status: Not updated.".format(sistername))
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
417 logging.exception("exception was:")
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
418 if current in sisteritems:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
419 url = sisteritems[current]
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
420 items.append(('sisterwiki', url, sistername, ''))
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
421 return items
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
422
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
423 def parent_item(self, item_name):
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
424 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
425 Return name of parent item for the current item
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
426
38
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
427 :rtype: unicode
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
428 :returns: parent item name
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
429 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
430 parent_item_name = wikiutil.ParentItemName(item_name)
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
431 if item_name and parent_item_name:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
432 return parent_item_name
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
433
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
434 # TODO: reimplement on-wiki-page sidebar definition with MoinMoin.converter
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
435
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
436 # Properties ##############################################################
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
437
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
438 def login_url(self):
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
439 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
440 Return URL usable for user login
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
441
38
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
442 :rtype: unicode (or None, if no login url is supported)
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
443 :returns: url for user login
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
444 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
445 url = None
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
446 if self.cfg.auth_login_inputs == ['special_no_input']:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
447 url = url_for('frontend.login', login=1)
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
448 if self.cfg.auth_have_login:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
449 url = url or url_for('frontend.login')
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
450 return url
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
451
2253
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
452 def get_fqnames(self, fqname):
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
453 """
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
454 Return the list of other fqnames associated with the item.
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
455 """
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
456 if fqname.field != NAME_EXACT:
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
457 return []
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
458 item = self.storage.get_item(**fqname.query)
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
459 fqnames = item.fqnames
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
460 fqnames.remove(fqname)
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
461 return fqnames or []
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
462
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
463 def get_namespaces(self, ns):
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
464 """
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
465 Return the list of tuples (composite name, namespace) referring to namespaces other
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
466 than the current namespace.
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
467 """
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
468 ns = u'' if ns.value == '~' else ns.value
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
469 namespace_root_mapping = []
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
470 for namespace, _ in app.cfg.namespace_mapping:
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
471 namespace = namespace.rstrip('/')
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
472 if namespace != ns:
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
473 fq_namespace = CompositeName(namespace, NAME_EXACT, u'')
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
474 namespace_root_mapping.append((namespace or '~', fq_namespace.get_root_fqname()))
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
475 return namespace_root_mapping
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
476
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
477
861
9a7889c04a25 fixed history view
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 859
diff changeset
478 def get_editor_info(meta, external=False):
9a7889c04a25 fixed history view
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 859
diff changeset
479 addr = meta.get(ADDRESS)
9a7889c04a25 fixed history view
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 859
diff changeset
480 hostname = meta.get(HOSTNAME)
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
481 text = _('anonymous') # link text
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
482 title = '' # link title
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
483 css = 'editor' # link/span css class
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
484 name = None # author name
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
485 uri = None # author homepage uri
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
486 email = None # pure email address of author
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
487 if app.cfg.show_hosts and addr:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
488 # only tell ip / hostname if show_hosts is True
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
489 if hostname:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
490 text = hostname[:15] # 15 = len(ipaddr)
1414
614005b5edb3 fixed some .format() unicode issues, partially fixing bug #124
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1397
diff changeset
491 name = title = u'{0}[{1}]'.format(hostname, addr)
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
492 css = 'editor host'
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
493 else:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
494 name = text = addr
1414
614005b5edb3 fixed some .format() unicode issues, partially fixing bug #124
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1397
diff changeset
495 title = u'[{0}]'.format(addr)
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
496 css = 'editor ip'
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
497
861
9a7889c04a25 fixed history view
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 859
diff changeset
498 userid = meta.get(USERID)
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
499 if userid:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
500 u = user.User(userid)
1286
d2704c2a8d39 meta NAME and User.name is always a list of unicode names
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1283
diff changeset
501 name = u.name0
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
502 text = name
1063
ee71ed6e97c6 change user.aliasname to user.display_name
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 969
diff changeset
503 display_name = u.display_name or name
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
504 if title:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
505 # we already have some address info
1832
ff503e7ea7a0 merged default into namespaces branch, some stuff XXX BROKEN
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1315 1801
diff changeset
506 title = u"{0} @ {1}".format(display_name, title)
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
507 else:
1063
ee71ed6e97c6 change user.aliasname to user.display_name
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 969
diff changeset
508 title = display_name
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
509 if u.mailto_author and u.email:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
510 email = u.email
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
511 css = 'editor mail'
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
512 else:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
513 homewiki = app.cfg.user_homewiki
313
8fa4a76d71ff cleanup interwiki code, new easier/more powerful functions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 248
diff changeset
514 if is_local_wiki(homewiki):
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
515 css = 'editor homepage local'
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
516 else:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
517 css = 'editor homepage interwiki'
313
8fa4a76d71ff cleanup interwiki code, new easier/more powerful functions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 248
diff changeset
518 uri = url_for_item(name, wiki_name=homewiki, _external=external)
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
519
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
520 result = dict(name=name, text=text, css=css, title=title)
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
521 if uri:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
522 result['uri'] = uri
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
523 if email:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
524 result['email'] = email
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
525 return result
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
526
1975
384555088cab lots of pep8 fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1974
diff changeset
527
2226
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
528 def shorten_fqname(fqname, length=25):
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
529 """
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
530 Shorten fqname
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
531
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
532 Shorten a given long fqname so that it looks good depending upon whether
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
533 the field is a UUID or not.
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
534
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
535 :param fqname: fqname, namedtuple
2590
92a9c6ef1ec7 reduce number of warning and error messages when running "m docs"
RogerHaase <haaserd@gmail.com>
parents: 2589
diff changeset
536 :param length: maximum length for shortened fqnames in case the field is not a UUID.
2226
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
537 :rtype: unicode
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
538 :returns: shortened fqname.
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
539 """
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
540 name = fqname.value
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
541 if len(name) > length:
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
542 if fqname.field in [REVID, ITEMID]:
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
543 name = shorten_id(name)
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
544 else:
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
545 name = shorten_item_name(name, length)
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
546 return name
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
547
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
548
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
549 def shorten_item_name(name, length=25):
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
550 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
551 Shorten item names
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
552
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
553 Shorten very long item names that tend to break the user
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
554 interface. The short name is usually fine, unless really stupid
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
555 long names are used (WYGIWYD).
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
556
38
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
557 :param name: item name, unicode
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
558 :param length: maximum length for shortened item names, int
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
559 :rtype: unicode
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
560 :returns: shortened version.
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
561 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
562 # First use only the sub page name, that might be enough
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
563 if len(name) > length:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
564 name = name.split('/')[-1]
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
565 # If it's not enough, replace the middle with '...'
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
566 if len(name) > length:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
567 half, left = divmod(length - 3, 2)
969
5bf6d7a2ffcf Convert all %r, %s, %x, %d, %i, %o to new Format String Syntax
Vedran Mileti? <rivanvx@gmail.com>
parents: 861
diff changeset
568 name = u'{0}...{1}'.format(name[:half + left], name[-half:])
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
569 return name
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
570
2409
51b90beddc7c Shortens contenttype display in the history view
sharky93 <rishabhr123@gmail.com>
parents: 2396
diff changeset
571 CONTENTTYPE_SHORTEN = {
51b90beddc7c Shortens contenttype display in the history view
sharky93 <rishabhr123@gmail.com>
parents: 2396
diff changeset
572 'text/x.moin.wiki': 'MoinWiki',
51b90beddc7c Shortens contenttype display in the history view
sharky93 <rishabhr123@gmail.com>
parents: 2396
diff changeset
573 }
51b90beddc7c Shortens contenttype display in the history view
sharky93 <rishabhr123@gmail.com>
parents: 2396
diff changeset
574
2492
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
575
2410
89ce7644a01d Adds todo for more content-types
sharky93 <rishabhr123@gmail.com>
parents: 2409
diff changeset
576 # TODO: Update dictionary with more content-types
2409
51b90beddc7c Shortens contenttype display in the history view
sharky93 <rishabhr123@gmail.com>
parents: 2396
diff changeset
577 def shorten_content_type(contenttype):
51b90beddc7c Shortens contenttype display in the history view
sharky93 <rishabhr123@gmail.com>
parents: 2396
diff changeset
578 """
51b90beddc7c Shortens contenttype display in the history view
sharky93 <rishabhr123@gmail.com>
parents: 2396
diff changeset
579 Shorten content-types
51b90beddc7c Shortens contenttype display in the history view
sharky93 <rishabhr123@gmail.com>
parents: 2396
diff changeset
580
51b90beddc7c Shortens contenttype display in the history view
sharky93 <rishabhr123@gmail.com>
parents: 2396
diff changeset
581 Shortens the content-type to terms that normal users understand.
51b90beddc7c Shortens contenttype display in the history view
sharky93 <rishabhr123@gmail.com>
parents: 2396
diff changeset
582
51b90beddc7c Shortens contenttype display in the history view
sharky93 <rishabhr123@gmail.com>
parents: 2396
diff changeset
583 :param name: contenttype, unicode
51b90beddc7c Shortens contenttype display in the history view
sharky93 <rishabhr123@gmail.com>
parents: 2396
diff changeset
584 :rtype: unicode
51b90beddc7c Shortens contenttype display in the history view
sharky93 <rishabhr123@gmail.com>
parents: 2396
diff changeset
585 :returns: shortened version of contenttype
51b90beddc7c Shortens contenttype display in the history view
sharky93 <rishabhr123@gmail.com>
parents: 2396
diff changeset
586 """
51b90beddc7c Shortens contenttype display in the history view
sharky93 <rishabhr123@gmail.com>
parents: 2396
diff changeset
587 ctype = contenttype.split(';')[0]
51b90beddc7c Shortens contenttype display in the history view
sharky93 <rishabhr123@gmail.com>
parents: 2396
diff changeset
588 if ctype in CONTENTTYPE_SHORTEN:
51b90beddc7c Shortens contenttype display in the history view
sharky93 <rishabhr123@gmail.com>
parents: 2396
diff changeset
589 return CONTENTTYPE_SHORTEN[ctype]
51b90beddc7c Shortens contenttype display in the history view
sharky93 <rishabhr123@gmail.com>
parents: 2396
diff changeset
590 else:
51b90beddc7c Shortens contenttype display in the history view
sharky93 <rishabhr123@gmail.com>
parents: 2396
diff changeset
591 return "Unknown"
1975
384555088cab lots of pep8 fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1974
diff changeset
592
384555088cab lots of pep8 fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1974
diff changeset
593
1110
5479a3b62b9f Change shorten_revid to shorten_id everywhere.
Bilal Akhtar <bilalakhtar@ubuntu.com>
parents: 1109
diff changeset
594 def shorten_id(name, length=7):
1109
b703c5e590a3 Create new template filter "shorten_revid" which shortens the specified text to 7 chars
Bilal Akhtar <bilalakhtar@ubuntu.com>
parents: 969
diff changeset
595 """
1110
5479a3b62b9f Change shorten_revid to shorten_id everywhere.
Bilal Akhtar <bilalakhtar@ubuntu.com>
parents: 1109
diff changeset
596 Shorten IDs to specified length
1109
b703c5e590a3 Create new template filter "shorten_revid" which shortens the specified text to 7 chars
Bilal Akhtar <bilalakhtar@ubuntu.com>
parents: 969
diff changeset
597
1110
5479a3b62b9f Change shorten_revid to shorten_id everywhere.
Bilal Akhtar <bilalakhtar@ubuntu.com>
parents: 1109
diff changeset
598 Shorten long IDs into just the first <length> characters. There's
5479a3b62b9f Change shorten_revid to shorten_id everywhere.
Bilal Akhtar <bilalakhtar@ubuntu.com>
parents: 1109
diff changeset
599 no need to display the whole IDs everywhere.
1109
b703c5e590a3 Create new template filter "shorten_revid" which shortens the specified text to 7 chars
Bilal Akhtar <bilalakhtar@ubuntu.com>
parents: 969
diff changeset
600
b703c5e590a3 Create new template filter "shorten_revid" which shortens the specified text to 7 chars
Bilal Akhtar <bilalakhtar@ubuntu.com>
parents: 969
diff changeset
601 :param name: item name, unicode
1110
5479a3b62b9f Change shorten_revid to shorten_id everywhere.
Bilal Akhtar <bilalakhtar@ubuntu.com>
parents: 1109
diff changeset
602 :param length: Maximum length of the resulting ID, int
1109
b703c5e590a3 Create new template filter "shorten_revid" which shortens the specified text to 7 chars
Bilal Akhtar <bilalakhtar@ubuntu.com>
parents: 969
diff changeset
603 :rtype: unicode
1110
5479a3b62b9f Change shorten_revid to shorten_id everywhere.
Bilal Akhtar <bilalakhtar@ubuntu.com>
parents: 1109
diff changeset
604 :returns: <name> truncated to <length> characters
1109
b703c5e590a3 Create new template filter "shorten_revid" which shortens the specified text to 7 chars
Bilal Akhtar <bilalakhtar@ubuntu.com>
parents: 969
diff changeset
605 """
b703c5e590a3 Create new template filter "shorten_revid" which shortens the specified text to 7 chars
Bilal Akhtar <bilalakhtar@ubuntu.com>
parents: 969
diff changeset
606
1110
5479a3b62b9f Change shorten_revid to shorten_id everywhere.
Bilal Akhtar <bilalakhtar@ubuntu.com>
parents: 1109
diff changeset
607 return name[:length]
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
608
126
81f0ff7a5cae global / subitem index: do not show mimetype as text, but is a mimetype specific link class / icon
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 125
diff changeset
609 MIMETYPE_TO_CLASS = {
81f0ff7a5cae global / subitem index: do not show mimetype as text, but is a mimetype specific link class / icon
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 125
diff changeset
610 'application/pdf': 'pdf',
476
a716e61ae9c7 contenttype texts are replaced by icons in global history page, all icons are GPL licensed (picked from tango icons library).
Akash Sinha <akash2607@gmail.com>
parents: 248
diff changeset
611 'application/zip': 'package',
a716e61ae9c7 contenttype texts are replaced by icons in global history page, all icons are GPL licensed (picked from tango icons library).
Akash Sinha <akash2607@gmail.com>
parents: 248
diff changeset
612 'application/x-tar': 'package',
526
035656874a40 icluding tgz also as archive package for icon display, similar to tar(missed this earlier)
Akash Sinha <akash2607@gmail.com>
parents: 510
diff changeset
613 'application/x-gtar': 'package',
476
a716e61ae9c7 contenttype texts are replaced by icons in global history page, all icons are GPL licensed (picked from tango icons library).
Akash Sinha <akash2607@gmail.com>
parents: 248
diff changeset
614 'application/x-twikidraw': 'drawing',
a716e61ae9c7 contenttype texts are replaced by icons in global history page, all icons are GPL licensed (picked from tango icons library).
Akash Sinha <akash2607@gmail.com>
parents: 248
diff changeset
615 'application/x-anywikidraw': 'drawing',
a716e61ae9c7 contenttype texts are replaced by icons in global history page, all icons are GPL licensed (picked from tango icons library).
Akash Sinha <akash2607@gmail.com>
parents: 248
diff changeset
616 'application/x-svgdraw': 'drawing',
126
81f0ff7a5cae global / subitem index: do not show mimetype as text, but is a mimetype specific link class / icon
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 125
diff changeset
617 }
81f0ff7a5cae global / subitem index: do not show mimetype as text, but is a mimetype specific link class / icon
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 125
diff changeset
618
1975
384555088cab lots of pep8 fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1974
diff changeset
619
216
661a57c747bd replace mimetype by contenttype, use more constants
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 174
diff changeset
620 def contenttype_to_class(contenttype):
126
81f0ff7a5cae global / subitem index: do not show mimetype as text, but is a mimetype specific link class / icon
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 125
diff changeset
621 """
216
661a57c747bd replace mimetype by contenttype, use more constants
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 174
diff changeset
622 Convert a contenttype string to a css class.
126
81f0ff7a5cae global / subitem index: do not show mimetype as text, but is a mimetype specific link class / icon
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 125
diff changeset
623 """
216
661a57c747bd replace mimetype by contenttype, use more constants
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 174
diff changeset
624 cls = MIMETYPE_TO_CLASS.get(contenttype)
126
81f0ff7a5cae global / subitem index: do not show mimetype as text, but is a mimetype specific link class / icon
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 125
diff changeset
625 if not cls:
81f0ff7a5cae global / subitem index: do not show mimetype as text, but is a mimetype specific link class / icon
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 125
diff changeset
626 # just use the major part of mimetype
216
661a57c747bd replace mimetype by contenttype, use more constants
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 174
diff changeset
627 cls = contenttype.split('/', 1)[0]
969
5bf6d7a2ffcf Convert all %r, %s, %x, %d, %i, %o to new Format String Syntax
Vedran Mileti? <rivanvx@gmail.com>
parents: 861
diff changeset
628 return 'moin-mime-{0}'.format(cls)
126
81f0ff7a5cae global / subitem index: do not show mimetype as text, but is a mimetype specific link class / icon
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 125
diff changeset
629
81f0ff7a5cae global / subitem index: do not show mimetype as text, but is a mimetype specific link class / icon
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 125
diff changeset
630
770
a4ec2c6f0bb7 history: do not yield Revision objects, but directly result documents from whoosh
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 526
diff changeset
631 def utctimestamp(dt):
a4ec2c6f0bb7 history: do not yield Revision objects, but directly result documents from whoosh
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 526
diff changeset
632 """
a4ec2c6f0bb7 history: do not yield Revision objects, but directly result documents from whoosh
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 526
diff changeset
633 convert a datetime object (UTC) to a UNIX timestamp (UTC)
a4ec2c6f0bb7 history: do not yield Revision objects, but directly result documents from whoosh
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 526
diff changeset
634
a4ec2c6f0bb7 history: do not yield Revision objects, but directly result documents from whoosh
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 526
diff changeset
635 Note: time library writers seem to have a distorted relationship to inverse
a4ec2c6f0bb7 history: do not yield Revision objects, but directly result documents from whoosh
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 526
diff changeset
636 functions and also to UTC (see time.gmtime, see datetime.utcfromtimestamp).
a4ec2c6f0bb7 history: do not yield Revision objects, but directly result documents from whoosh
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 526
diff changeset
637 """
a4ec2c6f0bb7 history: do not yield Revision objects, but directly result documents from whoosh
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 526
diff changeset
638 from calendar import timegm
a4ec2c6f0bb7 history: do not yield Revision objects, but directly result documents from whoosh
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 526
diff changeset
639 return timegm(dt.timetuple())
a4ec2c6f0bb7 history: do not yield Revision objects, but directly result documents from whoosh
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 526
diff changeset
640
a4ec2c6f0bb7 history: do not yield Revision objects, but directly result documents from whoosh
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 526
diff changeset
641
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
642 def setup_jinja_env():
2226
09a9bffa1581 Added Support for non-unique fields plus toggling b//w fqname and value on mouseover.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2217
diff changeset
643 app.jinja_env.filters['shorten_fqname'] = shorten_fqname
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
644 app.jinja_env.filters['shorten_item_name'] = shorten_item_name
1110
5479a3b62b9f Change shorten_revid to shorten_id everywhere.
Bilal Akhtar <bilalakhtar@ubuntu.com>
parents: 1109
diff changeset
645 app.jinja_env.filters['shorten_id'] = shorten_id
216
661a57c747bd replace mimetype by contenttype, use more constants
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 174
diff changeset
646 app.jinja_env.filters['contenttype_to_class'] = contenttype_to_class
1145
5421be737643 Simplify string escaping filter.
Sam Toyer <samATqxcvDOTnet>
parents: 1144
diff changeset
647 app.jinja_env.filters['json_dumps'] = dumps
2409
51b90beddc7c Shortens contenttype display in the history view
sharky93 <rishabhr123@gmail.com>
parents: 2396
diff changeset
648 app.jinja_env.filters['shorten_ctype'] = shorten_content_type
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
649 # please note that these filters are installed by flask-babel:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
650 # datetimeformat, dateformat, timeformat, timedeltaformat
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
651
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
652 app.jinja_env.globals.update({
2011
791bdedb0c20 fix lots of pep8 issues, mainly E12x
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
653 # please note that flask-babel/jinja2.ext installs:
791bdedb0c20 fix lots of pep8 issues, mainly E12x
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
654 # _, gettext, ngettext
791bdedb0c20 fix lots of pep8 issues, mainly E12x
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
655 'isinstance': isinstance,
791bdedb0c20 fix lots of pep8 issues, mainly E12x
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
656 'list': list,
791bdedb0c20 fix lots of pep8 issues, mainly E12x
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
657 'Type': Type,
791bdedb0c20 fix lots of pep8 issues, mainly E12x
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
658 # please note that flask-themes installs:
791bdedb0c20 fix lots of pep8 issues, mainly E12x
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
659 # theme, theme_static
791bdedb0c20 fix lots of pep8 issues, mainly E12x
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
660 'theme_supp': ThemeSupport(app.cfg),
791bdedb0c20 fix lots of pep8 issues, mainly E12x
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
661 'user': flaskg.user,
791bdedb0c20 fix lots of pep8 issues, mainly E12x
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
662 'storage': flaskg.storage,
791bdedb0c20 fix lots of pep8 issues, mainly E12x
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
663 'clock': flaskg.clock,
791bdedb0c20 fix lots of pep8 issues, mainly E12x
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
664 'cfg': app.cfg,
2519
b942154b2d74 merged bootstrap and main repo
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2492 2292
diff changeset
665 'item_name': u'@NONAMEGIVEN', # XXX can we just use u'' ?
2011
791bdedb0c20 fix lots of pep8 issues, mainly E12x
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
666 'url_for_item': url_for_item,
791bdedb0c20 fix lots of pep8 issues, mainly E12x
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
667 'get_editor_info': lambda meta: get_editor_info(meta),
791bdedb0c20 fix lots of pep8 issues, mainly E12x
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
668 'utctimestamp': lambda dt: utctimestamp(dt),
791bdedb0c20 fix lots of pep8 issues, mainly E12x
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
669 'gen': make_generator(),
791bdedb0c20 fix lots of pep8 issues, mainly E12x
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
670 'search_form': SearchForm.from_defaults(),
791bdedb0c20 fix lots of pep8 issues, mainly E12x
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
671 })