2011-03-28 16:52:43 +02:00
|
|
|
import os
|
|
|
|
from logging import getLogger
|
|
|
|
|
|
|
|
from genshi.input import HTML
|
|
|
|
from genshi.filters import Transformer
|
|
|
|
|
|
|
|
import ckan.lib.helpers as h
|
|
|
|
|
|
|
|
from ckan.plugins import implements, SingletonPlugin
|
|
|
|
from ckan.plugins import IRoutes, IConfigurer
|
|
|
|
from ckan.plugins import IConfigurable, IGenshiStreamFilter
|
|
|
|
|
|
|
|
log = getLogger(__name__)
|
|
|
|
|
|
|
|
class Harvest(SingletonPlugin):
|
|
|
|
|
|
|
|
implements(IConfigurable)
|
|
|
|
implements(IRoutes, inherit=True)
|
|
|
|
implements(IConfigurer, inherit=True)
|
|
|
|
|
|
|
|
def configure(self, config):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def before_map(self, map):
|
|
|
|
|
2011-05-13 15:17:58 +02:00
|
|
|
controller = 'ckanext.harvest.controllers.view:ViewController'
|
|
|
|
map.connect('harvest', '/harvest',controller=controller,action='index')
|
2011-03-28 16:52:43 +02:00
|
|
|
|
2011-05-13 15:17:58 +02:00
|
|
|
map.connect('/harvest/new', controller=controller, action='new')
|
|
|
|
map.connect('/harvest/edit/:id', controller=controller, action='edit')
|
|
|
|
map.connect('/harvest/delete/:id',controller=controller, action='delete')
|
|
|
|
map.connect('/harvest/:id', controller=controller, action='read')
|
2011-03-28 16:52:43 +02:00
|
|
|
|
2011-05-13 15:17:58 +02:00
|
|
|
map.connect('harvesting_job_create', '/harvest/refresh/:id',controller=controller,
|
|
|
|
action='create_harvesting_job')
|
2011-03-28 16:52:43 +02:00
|
|
|
|
|
|
|
return map
|
|
|
|
|
|
|
|
def update_config(self, config):
|
|
|
|
here = os.path.dirname(__file__)
|
2011-04-18 10:49:25 +02:00
|
|
|
template_dir = os.path.join(here, 'templates')
|
|
|
|
public_dir = os.path.join(here, 'public')
|
2011-03-28 16:52:43 +02:00
|
|
|
if config.get('extra_template_paths'):
|
|
|
|
config['extra_template_paths'] += ','+template_dir
|
|
|
|
else:
|
|
|
|
config['extra_template_paths'] = template_dir
|
|
|
|
if config.get('extra_public_paths'):
|
|
|
|
config['extra_public_paths'] += ','+public_dir
|
|
|
|
else:
|
|
|
|
config['extra_public_paths'] = public_dir
|