Mercurial > wikked
annotate manage.py @ 35:2b35d719f342
Handle wiki and page permissions for read/write access.
Refactored code to only have one place where page title "slugification" happens.
Made that "slugification" better by replacing diacritics with their ANSI
character equivalent (on both server and client).
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 06 Jan 2013 20:22:36 -0800 |
parents | 420ff74c2e28 |
children | f63a2062fb99 |
rev | line source |
---|---|
0 | 1 import os.path |
13
30ae685b86df
Added support for authentatication
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
2 import logging |
30ae685b86df
Added support for authentatication
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
3 from flask.ext.script import Manager, Command, prompt, prompt_pass |
30ae685b86df
Added support for authentatication
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
4 from wikked import app, wiki |
30ae685b86df
Added support for authentatication
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
5 |
0 | 6 |
7 manager = Manager(app) | |
8 | |
13
30ae685b86df
Added support for authentatication
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
9 |
0 | 10 @manager.command |
13
30ae685b86df
Added support for authentatication
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
11 def users(): |
30ae685b86df
Added support for authentatication
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
12 """Lists users of this wiki.""" |
30ae685b86df
Added support for authentatication
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
13 print "Users:" |
30ae685b86df
Added support for authentatication
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
14 for user in wiki.auth.getUsers(): |
30ae685b86df
Added support for authentatication
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
15 print " - " + user.username |
30ae685b86df
Added support for authentatication
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
16 print "" |
30ae685b86df
Added support for authentatication
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
17 |
30ae685b86df
Added support for authentatication
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
18 @manager.command |
30ae685b86df
Added support for authentatication
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
19 def new_user(): |
30ae685b86df
Added support for authentatication
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
20 """Generates the entry for a new user so you can |
30ae685b86df
Added support for authentatication
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
21 copy/paste it in your `.wikirc`. |
30ae685b86df
Added support for authentatication
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
22 """ |
30ae685b86df
Added support for authentatication
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
23 username = prompt('Username: ') |
30ae685b86df
Added support for authentatication
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
24 password = prompt_pass('Password: ') |
30ae685b86df
Added support for authentatication
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
25 password = app.bcrypt.generate_password_hash(password) |
30ae685b86df
Added support for authentatication
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
26 print "[users]" |
30ae685b86df
Added support for authentatication
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
27 print "%s = %s" % (username, password) |
30ae685b86df
Added support for authentatication
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
28 |
30ae685b86df
Added support for authentatication
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
29 |
30ae685b86df
Added support for authentatication
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
30 @manager.command |
30ae685b86df
Added support for authentatication
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
31 def reset_index(): |
30ae685b86df
Added support for authentatication
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
32 """ Re-generates the index, if search is broken |
30ae685b86df
Added support for authentatication
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
33 somehow in your wiki. |
30ae685b86df
Added support for authentatication
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
34 """ |
30ae685b86df
Added support for authentatication
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
35 wiki.index.reset(wiki.getPages()) |
0 | 36 |
37 | |
30
420ff74c2e28
Added a shell command to list all the pages in the wiki.
Ludovic Chabant <ludovic@chabant.com>
parents:
13
diff
changeset
|
38 @manager.command |
420ff74c2e28
Added a shell command to list all the pages in the wiki.
Ludovic Chabant <ludovic@chabant.com>
parents:
13
diff
changeset
|
39 def list(): |
420ff74c2e28
Added a shell command to list all the pages in the wiki.
Ludovic Chabant <ludovic@chabant.com>
parents:
13
diff
changeset
|
40 """ Lists page names in the wiki. |
420ff74c2e28
Added a shell command to list all the pages in the wiki.
Ludovic Chabant <ludovic@chabant.com>
parents:
13
diff
changeset
|
41 """ |
420ff74c2e28
Added a shell command to list all the pages in the wiki.
Ludovic Chabant <ludovic@chabant.com>
parents:
13
diff
changeset
|
42 for url in wiki.getPageUrls(): |
420ff74c2e28
Added a shell command to list all the pages in the wiki.
Ludovic Chabant <ludovic@chabant.com>
parents:
13
diff
changeset
|
43 print url |
420ff74c2e28
Added a shell command to list all the pages in the wiki.
Ludovic Chabant <ludovic@chabant.com>
parents:
13
diff
changeset
|
44 |
420ff74c2e28
Added a shell command to list all the pages in the wiki.
Ludovic Chabant <ludovic@chabant.com>
parents:
13
diff
changeset
|
45 |
0 | 46 if __name__ == "__main__": |
47 manager.run() | |
48 |