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

Librarify #18

Merged
merged 17 commits into from
Jun 7, 2015
Merged

Librarify #18

merged 17 commits into from
Jun 7, 2015

Conversation

korroz
Copy link
Contributor

@korroz korroz commented May 30, 2015

The goal of this branch was to make the core functionality of nomnoml standalone in the form of a single javascript library file. When I started the core functionality was tightly coupled with the nomnoml web application so a lot of work went into refactoring dependencies. In the end this branch has these main features:

  • Standalone nomnoml.js.
  • Only dependency for the standalone is on lodash.
  • RequireJS (amd) and global support.
  • Configured as a Bower package for easy consumption.

Lesser features of the project:

  • Project is now using the npm package manager.
  • Project is now using the Bower package manager for front-end dependencies.
  • Switched from depending on underscore to lodash. (Bower)
  • Project uses gulp for building nomnoml.js. (npm)

Another sort of outstanding issue is to register the repo in Bower so people can use the short form nomnoml when installing the package instead of the full url to the github repo.

The above are the major points. Code wise there have been some major restructuring that may be interesting to note, some of which:

  • The underscore extensions were decoupled and now simply live on an object called _skanaar.
  • The vector.js helper functions were pushed into the nomnoml namespace as the object nomnoml.vectorMath.
  • All core functionality was pulled out from nomnoml.app.js, moving many functions and even splitting fitCanvasSize() into two.

I also need to mention that while this is a good step, separating core from app there are still things I'm not particularly pleased with, so there are areas which could use further improvement.

And lastly, this should close issue #17.

korroz added 17 commits May 29, 2015 23:32
We shouldn't contaminate underscore with custom extensions.
Many things happen in this commit and they are all intermingled in ways
they are hard to separate.

 - Start using Bower for dependencies, reason being to make nomnoml itself
   a bower package.
 - Upgrade Dagre from 0.4.5 to 0.7.1, reason being that the older version
   wasn't a bower package and didn't support RequireJS, the new version
   has both of these features.
 - Switch from using Underscore to using Lo-Dash, because Dagre depends on
   Lo-Dash it was just nicer if nomnoml switched to that as well.

Known issues:

 - With the upgrade of Dagre the layout doesn't come out exactly the same.
   The upgrade also messes with the rendering of relation arrows.
Turns out that with the upgrade of Dagre, the path now already comes with
the end points calculated so now nomnoml doesn't have to do that manually
anymore.
Since Dagre is now providing the necessary points we can let the layout
function stop adding the compartment position to the relation path since
that was a work around for later figuring out the intersection point with
the nodes involved.
Since the latest version (0.7.1) of Dagre caused so many undesireable
effects, going back to the older version and embedding it within nomnoml
instead seems like a better option. The size of `nomnoml.js` went from 40k
to 80k as a result (note: Dagre istelf embeds graphlib).
@dlobue
Copy link

dlobue commented Jun 4, 2015

@korroz very nice! would it be possible to leverage what you've done to create a CLI tool that outputs a SVG (or any image format really)?

skanaar added a commit that referenced this pull request Jun 7, 2015
@skanaar skanaar merged commit 5700faf into skanaar:master Jun 7, 2015
@korroz korroz deleted the librarify branch June 7, 2015 18:01
@korroz
Copy link
Contributor Author

korroz commented Jun 7, 2015

@dlobue thanks!

Making nomnoml capable of outputting on a command line was exactly my ambition actually. However there is one rather major technical challenge, namely text measuring. Without a rendering context (such as a browser) getting the length of text is impossible. So even if the output would be SVG it seems like you still need something like a headless browser (like PhantomJS) to produce a layout.

But yeah, it's something I will look at in the future.

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

Successfully merging this pull request may close these issues.

None yet

3 participants