comparison manage.py @ 112:a65cedc183d6

Added more functions to the `manage` CLI tool.
author Ludovic Chabant <ludovic@chabant.com>
date Sat, 16 Nov 2013 08:35:08 -0800
parents 5c24e8f8b095
children 7c7f7eca51ae
comparison
equal deleted inserted replaced
111:e5dea315583b 112:a65cedc183d6
4 settings.LOG_FORMAT = "[%(levelname)s]: %(message)s" 4 settings.LOG_FORMAT = "[%(levelname)s]: %(message)s"
5 settings.UPDATE_WIKI_ON_START = False 5 settings.UPDATE_WIKI_ON_START = False
6 6
7 # Create the app and the wiki. 7 # Create the app and the wiki.
8 from wikked.web import app, wiki 8 from wikked.web import app, wiki
9 from wikked.page import FileSystemPage
10 9
11 # Create the manager. 10 # Create the manager.
12 from flask.ext.script import Manager, prompt, prompt_pass 11 from flask.ext.script import Manager, prompt, prompt_pass
13 manager = Manager(app) 12 manager = Manager(app)
14 13
36 35
37 @manager.command 36 @manager.command
38 def reset(): 37 def reset():
39 """ Re-generates the database and the full-text-search index. 38 """ Re-generates the database and the full-text-search index.
40 """ 39 """
41 page_infos = wiki.fs.getPageInfos() 40 wiki.reset()
42 fs_pages = FileSystemPage.fromPageInfos(wiki, page_infos)
43 wiki.db.reset(fs_pages)
44 wiki.index.reset(wiki.getPages())
45 41
46 42
47 @manager.command 43 @manager.command
48 def update(): 44 def update(url=None):
49 """ Updates the database and the full-text-search index with any 45 """ Updates the database and the full-text-search index with any
50 changed/new files. 46 changed/new files.
51 """ 47 """
52 page_infos = wiki.fs.getPageInfos() 48 wiki.update(url)
53 fs_pages = FileSystemPage.fromPageInfos(wiki, page_infos)
54 wiki.db.update(fs_pages)
55 wiki.index.update(wiki.getPages())
56 49
57 50
58 @manager.command 51 @manager.command
59 def list(): 52 def list():
60 """ Lists page names in the wiki. 53 """ Lists page names in the wiki.
71 if resolve: 64 if resolve:
72 page._force_resolve = True 65 page._force_resolve = True
73 print page.text 66 print page.text
74 67
75 68
69 @manager.command
70 def linksfrom(url):
71 page = wiki.getPage(url)
72 for l in page.links:
73 print l
74
75
76 @manager.command
77 def linksto(url):
78 page = wiki.getPage(url)
79 for l in page.getIncomingLinks():
80 print l
81
82
76 if __name__ == "__main__": 83 if __name__ == "__main__":
77 manager.run() 84 manager.run()