annotate MoinMoin/action/rss_rc.py @ 5997:6de72050e1b9

rss_rc action: use unicode to fix python 2.7.5 compatibility
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Wed, 12 Jun 2013 12:19:50 +0200
parents f8bb40fb3ac4
children 12097531880a
rev   line source
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
2 RSS Handling
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
3
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
4 If you do changes, please check if it still validates after your changes:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
5
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
6 http://feedvalidator.org/
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
7
1918
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1816
diff changeset
8 @copyright: 2006-2007 MoinMoin:ThomasWaldmann
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
9 @license: GNU GPL, see COPYING for details.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
10 """
1791
6dd2e29acffe Eclipse PyDev Check: fixed lots of its errors and warnings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1665
diff changeset
11 import StringIO, re, time
476
4be11eec9c4f MoinMoin.util.datetime -> timefuncs to avoid conflict/confusion with stdlib datetime, also moved util.W3CDate there
Thomas Waldmann <tw@waldmann-edv.de>
parents: 108
diff changeset
12 from MoinMoin import wikixml, config, wikiutil
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
13 from MoinMoin.logfile import editlog
476
4be11eec9c4f MoinMoin.util.datetime -> timefuncs to avoid conflict/confusion with stdlib datetime, also moved util.W3CDate there
Thomas Waldmann <tw@waldmann-edv.de>
parents: 108
diff changeset
14 from MoinMoin.util import timefuncs
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
15 from MoinMoin.Page import Page
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
16 from MoinMoin.wikixml.util import RssGenerator
5844
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
17 from MoinMoin.action import AttachFile
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
18
1665
c57f72b49ea2 cleanup rss_rc action, use page.url
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1184
diff changeset
19 def full_url(request, page, querystr=None, anchor=None):
3234
a739558ca3dc Page.url() default changed to relative=False
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2450
diff changeset
20 url = page.url(request, anchor=anchor, querystr=querystr)
1816
4a31739bc6e1 Page.url(): removed escaping support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1799
diff changeset
21 return request.getQualifiedURL(url)
1665
c57f72b49ea2 cleanup rss_rc action, use page.url
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1184
diff changeset
22
5844
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
23 def attach_url(request, pagename, filename, do):
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
24 url = AttachFile.getAttachUrl(pagename, filename, request, do=do)
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
25 return request.getQualifiedURL(url)
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
26
5845
0e1b4214318f action/rss_rc.py: added ability to set pagename-based filtering for RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5844
diff changeset
27 def match_page(pagename, page_pattern):
0e1b4214318f action/rss_rc.py: added ability to set pagename-based filtering for RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5844
diff changeset
28 # Match everything for empty pattern
0e1b4214318f action/rss_rc.py: added ability to set pagename-based filtering for RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5844
diff changeset
29 if not page_pattern:
0e1b4214318f action/rss_rc.py: added ability to set pagename-based filtering for RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5844
diff changeset
30 return True
0e1b4214318f action/rss_rc.py: added ability to set pagename-based filtering for RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5844
diff changeset
31 # If pattern begins with circumflex, interpret it as regex
0e1b4214318f action/rss_rc.py: added ability to set pagename-based filtering for RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5844
diff changeset
32 elif page_pattern[0] == "^":
0e1b4214318f action/rss_rc.py: added ability to set pagename-based filtering for RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5844
diff changeset
33 return re.match(page_pattern, pagename) is not None
0e1b4214318f action/rss_rc.py: added ability to set pagename-based filtering for RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5844
diff changeset
34 # Handy hack for getting rss for page tree
0e1b4214318f action/rss_rc.py: added ability to set pagename-based filtering for RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5844
diff changeset
35 elif page_pattern.endswith("/"):
0e1b4214318f action/rss_rc.py: added ability to set pagename-based filtering for RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5844
diff changeset
36 return (pagename == page_pattern[:-1]) or \
0e1b4214318f action/rss_rc.py: added ability to set pagename-based filtering for RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5844
diff changeset
37 pagename.startswith(page_pattern)
0e1b4214318f action/rss_rc.py: added ability to set pagename-based filtering for RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5844
diff changeset
38 else:
0e1b4214318f action/rss_rc.py: added ability to set pagename-based filtering for RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5844
diff changeset
39 return pagename == page_pattern
0e1b4214318f action/rss_rc.py: added ability to set pagename-based filtering for RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5844
diff changeset
40
5992
f8bb40fb3ac4 rss_rc action: optimize single page performance a lot
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5990
diff changeset
41 def is_single_page_match(page_pattern):
f8bb40fb3ac4 rss_rc action: optimize single page performance a lot
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5990
diff changeset
42 # note: keep this code in sync with match_page()!
f8bb40fb3ac4 rss_rc action: optimize single page performance a lot
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5990
diff changeset
43 if not page_pattern:
f8bb40fb3ac4 rss_rc action: optimize single page performance a lot
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5990
diff changeset
44 return False
f8bb40fb3ac4 rss_rc action: optimize single page performance a lot
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5990
diff changeset
45 elif page_pattern[0] == "^":
f8bb40fb3ac4 rss_rc action: optimize single page performance a lot
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5990
diff changeset
46 return False
f8bb40fb3ac4 rss_rc action: optimize single page performance a lot
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5990
diff changeset
47 elif page_pattern.endswith("/"):
f8bb40fb3ac4 rss_rc action: optimize single page performance a lot
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5990
diff changeset
48 return False
f8bb40fb3ac4 rss_rc action: optimize single page performance a lot
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5990
diff changeset
49 else:
f8bb40fb3ac4 rss_rc action: optimize single page performance a lot
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5990
diff changeset
50 return True
f8bb40fb3ac4 rss_rc action: optimize single page performance a lot
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5990
diff changeset
51
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
52 def execute(pagename, request):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
53 """ Send recent changes as an RSS document
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
54 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
55 if not wikixml.ok:
4183
fc20a076aad0 Accomodate for consolidation of Request/Response
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4176
diff changeset
56 request.mimetype = 'text/plain'
1799
06ce4843b9b5 remove some XXX strings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1791
diff changeset
57 request.write("rss_rc action is not supported because of missing pyxml module.")
06ce4843b9b5 remove some XXX strings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1791
diff changeset
58 return
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
59
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
60 cfg = request.cfg
5843
89fbca5396a1 action/rss_rc.py: proper support of rename, revert, page creation.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5842
diff changeset
61 _ = request.getText
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
62
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
63 # get params
5851
ab0bc2441518 action/rss_rc.py: Retrieval of configuration options changed from getattr() since they are in config now already. Last rev which does not depend on configuration options presence: 468e63254a4a.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5848
diff changeset
64 def_max_items = max_items = cfg.rss_items_default
ab0bc2441518 action/rss_rc.py: Retrieval of configuration options changed from getattr() since they are in config now already. Last rev which does not depend on configuration options presence: 468e63254a4a.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5848
diff changeset
65 items_limit = cfg.rss_items_limit
ab0bc2441518 action/rss_rc.py: Retrieval of configuration options changed from getattr() since they are in config now already. Last rev which does not depend on configuration options presence: 468e63254a4a.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5848
diff changeset
66 unique = cfg.rss_unique
ab0bc2441518 action/rss_rc.py: Retrieval of configuration options changed from getattr() since they are in config now already. Last rev which does not depend on configuration options presence: 468e63254a4a.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5848
diff changeset
67 diffs = cfg.rss_diffs
ab0bc2441518 action/rss_rc.py: Retrieval of configuration options changed from getattr() since they are in config now already. Last rev which does not depend on configuration options presence: 468e63254a4a.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5848
diff changeset
68 ddiffs = cfg.rss_ddiffs
ab0bc2441518 action/rss_rc.py: Retrieval of configuration options changed from getattr() since they are in config now already. Last rev which does not depend on configuration options presence: 468e63254a4a.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5848
diff changeset
69 max_lines = cfg.rss_lines_default
ab0bc2441518 action/rss_rc.py: Retrieval of configuration options changed from getattr() since they are in config now already. Last rev which does not depend on configuration options presence: 468e63254a4a.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5848
diff changeset
70 lines_limit = cfg.rss_lines_limit
ab0bc2441518 action/rss_rc.py: Retrieval of configuration options changed from getattr() since they are in config now already. Last rev which does not depend on configuration options presence: 468e63254a4a.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5848
diff changeset
71 show_att = cfg.rss_show_attachment_entries
ab0bc2441518 action/rss_rc.py: Retrieval of configuration options changed from getattr() since they are in config now already. Last rev which does not depend on configuration options presence: 468e63254a4a.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5848
diff changeset
72 page_pattern = cfg.rss_page_filter_pattern
5841
8b3c4b85921b action/rss_rc.py: param parsing rewritten to support retrieval of default values from wiki configuration.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5840
diff changeset
73
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
74 try:
5841
8b3c4b85921b action/rss_rc.py: param parsing rewritten to support retrieval of default values from wiki configuration.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5840
diff changeset
75 max_items = min(int(request.values.get('items', max_items)),
8b3c4b85921b action/rss_rc.py: param parsing rewritten to support retrieval of default values from wiki configuration.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5840
diff changeset
76 items_limit)
8b3c4b85921b action/rss_rc.py: param parsing rewritten to support retrieval of default values from wiki configuration.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5840
diff changeset
77 except ValueError:
8b3c4b85921b action/rss_rc.py: param parsing rewritten to support retrieval of default values from wiki configuration.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5840
diff changeset
78 pass
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
79 try:
5841
8b3c4b85921b action/rss_rc.py: param parsing rewritten to support retrieval of default values from wiki configuration.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5840
diff changeset
80 unique = int(request.values.get('unique', unique))
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
81 except ValueError:
5841
8b3c4b85921b action/rss_rc.py: param parsing rewritten to support retrieval of default values from wiki configuration.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5840
diff changeset
82 pass
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
83 try:
5841
8b3c4b85921b action/rss_rc.py: param parsing rewritten to support retrieval of default values from wiki configuration.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5840
diff changeset
84 diffs = int(request.values.get('diffs', diffs))
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
85 except ValueError:
5841
8b3c4b85921b action/rss_rc.py: param parsing rewritten to support retrieval of default values from wiki configuration.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5840
diff changeset
86 pass
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
87 ## ddiffs inserted by Ralf Zosel <ralf@zosel.com>, 04.12.2003
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
88 try:
5841
8b3c4b85921b action/rss_rc.py: param parsing rewritten to support retrieval of default values from wiki configuration.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5840
diff changeset
89 ddiffs = int(request.values.get('ddiffs', ddiffs))
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
90 except ValueError:
5841
8b3c4b85921b action/rss_rc.py: param parsing rewritten to support retrieval of default values from wiki configuration.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5840
diff changeset
91 pass
5840
4a982b04461d action/rss_rc.py: new option - lines - set max lines for diff/content shown in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5839
diff changeset
92 try:
5841
8b3c4b85921b action/rss_rc.py: param parsing rewritten to support retrieval of default values from wiki configuration.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5840
diff changeset
93 max_lines = min(int(request.values.get('lines', max_lines)),
8b3c4b85921b action/rss_rc.py: param parsing rewritten to support retrieval of default values from wiki configuration.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5840
diff changeset
94 lines_limit)
5840
4a982b04461d action/rss_rc.py: new option - lines - set max lines for diff/content shown in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5839
diff changeset
95 except ValueError:
5841
8b3c4b85921b action/rss_rc.py: param parsing rewritten to support retrieval of default values from wiki configuration.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5840
diff changeset
96 pass
5844
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
97 try:
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
98 show_att = int(request.values.get('show_att', show_att))
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
99 except ValueError:
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
100 pass
5845
0e1b4214318f action/rss_rc.py: added ability to set pagename-based filtering for RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5844
diff changeset
101 try:
0e1b4214318f action/rss_rc.py: added ability to set pagename-based filtering for RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5844
diff changeset
102 page_pattern = request.values.get('page', page_pattern)
0e1b4214318f action/rss_rc.py: added ability to set pagename-based filtering for RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5844
diff changeset
103 except ValueError:
0e1b4214318f action/rss_rc.py: added ability to set pagename-based filtering for RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5844
diff changeset
104 pass
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
105
5992
f8bb40fb3ac4 rss_rc action: optimize single page performance a lot
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5990
diff changeset
106 # if we are just interested in a specific page, using the local edit-log
f8bb40fb3ac4 rss_rc action: optimize single page performance a lot
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5990
diff changeset
107 # of that page is much faster than the global one - esp. if the page was
f8bb40fb3ac4 rss_rc action: optimize single page performance a lot
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5990
diff changeset
108 # NOT recently changed and the global edit-log is rather big.
f8bb40fb3ac4 rss_rc action: optimize single page performance a lot
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5990
diff changeset
109 kw = dict(rootpagename=page_pattern) if is_single_page_match(page_pattern) else {}
f8bb40fb3ac4 rss_rc action: optimize single page performance a lot
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5990
diff changeset
110 log = editlog.EditLog(request, **kw)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
111 logdata = []
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
112 counter = 0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
113 pages = {}
15
5a2a8201bb6f make moin friendlier to proxies, thanks to ASF
Thomas Waldmann <tw@waldmann-edv.de>
parents: 0
diff changeset
114 lastmod = 0
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
115 for line in log.reverse():
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
116 if not request.user.may.read(line.pagename):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
117 continue
5844
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
118 if ((not show_att and not line.action.startswith('SAVE')) or
5845
0e1b4214318f action/rss_rc.py: added ability to set pagename-based filtering for RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5844
diff changeset
119 ((line.pagename in pages) and unique) or
0e1b4214318f action/rss_rc.py: added ability to set pagename-based filtering for RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5844
diff changeset
120 not match_page(line.pagename, page_pattern)):
0e1b4214318f action/rss_rc.py: added ability to set pagename-based filtering for RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5844
diff changeset
121 continue
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
122 line.editor = line.getInterwikiEditorData(request)
476
4be11eec9c4f MoinMoin.util.datetime -> timefuncs to avoid conflict/confusion with stdlib datetime, also moved util.W3CDate there
Thomas Waldmann <tw@waldmann-edv.de>
parents: 108
diff changeset
123 line.time = timefuncs.tmtuple(wikiutil.version2timestamp(line.ed_time_usecs)) # UTC
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
124 logdata.append(line)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
125 pages[line.pagename] = None
15
5a2a8201bb6f make moin friendlier to proxies, thanks to ASF
Thomas Waldmann <tw@waldmann-edv.de>
parents: 0
diff changeset
126
5a2a8201bb6f make moin friendlier to proxies, thanks to ASF
Thomas Waldmann <tw@waldmann-edv.de>
parents: 0
diff changeset
127 if not lastmod:
5a2a8201bb6f make moin friendlier to proxies, thanks to ASF
Thomas Waldmann <tw@waldmann-edv.de>
parents: 0
diff changeset
128 lastmod = wikiutil.version2timestamp(line.ed_time_usecs)
5a2a8201bb6f make moin friendlier to proxies, thanks to ASF
Thomas Waldmann <tw@waldmann-edv.de>
parents: 0
diff changeset
129
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
130 counter += 1
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
131 if counter >= max_items:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
132 break
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
133 del log
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
134
1113
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
135 timestamp = timefuncs.formathttpdate(lastmod)
5844
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
136 etag = "%d-%d-%d-%d-%d-%d-%d" % (lastmod, max_items, diffs, ddiffs, unique,
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
137 max_lines, show_att)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
138
1113
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
139 # for 304, we look at if-modified-since and if-none-match headers,
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
140 # one of them must match and the other is either not there or must match.
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
141 if request.if_modified_since == timestamp:
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
142 if request.if_none_match:
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
143 if request.if_none_match == etag:
4183
fc20a076aad0 Accomodate for consolidation of Request/Response
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4176
diff changeset
144 request.status_code = 304
1113
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
145 else:
4183
fc20a076aad0 Accomodate for consolidation of Request/Response
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4176
diff changeset
146 request.status_code = 304
1113
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
147 elif request.if_none_match == etag:
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
148 if request.if_modified_since:
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
149 if request.if_modified_since == timestamp:
4183
fc20a076aad0 Accomodate for consolidation of Request/Response
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4176
diff changeset
150 request.status_code = 304
1113
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
151 else:
4183
fc20a076aad0 Accomodate for consolidation of Request/Response
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4176
diff changeset
152 request.status_code = 304
1113
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
153 else:
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
154 # generate an Expires header, using whatever setting the admin
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
155 # defined for suggested cache lifetime of the RecentChanges RSS doc
4176
85884c67228d Replaced/removed calls to request.emit_http_headers
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 3234
diff changeset
156 expires = time.time() + cfg.rss_cache
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
157
5629
32a0bf3c4e43 fix Content-Type header (mimetype) for rss_rc and sisterpages actions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5591
diff changeset
158 request.mimetype = 'application/rss+xml'
4183
fc20a076aad0 Accomodate for consolidation of Request/Response
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4176
diff changeset
159 request.expires = expires
fc20a076aad0 Accomodate for consolidation of Request/Response
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4176
diff changeset
160 request.last_modified = lastmod
5591
1dff6cfdcf90 http headers: for most cases, do not use .add, but .__setitem__
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4424
diff changeset
161 request.headers['Etag'] = etag
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
162
1113
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
163 # send the generated XML document
4334
7add275cf4de Fixed: deprecated (and missing) getBaseURL() method
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4201
diff changeset
164 baseurl = request.url_root
1113
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
165
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
166 logo = re.search(r'src="([^"]*)"', cfg.logo_string)
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
167 if logo:
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
168 logo = request.getQualifiedURL(logo.group(1))
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
169
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
170 # prepare output
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
171 out = StringIO.StringIO()
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
172 handler = RssGenerator(out)
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
173
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
174 # start SAX stream
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
175 handler.startDocument()
5990
aee4ff651134 rss_rc action: fix python 2.7.5 compatibility
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5854
diff changeset
176 handler._write(
5997
6de72050e1b9 rss_rc action: use unicode to fix python 2.7.5 compatibility
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5992
diff changeset
177 u'<!--\n'
6de72050e1b9 rss_rc action: use unicode to fix python 2.7.5 compatibility
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5992
diff changeset
178 u' Add an "items=nnn" URL parameter to get more than the \n'
6de72050e1b9 rss_rc action: use unicode to fix python 2.7.5 compatibility
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5992
diff changeset
179 u' default %(def_max_items)d items. You cannot get more than \n'
6de72050e1b9 rss_rc action: use unicode to fix python 2.7.5 compatibility
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5992
diff changeset
180 u' %(items_limit)d items though.\n'
6de72050e1b9 rss_rc action: use unicode to fix python 2.7.5 compatibility
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5992
diff changeset
181 u' \n'
6de72050e1b9 rss_rc action: use unicode to fix python 2.7.5 compatibility
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5992
diff changeset
182 u' Add "unique=1" to get a list of changes where page names are unique,\n'
6de72050e1b9 rss_rc action: use unicode to fix python 2.7.5 compatibility
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5992
diff changeset
183 u' i.e. where only the latest change of each page is reflected.\n'
6de72050e1b9 rss_rc action: use unicode to fix python 2.7.5 compatibility
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5992
diff changeset
184 u' \n'
6de72050e1b9 rss_rc action: use unicode to fix python 2.7.5 compatibility
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5992
diff changeset
185 u' Add "diffs=1" to add change diffs to the description of each items.\n'
6de72050e1b9 rss_rc action: use unicode to fix python 2.7.5 compatibility
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5992
diff changeset
186 u' \n'
6de72050e1b9 rss_rc action: use unicode to fix python 2.7.5 compatibility
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5992
diff changeset
187 u' Add "ddiffs=1" to link directly to the diff (good for FeedReader).\n'
6de72050e1b9 rss_rc action: use unicode to fix python 2.7.5 compatibility
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5992
diff changeset
188 u' \n'
6de72050e1b9 rss_rc action: use unicode to fix python 2.7.5 compatibility
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5992
diff changeset
189 u' Add "lines=nnn" to change maximum number of diff/body lines \n'
6de72050e1b9 rss_rc action: use unicode to fix python 2.7.5 compatibility
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5992
diff changeset
190 u' to show. Cannot be more than %(lines_limit)d.\n'
6de72050e1b9 rss_rc action: use unicode to fix python 2.7.5 compatibility
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5992
diff changeset
191 u' \n'
6de72050e1b9 rss_rc action: use unicode to fix python 2.7.5 compatibility
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5992
diff changeset
192 u' Add "show_att=1" to show items related to attachments.\n'
6de72050e1b9 rss_rc action: use unicode to fix python 2.7.5 compatibility
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5992
diff changeset
193 u' \n'
6de72050e1b9 rss_rc action: use unicode to fix python 2.7.5 compatibility
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5992
diff changeset
194 u' Add "page=pattern" to show feed only for specific pages.\n'
6de72050e1b9 rss_rc action: use unicode to fix python 2.7.5 compatibility
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5992
diff changeset
195 u' Pattern can be empty (it would match to all pages), \n'
6de72050e1b9 rss_rc action: use unicode to fix python 2.7.5 compatibility
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5992
diff changeset
196 u' can start with circumflex (it would be interpreted as \n'
6de72050e1b9 rss_rc action: use unicode to fix python 2.7.5 compatibility
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5992
diff changeset
197 u' regular expression in this case), end with slash (for \n'
6de72050e1b9 rss_rc action: use unicode to fix python 2.7.5 compatibility
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5992
diff changeset
198 u' getting feed for page tree) or point to specific page (if \n'
6de72050e1b9 rss_rc action: use unicode to fix python 2.7.5 compatibility
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5992
diff changeset
199 u' none of the above can be applied).\n'
6de72050e1b9 rss_rc action: use unicode to fix python 2.7.5 compatibility
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5992
diff changeset
200 u' \n'
6de72050e1b9 rss_rc action: use unicode to fix python 2.7.5 compatibility
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5992
diff changeset
201 u' Current settings: items=%(max_items)i, unique=%(unique)i, \n'
6de72050e1b9 rss_rc action: use unicode to fix python 2.7.5 compatibility
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5992
diff changeset
202 u' diffs=%(diffs)i, ddiffs=%(ddiffs)i, lines=%(max_lines)i, \n'
6de72050e1b9 rss_rc action: use unicode to fix python 2.7.5 compatibility
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5992
diff changeset
203 u' show_att=%(show_att)i\n'
6de72050e1b9 rss_rc action: use unicode to fix python 2.7.5 compatibility
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5992
diff changeset
204 u'-->\n' % locals()
5990
aee4ff651134 rss_rc action: fix python 2.7.5 compatibility
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5854
diff changeset
205 )
1113
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
206
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
207 # emit channel description
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
208 handler.startNode('channel', {
4334
7add275cf4de Fixed: deprecated (and missing) getBaseURL() method
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4201
diff changeset
209 (handler.xmlns['rdf'], 'about'): request.url_root,
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
210 })
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
211 handler.simpleNode('title', cfg.sitename)
1665
c57f72b49ea2 cleanup rss_rc action, use page.url
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1184
diff changeset
212 page = Page(request, pagename)
c57f72b49ea2 cleanup rss_rc action, use page.url
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1184
diff changeset
213 handler.simpleNode('link', full_url(request, page))
5848
468e63254a4a action/rss_rc.py: forcing unicode for comment strings.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5847
diff changeset
214 handler.simpleNode('description', u'RecentChanges at %s' % cfg.sitename)
1113
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
215 if logo:
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
216 handler.simpleNode('image', None, {
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
217 (handler.xmlns['rdf'], 'resource'): logo,
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
218 })
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
219 if cfg.interwikiname:
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
220 handler.simpleNode(('wiki', 'interwiki'), cfg.interwikiname)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
221
1113
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
222 handler.startNode('items')
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
223 handler.startNode(('rdf', 'Seq'))
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
224 for item in logdata:
1665
c57f72b49ea2 cleanup rss_rc action, use page.url
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1184
diff changeset
225 anchor = "%04d%02d%02d%02d%02d%02d" % item.time[:6]
c57f72b49ea2 cleanup rss_rc action, use page.url
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1184
diff changeset
226 page = Page(request, item.pagename)
c57f72b49ea2 cleanup rss_rc action, use page.url
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1184
diff changeset
227 link = full_url(request, page, anchor=anchor)
c57f72b49ea2 cleanup rss_rc action, use page.url
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1184
diff changeset
228 handler.simpleNode(('rdf', 'li'), None, attr={(handler.xmlns['rdf'], 'resource'): link, })
1113
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
229 handler.endNode(('rdf', 'Seq'))
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
230 handler.endNode('items')
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
231 handler.endNode('channel')
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
232
1113
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
233 # emit logo data
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
234 if logo:
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
235 handler.startNode('image', attr={
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
236 (handler.xmlns['rdf'], 'about'): logo,
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
237 })
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
238 handler.simpleNode('title', cfg.sitename)
1665
c57f72b49ea2 cleanup rss_rc action, use page.url
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1184
diff changeset
239 handler.simpleNode('link', baseurl)
1113
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
240 handler.simpleNode('url', logo)
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
241 handler.endNode('image')
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
242
5843
89fbca5396a1 action/rss_rc.py: proper support of rename, revert, page creation.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5842
diff changeset
243 # Mapping { oldname: curname } for maintaining page renames
89fbca5396a1 action/rss_rc.py: proper support of rename, revert, page creation.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5842
diff changeset
244 pagename_map = {}
89fbca5396a1 action/rss_rc.py: proper support of rename, revert, page creation.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5842
diff changeset
245
1113
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
246 # emit items
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
247 for item in logdata:
5843
89fbca5396a1 action/rss_rc.py: proper support of rename, revert, page creation.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5842
diff changeset
248 if item.pagename in pagename_map:
89fbca5396a1 action/rss_rc.py: proper support of rename, revert, page creation.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5842
diff changeset
249 cur_pagename = pagename_map[item.pagename]
89fbca5396a1 action/rss_rc.py: proper support of rename, revert, page creation.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5842
diff changeset
250 else:
89fbca5396a1 action/rss_rc.py: proper support of rename, revert, page creation.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5842
diff changeset
251 cur_pagename = item.pagename
89fbca5396a1 action/rss_rc.py: proper support of rename, revert, page creation.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5842
diff changeset
252 page = Page(request, cur_pagename)
89fbca5396a1 action/rss_rc.py: proper support of rename, revert, page creation.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5842
diff changeset
253 action = item.action
89fbca5396a1 action/rss_rc.py: proper support of rename, revert, page creation.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5842
diff changeset
254 comment = item.comment
1665
c57f72b49ea2 cleanup rss_rc action, use page.url
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1184
diff changeset
255 anchor = "%04d%02d%02d%02d%02d%02d" % item.time[:6]
c57f72b49ea2 cleanup rss_rc action, use page.url
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1184
diff changeset
256 rdflink = full_url(request, page, anchor=anchor)
c57f72b49ea2 cleanup rss_rc action, use page.url
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1184
diff changeset
257 handler.startNode('item', attr={(handler.xmlns['rdf'], 'about'): rdflink, })
15
5a2a8201bb6f make moin friendlier to proxies, thanks to ASF
Thomas Waldmann <tw@waldmann-edv.de>
parents: 0
diff changeset
258
1113
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
259 # general attributes
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
260 handler.simpleNode('title', item.pagename)
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
261 handler.simpleNode(('dc', 'date'), timefuncs.W3CDate(item.time))
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
262
5843
89fbca5396a1 action/rss_rc.py: proper support of rename, revert, page creation.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5842
diff changeset
263 show_diff = diffs
89fbca5396a1 action/rss_rc.py: proper support of rename, revert, page creation.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5842
diff changeset
264
5844
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
265 if action.startswith('ATT'): # Attachment
5843
89fbca5396a1 action/rss_rc.py: proper support of rename, revert, page creation.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5842
diff changeset
266 show_diff = 0
5844
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
267 filename = wikiutil.url_unquote(item.extra)
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
268 att_exists = AttachFile.exists(request, cur_pagename, filename)
5839
d415cb95645c action/rss_rc.py: proper links to appropriate diffs when ddiffs=1 and proper link/content for log entry related to new page.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5838
diff changeset
269
5844
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
270 if action == 'ATTNEW':
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
271 # Once attachment deleted this link becomes invalid but we
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
272 # preserve it to prevent appearance of new RSS entries in
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
273 # RSS readers.
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
274 if ddiffs:
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
275 handler.simpleNode('link', attach_url(request,
5853
e1a4caec2513 [minor] rss_rc: subaction in link for ATTNEW feed entries changed from get to view as less surprising.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5851
diff changeset
276 cur_pagename, filename, do='view'))
5839
d415cb95645c action/rss_rc.py: proper links to appropriate diffs when ddiffs=1 and proper link/content for log entry related to new page.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5838
diff changeset
277
5848
468e63254a4a action/rss_rc.py: forcing unicode for comment strings.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5847
diff changeset
278 comment = _(u"Upload of attachment '%(filename)s'.") % {
5844
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
279 'filename': filename}
5839
d415cb95645c action/rss_rc.py: proper links to appropriate diffs when ddiffs=1 and proper link/content for log entry related to new page.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5838
diff changeset
280
5844
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
281 elif action == 'ATTDEL':
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
282 if ddiffs:
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
283 handler.simpleNode('link', full_url(request, page,
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
284 querystr={'action': 'AttachFile'}))
5839
d415cb95645c action/rss_rc.py: proper links to appropriate diffs when ddiffs=1 and proper link/content for log entry related to new page.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5838
diff changeset
285
5848
468e63254a4a action/rss_rc.py: forcing unicode for comment strings.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5847
diff changeset
286 comment = _(u"Attachment '%(filename)s' deleted.") % {
5844
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
287 'filename': filename}
5839
d415cb95645c action/rss_rc.py: proper links to appropriate diffs when ddiffs=1 and proper link/content for log entry related to new page.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5838
diff changeset
288
5844
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
289 elif action == 'ATTDRW':
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
290 if ddiffs:
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
291 handler.simpleNode('link', attach_url(request,
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
292 cur_pagename, filename, do='view'))
5839
d415cb95645c action/rss_rc.py: proper links to appropriate diffs when ddiffs=1 and proper link/content for log entry related to new page.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5838
diff changeset
293
5848
468e63254a4a action/rss_rc.py: forcing unicode for comment strings.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5847
diff changeset
294 comment = _(u"Drawing '%(filename)s' saved.") % {
5844
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
295 'filename': filename}
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
296
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
297 elif action.startswith('SAVE'):
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
298 if action == 'SAVE/REVERT':
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
299 to_rev = int(item.extra)
5848
468e63254a4a action/rss_rc.py: forcing unicode for comment strings.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5847
diff changeset
300 comment = (_(u"Revert to revision %(rev)d.") % {
5844
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
301 'rev': to_rev}) + "<br />" \
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
302 + _("Comment:") + " " + comment
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
303
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
304 elif action == 'SAVE/RENAME':
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
305 show_diff = 0
5848
468e63254a4a action/rss_rc.py: forcing unicode for comment strings.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5847
diff changeset
306 comment = (_(u"Renamed from '%(oldpagename)s'.") % {
5844
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
307 'oldpagename': item.extra}) + "<br />" \
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
308 + _("Comment:") + " " + comment
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
309 if item.pagename in pagename_map:
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
310 newpage = pagename_map[item.pagename]
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
311 del pagename_map[item.pagename]
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
312 pagename_map[item.extra] = newpage
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
313 else:
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
314 pagename_map[item.extra] = item.pagename
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
315
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
316 elif action == 'SAVENEW':
5848
468e63254a4a action/rss_rc.py: forcing unicode for comment strings.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5847
diff changeset
317 comment = _(u"New page:\n") + comment
5844
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
318
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
319 item_rev = int(item.rev)
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
320
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
321 # If we use diffs/ddiffs, we should calculate proper links and
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
322 # content
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
323 if ddiffs:
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
324 # first revision can't have older revisions to diff with
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
325 if item_rev == 1:
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
326 handler.simpleNode('link', full_url(request, page,
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
327 querystr={'action': 'recall',
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
328 'rev': str(item_rev)}))
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
329 else:
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
330 handler.simpleNode('link', full_url(request, page,
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
331 querystr={'action': 'diff',
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
332 'rev1': str(item_rev),
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
333 'rev2': str(item_rev - 1)}))
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
334
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
335 if show_diff:
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
336 if item_rev == 1:
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
337 lines = Page(request, cur_pagename,
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
338 rev=item_rev).getlines()
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
339 else:
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
340 lines = wikiutil.pagediff(request, cur_pagename,
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
341 item_rev - 1, cur_pagename, item_rev, ignorews=1)
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
342
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
343 if len(lines) > max_lines:
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
344 lines = lines[:max_lines] + ['...\n']
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
345
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
346 lines = '\n'.join(lines)
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
347 lines = wikiutil.escape(lines)
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
348
5848
468e63254a4a action/rss_rc.py: forcing unicode for comment strings.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5847
diff changeset
349 comment = u'%s\n<pre>\n%s\n</pre>\n' % (comment, lines)
5844
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
350
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
351 if not ddiffs:
3d997b1235fe action/rss_rc.py: added ability to show attachment-related actions in RSS.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5843
diff changeset
352 handler.simpleNode('link', full_url(request, page))
5839
d415cb95645c action/rss_rc.py: proper links to appropriate diffs when ddiffs=1 and proper link/content for log entry related to new page.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5838
diff changeset
353
5843
89fbca5396a1 action/rss_rc.py: proper support of rename, revert, page creation.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5842
diff changeset
354 if comment:
89fbca5396a1 action/rss_rc.py: proper support of rename, revert, page creation.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5842
diff changeset
355 handler.simpleNode('description', comment)
1113
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
356
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
357 # contributor
5842
97e36f417f6e action/rss_rc.py: preserving show_names configuration option.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5841
diff changeset
358 if cfg.show_names:
97e36f417f6e action/rss_rc.py: preserving show_names configuration option.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5841
diff changeset
359 edattr = {}
97e36f417f6e action/rss_rc.py: preserving show_names configuration option.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5841
diff changeset
360 if cfg.show_hosts:
97e36f417f6e action/rss_rc.py: preserving show_names configuration option.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5841
diff changeset
361 edattr[(handler.xmlns['wiki'], 'host')] = item.hostname
97e36f417f6e action/rss_rc.py: preserving show_names configuration option.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5841
diff changeset
362 if item.editor[0] == 'interwiki':
97e36f417f6e action/rss_rc.py: preserving show_names configuration option.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5841
diff changeset
363 edname = "%s:%s" % item.editor[1]
97e36f417f6e action/rss_rc.py: preserving show_names configuration option.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5841
diff changeset
364 ##edattr[(None, 'link')] = baseurl + wikiutil.quoteWikiname(edname)
97e36f417f6e action/rss_rc.py: preserving show_names configuration option.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5841
diff changeset
365 else: # 'ip'
97e36f417f6e action/rss_rc.py: preserving show_names configuration option.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5841
diff changeset
366 edname = item.editor[1]
97e36f417f6e action/rss_rc.py: preserving show_names configuration option.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5841
diff changeset
367 ##edattr[(None, 'link')] = link + "?action=info"
1113
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
368
5842
97e36f417f6e action/rss_rc.py: preserving show_names configuration option.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5841
diff changeset
369 # this edattr stuff, esp. None as first tuple element breaks things (tracebacks)
97e36f417f6e action/rss_rc.py: preserving show_names configuration option.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5841
diff changeset
370 # if you know how to do this right, please send us a patch
1113
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
371
5842
97e36f417f6e action/rss_rc.py: preserving show_names configuration option.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5841
diff changeset
372 handler.startNode(('dc', 'contributor'))
97e36f417f6e action/rss_rc.py: preserving show_names configuration option.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5841
diff changeset
373 handler.startNode(('rdf', 'Description'), attr=edattr)
97e36f417f6e action/rss_rc.py: preserving show_names configuration option.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5841
diff changeset
374 handler.simpleNode(('rdf', 'value'), edname)
97e36f417f6e action/rss_rc.py: preserving show_names configuration option.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5841
diff changeset
375 handler.endNode(('rdf', 'Description'))
97e36f417f6e action/rss_rc.py: preserving show_names configuration option.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5841
diff changeset
376 handler.endNode(('dc', 'contributor'))
1113
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
377
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
378 # wiki extensions
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
379 handler.simpleNode(('wiki', 'version'), "%i" % (item.ed_time_usecs))
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
380 handler.simpleNode(('wiki', 'status'), ('deleted', 'updated')[page.exists()])
1665
c57f72b49ea2 cleanup rss_rc action, use page.url
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1184
diff changeset
381 handler.simpleNode(('wiki', 'diff'), full_url(request, page, querystr={'action': 'diff'}))
c57f72b49ea2 cleanup rss_rc action, use page.url
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1184
diff changeset
382 handler.simpleNode(('wiki', 'history'), full_url(request, page, querystr={'action': 'info'}))
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
383 # handler.simpleNode(('wiki', 'importance'), ) # ( major | minor )
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
384 # handler.simpleNode(('wiki', 'version'), ) # ( #PCDATA )
1113
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
385
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
386 handler.endNode('item')
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
387
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
388 # end SAX stream
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
389 handler.endDocument()
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
390
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
391 request.write(out.getvalue())
9485500daadf read if-modified-since and if-none-match headers, first use for rss_rc action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
392