[ckan-dev] New way of handling previews

Dominik Moritz domoritz at gmail.com
Tue Aug 28 19:35:27 UTC 2012


Hello everyone,

David had the idea to put the preview for resources and especially recline into an iframe which would avoid problems with interfering css and js. While doing this I noticed that there is a lot of code in application.js that decides how to embed the preview into the page. However, this can also easily be done on the server. I think that it would make sense because this way we only have to load what is really necessary instead of the whole preview js/ css stuff.

Do give you an idea, here is a possible mapping for previews:
- html -> show in an iframe
- sth for recline -> show recline in an iframe that resizes to the right height
- image -> embed directly with a max-height and max-width
- txt -> embed directly or show in an iframe 

Notice one problem with embedding text directly! You would have to fetch it before the request can return. However, we could write a small script that does that on the client. 

What I did to show what our idea looks like:
- created a new page which only displays the preview
- put an iframe where the preview used to be
- added some code to package.py to get the appropriate resource url
- updated recline to the latest version without further changes to the css or js

The only thing that is not fully working is the embed button. It is not possible to yet to save the recline state object to the embed url. 

You can have a look at the changes on https://github.com/domoritz/ckan/commits/2888-datapreview-iframe
And a fake pull request that shows all changes: https://github.com/okfn/ckan/pull/115

Please keep in mind that the changes are only there to show my idea. But if you like it I can redo it on the demo branch. 

Let me know what you think. I've probably missed something important and would be glad to improve the solution. 

Best,
Dominik



More information about the ckan-dev mailing list