| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
if __name__ == "__main__": |
|---|
| 4 |
import cherrypy |
|---|
| 5 |
import os |
|---|
| 6 |
base_dir = os.getcwd() |
|---|
| 7 |
|
|---|
| 8 |
from amplee.indexer import * |
|---|
| 9 |
def setup_index(): |
|---|
| 10 |
index = Indexer() |
|---|
| 11 |
container = ShelveContainer(os.path.join(base_dir, 'index.p')) |
|---|
| 12 |
index.register(PublishedIndex('pi', container=container, granularity=DateIndex.day)) |
|---|
| 13 |
index.register(UpdatedIndex('ui', container=container, granularity=DateIndex.minute)) |
|---|
| 14 |
index.register(EditedIndex('ei', container=container, granularity=DateIndex.minute)) |
|---|
| 15 |
index.register(AuthorIndex('ai', container=container, index_email=True, index_uri=True)) |
|---|
| 16 |
index.register(CategoryIndex('ci', container=container)) |
|---|
| 17 |
|
|---|
| 18 |
return index |
|---|
| 19 |
|
|---|
| 20 |
cherrypy.config.update({'engine.autoreload_on' : False, |
|---|
| 21 |
'server.socket_port' : 8080, |
|---|
| 22 |
'server.socket_host': '127.0.0.1', |
|---|
| 23 |
'server.socket_queue_size': 15, |
|---|
| 24 |
'log.screen': True, |
|---|
| 25 |
'log.access_file': os.path.join(base_dir, 'access.log'), |
|---|
| 26 |
'log.error_file': os.path.join(base_dir, 'error.log'), |
|---|
| 27 |
'checker.on': False,}) |
|---|
| 28 |
|
|---|
| 29 |
index = setup_index() |
|---|
| 30 |
|
|---|
| 31 |
from cherrypy._cpdispatch import MethodDispatcher |
|---|
| 32 |
from application import Application |
|---|
| 33 |
mainapp = Application(index) |
|---|
| 34 |
cherrypy.tree.mount(mainapp, '/', {'/': { 'request.dispatch': MethodDispatcher(), |
|---|
| 35 |
'tools.etags.on': True, |
|---|
| 36 |
'tools.etags.autotags': False}, |
|---|
| 37 |
'/static': {'tools.staticdir.on': True, |
|---|
| 38 |
'tools.staticdir.dir': os.path.join(base_dir, 'static')}}) |
|---|
| 39 |
|
|---|
| 40 |
from searchapplication import SearchApplication |
|---|
| 41 |
cherrypy.tree.mount(SearchApplication(index, mainapp.servdoc), '/search') |
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
cherrypy.engine.start() |
|---|
| 45 |
cherrypy.engine.block() |
|---|