annotate MoinMoin/themes/__init__.py @ 2683:5a6660508036

Changed the order of items in blog meta data view and also removed unnecessary show/modify option in Global index
author Saurabh Kathpalia <saurabh.kathpalia95@gmail.com>
date Fri, 01 Aug 2014 17:51:20 +0530
parents e130fc605c63
children b8680cd6cf91
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')
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
164 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
165 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
166 from MoinMoin.items import Item
2662
2a50e6628a16 Fix to issue #433
Saurabh Kathpalia <saurabh.kathpalia95@gmail.com>
parents: 2651
diff changeset
167 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
168 label = _('Unsubscribe')
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
169 else:
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
170 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
171 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
172
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
173 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
174
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
175 iconcls = icon[endpoint]
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
176
2662
2a50e6628a16 Fix to issue #433
Saurabh Kathpalia <saurabh.kathpalia95@gmail.com>
parents: 2651
diff changeset
177 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
178 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
179
2662
2a50e6628a16 Fix to issue #433
Saurabh Kathpalia <saurabh.kathpalia95@gmail.com>
parents: 2651
diff changeset
180 # Special Supplementation defined only for named items
2a50e6628a16 Fix to issue #433
Saurabh Kathpalia <saurabh.kathpalia95@gmail.com>
parents: 2651
diff changeset
181 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
182
7fb6bff63aa0 fixes #64, discussion moved under item_navigation
sharky93 <rishabhr123@gmail.com>
parents: 2446
diff changeset
183 iconcls = icon[endpoint]
2492
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
184
2393
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
185 if endpoint == 'special.supplementation':
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
186 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
187 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
188 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
189 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
190 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
191 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
192 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
193 label = _(sub_item_name)
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
194 title = None
0cb9f75fb9ba Refactored local_panel rendering code, almost everything processed on python side
sharky93 <rishabhr123@gmail.com>
parents: 2387
diff changeset
195
2482
f50f7d1cbf14 Fixes non-display of delete, destroy, other item actions, variable value was being overwritten
sharky93 <rishabhr123@gmail.com>
parents: 2480
diff changeset
196 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
197 else:
2662
2a50e6628a16 Fix to issue #433
Saurabh Kathpalia <saurabh.kathpalia95@gmail.com>
parents: 2651
diff changeset
198 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
199 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
200
2381
aa19b1b69b5c adds helper function to render the local panel
sharky93 <rishabhr123@gmail.com>
parents: 2380
diff changeset
201 return user_actions, item_navigation, item_actions
aa19b1b69b5c adds helper function to render the local panel
sharky93 <rishabhr123@gmail.com>
parents: 2380
diff changeset
202
2387
9bf41329f031 icon dict to map endpoints with icon retrieved from helper functions
sharky93 <rishabhr123@gmail.com>
parents: 2381
diff changeset
203 def get_endpoint_iconmap(self):
2492
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
204 icon = {'frontend.quicklink_item': "icon-star-empty",
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
205 'frontend.subscribe_item': "icon-envelope",
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
206 'frontend.index': "icon-list-alt",
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
207 'frontend.sitemap': "icon-sitemap",
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
208 'frontend.rename_item': "icon-tag",
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
209 'frontend.delete_item': "icon-trash",
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
210 'frontend.destroy_item': "icon-fire",
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
211 'frontend.similar_names': "icon-search",
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
212 'frontend.download_item': "icon-download-alt",
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
213 'frontend.copy_item': "icon-comment",
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
214 'special.supplementation': "icon-comments",
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
215 'frontend.show_item': "icon-eye-open",
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
216 'frontend.modify_item': "icon-pencil",
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
217 'frontend.history': "icon-time",
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
218 'frontend.show_item_meta': "icon-wrench",
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
219 'frontend.highlight_item': "icon-code",
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
220 'frontend.backrefs': "icon-share",
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
221 'special.comments': "icon-comment",
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
222 'special.transclusions': "icon-edit", }
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
223 return icon
2387
9bf41329f031 icon dict to map endpoints with icon retrieved from helper functions
sharky93 <rishabhr123@gmail.com>
parents: 2381
diff changeset
224
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
225 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
226 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
227 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
228
38
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
229 :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
230 :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
231 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
232 breadcrumbs = []
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
233 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
234 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
235 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
236 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
237 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
238 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
239 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
240 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
241 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
242 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
243 if not item_name:
2252
ecd43cdbb9b6 breadcrubms now show up titles properly.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2236
diff changeset
244 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
245 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
246 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
247 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
248 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
249 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
250 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
251 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
252
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
253 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
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 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
256
38
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
257 :rtype: list
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
258 :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
259 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
260 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
261 breadcrumbs = []
1281
0a70177ce4de user: changed method names for better PEP8 compliance
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1278
diff changeset
262 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
263 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
264 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
265 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
266 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
267 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
268 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
269 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
270 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
271 else:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
272 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
273 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
274 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
275 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
276
2263
6dd5af01d54d Sub-items pannel now has fqname support.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2253
diff changeset
277 def subitem_index(self, fqname):
1123
ebc4f8213e74 Add a flat subitem index for show item view.
Sam Toyer <samATqxcvDOTnet>
parents: 1110
diff changeset
278 """
2263
6dd5af01d54d Sub-items pannel now has fqname support.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2253
diff changeset
279 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
280
ebc4f8213e74 Add a flat subitem index for show item view.
Sam Toyer <samATqxcvDOTnet>
parents: 1110
diff changeset
281 :rtype: list
ebc4f8213e74 Add a flat subitem index for show item view.
Sam Toyer <samATqxcvDOTnet>
parents: 1110
diff changeset
282 :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
283 """
ebc4f8213e74 Add a flat subitem index for show item view.
Sam Toyer <samATqxcvDOTnet>
parents: 1110
diff changeset
284 from MoinMoin.items import Item
2263
6dd5af01d54d Sub-items pannel now has fqname support.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2253
diff changeset
285 if not isinstance(fqname, CompositeName):
6dd5af01d54d Sub-items pannel now has fqname support.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2253
diff changeset
286 fqname = split_fqname(fqname)
6dd5af01d54d Sub-items pannel now has fqname support.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2253
diff changeset
287 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
288 return item.get_mixed_index()
1123
ebc4f8213e74 Add a flat subitem index for show item view.
Sam Toyer <samATqxcvDOTnet>
parents: 1110
diff changeset
289
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
290 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
291 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
292 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
293
38
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
294 :rtype: tuple
1063
ee71ed6e97c6 change user.aliasname to user.display_name
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 969
diff changeset
295 :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
296 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
297 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
298 name = user.name0
1063
ee71ed6e97c6 change user.aliasname to user.display_name
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 969
diff changeset
299 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
300 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
301 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
302 # 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
303 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
304 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
305 else:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
306 # 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
307 exists = True
2279
49bc6f85f918 Fixed pep8 errors.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2273
diff changeset
308 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
309 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
310
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
311 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
312 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
313 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
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 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
316 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
317
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
318 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
319 * PageName
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
320 * 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
321 * 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
322 * url
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
323 * 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
324
38
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
325 :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
326 :rtype: tuple
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
327 :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
328 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
329 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
330 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
331
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
332 # 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
333 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
334 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
335 try:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
336 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
337 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
338 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
339 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
340 # 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
341 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
342 else:
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
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
344
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
345 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
346 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
347 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
348 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
349
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
350 # 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
351 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
352 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
353
2217
431815d4f4a6 Fixed interwiki patch to deal with new composite name.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2117
diff changeset
354 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
355 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
356 wiki_name = ''
2217
431815d4f4a6 Fixed interwiki patch to deal with new composite name.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2117
diff changeset
357 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
358 if not title:
2230
f2bd327932fb Fixes #6. Quicklinks now use abbreviated fqnames.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2226
diff changeset
359 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
360 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
361
1764
19b19d4d9291 Add a @timed decorator.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1726
diff changeset
362 @timed()
2282
5c424120a253 Fixed #21, now links in navbar link to current namespace.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2279
diff changeset
363 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
364 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
365 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
366
38
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
367 :rtype: list
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
368 :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
369 """
2282
5c424120a253 Fixed #21, now links in navbar link to current namespace.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2279
diff changeset
370 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
371 fqname = split_fqname(fqname)
5c424120a253 Fixed #21, now links in navbar link to current namespace.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2279
diff changeset
372 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
373 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
374 # 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
375 items = []
423d8d791cc9 Fix for Issue#291, home link now coloured as should be
sharky93 <rishabhr123@gmail.com>
parents: 2011
diff changeset
376 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
377 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
378 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
379 root_fqname = fqname.get_root_fqname()
2292
7b7e07bb6f8a Removed linking of all view to home.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2282
diff changeset
380 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
381 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
382 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
383 args['namespace'] = fqname.namespace
5c424120a253 Fixed #21, now links in navbar link to current namespace.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2279
diff changeset
384 elif endpoint == "frontend.index":
5c424120a253 Fixed #21, now links in navbar link to current namespace.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2279
diff changeset
385 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
386 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
387
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
388 # 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
389 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
390 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
391 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
392
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
393 # 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
394 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
395 if is_local_wiki(sistername):
1885
063c879ef79b sistersites: fix tuple member count
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1801
diff changeset
396 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
397 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
398 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
399 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
400 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
401 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
402 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
403 try:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
404 sisteritems = {}
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
405 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
406 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
407 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
408 try:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
409 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
410 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
411 except:
1975
384555088cab lots of pep8 fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1974
diff changeset
412 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
413 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
414 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
415 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
416 except IOError as err:
1975
384555088cab lots of pep8 fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1974
diff changeset
417 (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
418 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
419 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
420 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
421 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
422 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
423 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
424
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
425 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
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 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
428
38
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
429 :rtype: unicode
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
430 :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
431 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
432 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
433 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
434 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
435
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
436 # 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
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 # Properties ##############################################################
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 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
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 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
443
38
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
444 :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
445 :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
446 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
447 url = None
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
448 if self.cfg.auth_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
449 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
450 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
451 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
452 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
453
2253
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
454 def get_fqnames(self, fqname):
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
455 """
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
456 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
457 """
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
458 if fqname.field != NAME_EXACT:
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
459 return []
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
460 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
461 fqnames = item.fqnames
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
462 fqnames.remove(fqname)
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
463 return fqnames or []
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
464
2679
e130fc605c63 Solves issue #394
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2673
diff changeset
465 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
466 """
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
467 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
468 than the current namespace.
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
469 """
2679
e130fc605c63 Solves issue #394
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2673
diff changeset
470 if ns is not None and ns.value == '~':
e130fc605c63 Solves issue #394
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2673
diff changeset
471 ns = u''
2253
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
472 namespace_root_mapping = []
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
473 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
474 namespace = namespace.rstrip('/')
2679
e130fc605c63 Solves issue #394
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2673
diff changeset
475 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
476 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
477 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
478 return namespace_root_mapping
46b74c363c6f UI for indicating multiple names and switching namespaces.
Ashutosh Singla <ashu1461@gmail.com>
parents: 2252
diff changeset
479
2669
7798855349f6 Improved Metadata view
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2651
diff changeset
480 def item_exists(self, itemname):
7798855349f6 Improved Metadata view
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2651
diff changeset
481 """
7798855349f6 Improved Metadata view
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2651
diff changeset
482 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
483
7798855349f6 Improved Metadata view
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2651
diff changeset
484 :rtype: boolean
7798855349f6 Improved Metadata view
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2651
diff changeset
485 :returns: whether item pointed to by the link exists or not
7798855349f6 Improved Metadata view
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2651
diff changeset
486 """
7798855349f6 Improved Metadata view
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2651
diff changeset
487 return self.storage.has_item(itemname)
7798855349f6 Improved Metadata view
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2651
diff changeset
488
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
489
861
9a7889c04a25 fixed history view
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 859
diff changeset
490 def get_editor_info(meta, external=False):
9a7889c04a25 fixed history view
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 859
diff changeset
491 addr = meta.get(ADDRESS)
9a7889c04a25 fixed history view
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 859
diff changeset
492 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
493 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
494 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
495 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
496 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
497 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
498 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
499 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
500 # 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
501 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
502 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
503 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
504 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
505 else:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
506 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
507 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
508 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
509
861
9a7889c04a25 fixed history view
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 859
diff changeset
510 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
511 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
512 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
513 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
514 text = name
1063
ee71ed6e97c6 change user.aliasname to user.display_name
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 969
diff changeset
515 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
516 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
517 # 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
518 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
519 else:
1063
ee71ed6e97c6 change user.aliasname to user.display_name
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 969
diff changeset
520 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
521 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
522 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
523 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
524 else:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
525 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
526 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
527 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
528 else:
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 interwiki'
313
8fa4a76d71ff cleanup interwiki code, new easier/more powerful functions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 248
diff changeset
530 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
531
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
532 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
533 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
534 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
535 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
536 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
537 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
538
1975
384555088cab lots of pep8 fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1974
diff changeset
539
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
540 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
541 """
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 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
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 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
545 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
546
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 :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
548 :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
549 :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
550 :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
551 """
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 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
553 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
554 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
555 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
556 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
557 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
558 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
559
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
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
561 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
562 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
563 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
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 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
566 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
567 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
568
38
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
569 :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
570 :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
571 :rtype: unicode
1d8e9b1153d6 docstrings: convert epydoc fields to rst/sphinx fields
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 26
diff changeset
572 :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
573 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
574 # 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
575 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
576 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
577 # 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
578 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
579 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
580 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
581 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
582
2409
51b90beddc7c Shortens contenttype display in the history view
sharky93 <rishabhr123@gmail.com>
parents: 2396
diff changeset
583 CONTENTTYPE_SHORTEN = {
51b90beddc7c Shortens contenttype display in the history view
sharky93 <rishabhr123@gmail.com>
parents: 2396
diff changeset
584 'text/x.moin.wiki': 'MoinWiki',
51b90beddc7c Shortens contenttype display in the history view
sharky93 <rishabhr123@gmail.com>
parents: 2396
diff changeset
585 }
51b90beddc7c Shortens contenttype display in the history view
sharky93 <rishabhr123@gmail.com>
parents: 2396
diff changeset
586
2492
f1d470ade3c0 PEP8 fixes
sharky93 <rishabhr123@gmail.com>
parents: 2491
diff changeset
587
1110
5479a3b62b9f Change shorten_revid to shorten_id everywhere.
Bilal Akhtar <bilalakhtar@ubuntu.com>
parents: 1109
diff changeset
588 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
589 """
1110
5479a3b62b9f Change shorten_revid to shorten_id everywhere.
Bilal Akhtar <bilalakhtar@ubuntu.com>
parents: 1109
diff changeset
590 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
591
1110
5479a3b62b9f Change shorten_revid to shorten_id everywhere.
Bilal Akhtar <bilalakhtar@ubuntu.com>
parents: 1109
diff changeset
592 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
593 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
594
b703c5e590a3 Create new template filter "shorten_revid" which shortens the specified text to 7 chars
Bilal Akhtar <bilalakhtar@ubuntu.com>
parents: 969
diff changeset
595 :param name: item name, unicode
1110
5479a3b62b9f Change shorten_revid to shorten_id everywhere.
Bilal Akhtar <bilalakhtar@ubuntu.com>
parents: 1109
diff changeset
596 :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
597 :rtype: unicode
1110
5479a3b62b9f Change shorten_revid to shorten_id everywhere.
Bilal Akhtar <bilalakhtar@ubuntu.com>
parents: 1109
diff changeset
598 :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
599 """
b703c5e590a3 Create new template filter "shorten_revid" which shortens the specified text to 7 chars
Bilal Akhtar <bilalakhtar@ubuntu.com>
parents: 969
diff changeset
600
1110
5479a3b62b9f Change shorten_revid to shorten_id everywhere.
Bilal Akhtar <bilalakhtar@ubuntu.com>
parents: 1109
diff changeset
601 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
602
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
603 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
604 '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
605 '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
606 '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
607 '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
608 '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
609 '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
610 '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
611 }
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
612
1975
384555088cab lots of pep8 fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1974
diff changeset
613
216
661a57c747bd replace mimetype by contenttype, use more constants
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 174
diff changeset
614 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
615 """
216
661a57c747bd replace mimetype by contenttype, use more constants
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 174
diff changeset
616 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
617 """
216
661a57c747bd replace mimetype by contenttype, use more constants
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 174
diff changeset
618 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
619 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
620 # 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
621 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
622 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
623
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
624
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
625 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
626 """
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 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
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 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
630 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
631 """
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 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
633 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
634
a4ec2c6f0bb7 history: do not yield Revision objects, but directly result documents from whoosh
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 526
diff changeset
635
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
636 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
637 """
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 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
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 :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
641 :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
642 :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
643 """
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 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
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
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
647 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
648 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
649 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
650 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
651 app.jinja_env.filters['contenttype_to_class'] = contenttype_to_class
1145
5421be737643 Simplify string escaping filter.
Sam Toyer <samATqxcvDOTnet>
parents: 1144
diff changeset
652 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
653 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
654 # 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
655 # 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
656
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
657 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
658 # 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
659 # _, gettext, ngettext
791bdedb0c20 fix lots of pep8 issues, mainly E12x
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
660 'isinstance': isinstance,
791bdedb0c20 fix lots of pep8 issues, mainly E12x
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
661 'list': list,
791bdedb0c20 fix lots of pep8 issues, mainly E12x
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
662 'Type': Type,
791bdedb0c20 fix lots of pep8 issues, mainly E12x
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
663 # 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
664 # theme, theme_static
791bdedb0c20 fix lots of pep8 issues, mainly E12x
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
665 '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
666 'user': flaskg.user,
791bdedb0c20 fix lots of pep8 issues, mainly E12x
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
667 'storage': flaskg.storage,
791bdedb0c20 fix lots of pep8 issues, mainly E12x
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
668 'clock': flaskg.clock,
791bdedb0c20 fix lots of pep8 issues, mainly E12x
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
669 'cfg': app.cfg,
2519
b942154b2d74 merged bootstrap and main repo
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2492 2292
diff changeset
670 '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
671 '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
672 '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
673 '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
674 '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
675 'gen': make_generator(),
791bdedb0c20 fix lots of pep8 issues, mainly E12x
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
676 '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
677 })