ckan / ideas

[DEPRECATED] Use the main CKAN repo Discussions instead:
https://github.com/ckan/ckan/discussions
40 stars 2 forks source link

RFE: Automatic template directory #224

Closed ThrawnCA closed 4 years ago

ThrawnCA commented 5 years ago

CKAN Version if known (or site URL)

2.7.3

Please describe the expected behaviour

We would like a location where we can place new templates and have them automatically visible.

Please describe the actual behaviour

The public directory automatically exposes its contents, but it does not allow pages to take advantage of the template engine. The templates directory requires additional routes to be configured in code.

What steps can be taken to reproduce the issue?

We currently achieve what we want using extension code like the following:

plugin.py:

def before_map(self, map):
    with SubMapper(map, controller='ckanext.qgov.common.controller:QGOVController') as m:
         m.connect('article', '/article/{path:[-_a-zA-Z0-9/]+}', action='static_content')

controller.py:

def static_content(self, path):
    try:
        return render('static-content/{path}/index.html'.format(path=path))
    except TemplateNotFound:
        LOG.warn(path + " not found")
        base.abort(404)

It would be nice to have a core feature for this.

rufuspollock commented 4 years ago

INVALID. I think this is a "read the docs" issue.

ThrawnCA commented 4 years ago

@rufuspollock I've read quite a bit of the CKAN docs, but I didn't find anything that would provide this functionality. Can you point me in the right direction?