[ckan-dev] implimenting stream filters
Adrià Mercader
adria.mercader at okfn.org
Fri Oct 4 10:31:56 UTC 2013
Hi,
Make sure to use the "latest" version of the CKAN docs (not sure how you
got to the "ckan-docs-theme" one). Notice the version on the URL. There are
links to docs to the different versions of CKAN in the lower right hand
corner
http://docs.ckan.org/en/latest/extensions/index.html
If you want to help marking the IGenshiStreamFilter interface a PR would be
most welcomed :). A notice in this docstring should suffice:
https://github.com/okfn/ckan/blob/master/ckan/plugins/interfaces.py#L54
Looking at the example looks like you already figured out how to fix it,
but just in case, a custom template + a helper function is the way I would
go.
Hope this helps,
Adrià
On 3 October 2013 14:49, Stefan Oderbolz <stefan.oderbolz at liip.ch> wrote:
> No, I think this is the most up-to-date documentation. I'd suggest you
> have a look at the documentation about "Theming" if you want to change the
> frontend of CKAN (http://docs.ckan.org/en/ckan-docs-theme/theming.html).
>
>
> On Thu, Oct 3, 2013 at 3:13 PM, Koebrick, Andrew (MNIT) <
> andrew.koebrick at state.mn.us> wrote:
>
>> Stefan,****
>>
>> ** **
>>
>> Thanks for the tips, I will play around. I had thought that the Genshi
>> was deprecated, but then saw it documented here:****
>>
>>
>> http://docs.ckan.org/en/ckan-docs-theme/writing-extensions.html#example-extensionwhich is marked as “CKAN Documentation 2.2a documentation”.
>> ****
>>
>>
>> As I continue to get into the guts of the code, is there an accurate
>> up-to-date location I can look to for documentation?****
>>
>> ** **
>>
>> Andrew****
>>
>> ** **
>>
>> *From:* ckan-dev-bounces at lists.okfn.org [mailto:
>> ckan-dev-bounces at lists.okfn.org] *On Behalf Of *Stefan Oderbolz
>> *Sent:* Thursday, October 03, 2013 2:34 AM
>> *To:* CKAN Development Discussions
>> *Subject:* Re: [ckan-dev] implimenting stream filters****
>>
>> ** **
>>
>> Hi Andrew,****
>>
>> ** **
>>
>> afaik IGenshiStreamFilter is deprecated and you shouldn't use it anymore.
>> ****
>>
>> ** **
>>
>> But there are several ways to achieve what you want. By default CKAN
>> shows the key of each extra-fields as-is (you can find the code here:
>> https://github.com/okfn/ckan/blob/master/ckan/templates/package/snippets/additional_info.html#L61
>> ). ****
>>
>> ** **
>>
>> As you can see the displayed text is translated, so this would be one way
>> to change the name that is displayed (e.g. you could specify "dsOriginator"
>> should be translated to "Originator").****
>>
>> ** **
>>
>> Another way would be to override the "additional_info.html" template, so
>> that for each displayed key the "ds" prefix is getting removed, something
>> like****
>>
>> <span scope="row" class="dataset-label" property="rdfs:label">{{
>> _(key)|replace('ds', '') }}</span>****
>>
>> ** **
>>
>> Note that this might fail if you have keys that contain "ds", a regex
>> would be a better approach.****
>>
>> ** **
>>
>> ** **
>>
>> ** **
>>
>> On Wed, Oct 2, 2013 at 11:08 PM, Koebrick, Andrew (MNIT) <
>> andrew.koebrick at state.mn.us> wrote:****
>>
>> I am attempting to make an extension that customizes the output of some
>> additional fields associated with datasets in our ckan setup. For example,
>> we have fields called “dsOriginator” which I would like to have displayed
>> as just “Originator”. I know the extension is at least partially
>> functional since it is pulling our custom templates, but it does not seem
>> to do the transform as expectedLive example at:
>> http://devel.gisdata.mn.gov/dataset/base-2008-naip-airphotos-cir-wms****
>>
>> ****
>>
>> I would be grateful for any pointers. ****
>>
>> ++++++++++++++++++++++++++++++++++++++++++****
>>
>> ****
>>
>> from pylons import config****
>>
>> from pylons import request****
>>
>> from genshi.input import HTML****
>>
>> from genshi.filters import Transformer****
>>
>> from ckan.plugins import IGenshiStreamFilter****
>>
>> ****
>>
>> import ckan.plugins as plugins****
>>
>> ****
>>
>> class geodatamn(plugins.SingletonPlugin):****
>>
>> plugins.implements(plugins.IConfigurer, inherit=True)****
>>
>> plugins.implements(IGenshiStreamFilter, inherit=True)****
>>
>> ****
>>
>> ****
>>
>> def update_config(self, config):****
>>
>> plugins.toolkit.add_template_directory(config, 'templates')****
>>
>> ****
>>
>> def filter(self, stream):****
>>
>> """Update metadata field names to be human readable****
>>
>> """****
>>
>> stream = stream | Transformer('body').substitute('dsOriginator',
>> 'Originator')****
>>
>> ****
>>
>> return stream****
>>
>> ++++++++++++++++++++++++++++++++++++++++++++++++++****
>>
>> ****
>>
>> *Andrew Koebrick | * MINNESOTA GEOSPATIAL INFORMATION OFFICE****
>>
>> Web Coordinator / Systems administrator / Librarian****
>>
>> MN.IT Services @ CENTRAL****
>>
>> 651-201-2465 (w) *| * 651-296-6398 (f) *|* andrew.koebrick at state.mn.us
>> ****
>>
>> 658 Cedar St., Room 300, St. Paul, MN 55155, www.mngeo.state.mn.us****
>>
>> **** <http://www.mn.gov/oet>
>>
>> Information Technology for Minnesota Government *|* *mn.gov/oet*****<http://www.mn.gov/oet>
>>
>> **** <http://www.mn.gov/oet>
>>
>> **** <http://www.mn.gov/oet>
>>
>>
>> _______________________________________________
>> ckan-dev mailing list
>> *ckan-dev at lists.okfn.org*
>> *http://lists.okfn.org/mailman/listinfo/ckan-dev*
>> Unsubscribe: *http://lists.okfn.org/mailman/options/ckan-dev*****<http://www.mn.gov/oet>
>>
>>
>>
>> **** <http://www.mn.gov/oet>
>>
>> ** ** <http://www.mn.gov/oet>
>>
>> -- **** <http://www.mn.gov/oet>
>>
>> Liip AG // Feldstrasse 133 // CH-8004 Zurich
>> Tel +41 43 500 39 80 // GnuPG 0x7B588C67 // *www.liip.ch*****<http://www.mn.gov/oet>
>>
>> _______________________________________________
>> ckan-dev mailing list
>> ckan-dev at lists.okfn.org
>> http://lists.okfn.org/mailman/listinfo/ckan-dev
>> Unsubscribe: http://lists.okfn.org/mailman/options/ckan-dev
>>
>>
>
>
> --
> Liip AG // Feldstrasse 133 // CH-8004 Zurich
> Tel +41 43 500 39 80 // GnuPG 0x7B588C67 // www.liip.ch
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> http://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: http://lists.okfn.org/mailman/options/ckan-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20131004/cf1483b3/attachment-0001.html>
More information about the ckan-dev
mailing list