Name: npr-pym-liveblog-loader
Owner: NPR visuals team
Description: NPR custom pym & liveblog loader - Handles special libraries for NPR.org while still being reusable by member stations
Created: 2017-07-05 15:58:23.0
Updated: 2017-07-05 15:59:50.0
Pushed: 2017-07-05 16:39:12.0
Homepage: null
Size: 118
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
NPR custom pym & customized child tracker loader that handles specific library needs inside npr.org while still being usable by our member stations.
Being able to use the same loader script inside NPR.org and inside our member station websites is a goal that we need to prepare to in advance so that we can profit for future developments in our CMS API as well as avoiding separation in our code.
Using an external script together with versioning will allow us moving forward to be able to patch assets embedded in a centralized fashion.
If you do not know what pym.js is and why it may be useful for you please check pym.js documentation. You'll see the standard loader in that documentation which follows the same practices as we used in our custom one.
But we needed some flexibility to account for NPR.org specific needs and did not want to pollute the standard pym-loader with NPR specific needs…that's why we have created a custom loader to account for our specific needs.
Important: The version of pym that this loader points to is defined in package.json if a MAJOR release of pym is added then we should also change it here.
The following things are assumed to be true in this documentation.
For more details on the technology stack used in NPR Visuals' app template, see our development environment blog post.
Modern versions of Windows and Linux should work equally well but are untested by the NPR Visuals Team.
The project contains the following folders and important files:
dist
– Unminified and minified versions of pym.js library and the pym-loader.js loader.examples
– Collection of working use cases for npr-pym-loader.jssrc
– Source files for this projectGruntfile.js
– Grunt.js task runner config filenprapps_tools
– NPR Deployment tools to the CDNNode.js is required. If you don't already have it, get it like this:
install node
Then bootstrap the project:
install
In this project the only project secrets that we have are the Sauce Labs credentials to secure a tunnel between Travis and Sauce Labs used in our continuous integration process. Those keys have been encrypted through Travis; you can read more about that process here
Project secrets should never be stored anywhere else in the repository. They will be leaked to the client if you do. Instead, always store passwords, keys, etc. in environment variables and document that they are needed here in the README.
In order to run pym.js the best approach is to fire up a local webserver and go to the examples to see it in action.
The included server includes livereload
so each time you change something on the examples
or src
folder the server will refresh the page for you.
npr-pym-liveblog-loader
unt server
Grunt configuration is included for running common development tasks.
Javascript can be linted with jshint:
t jshint
Unminified source can be regenerated with:
t concat
Minified source can be regenerated with:
t uglify
API documention can be generated with jsdoc:
t jsdoc
We use grunt tasks to build the project into the dist
folder. Linting JS, preprocessing, uglyfing, etc.
unt
That execution will create a minified and unminified version of our custom folder on the dist
folder.
It will also generate an API documentation if you want to check that out run:
unt server
and navigate to http://localhost:9000/api/npr-pym-liveblog-loader/X.X.X/ on your browser.
Where X.X.X is the actual version of the loader defined in `package.json
NPR only If a new version of the npr pym loader is needed the workflow would be:
We use grunt tasks to build the project into the dist
folder. Linting JS, preprocessing, uglyfing, etc.
unt
That execution will create a minified and unminified version of our custom folder on the dist
folder.
It will also generate an API documentation if you want to check that out run:
unt server
and navigate to http://localhost:9000/api/npr-pym-liveblog-loader/X.X.X/ on your browser.
Where X.X.X is the actual version of the loader defined in `package.json
After having build the new version of the library see above.
NPR only If a new version of the projects is needed the workflow would be:
prapps_tools
rtualenv npr-pym-liveblog-loader
install -r requirements.txt
deploy
This will deploy whatever is inside the dist
folder to S3 and make it available through a CDN at https://pym.nprapps.org/
The project follows the semantic versioning pattern MAJOR.MINOR.PATCH.
To minimize the impact on our current and future customers, on the uncompressed and on the minified production side of npr-pym-loader we are only going to keep the major version exposed. That we can apply PATCHES and MINOR version changes without any change being made on our customer's code but we maintain the possibility of new major releases that are somewhat disruptive with previous versions of the library.
Released under the MIT open source license. See LICENSE
for details.
npr-pym-liveblog-loader.js was built by the NPR Visuals team