Below are instructions for hosting and building the site and a layout of how the code is organized.
CNX webview is designed to be run as a frontend for cnx-archive.
- If necessary, install Node.js and npm (included with Node.js).
- Run
npm install -g grunt-cli bower
in the command line to install grunt-cli and bower. - From the root
webview
directory, runnpm install
in the command line to install test and build dependencies.
npm install
runsbower install
andgrunt install
, both of which can also be run independentlybower install
downloads front-end dependenciesgrunt install
compiles the Aloha-Editor (which is downloaded by bower)
From the root webview
directory, run npm test
.
From the root webview
directory, run grunt dist
.
The dist
directory containing the built site will be added to the root webview
directory.
From the root webview
directory, run npm run-script upgrade
, which executes the following commands:
npm update
bower update
grunt install --verbose
- Install nginx
- Run
grunt nginx:start
(usesnginx.development.conf
) - Point your browser to http://localhost:8000/test for mock data
- If you have https://github.com/Connexions/cnx-archive installed, you can point your browser to http://localhost:8000
-
Update settings in
src/scripts/settings.coffee
if necessary to, for example, include the correct Google Analytics ID, and to point to wherevercnxarchive
is being hosted. -
Ensure resources are being served with the correct MIME type, including fonts.
- Example nginx MIME types that may need to be added:
types {
image/svg+xml svg svgz;
font/truetype ttf;
font/opentype otf;
application/font-woff woff;
}
- Configure your server to point at
dist/index.html
(orsrc/index.html
for development)
- Unresolveable URIs should load
dist/index.html
orsrc/index.html
- If not hosting the site from the domain root, update
root
insrc/scripts/settings.coffee
scripts
,styles
, andimages
routes should be rewritten to the correct paths- Example nginx development config:
server {
listen 80;
server_name $hostname;
root /path/to/webview/src/;
index index.html;
try_files $uri $uri/ /index.html;
location /resources/ {
proxy_pass http://localhost:6543;
}
location ~ ^.*/bower_components/(.*)$ {
alias /path/to/webview/bower_components/$1;
}
location ~ ^.*/(data|scripts|styles|images)/(.*) {
try_files $uri $uri/ /$1/$2 /test/$1/$2;
}
location ~ ^.*/test/(.*)/(.*) {
try_files $uri $uri/ /test/$1 /test/$2 /test/index.html;
}
location ~ ^.*/test/(.*) {
try_files $uri $uri/ /test/$1 /test/index.html;
}
}
- Example nginx production config:
server {
listen 80;
server_name $hostname;
root /path/to/webview/dist/;
index index.html;
try_files $uri $uri/ /index.html;
location /resources/ {
proxy_pass http://localhost:6543;
}
location ~ ^.*/(data|scripts|styles|images|fonts)/(.*) {
try_files $uri $uri/ /$1/$2;
}
}
When running the development version of the site with its corresponding config, you can
access a test version of the site that simulates AJAX requests by appending /test
to the root URI
(for example: http://localhost/test
).
Note: Mock test data is only available for the College Physics book.
bower_components/
3rd Party Libraries (added after install)node_modules/
Node Modules (added after install)dist/
Production version of the site (added after build)src/
Development version of the sitesrc/data/
Hardcoded datasrc/images/
Images used throughout the sitesrc/scripts/
Site scripts and 3rd party librariessrc/scripts/collections
Backbone Collectionssrc/scripts/helpers
Helpers for Handlebars, Backbone, and generic codesrc/scripts/models
Backbone Modelssrc/scripts/modules
Self-contained, reusable Modules used to construct pagessrc/scripts/pages
Backbone Views representing an entire page (or the entire viewport)src/scripts/config.js
Require.js configurationsrc/scripts/loader.coffee
App loader, responsible for setting up global listenerssrc/scripts/main.js
Initial script called by Requirejssrc/scripts/router.coffee
Backbone Routersrc/scripts/session.coffee
Session state singleton (Backbone Model)src/scripts/settings.js
Global application config settings (remains in place after build)src/styles/
App-specific LESS variables and mixinssrc/index.html
App's HTML Pagetest/
Unit tests
This software is subject to the provisions of the GNU Affero General Public License Version 3.0 (AGPL). See license.txt for details. Copyright (c) 2013 Rice University.