Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build process for OpenSpendingJS #40

Open
trickvi opened this issue Sep 12, 2013 · 0 comments
Open

Build process for OpenSpendingJS #40

trickvi opened this issue Sep 12, 2013 · 0 comments

Comments

@trickvi
Copy link
Contributor

trickvi commented Sep 12, 2013

Moved from openspending/openspending#665

Have a build process for building openspendingjs into one consolidated file.

Email from @tryggvib

http://lists.okfn.org/pipermail/openspending-dev/2013-May/000791.html

I've taken a stab at this and created a build process for openspendingjs
using Gruntjs (http://gruntjs.com). To make the build process clean I'm
working from a new directory structure (that sits besides the current
one). What I envision we will have in the end is something like many of
the open source / javascript libraries out there:

openspendingjs
    |
    |- dist/ (where build results go so we'll have versioning, examples below)
    |     |- openspending-.js (concatenated javascript files)
    |     |- openspending-.min.js (minified javascript files)
    |     |- openspending-.css (concatenated css files)
    |     `- openspending-.min.css (minified css files)
    |
    |- lib/ (where we put external libraries, examples below)
    |    |- kartograph-.js
    |    `- raphael-.js
    |
    |- src/
    |     |
    |     |- utils (various openspendingjs utils, examples below)
    |     |     |- openspending.amounts.js (utils for dealing with amounts)
    |     |     |- openspending.colors.js (utils for managing colors)
    |     |     |- openspending.aggregator.js (API aggregator)
    |     |     `- README.md (information about the utils)
    |     |
    |     |- visualisations (where visualisation files go, examples below)
    |     |     |- jquery.choropleth.js (jquery plugin to create a choropleth map)
    |     |     |- jquery.treemap.js (jquery plugin to create a treemap)
    |     |     `- README.md (information about the visualisations)
    |     |
    |     `- css (where stylesheets go, example below)
    |           `- treemap.css
    |
    |- package.json (information about the package)
    |- README.md (information about the project)
    |- CONTRIBUTORS (who has contributued)
    |- LICENSE (license for the project)
    `- Gruntfile.js (build configurations)

Like I said, I've taken a stab at this and created a branch with this
structure (without touching the other structure - I even still use
lib/vendor/ instead of lib). I deleted some things (like the flash
folder). Here's the branch on github if you want to take a look:
https://github.com/openspending/openspendingjs/tree/build-process

There are some new things there like how the visualisations are managed.
I moved them into being jquery plugins. They don't have to be, we could
use our OpenSpending object, but I did this when I felt visualisations
shouldn't be a core part of OpenSpending (I felt the utils should be).
So I thought having them as jquery plugins might maybe result in more
visualisation contributions (in retrospect I think I should move them
back under OpenSpending so we'll be famous!). However it is cool that in
order to create a treemap on a site one can now either do:

<div class="treemap" data-dataset="uppgjor-rikissjods"></div>

or:

$(some selector).treemap({data:{dataset:'uppgjor-rikissjods'}})

Plus a bunch of other options (it just feels natural when you've worked
a lot with bootstrap). Of course you need to load the
openspending-.min.js and openspending-.min.css files.
This approach might make a plugin creation (e.g. for WordPress) a lot
simpler (drop in the js and the css files, make a simple parser with the
configurations to create a new div).

I'm really interested in hearing your opinions. I've probably made some
weird decisions here and there while trying to keep all of those balls
up in the air, but this is how I think the openspendingjs library could be.

I'm especially interested in hearing from visualisation experts out
there. Would this make contributing new and fresh visualisations easier?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant