[ckan-dev] New way of handling previews

Toby Dacre toby.okfn at gmail.com
Thu Aug 30 09:26:25 UTC 2012


On 28 August 2012 20:35, Dominik Moritz <domoritz at gmail.com> wrote:

> 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.
>
>
Dominik,

looks good, one thing I'd really say is to keep things like the javascript
separate from application.js as it will need to be done for both jinja2 and
genshi templates at least on the non-iframed side of things and all the
iframed code should be stand alone from the rest of the ckan code.

It'll want to be used via a helper function but that can be done later.
I'm also keen for it to not be tied down by using html ids etc (non-iframed
side again) so that we could embed several on a page if the whim took us -
this costs nothing now but is costly later.

I'd love to see this in a branch on github/okfn/ckan so I could easily give
it a ride but the general idea/implementation seems fine.

Finally please try to keep your code nicely formatted especially around
long lines - viewing on github is painful if you need to horizontally
scroll to see hidden code. whitespaceisimportanttoo;p

Toby

> Best,
> Dominik
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> http://lists.okfn.org/mailman/listinfo/ckan-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20120830/a2a1f97a/attachment-0001.html>


More information about the ckan-dev mailing list