Mercurial > wikked
diff manage.py @ 13:30ae685b86df
Added support for authentatication
- Added `.wikirc` config file.
- Added login, logout.
- Added users and groups.
- CLI command to generate user.
- CLI command to reset the index.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 30 Dec 2012 19:57:52 -0800 |
parents | c946f4facfa2 |
children | 420ff74c2e28 |
line wrap: on
line diff
--- a/manage.py Sat Dec 29 18:24:38 2012 -0800 +++ b/manage.py Sun Dec 30 19:57:52 2012 -0800 @@ -1,13 +1,38 @@ import os.path -from flask.ext.script import Manager, Command -from wikked import app +import logging +from flask.ext.script import Manager, Command, prompt, prompt_pass +from wikked import app, wiki + manager = Manager(app) + @manager.command -def stats(): - """Prints some stats about the wiki.""" - pass +def users(): + """Lists users of this wiki.""" + print "Users:" + for user in wiki.auth.getUsers(): + print " - " + user.username + print "" + +@manager.command +def new_user(): + """Generates the entry for a new user so you can + copy/paste it in your `.wikirc`. + """ + username = prompt('Username: ') + password = prompt_pass('Password: ') + password = app.bcrypt.generate_password_hash(password) + print "[users]" + print "%s = %s" % (username, password) + + +@manager.command +def reset_index(): + """ Re-generates the index, if search is broken + somehow in your wiki. + """ + wiki.index.reset(wiki.getPages()) if __name__ == "__main__":