Repository navigation
Development
Boulevardier is a front-end-only application that presents TEI-encoded content and other pages delivered by your webserver in an interactive user interface. The application relies on the following libraries and tools:
- Backbone: MVC application framework
- Bootstrap: front-end framework for menu widget and CSS layout
- GulpJS: development workflow and build
- JQuery: programmatic access to DOM elements and events
- Leaflet: map loading and interaction
- LessCSS: CSS modularity
- RequireJS: dependency management
- Slidesjs: image display and navigation
- Underscore: functional utilities
at the versions indicated in the main.js and index.html files for the project.
Refer to the usage page for information on using the application with your content.
##Application architecture
The Boulevardier application is structured largely following Backbone's approach to MVC, which tends to combine the V/C into a single entity. Since most changes to application state are driven by user's triggering of DOM events, and the sources/targets of those events are tied to view classes, the application views often serve as the instigators of state change.
Views in the application correspond to the following roles:
- app: global display state, e.g., browser window resizing
- article: display of the content of a single TEI document
- issue: display of articles; this view is "structural" and provides no content
- map: wrapper for Leaflet.js configuration
- marker: a view-controller corresponding to a Leaflet marker
- menu: the items in a menu
- page: the content of a full-page, static-HTML display
- partial: the content of a page partial
Each view has a corresponding model, with the exception of "page" and "partial", whose content is static.
###Loading/initialization
The application starts, according to the RequireJS configuration specified in the index.html file, in the file app/js/main.js, which includes both additional RquireJS configuration data and initialization of a model to represent the larger application, defined in models/app.js:
main.js
models/
└── app.js
views/
└── app.js
The models/app component serves as a store for application configuration data as well as persistence for several objects in the application that are singletons over the lifetime of the application.
###Templating/partials
Page partials have three sources in the application: static HTML partials, ERB-style Javascript templates used in view classes when modifying DOM nodes, and XSLT stylesheets used in view classes when generating HTML from TEI sources.
Static HTML partials are used whenever there is no need to condition content on the state of the application, for example, when displaying an "About" page. In M&T, rendering of these partials is handled by the 'views/partial' class, and the static content is pulled from the named partial in the pages/ directory.
Javascript and XSLT templates are used whenever content is generated from a varying source, for example, when displaying the content for an article or for an item in a menu. Given that the underlying source of site content is primarily TEI-encoded documents, dynamic content tends to use both Javascript and XSLT templates. For example, the dropdown menu displaying on a page has fixed, "outer" content corresponding to the markup for any menu handlable by the application's CSS stylesheets. This fixed content exists in an ERB-style content with a single "items" parameter (see partials/menu.html). The items themselves are generated using an XSLT stylesheet (script/xsl/article-menu.xsl), which transforms an article into an <li> item that can represent it in a menu.
##Testing Refer to TravisCI for the current test status of a development fork of the mapsandtexts repo.
This repository uses Karma/Mocha/Chai for unit testing the models of the Backbone application. The tests may be run locally once npm and bower components have been installed:
~/dev/boulevardier/ $ npm install
~/dev/boulevardier/ $ bower install
~/dev/boulevardier/ $ ./node_modules/karma/bin/karma start --single-run
The karma command refers to the configuration specified in the boulevardier/karma.conf.js file for determining which browsers to use during the test run. The unit test specifications are located under boulevardier/test/spec.
##Build and deployment
Building a deployment version of the application may be done using the gulp tool, which is listed as a project dependency in package.json:
~/dev $ git clone git@github.com:kirschbombe/boulevardier.git && cd boulevardier/
~/dev/boulevardier/ $ npm install
The Gulpfile.js file defines a number of tasks which may be useful during development, including:
- watching LESS files for changes, triggering a rebuild of the project CSS file
- combining and minifying JS files
- running JSHint on project Javascript files
- producing a deployment version of the application
The build task, which is used to generate the dist/ directory in the master branch is produced with the following command:
~/dev/boulevardier/ $ rm -rf dist/; gulp build
~/dev/boulevardier/ $ git commit dist/ -m"..."
Once a feature branch has been merged into master and a new dist/ directory is generated, the dist branch should have the updated master branch merged into it. That may be done using the following commands:
~/dev/boulevardier/ $ git checkout --track origin/dist
~/dev/boulevardier/ $ git merge -s recursive -X subtree=dist master -X theirs
The additional merge parameters allow the dist branch to have a directory layout that does not include development resources. As this merge currently requires some manual cleanup, it has not been added as a post-commit hook for master, but the intention is to add this functionality in the future.