annotate MoinMoin/apps/misc/views.py @ 2017:615ca978863f

remove more system items / sysitems_upgrade related code
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 02 Mar 2013 18:15:47 +0100
parents 384555088cab
children 5f2fb2d7ed87
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: 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 # 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
3
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
4 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
5 MoinMoin - miscellaneous views
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 Misc. stuff that doesn't fit into another view category.
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
1343
8afe9dc4547d fix xml sitemap timestamps
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 953
diff changeset
10 import time
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
11
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
12 from flask import Response
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
13 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: 26
diff changeset
14 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
15
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
16 from MoinMoin.apps.misc import misc
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
17
1973
286e315935ae refactor usage of constants
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1832
diff changeset
18 from MoinMoin.constants.keys import MTIME
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 from MoinMoin.themes import render_template
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
20
1975
384555088cab lots of pep8 fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1974
diff changeset
21
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
22 @misc.route('/sitemap')
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
23 def sitemap():
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
24 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
25 Google (and others) XML sitemap
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
26 """
1343
8afe9dc4547d fix xml sitemap timestamps
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 953
diff changeset
27 def format_timestamp(t):
8afe9dc4547d fix xml sitemap timestamps
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 953
diff changeset
28 tm = time.gmtime(t)
1344
59220d491dc3 fix xml sitemap timestamps (now really, we need the colon in the tz)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1343
diff changeset
29 return time.strftime("%Y-%m-%dT%H:%M:%S+00:00", tm)
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
30
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
31 sitemap = []
953
326f7a365007 search/indexing: remove all_revs=False params (it is the default)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 904
diff changeset
32 for rev in flaskg.storage.documents(wikiname=app.cfg.interwikiname):
1039
b521a6667a54 access to Item's name through name property instead of meta directly.
Luis Henrique Fagundes <lhfagundes@gmail.com>
parents: 953
diff changeset
33 name = rev.name
852
5ad4ae0b1e09 lots of fixes / adaptions for storage-ng code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 800
diff changeset
34 mtime = rev.meta[MTIME]
2017
615ca978863f remove more system items / sysitems_upgrade related code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
35 # these are the content items:
615ca978863f remove more system items / sysitems_upgrade related code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
36 changefreq = "daily"
615ca978863f remove more system items / sysitems_upgrade related code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1975
diff changeset
37 priority = "0.5"
800
73409db95e56 whooshify sitemap and urls_names
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 136
diff changeset
38 sitemap.append((name, format_timestamp(mtime), changefreq, priority))
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
39 # add an entry for root url
800
73409db95e56 whooshify sitemap and urls_names
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 136
diff changeset
40 root_item = app.cfg.item_root
953
326f7a365007 search/indexing: remove all_revs=False params (it is the default)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 904
diff changeset
41 revs = list(flaskg.storage.documents(wikiname=app.cfg.interwikiname, name=root_item))
852
5ad4ae0b1e09 lots of fixes / adaptions for storage-ng code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 800
diff changeset
42 if revs:
5ad4ae0b1e09 lots of fixes / adaptions for storage-ng code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 800
diff changeset
43 mtime = revs[0].meta[MTIME]
800
73409db95e56 whooshify sitemap and urls_names
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 136
diff changeset
44 sitemap.append((u'', format_timestamp(mtime), "hourly", "1.0"))
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
45 sitemap.sort()
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
46 content = render_template('misc/sitemap.xml', sitemap=sitemap)
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
47 return Response(content, mimetype='text/xml')
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
48
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
49
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
50 @misc.route('/urls_names')
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
51 def urls_names():
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
52 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
53 List of all item URLs and names, e.g. for sisteritems.
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
54
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
55 This view generates a list of item URLs and item names, so that other wikis
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
56 can implement SisterWiki functionality easily.
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
57 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
58 """
904
46263060782e remove references to "trash" (is an implementation detail and might change)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 852
diff changeset
59 # XXX we currently also get deleted items, fix this
1039
b521a6667a54 access to Item's name through name property instead of meta directly.
Luis Henrique Fagundes <lhfagundes@gmail.com>
parents: 953
diff changeset
60 item_names = sorted([rev.name for rev in flaskg.storage.documents(wikiname=app.cfg.interwikiname)])
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
61 content = render_template('misc/urls_names.txt', item_names=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
62 return Response(content, mimetype='text/plain')