Mercurial > wikked
annotate wikked/views/special.py @ 424:1066d0986082
web: Add button to force refresh a cached page list.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Fri, 24 Mar 2017 16:46:37 -0700 |
parents | 49da205b4946 |
children | e28f2c76691c |
rev | line source |
---|---|
424
1066d0986082
web: Add button to force refresh a cached page list.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
1 from flask import request, redirect, url_for, render_template, abort |
341
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
2 from flask.ext.login import current_user |
368
831b22e93f94
Implement error and permission handling for UI views.
Ludovic Chabant <ludovic@chabant.com>
parents:
353
diff
changeset
|
3 from wikked.views import ( |
424
1066d0986082
web: Add button to force refresh a cached page list.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
4 requires_auth, requires_reader_auth, |
368
831b22e93f94
Implement error and permission handling for UI views.
Ludovic Chabant <ludovic@chabant.com>
parents:
353
diff
changeset
|
5 add_auth_data, add_navigation_data) |
310
bc02d4925096
Don't initialize a wiki instance in Flask until we need one.
Ludovic Chabant <ludovic@chabant.com>
parents:
307
diff
changeset
|
6 from wikked.web import app, get_wiki |
341
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
7 from wikked.webimpl.special import ( |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
8 get_orphans, get_broken_redirects, get_double_redirects, |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
9 get_dead_ends) |
312
86d6732b522a
Cleaner code for the special pages' views.
Ludovic Chabant <ludovic@chabant.com>
parents:
310
diff
changeset
|
10 |
86d6732b522a
Cleaner code for the special pages' views.
Ludovic Chabant <ludovic@chabant.com>
parents:
310
diff
changeset
|
11 |
341
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
12 special_sections = [ |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
13 { |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
14 'name': 'wiki', |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
15 'title': 'Wiki' |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
16 }, |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
17 { |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
18 'name': 'lists', |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
19 'title': 'Page Lists' |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
20 }, |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
21 { |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
22 'name': 'users', |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
23 'title': 'Users' |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
24 } |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
25 ] |
324 | 26 |
341
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
27 special_pages = { |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
28 'changes': { |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
29 "title": "Recent Changes", |
419
f4629148e72e
web: Add the list of users in the special pages section.
Ludovic Chabant <ludovic@chabant.com>
parents:
368
diff
changeset
|
30 "view": 'site_history', |
341
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
31 "description": "See all changes in the wiki.", |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
32 "section": "wiki", |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
33 }, |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
34 'orphans': { |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
35 "title": "Orphaned Pages", |
419
f4629148e72e
web: Add the list of users in the special pages section.
Ludovic Chabant <ludovic@chabant.com>
parents:
368
diff
changeset
|
36 "view": 'special_list_orphans', |
341
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
37 "description": ("Lists pages in the wiki that have no " |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
38 "links to them."), |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
39 "section": "lists", |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
40 "template": "special-orphans.html" |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
41 }, |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
42 'broken-redirects': { |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
43 "title": "Broken Redirects", |
419
f4629148e72e
web: Add the list of users in the special pages section.
Ludovic Chabant <ludovic@chabant.com>
parents:
368
diff
changeset
|
44 "view": 'special_list_broken_redirects', |
341
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
45 "description": ("Lists pages that redirect to a missing " |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
46 "page."), |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
47 "section": "lists", |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
48 "template": "special-broken-redirects.html" |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
49 }, |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
50 'double-redirects': { |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
51 "title": "Double Redirects", |
422
49da205b4946
web: Fix URL for "double redirects" special page.
Ludovic Chabant <ludovic@chabant.com>
parents:
419
diff
changeset
|
52 "view": 'special_list_double_redirects', |
341
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
53 "description": "Lists pages that redirect twice or more.", |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
54 "section": "lists", |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
55 "template": "special-double-redirects.html" |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
56 }, |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
57 'dead-ends': { |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
58 "title": "Dead-End Pages", |
419
f4629148e72e
web: Add the list of users in the special pages section.
Ludovic Chabant <ludovic@chabant.com>
parents:
368
diff
changeset
|
59 "view": 'special_list_dead_ends', |
341
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
60 "description": ("Lists pages that don't have any " |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
61 "outgoing links."), |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
62 "section": "lists", |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
63 "template": "special-dead-ends.html" |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
64 }, |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
65 'users': { |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
66 "title": "All Users", |
419
f4629148e72e
web: Add the list of users in the special pages section.
Ludovic Chabant <ludovic@chabant.com>
parents:
368
diff
changeset
|
67 "view": 'special_users', |
341
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
68 "description": "A list of all registered users.", |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
69 "section": "users", |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
70 } |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
71 } |
147
d7890b46358e
Split all Flask views into separate modules.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
72 |
d7890b46358e
Split all Flask views into separate modules.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
73 |
341
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
74 @app.route('/special') |
368
831b22e93f94
Implement error and permission handling for UI views.
Ludovic Chabant <ludovic@chabant.com>
parents:
353
diff
changeset
|
75 @requires_reader_auth |
341
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
76 def special_pages_dashboard(): |
352
8123065b3eda
Make the special dashboard page more consistent with the other special pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
341
diff
changeset
|
77 data = { |
8123065b3eda
Make the special dashboard page more consistent with the other special pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
341
diff
changeset
|
78 'is_special_page': True, |
8123065b3eda
Make the special dashboard page more consistent with the other special pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
341
diff
changeset
|
79 'sections': []} |
341
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
80 for info in special_sections: |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
81 sec = {'title': info['title'], 'pages': []} |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
82 for k, p in special_pages.items(): |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
83 if p['section'] == info['name']: |
419
f4629148e72e
web: Add the list of users in the special pages section.
Ludovic Chabant <ludovic@chabant.com>
parents:
368
diff
changeset
|
84 pdata = p.copy() |
f4629148e72e
web: Add the list of users in the special pages section.
Ludovic Chabant <ludovic@chabant.com>
parents:
368
diff
changeset
|
85 pdata['url'] = url_for(pdata['view']) |
f4629148e72e
web: Add the list of users in the special pages section.
Ludovic Chabant <ludovic@chabant.com>
parents:
368
diff
changeset
|
86 sec['pages'].append(pdata) |
341
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
87 sec['pages'] = sorted(sec['pages'], key=lambda i: i['title']) |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
88 data['sections'].append(sec) |
147
d7890b46358e
Split all Flask views into separate modules.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
89 |
341
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
90 add_auth_data(data) |
352
8123065b3eda
Make the special dashboard page more consistent with the other special pages.
Ludovic Chabant <ludovic@chabant.com>
parents:
341
diff
changeset
|
91 add_navigation_data(None, data) |
341
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
92 return render_template('special-pages.html', **data) |
147
d7890b46358e
Split all Flask views into separate modules.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
93 |
152
8e75c12b1cc9
Search preview changes:
Ludovic Chabant <ludovic@chabant.com>
parents:
151
diff
changeset
|
94 |
341
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
95 def call_api(page_name, api_func, *args, **kwargs): |
310
bc02d4925096
Don't initialize a wiki instance in Flask until we need one.
Ludovic Chabant <ludovic@chabant.com>
parents:
307
diff
changeset
|
96 wiki = get_wiki() |
341
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
97 user = current_user.get_id() |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
98 info = special_pages[page_name] |
353
ae6760f34eb1
Fix navigation on special pages, add RAW URL in the footer.
Ludovic Chabant <ludovic@chabant.com>
parents:
352
diff
changeset
|
99 |
ae6760f34eb1
Fix navigation on special pages, add RAW URL in the footer.
Ludovic Chabant <ludovic@chabant.com>
parents:
352
diff
changeset
|
100 raw_url = None |
ae6760f34eb1
Fix navigation on special pages, add RAW URL in the footer.
Ludovic Chabant <ludovic@chabant.com>
parents:
352
diff
changeset
|
101 if 'raw_url' in kwargs: |
ae6760f34eb1
Fix navigation on special pages, add RAW URL in the footer.
Ludovic Chabant <ludovic@chabant.com>
parents:
352
diff
changeset
|
102 raw_url = kwargs['raw_url'] |
ae6760f34eb1
Fix navigation on special pages, add RAW URL in the footer.
Ludovic Chabant <ludovic@chabant.com>
parents:
352
diff
changeset
|
103 del kwargs['raw_url'] |
ae6760f34eb1
Fix navigation on special pages, add RAW URL in the footer.
Ludovic Chabant <ludovic@chabant.com>
parents:
352
diff
changeset
|
104 |
341
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
105 data = api_func(wiki, user, *args, **kwargs) |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
106 add_auth_data(data) |
353
ae6760f34eb1
Fix navigation on special pages, add RAW URL in the footer.
Ludovic Chabant <ludovic@chabant.com>
parents:
352
diff
changeset
|
107 add_navigation_data(None, data, raw_url=raw_url) |
341
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
108 data['title'] = info['title'] |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
109 data['is_special_page'] = True |
424
1066d0986082
web: Add button to force refresh a cached page list.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
110 data['refresh'] = { |
1066d0986082
web: Add button to force refresh a cached page list.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
111 'url': url_for('special_list_refresh'), |
1066d0986082
web: Add button to force refresh a cached page list.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
112 'list_name': page_name.replace('-', '_'), |
1066d0986082
web: Add button to force refresh a cached page list.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
113 'postback': page_name |
1066d0986082
web: Add button to force refresh a cached page list.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
114 } |
341
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
115 return render_template(info['template'], **data) |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
116 |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
117 |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
118 @app.route('/special/list/orphans') |
368
831b22e93f94
Implement error and permission handling for UI views.
Ludovic Chabant <ludovic@chabant.com>
parents:
353
diff
changeset
|
119 @requires_reader_auth |
341
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
120 def special_list_orphans(): |
353
ae6760f34eb1
Fix navigation on special pages, add RAW URL in the footer.
Ludovic Chabant <ludovic@chabant.com>
parents:
352
diff
changeset
|
121 return call_api('orphans', get_orphans, |
ae6760f34eb1
Fix navigation on special pages, add RAW URL in the footer.
Ludovic Chabant <ludovic@chabant.com>
parents:
352
diff
changeset
|
122 raw_url='/api/orphans') |
341
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
123 |
152
8e75c12b1cc9
Search preview changes:
Ludovic Chabant <ludovic@chabant.com>
parents:
151
diff
changeset
|
124 |
341
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
125 @app.route('/special/list/broken-redirects') |
368
831b22e93f94
Implement error and permission handling for UI views.
Ludovic Chabant <ludovic@chabant.com>
parents:
353
diff
changeset
|
126 @requires_reader_auth |
341
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
127 def special_list_broken_redirects(): |
353
ae6760f34eb1
Fix navigation on special pages, add RAW URL in the footer.
Ludovic Chabant <ludovic@chabant.com>
parents:
352
diff
changeset
|
128 return call_api('broken-redirects', get_broken_redirects, |
ae6760f34eb1
Fix navigation on special pages, add RAW URL in the footer.
Ludovic Chabant <ludovic@chabant.com>
parents:
352
diff
changeset
|
129 raw_url='/api/broken-redirects') |
341
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
130 |
152
8e75c12b1cc9
Search preview changes:
Ludovic Chabant <ludovic@chabant.com>
parents:
151
diff
changeset
|
131 |
341
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
132 @app.route('/special/list/double-redirects') |
368
831b22e93f94
Implement error and permission handling for UI views.
Ludovic Chabant <ludovic@chabant.com>
parents:
353
diff
changeset
|
133 @requires_reader_auth |
341
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
134 def special_list_double_redirects(): |
353
ae6760f34eb1
Fix navigation on special pages, add RAW URL in the footer.
Ludovic Chabant <ludovic@chabant.com>
parents:
352
diff
changeset
|
135 return call_api('double-redirects', get_double_redirects, |
ae6760f34eb1
Fix navigation on special pages, add RAW URL in the footer.
Ludovic Chabant <ludovic@chabant.com>
parents:
352
diff
changeset
|
136 raw_url='/api/double-redirects') |
341
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
137 |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
138 |
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
139 @app.route('/special/list/dead-ends') |
368
831b22e93f94
Implement error and permission handling for UI views.
Ludovic Chabant <ludovic@chabant.com>
parents:
353
diff
changeset
|
140 @requires_reader_auth |
341
37f426e067c4
Big refactor to get rid of this whole single page app crap.
Ludovic Chabant <ludovic@chabant.com>
parents:
336
diff
changeset
|
141 def special_list_dead_ends(): |
353
ae6760f34eb1
Fix navigation on special pages, add RAW URL in the footer.
Ludovic Chabant <ludovic@chabant.com>
parents:
352
diff
changeset
|
142 return call_api('dead-ends', get_dead_ends, |
ae6760f34eb1
Fix navigation on special pages, add RAW URL in the footer.
Ludovic Chabant <ludovic@chabant.com>
parents:
352
diff
changeset
|
143 raw_url='/api/dead-ends') |
424
1066d0986082
web: Add button to force refresh a cached page list.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
144 |
1066d0986082
web: Add button to force refresh a cached page list.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
145 |
1066d0986082
web: Add button to force refresh a cached page list.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
146 @app.route('/special/list-refresh', methods=['POST']) |
1066d0986082
web: Add button to force refresh a cached page list.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
147 @requires_auth('administrators') |
1066d0986082
web: Add button to force refresh a cached page list.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
148 def special_list_refresh(): |
1066d0986082
web: Add button to force refresh a cached page list.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
149 list_name = request.form.get('list_name') |
1066d0986082
web: Add button to force refresh a cached page list.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
150 postback_name = request.form.get('postback') |
1066d0986082
web: Add button to force refresh a cached page list.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
151 if not list_name: |
1066d0986082
web: Add button to force refresh a cached page list.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
152 abort(400) |
1066d0986082
web: Add button to force refresh a cached page list.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
153 |
1066d0986082
web: Add button to force refresh a cached page list.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
154 info = special_pages.get(postback_name) |
1066d0986082
web: Add button to force refresh a cached page list.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
155 if not info: |
1066d0986082
web: Add button to force refresh a cached page list.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
156 abort(400) |
1066d0986082
web: Add button to force refresh a cached page list.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
157 |
1066d0986082
web: Add button to force refresh a cached page list.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
158 postback_url = url_for(info['view']) |
1066d0986082
web: Add button to force refresh a cached page list.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
159 |
1066d0986082
web: Add button to force refresh a cached page list.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
160 wiki = get_wiki() |
1066d0986082
web: Add button to force refresh a cached page list.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
161 wiki.db.removePageList(list_name) |
1066d0986082
web: Add button to force refresh a cached page list.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
162 |
1066d0986082
web: Add button to force refresh a cached page list.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
163 return redirect(postback_url) |