[ckan-dev] angular and ckan

Matthew Fullerton matthew at smartlane.de
Mon Aug 8 19:12:38 UTC 2016


Hi Dan,

Here are some very basic notes I made quite a while ago when we did this:


---

We have the situation that we (at least initially) want to serve Angular Apps inside CKAN pages. It is uncommon to use a server-side rendering framework with a framework designed for complete frontend-based apps, but it is not uncommon to use frameworks/libraries to add functionality to the frontend in general (e.g. jQuery, and the CKAN Visualizations use Backbone). But AngularJS is quite a brute, and integrating it requires some care.

Key points:

  *   The Angular code lives in the ckanext-smartlane CKAN extension along with our CKAN-rendered templates. It is split up as follows:
     *   The environment (tests, config for which JS packages are needed etc.) right at the top under angular-apps
     *   The html templates (views) are served as CKAN templates. For the main app page a route is added to the CKAN Extension controller, and then a catch-all route is added for the partials. This may be a sensible approach to follow per app.
     *   All JavaScript and CSS is served via Fanstatic for performance reasons as recommended by CKAN - http://docs.ckan.org/en/latest/theming/fanstatic.html
  *   JS/CSS files are included as resources in the templates - http://docs.ckan.org/en/latest/contributing/frontend/resources.html
  *   Fanstatic is tempered a bit with a resource.config - http://docs.ckan.org/en/latest/contributing/frontend/resources.html?highlight=config#resource-config
  *   We have the problem that Jinja2 on the server side will try to render the template code. To avoid this, surround the code with {% raw %} ... {% endraw %}.

---


If you'd like any more detail on the individual parts, let me know, I'm sure I can dig it out.


Best,

Matt


---------------------------------------------------------------------
Matthew Fullerton

Smartlane UG (haftungsbeschränkt)
Metzstraße 29a
81667 München

matthew at smartlane.de
T +49.176.5789.6501
F +49.89.9041.1930.2

www.smartlane.de<http://www.smartlane.de/>

---------------------------------------------------------------------
Geschäftsführer: Dr. Mathias Baur, Florian Schimandl
Unternehmenssitz: München
Handelsregister beim Amtsgericht: München
Handelsregister-Nummer: HRB 220483
USt. ID-Nr.: DE301856148
Finanzamt: München
---------------------------------------------------------------------
________________________________
Von: ckan-dev <ckan-dev-bounces at lists.okfn.org> im Auftrag von Dan Mihaila <danmihaila at gmail.com>
Gesendet: Freitag, 5. August 2016 10:53
An: CKAN Development Discussions
Betreff: [ckan-dev] angular and ckan

Hello,
I wanted to ask on this list if anybody tried to integrate an angular application with a ckan instance. I was wondering if there is a need for an extension that will allow to easily integrate (embed or other solution).
We integrated an angular application, but in a static way: embed in template, with no other configurations or extension. (https://data.humdata.org/explore - just click on any link)

Cheers,

Dan Mihaila, IT Consultant
(M) +40 722 502 304 * (GTalk) dan.mihaila at gmail.com<mailto:dan.mihaila at gmail.com> * (Skype) carcotelul
* (Twitter) dan_mihaila * (Yahoo) carcotelul
 <mailto:dmihaila at dginternational.org>


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20160808/0b078291/attachment-0003.html>


More information about the ckan-dev mailing list