annotate MoinMoin/themes/__init__.py @ 2857:0b4b562f5b87

change icon for similar names to fa-search-minus
author RogerHaase <haaserd@gmail.com>
date Sat, 22 Nov 2014 15:06:04 -0700
parents 615599f53b07
children 7de85ecc3669
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
2651
2003e3685733 Improved search GUI - Added information about contenttype and item size in the items metadata. Also added color coding for various stuff like green for metadata, yellow for search term suggestions, blue for item names. Also added search options to help in search - search all revisions or the latest ones, sort search results by time - newer first, older first or default, search items of particular contenttype(s). Also removed the second search bar in the upper right corner in search page.
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2590
diff changeset
26 from MoinMoin.constants.contenttypes import CONTENTTYPES_MAP
2292
7b7e07bb6f8a Removed linking of all view to home.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2282
diff changeset
27 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
28 from MoinMoin.search import SearchForm
2651
2003e3685733 Improved search GUI - Added information about contenttype and item size in the items metadata. Also added color coding for various stuff like green for metadata, yellow for search term suggestions, blue for item names. Also added search options to help in search - search all revisions or the latest ones, sort search results by time - newer first, older first or default, search items of particular contenttype(s). Also removed the second search bar in the upper right corner in search page.
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2590
diff changeset
29 from MoinMoin.util.interwiki import split_interwiki, getInterwikiHome, is_local_wiki, is_known_wiki, url_for_item, CompositeName, split_fqname, get_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
30 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
31 from MoinMoin.util.forms import make_generator
1764
19b19d4d9291 Add a @timed decorator.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1726
diff changeset
32 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
33 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
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
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
36 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
37 # 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
38 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
39 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
40 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
41 else:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
42 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
43 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
44 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
45 except KeyError:
1975
384555088cab lots of pep8 fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1974
diff changeset
46 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
47 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
48 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
49 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
50
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
51
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
52 def render_template(template, **context):
1764
19b19d4d9291 Add a @timed decorator.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1726
diff changeset
53 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
54
1975
384555088cab lots of pep8 fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1974
diff changeset
55
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
56 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
57 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
58 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
59 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
60 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
61 else:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
62 # 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
63 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
64 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
65 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
66 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
67 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
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
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
70 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
71 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
72 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
73 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
74 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
75 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
76 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
77 self.storage = flaskg.storage
1975
384555088cab lots of pep8 fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1974
diff changeset
78 self.ui_lang = 'en' # XXX
384555088cab lots of pep8 fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1974
diff changeset
79 self.ui_dir = 'ltr' # XXX
384555088cab lots of pep8 fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1974
diff changeset
80 self.content_lang = flaskg.content_lang # XXX
384555088cab lots of pep8 fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1974
diff changeset
81 self.content_dir = 'ltr' # XXX
384555088cab lots of pep8 fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1974
diff changeset
82 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
83
2662
2a50e6628a16 Fix to issue #433
Saurabh Kathpalia <saurabh.kathpalia95@gmail.com>
parents: 2651
diff changeset
84 def get_action_tabs(self, fqname, current_endpoint):
2489
d29bfd06cd8c Fixes the global index view, issue with checking existence of empty string
sharky93 <rishabhr123@gmail.com>
parents: 2482
diff changeset
85
2683
5a6660508036 Changed the order of items in blog meta data view and also removed unnecessary show/modify option in Global index
Saurabh Kathpalia <saurabh.kathpalia95@gmail.com>
parents: 2679
diff changeset
86 if not fqname or not fqname.value:
2489
d29bfd06cd8c Fixes the global index view, issue with checking existence of empty string
sharky93 <rishabhr123@gmail.com>
parents: 2482
diff changeset
87 return []
d29bfd06cd8c Fixes the global index view, issue with checking existence of empty string
sharky93 <rishabhr123@gmail.com>
parents: 2482
diff changeset
88
2662
2a50e6628a16 Fix to issue #433
Saurabh Kathpalia <saurabh.kathpalia95@gmail.com>
parents: 2651
diff changeset
89 # TODO: Need to add fqname support to has_item in indexing.py
2a50e6628a16 Fix to issue #433
Saurabh Kathpalia <saurabh.kathpalia95@gmail.com>
parents: 2651
diff changeset
90 exists = bool(flaskg.storage.get_item(**fqname.query))
2492
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
91
2395
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
92 navtabs_endpoints = ['frontend.show_item', 'frontend.history',
2492
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
93 'frontend.show_item_meta', 'frontend.highlight_item', 'frontend.backrefs',
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
94 '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
95
2662
2a50e6628a16 Fix to issue #433
Saurabh Kathpalia <saurabh.kathpalia95@gmail.com>
parents: 2651
diff changeset
96 if self.user.may.write(fqname):
2395
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
97 navtabs_endpoints.append('frontend.modify_item')
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
98
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
99 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
100
2395
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
101 navtabs = []
2492
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
102 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
103
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
104 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
105 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
106 if not check_exists or exists:
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
107 if endpoint in navtabs_endpoints:
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
108
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
109 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
110 linkcls = None
2492
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
111
2395
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
112 if endpoint == 'special.comments':
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
113 maincls = "moin-toggle-comments-button"
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
114 href = "#"
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
115 elif endpoint == 'special.transclusions':
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
116 maincls = "moin-transclusions-button"
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
117 href = "#"
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
118 else:
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
119 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
120 # 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
121 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
122 linkcls = "moin-modify-button"
2662
2a50e6628a16 Fix to issue #433
Saurabh Kathpalia <saurabh.kathpalia95@gmail.com>
parents: 2651
diff changeset
123 href = url_for(endpoint, item_name=fqname)
2396
35b64d97bd9c Fixes #39, by making the history tab active for diff views
sharky93 <rishabhr123@gmail.com>
parents: 2395
diff changeset
124 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
125 maincls = "active"
2395
e0a4950b9658 Refactored tab views code, major part on python side
sharky93 <rishabhr123@gmail.com>
parents: 2394
diff changeset
126
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
127 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
128 return navtabs
7df17df524e7 adds helper function to render action tabs
sharky93 <rishabhr123@gmail.com>
parents: 2328
diff changeset
129
2662
2a50e6628a16 Fix to issue #433
Saurabh Kathpalia <saurabh.kathpalia95@gmail.com>
parents: 2651
diff changeset
130 def get_local_panel(self, fqname):
2489
d29bfd06cd8c Fixes the global index view, issue with checking existence of empty string
sharky93 <rishabhr123@gmail.com>
parents: 2482
diff changeset
131
2662
2a50e6628a16 Fix to issue #433
Saurabh Kathpalia <saurabh.kathpalia95@gmail.com>
parents: 2651
diff changeset
132 if not fqname:
2489
d29bfd06cd8c Fixes the global index view, issue with checking existence of empty string
sharky93 <rishabhr123@gmail.com>
parents: 2482
diff changeset
133 return [], [], []
d29bfd06cd8c Fixes the global index view, issue with checking existence of empty string
sharky93 <rishabhr123@gmail.com>
parents: 2482
diff changeset
134
2662
2a50e6628a16 Fix to issue #433
Saurabh Kathpalia <saurabh.kathpalia95@gmail.com>
parents: 2651
diff changeset
135 item = flaskg.storage.get_item(**fqname.query)
2489
d29bfd06cd8c Fixes the global index view, issue with checking existence of empty string
sharky93 <rishabhr123@gmail.com>
parents: 2482
diff changeset
136
2662
2a50e6628a16 Fix to issue #433
Saurabh Kathpalia <saurabh.kathpalia95@gmail.com>
parents: 2651
diff changeset
137 if not item:
2491
8f054781b48a more defensive checking for item existence, improved generation of current_url, pep8 fixes remain
sharky93 <rishabhr123@gmail.com>
parents: 2489
diff changeset
138 return [], [], []
8f054781b48a more defensive checking for item existence, improved generation of current_url, pep8 fixes remain
sharky93 <rishabhr123@gmail.com>
parents: 2489
diff changeset
139
2393
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
140 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
141 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
142 item_actions_endpoints = ['frontend.rename_item', 'frontend.delete_item', 'frontend.destroy_item',
2492
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
143 'frontend.download_item',
2662
2a50e6628a16 Fix to issue #433
Saurabh Kathpalia <saurabh.kathpalia95@gmail.com>
parents: 2651
diff changeset
144 'frontend.copy_item', ] if self.user.may.write(fqname) else []
2393
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
145
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
146 user_actions = []
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
147 item_navigation = []
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
148 item_actions = []
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 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
151
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
152 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
153 if endpoint not in app.cfg.endpoints_excluded:
2662
2a50e6628a16 Fix to issue #433
Saurabh Kathpalia <saurabh.kathpalia95@gmail.com>
parents: 2651
diff changeset
154 if not check_exists or item:
2393
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
155 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
156 if flaskg.user.valid:
2662
2a50e6628a16 Fix to issue #433
Saurabh Kathpalia <saurabh.kathpalia95@gmail.com>
parents: 2651
diff changeset
157 href = url_for(endpoint, item_name=fqname)
2393
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
158 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
159 # 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
160
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
161 if endpoint == 'frontend.quicklink_item':
2662
2a50e6628a16 Fix to issue #433
Saurabh Kathpalia <saurabh.kathpalia95@gmail.com>
parents: 2651
diff changeset
162 if not flaskg.user.is_quicklinked_to([fqname]):
2393
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
163 label = _('Add Link')
2708
b8680cd6cf91 Fixed quicklinks and their tooltips
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2683
diff changeset
164 else:
b8680cd6cf91 Fixed quicklinks and their tooltips
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2683
diff changeset
165 label = _('Remove Link')
b8680cd6cf91 Fixed quicklinks and their tooltips
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2683
diff changeset
166 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
167 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
168 from MoinMoin.items import Item
2662
2a50e6628a16 Fix to issue #433
Saurabh Kathpalia <saurabh.kathpalia95@gmail.com>
parents: 2651
diff changeset
169 if flaskg.user.is_subscribed_to(item.item):
2393
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
170 label = _('Unsubscribe')
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
171 else:
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
172 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
173 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
174
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
175 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
176
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
177 iconcls = icon[endpoint]
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
178
2662
2a50e6628a16 Fix to issue #433
Saurabh Kathpalia <saurabh.kathpalia95@gmail.com>
parents: 2651
diff changeset
179 href = url_for(endpoint, item_name=fqname)
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
180 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
181
2662
2a50e6628a16 Fix to issue #433
Saurabh Kathpalia <saurabh.kathpalia95@gmail.com>
parents: 2651
diff changeset
182 # Special Supplementation defined only for named items
2a50e6628a16 Fix to issue #433
Saurabh Kathpalia <saurabh.kathpalia95@gmail.com>
parents: 2651
diff changeset
183 elif endpoint in item_navigation_endpoints and fqname.field == NAME_EXACT:
2448
7fb6bff63aa0 fixes #64, discussion moved under item_navigation
sharky93 <rishabhr123@gmail.com>
parents: 2446
diff changeset
184
7fb6bff63aa0 fixes #64, discussion moved under item_navigation
sharky93 <rishabhr123@gmail.com>
parents: 2446
diff changeset
185 iconcls = icon[endpoint]
2492
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
186
2393
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
187 if endpoint == 'special.supplementation':
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
188 for sub_item_name in app.cfg.supplementation_item_names:
2662
2a50e6628a16 Fix to issue #433
Saurabh Kathpalia <saurabh.kathpalia95@gmail.com>
parents: 2651
diff changeset
189 current_sub = fqname.value.rsplit('/', 1)[-1]
2393
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
190 if current_sub not in app.cfg.supplementation_item_names:
2662
2a50e6628a16 Fix to issue #433
Saurabh Kathpalia <saurabh.kathpalia95@gmail.com>
parents: 2651
diff changeset
191 supp_name = '%s/%s' % (fqname.value, sub_item_name)
2393
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
192 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
193 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
194 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
195 label = _(sub_item_name)
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
196 title = None
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
197
2482
f50f7d1cbf14 Fixes non-display of delete, destroy, other item actions, variable value was being overwritten
sharky93 <rishabhr123@gmail.com>
parents: 2480
diff changeset
198 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
199 else:
2662
2a50e6628a16 Fix to issue #433
Saurabh Kathpalia <saurabh.kathpalia95@gmail.com>
parents: 2651
diff changeset
200 href = url_for(endpoint, item_name=fqname)
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
201 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
202
2381
aa19b1b69b5c adds helper function to render the local panel
sharky93 <rishabhr123@gmail.com>
parents: 2380
diff changeset
203 return user_actions, item_navigation, item_actions
aa19b1b69b5c adds helper function to render the local panel
sharky93 <rishabhr123@gmail.com>
parents: 2380
diff changeset
204
2387
9bf41329f031 icon dict to map endpoints with icon retrieved from helper functions
sharky93 <rishabhr123@gmail.com>
parents: 2381
diff changeset
205 def get_endpoint_iconmap(self):
2834
615599f53b07 fix #443 part 2 convert font awesome 3 class names to font awesome 4 class names
RogerHaase <haaserd@gmail.com>
parents: 2708
diff changeset
206 icon = {'frontend.quicklink_item': "fa fa-star-o",
615599f53b07 fix #443 part 2 convert font awesome 3 class names to font awesome 4 class names
RogerHaase <haaserd@gmail.com>
parents: 2708
diff changeset
207 'frontend.subscribe_item': "fa fa-envelope-o",
615599f53b07 fix #443 part 2 convert font awesome 3 class names to font awesome 4 class names
RogerHaase <haaserd@gmail.com>
parents: 2708
diff changeset
208 'frontend.index': "fa fa-list-alt",
615599f53b07 fix #443 part 2 convert font awesome 3 class names to font awesome 4 class names
RogerHaase <haaserd@gmail.com>
parents: 2708
diff changeset
209 'frontend.sitemap': "fa fa-sitemap",
615599f53b07 fix #443 part 2 convert font awesome 3 class names to font awesome 4 class names
RogerHaase <haaserd@gmail.com>
parents: 2708
diff changeset
210 'frontend.rename_item': "fa fa-tag",
615599f53b07 fix #443 part 2 convert font awesome 3 class names to font awesome 4 class names
RogerHaase <haaserd@gmail.com>
parents: 2708
diff changeset
211 'frontend.delete_item': "fa fa-trash-o",
615599f53b07 fix #443 part 2 convert font awesome 3 class names to font awesome 4 class names
RogerHaase <haaserd@gmail.com>
parents: 2708
diff changeset
212 'frontend.destroy_item': "fa fa-fire",
2857
0b4b562f5b87 change icon for similar names to fa-search-minus
RogerHaase <haaserd@gmail.com>
parents: 2834
diff changeset
213 'frontend.similar_names': "fa fa-search-minus",
2834
615599f53b07 fix #443 part 2 convert font awesome 3 class names to font awesome 4 class names
RogerHaase <haaserd@gmail.com>
parents: 2708
diff changeset
214 'frontend.download_item': "fa fa-download",
615599f53b07 fix #443 part 2 convert font awesome 3 class names to font awesome 4 class names
RogerHaase <haaserd@gmail.com>
parents: 2708
diff changeset
215 'frontend.copy_item': "fa fa-comment-o",
615599f53b07 fix #443 part 2 convert font awesome 3 class names to font awesome 4 class names
RogerHaase <haaserd@gmail.com>
parents: 2708
diff changeset
216 'special.supplementation': "fa fa-comments-o",
615599f53b07 fix #443 part 2 convert font awesome 3 class names to font awesome 4 class names
RogerHaase <haaserd@gmail.com>
parents: 2708
diff changeset
217 'frontend.show_item': "fa fa-eye",
615599f53b07 fix #443 part 2 convert font awesome 3 class names to font awesome 4 class names
RogerHaase <haaserd@gmail.com>
parents: 2708
diff changeset
218 'frontend.modify_item': "fa fa-pencil",
615599f53b07 fix #443 part 2 convert font awesome 3 class names to font awesome 4 class names
RogerHaase <haaserd@gmail.com>
parents: 2708
diff changeset
219 'frontend.history': "fa fa-clock-o",
615599f53b07 fix #443 part 2 convert font awesome 3 class names to font awesome 4 class names
RogerHaase <haaserd@gmail.com>
parents: 2708
diff changeset
220 'frontend.show_item_meta': "fa fa-wrench",
615599f53b07 fix #443 part 2 convert font awesome 3 class names to font awesome 4 class names
RogerHaase <haaserd@gmail.com>
parents: 2708
diff changeset
221 'frontend.highlight_item': "fa fa-code",
615599f53b07 fix #443 part 2 convert font awesome 3 class names to font awesome 4 class names
RogerHaase <haaserd@gmail.com>
parents: 2708
diff changeset
222 'frontend.backrefs': "fa fa-share",
615599f53b07 fix #443 part 2 convert font awesome 3 class names to font awesome 4 class names
RogerHaase <haaserd@gmail.com>
parents: 2708
diff changeset
223 'special.comments': "fa fa-comment-o",
615599f53b07 fix #443 part 2 convert font awesome 3 class names to font awesome 4 class names
RogerHaase <haaserd@gmail.com>
parents: 2708
diff changeset
224 'special.transclusions': "fa fa-edit", }
2492
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
225 return icon
2387
9bf41329f031 icon dict to map endpoints with icon retrieved from helper functions
sharky93 <rishabhr123@gmail.com>
parents: 2381
diff changeset
226
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
227 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
228 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
229 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
230
38
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
231 :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
232 :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
233 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
234 breadcrumbs = []
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
235 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
236 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
237 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
238 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
239 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
240 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
241 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
242 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
243 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
244 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
245 if not item_name:
2252
ecd43cdbb9b6 breadcrubms now show up titles properly.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2236
diff changeset
246 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
247 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
248 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
249 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
250 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
251 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
252 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
253 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
254
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
255 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
256 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
257 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
258
38
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
259 :rtype: list
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
260 :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
261 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
262 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
263 breadcrumbs = []
1281
0a70177ce4de user: changed method names for better PEP8 compliance
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1278
diff changeset
264 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
265 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
266 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
267 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
268 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
269 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
270 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
271 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
272 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
273 else:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
274 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
275 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
276 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
277 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
278
2263
6dd5af01d54d Sub-items pannel now has fqname support.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2253
diff changeset
279 def subitem_index(self, fqname):
1123
ebc4f8213e74 Add a flat subitem index for show item view.
Sam Toyer <samATqxcvDOTnet>
parents: 1110
diff changeset
280 """
2263
6dd5af01d54d Sub-items pannel now has fqname support.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2253
diff changeset
281 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
282
ebc4f8213e74 Add a flat subitem index for show item view.
Sam Toyer <samATqxcvDOTnet>
parents: 1110
diff changeset
283 :rtype: list
ebc4f8213e74 Add a flat subitem index for show item view.
Sam Toyer <samATqxcvDOTnet>
parents: 1110
diff changeset
284 :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
285 """
ebc4f8213e74 Add a flat subitem index for show item view.
Sam Toyer <samATqxcvDOTnet>
parents: 1110
diff changeset
286 from MoinMoin.items import Item
2263
6dd5af01d54d Sub-items pannel now has fqname support.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2253
diff changeset
287 if not isinstance(fqname, CompositeName):
6dd5af01d54d Sub-items pannel now has fqname support.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2253
diff changeset
288 fqname = split_fqname(fqname)
6dd5af01d54d Sub-items pannel now has fqname support.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2253
diff changeset
289 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
290 return item.get_mixed_index()
1123
ebc4f8213e74 Add a flat subitem index for show item view.
Sam Toyer <samATqxcvDOTnet>
parents: 1110
diff changeset
291
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
292 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
293 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
294 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
295
38
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
296 :rtype: tuple
1063
ee71ed6e97c6 change user.aliasname to user.display_name
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 969
diff changeset
297 :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
298 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
299 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
300 name = user.name0
1063
ee71ed6e97c6 change user.aliasname to user.display_name
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 969
diff changeset
301 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
302 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
303 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
304 # 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
305 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
306 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
307 else:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
308 # 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
309 exists = True
2279
49bc6f85f918 Fixed pep8 errors.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2273
diff changeset
310 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
311 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
312
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
313 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
314 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
315 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
316
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
317 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
318 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
319
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
320 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
321 * PageName
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
322 * 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
323 * 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
324 * url
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
325 * 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
326
38
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
327 :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
328 :rtype: tuple
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
329 :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
330 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
331 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
332 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
333
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
334 # 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
335 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
336 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
337 try:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
338 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
339 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
340 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
341 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
342 # 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
343 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
344 else:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
345 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
346
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
347 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
348 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
349 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
350 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
351
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
352 # 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
353 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
354 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
355
2217
431815d4f4a6 Fixed interwiki patch to deal with new composite name.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2117
diff changeset
356 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
357 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
358 wiki_name = ''
2217
431815d4f4a6 Fixed interwiki patch to deal with new composite name.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2117
diff changeset
359 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
360 if not title:
2230
f2bd327932fb Fixes #6. Quicklinks now use abbreviated fqnames.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2226
diff changeset
361 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
362 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
363
1764
19b19d4d9291 Add a @timed decorator.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1726
diff changeset
364 @timed()
2282
5c424120a253 Fixed #21, now links in navbar link to current namespace.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2279
diff changeset
365 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
366 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
367 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
368
38
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
369 :rtype: list
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
370 :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
371 """
2282
5c424120a253 Fixed #21, now links in navbar link to current namespace.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2279
diff changeset
372 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
373 fqname = split_fqname(fqname)
5c424120a253 Fixed #21, now links in navbar link to current namespace.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2279
diff changeset
374 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
375 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
376 # 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
377 items = []
423d8d791cc9 Fix for Issue#291, home link now coloured as should be
sharky93 <rishabhr123@gmail.com>
parents: 2011
diff changeset
378 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
379 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
380 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
381 root_fqname = fqname.get_root_fqname()
2292
7b7e07bb6f8a Removed linking of all view to home.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2282
diff changeset
382 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
383 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
384 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
385 args['namespace'] = fqname.namespace
5c424120a253 Fixed #21, now links in navbar link to current namespace.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2279
diff changeset
386 elif endpoint == "frontend.index":
5c424120a253 Fixed #21, now links in navbar link to current namespace.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2279
diff changeset
387 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
388 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
389
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
390 # 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
391 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
392 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
393 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
394
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
395 # 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
396 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
397 if is_local_wiki(sistername):
1885
063c879ef79b sistersites: fix tuple member count
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1801
diff changeset
398 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
399 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
400 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
401 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
402 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
403 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
404 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
405 try:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
406 sisteritems = {}
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
407 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
408 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
409 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
410 try:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
411 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
412 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
413 except:
1975
384555088cab lots of pep8 fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1974
diff changeset
414 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
415 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
416 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
417 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
418 except IOError as err:
1975
384555088cab lots of pep8 fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1974
diff changeset
419 (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
420 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
421 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
422 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
423 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
424 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
425 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
426
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
427 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
428 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
429 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
430
38
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
431 :rtype: unicode
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
432 :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
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 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
435 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
436 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
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 # 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
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 # Properties ##############################################################
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
441
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
442 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
443 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
444 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
445
38
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
446 :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
447 :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
448 """
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 = None
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
450 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
451 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
452 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
453 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
454 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
455
2253
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
456 def get_fqnames(self, fqname):
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
457 """
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
458 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
459 """
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
460 if fqname.field != NAME_EXACT:
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
461 return []
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
462 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
463 fqnames = item.fqnames
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
464 fqnames.remove(fqname)
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
465 return fqnames or []
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
466
2679
e130fc605c63 Solves issue #394
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2673
diff changeset
467 def get_namespaces(self, ns=None):
2253
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
468 """
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
469 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
470 than the current namespace.
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
471 """
2679
e130fc605c63 Solves issue #394
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2673
diff changeset
472 if ns is not None and ns.value == '~':
e130fc605c63 Solves issue #394
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2673
diff changeset
473 ns = u''
2253
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
474 namespace_root_mapping = []
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
475 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
476 namespace = namespace.rstrip('/')
2679
e130fc605c63 Solves issue #394
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2673
diff changeset
477 if ns is None or namespace != ns:
2253
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
478 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
479 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
480 return namespace_root_mapping
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
481
2669
7798855349f6 Improved Metadata view
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2651
diff changeset
482 def item_exists(self, itemname):
7798855349f6 Improved Metadata view
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2651
diff changeset
483 """
7798855349f6 Improved Metadata view
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2651
diff changeset
484 Check whether the item pointed to by the given itemname exists or not
7798855349f6 Improved Metadata view
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2651
diff changeset
485
7798855349f6 Improved Metadata view
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2651
diff changeset
486 :rtype: boolean
7798855349f6 Improved Metadata view
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2651
diff changeset
487 :returns: whether item pointed to by the link exists or not
7798855349f6 Improved Metadata view
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2651
diff changeset
488 """
7798855349f6 Improved Metadata view
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2651
diff changeset
489 return self.storage.has_item(itemname)
7798855349f6 Improved Metadata view
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2651
diff changeset
490
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
491
861
9a7889c04a25 fixed history view
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 859
diff changeset
492 def get_editor_info(meta, external=False):
9a7889c04a25 fixed history view
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 859
diff changeset
493 addr = meta.get(ADDRESS)
9a7889c04a25 fixed history view
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 859
diff changeset
494 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
495 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
496 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
497 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
498 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
499 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
500 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
501 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
502 # 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
503 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
504 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
505 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
506 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
507 else:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
508 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
509 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
510 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
511
861
9a7889c04a25 fixed history view
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 859
diff changeset
512 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
513 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
514 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
515 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
516 text = name
1063
ee71ed6e97c6 change user.aliasname to user.display_name
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 969
diff changeset
517 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
518 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
519 # 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
520 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
521 else:
1063
ee71ed6e97c6 change user.aliasname to user.display_name
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 969
diff changeset
522 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
523 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
524 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
525 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
526 else:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
527 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
528 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
529 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
530 else:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
531 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
532 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
533
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
534 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
535 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
536 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
537 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
538 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
539 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
540
1975
384555088cab lots of pep8 fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1974
diff changeset
541
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
542 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
543 """
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 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
545
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 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
547 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
548
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
549 :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
550 :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
551 :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
552 :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
553 """
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
554 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
555 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
556 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
557 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
558 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
559 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
560 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
561
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
562
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
563 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
564 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
565 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
566
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
567 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
568 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
569 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
570
38
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
571 :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
572 :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
573 :rtype: unicode
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
574 :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
575 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
576 # 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
577 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
578 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
579 # 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
580 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
581 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
582 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
583 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
584
2409
51b90beddc7c Shortens contenttype display in the history view
sharky93 <rishabhr123@gmail.com>
parents: 2396
diff changeset
585 CONTENTTYPE_SHORTEN = {
51b90beddc7c Shortens contenttype display in the history view
sharky93 <rishabhr123@gmail.com>
parents: 2396
diff changeset
586 'text/x.moin.wiki': 'MoinWiki',
51b90beddc7c Shortens contenttype display in the history view
sharky93 <rishabhr123@gmail.com>
parents: 2396
diff changeset
587 }
51b90beddc7c Shortens contenttype display in the history view
sharky93 <rishabhr123@gmail.com>
parents: 2396
diff changeset
588
2492
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
589
1110
5479a3b62b9f Change shorten_revid to shorten_id everywhere.
Bilal Akhtar <bilalakhtar@ubuntu.com>
parents: 1109
diff changeset
590 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
591 """
1110
5479a3b62b9f Change shorten_revid to shorten_id everywhere.
Bilal Akhtar <bilalakhtar@ubuntu.com>
parents: 1109
diff changeset
592 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
593
1110
5479a3b62b9f Change shorten_revid to shorten_id everywhere.
Bilal Akhtar <bilalakhtar@ubuntu.com>
parents: 1109
diff changeset
594 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
595 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
596
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 :param name: item name, unicode
1110
5479a3b62b9f Change shorten_revid to shorten_id everywhere.
Bilal Akhtar <bilalakhtar@ubuntu.com>
parents: 1109
diff changeset
598 :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
599 :rtype: unicode
1110
5479a3b62b9f Change shorten_revid to shorten_id everywhere.
Bilal Akhtar <bilalakhtar@ubuntu.com>
parents: 1109
diff changeset
600 :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
601 """
b703c5e590a3 Create new template filter "shorten_revid" which shortens the specified text to 7 chars
Bilal Akhtar <bilalakhtar@ubuntu.com>
parents: 969
diff changeset
602
1110
5479a3b62b9f Change shorten_revid to shorten_id everywhere.
Bilal Akhtar <bilalakhtar@ubuntu.com>
parents: 1109
diff changeset
603 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
604
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
605 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
606 '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
607 '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
608 '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
609 '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
610 '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
611 '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
612 '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
613 }
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
614
1975
384555088cab lots of pep8 fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1974
diff changeset
615
216
661a57c747bd replace mimetype by contenttype, use more constants
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 174
diff changeset
616 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
617 """
216
661a57c747bd replace mimetype by contenttype, use more constants
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 174
diff changeset
618 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
619 """
216
661a57c747bd replace mimetype by contenttype, use more constants
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 174
diff changeset
620 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
621 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
622 # 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
623 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
624 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
625
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
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
627 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
628 """
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
629 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
630
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 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
632 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
633 """
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 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
635 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
636
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
2651
2003e3685733 Improved search GUI - Added information about contenttype and item size in the items metadata. Also added color coding for various stuff like green for metadata, yellow for search term suggestions, blue for item names. Also added search options to help in search - search all revisions or the latest ones, sort search results by time - newer first, older first or default, search items of particular contenttype(s). Also removed the second search bar in the upper right corner in search page.
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2590
diff changeset
638 def shorten_ctype(contenttype):
2003e3685733 Improved search GUI - Added information about contenttype and item size in the items metadata. Also added color coding for various stuff like green for metadata, yellow for search term suggestions, blue for item names. Also added search options to help in search - search all revisions or the latest ones, sort search results by time - newer first, older first or default, search items of particular contenttype(s). Also removed the second search bar in the upper right corner in search page.
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2590
diff changeset
639 """
2003e3685733 Improved search GUI - Added information about contenttype and item size in the items metadata. Also added color coding for various stuff like green for metadata, yellow for search term suggestions, blue for item names. Also added search options to help in search - search all revisions or the latest ones, sort search results by time - newer first, older first or default, search items of particular contenttype(s). Also removed the second search bar in the upper right corner in search page.
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2590
diff changeset
640 Returns user understandable terms for contenttype.
2003e3685733 Improved search GUI - Added information about contenttype and item size in the items metadata. Also added color coding for various stuff like green for metadata, yellow for search term suggestions, blue for item names. Also added search options to help in search - search all revisions or the latest ones, sort search results by time - newer first, older first or default, search items of particular contenttype(s). Also removed the second search bar in the upper right corner in search page.
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2590
diff changeset
641
2003e3685733 Improved search GUI - Added information about contenttype and item size in the items metadata. Also added color coding for various stuff like green for metadata, yellow for search term suggestions, blue for item names. Also added search options to help in search - search all revisions or the latest ones, sort search results by time - newer first, older first or default, search items of particular contenttype(s). Also removed the second search bar in the upper right corner in search page.
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2590
diff changeset
642 :param contenttype: contains the long form of the contenttype
2003e3685733 Improved search GUI - Added information about contenttype and item size in the items metadata. Also added color coding for various stuff like green for metadata, yellow for search term suggestions, blue for item names. Also added search options to help in search - search all revisions or the latest ones, sort search results by time - newer first, older first or default, search items of particular contenttype(s). Also removed the second search bar in the upper right corner in search page.
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2590
diff changeset
643 :rtype: unicode
2003e3685733 Improved search GUI - Added information about contenttype and item size in the items metadata. Also added color coding for various stuff like green for metadata, yellow for search term suggestions, blue for item names. Also added search options to help in search - search all revisions or the latest ones, sort search results by time - newer first, older first or default, search items of particular contenttype(s). Also removed the second search bar in the upper right corner in search page.
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2590
diff changeset
644 :returns: user understandable version of contenttype
2003e3685733 Improved search GUI - Added information about contenttype and item size in the items metadata. Also added color coding for various stuff like green for metadata, yellow for search term suggestions, blue for item names. Also added search options to help in search - search all revisions or the latest ones, sort search results by time - newer first, older first or default, search items of particular contenttype(s). Also removed the second search bar in the upper right corner in search page.
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2590
diff changeset
645 """
2003e3685733 Improved search GUI - Added information about contenttype and item size in the items metadata. Also added color coding for various stuff like green for metadata, yellow for search term suggestions, blue for item names. Also added search options to help in search - search all revisions or the latest ones, sort search results by time - newer first, older first or default, search items of particular contenttype(s). Also removed the second search bar in the upper right corner in search page.
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2590
diff changeset
646 return CONTENTTYPES_MAP.get(contenttype, "Unknown")
2003e3685733 Improved search GUI - Added information about contenttype and item size in the items metadata. Also added color coding for various stuff like green for metadata, yellow for search term suggestions, blue for item names. Also added search options to help in search - search all revisions or the latest ones, sort search results by time - newer first, older first or default, search items of particular contenttype(s). Also removed the second search bar in the upper right corner in search page.
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2590
diff changeset
647
2003e3685733 Improved search GUI - Added information about contenttype and item size in the items metadata. Also added color coding for various stuff like green for metadata, yellow for search term suggestions, blue for item names. Also added search options to help in search - search all revisions or the latest ones, sort search results by time - newer first, older first or default, search items of particular contenttype(s). Also removed the second search bar in the upper right corner in search page.
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2590
diff changeset
648
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 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
650 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
651 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
652 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
653 app.jinja_env.filters['contenttype_to_class'] = contenttype_to_class
1145
5421be737643 Simplify string escaping filter.
Sam Toyer <samATqxcvDOTnet>
parents: 1144
diff changeset
654 app.jinja_env.filters['json_dumps'] = dumps
2651
2003e3685733 Improved search GUI - Added information about contenttype and item size in the items metadata. Also added color coding for various stuff like green for metadata, yellow for search term suggestions, blue for item names. Also added search options to help in search - search all revisions or the latest ones, sort search results by time - newer first, older first or default, search items of particular contenttype(s). Also removed the second search bar in the upper right corner in search page.
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2590
diff changeset
655 app.jinja_env.filters['shorten_ctype'] = shorten_ctype
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
656 # 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
657 # 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
658
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
659 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
660 # 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
661 # _, gettext, ngettext
791bdedb0c20 fix lots of pep8 issues, mainly E12x
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
662 'isinstance': isinstance,
791bdedb0c20 fix lots of pep8 issues, mainly E12x
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
663 'list': list,
791bdedb0c20 fix lots of pep8 issues, mainly E12x
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
664 'Type': Type,
791bdedb0c20 fix lots of pep8 issues, mainly E12x
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
665 # 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
666 # theme, theme_static
791bdedb0c20 fix lots of pep8 issues, mainly E12x
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
667 '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
668 'user': flaskg.user,
791bdedb0c20 fix lots of pep8 issues, mainly E12x
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
669 'storage': flaskg.storage,
791bdedb0c20 fix lots of pep8 issues, mainly E12x
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
670 'clock': flaskg.clock,
791bdedb0c20 fix lots of pep8 issues, mainly E12x
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
671 'cfg': app.cfg,
2519
b942154b2d74 merged bootstrap and main repo
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2492 2292
diff changeset
672 '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
673 'url_for_item': url_for_item,
2651
2003e3685733 Improved search GUI - Added information about contenttype and item size in the items metadata. Also added color coding for various stuff like green for metadata, yellow for search term suggestions, blue for item names. Also added search options to help in search - search all revisions or the latest ones, sort search results by time - newer first, older first or default, search items of particular contenttype(s). Also removed the second search bar in the upper right corner in search page.
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2590
diff changeset
674 'get_fqname': get_fqname,
2011
791bdedb0c20 fix lots of pep8 issues, mainly E12x
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
675 '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
676 '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
677 'gen': make_generator(),
791bdedb0c20 fix lots of pep8 issues, mainly E12x
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
678 '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
679 })