[ckan-dev] How to add a folder with images to a CKAN plugin

George Sattler George.sattler at xvt.com.au
Tue Nov 25 22:17:08 UTC 2014


Hi Jesús
This should work okay. Here’s a really basic example of an extension that makes a ‘css’ and ‘images’ folder available. Install and add ‘static_example’ to your list of plugins. https://www.dropbox.com/s/cmzi8w34oqobmt3/ckanext-static_example.tar.gz?dl=0

You should then be able to access these assets:

<your_site>/example-file.txt
<your_site>/css/main.css
<your_site/images/titanic.jpg

Hope that helps.
Cheers
George


On 25 Nov 2014, at 11:44 pm, Jesús Redondo <redondogarciajesus at gmail.com<mailto:redondogarciajesus at gmail.com>> wrote:

Hello,

I would like to know how to include a folder and its subdirectories to a CKAN extension to be served as static content. This folders would include the images for the plugin. For example:

public
   |
   |- - Main_Images {some images}
   |            |
   |            |- Banners {some images}
   |
   |
   |- - Apps  {images}
           |
           |- App1 {images about app1}



So if my portal URL is http://portal.com<http://portal.com/> I would like to access the images in such fashion:

http://portal.com/Main_Images/image1.png
http://portal.com/Main_Images/Banners/banner1.png
http://portal.com/Apps/logo_apps1.png
http://portal.com/Apps/App1/imageapp1.png
... (and so on)

I have tried with a public folder by modifying plugin.py:

 p.toolkit.add_public_directory(config, 'public')

Unfortunately, this only includes that specific folder, but not the sub-folders (and it's too messy having all the images in the same path).

Thanks for the help,

Jesús Redondo

_______________________________________________
ckan-dev mailing list
ckan-dev at lists.okfn.org<mailto:ckan-dev at lists.okfn.org>
https://lists.okfn.org/mailman/listinfo/ckan-dev
Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev


________________________________
This email and any files transmitted with it is confidential and intended solely for the use of the addressee. The unauthorised use, dissemination, forwarding, printing or copying of this communication is strictly prohibited. If you have received this communication in error please notify us immediately by reply email and destroy this communication. Any views and opinions presented in this email are solely those of the author and do not necessarily represent the views of XVT Solutions. The recipient should check this email and any attachments for viruses. XVT Solutions accepts no liability for the content of this email, and any damage caused by any viruses that could potentially be transmitted through this email.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20141126/e1a36375/attachment-0003.html>


More information about the ckan-dev mailing list