Skip to content

Commit

Permalink
(refactor) add static site build process
Browse files Browse the repository at this point in the history
- This commit sets up a static site build process designed to eliminate the need for
  the front-end Django server. The build handles localization, Handlebars
  precompilation, and static asset management
- The following dev dependecies are introduced:
  - recursive-copy
  - js-yaml
  - node-gettext
  - gettext-parser
  - object-walk
  - handlebars
  - wax-on

Addresses: #655
  • Loading branch information
goldpbear committed Oct 13, 2017
1 parent c27d959 commit 3aca097
Show file tree
Hide file tree
Showing 17 changed files with 14,847 additions and 195 deletions.
11,110 changes: 11,110 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

13 changes: 11 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"build-scss": "./scripts/run-node-sass.sh",
"watch-scss": "./scripts/run-node-sass.sh -w",
"build-scss-production": "./scripts/run-node-sass.sh -p",
"start": "npm run build-scss && npm run watch-scss & npm run watch-js & ./src/manage.py runserver",
"start": "npm run build-scss && npm run watch-scss & npm run watch-js & webpack-dev-server",
"build-js": "webpack -d",
"build-js-production": "webpack -p && cat src/base/static/dist/bundle.js | gzip > src/base/static/dist/bundle.js.gz",
"watch-js": "webpack -d --watch",
Expand All @@ -44,6 +44,7 @@
"accessible-autocomplete": "git+https://github.com/mapseed/accessible-autocomplete.git",
"node-env-file": "^0.1.7",
"node-sass": "^4.0.0",
"npm": "^5.2.0",
"shelljs": "^0.5.3",
"static-eval": "^1.1.1",
"togeojson": "^0.16.0",
Expand All @@ -60,7 +61,15 @@
"babel-preset-es2015": "^6.24.1",
"catw": "^1.0.1",
"eslint-config-prettier": "^2.1.1",
"gettext-parser": "^1.2.2",
"handlebars": "^4.0.10",
"js-yaml": "^3.9.0",
"node-gettext": "^2.0.0",
"object-walk": "^0.1.1",
"prettier": "^1.4.4",
"watchify": "^3.4.0"
"recursive-copy": "^2.0.6",
"watchify": "^3.4.0",
"wax-on": "^1.2.0",
"webpack-dev-server": "^2.6.1"
}
}
4 changes: 4 additions & 0 deletions src/base/jstemplates/templates.js

Large diffs are not rendered by default.

277 changes: 277 additions & 0 deletions src/base/static/index.html

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/base/static/js/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ Shareabouts.Util = Util;
defaultPlaceTypeName: options.defaultPlaceTypeName,
placeTypes: options.placeTypes,
cluster: options.cluster,
appConfig: options.appConfig,
surveyConfig: options.surveyConfig,
supportConfig: options.supportConfig,
pagesConfig: options.pagesConfig,
Expand Down
20 changes: 10 additions & 10 deletions src/base/static/js/views/app-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module.exports = Backbone.View.extend({

var self = this,
// Only include submissions if the list view is enabled (anything but false)
includeSubmissions = Shareabouts.Config.flavor.app.list_enabled !== false,
includeSubmissions = this.options.appConfig.list_enabled !== false,
placeParams = {
// NOTE: this is to simply support the list view. It won't
// scale well, so let's think about a better solution.
Expand All @@ -56,8 +56,8 @@ module.exports = Backbone.View.extend({

// Use the page size as dictated by the server by default, unless
// directed to do otherwise in the configuration.
if (Shareabouts.Config.flavor.app.places_page_size) {
placeParams.page_size = Shareabouts.Config.flavor.app.places_page_size;
if (this.options.appConfig.places_page_size) {
placeParams.page_size = this.options.appConfig.places_page_size;
}

// Bootstrapped data from the page
Expand Down Expand Up @@ -284,14 +284,14 @@ module.exports = Backbone.View.extend({
// List view is enabled by default (undefined) or by enabling it
// explicitly. Set it to a falsey value to disable activity.
if (
_.isUndefined(Shareabouts.Config.flavor.app.list_enabled) ||
Shareabouts.Config.flavor.app.list_enabled
_.isUndefined(this.options.appConfig.list_enabled) ||
this.options.appConfig.list_enabled
) {
this.listView = new PlaceListView({
el: "#list-container",
placeCollections: self.places,
placeConfig: this.options.placeConfig,
}).render();
// this.listView = new PlaceListView({
// el: "#list-container",
// placeCollections: self.places,
// placeConfig: this.options.placeConfig,
// }).render();
}

// Cache panel elements that we use a lot
Expand Down
6 changes: 4 additions & 2 deletions src/base/static/js/views/place-list-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Backbone.Marionette.TemplateCache.prototype.compileTemplate = function(
};

var PlaceListItemView = Backbone.Marionette.Layout.extend({
template: "#place-detail",
template: Handlebars.templates["place-detail"],
tagName: "li",
className: "clearfix",
regions: {
Expand Down Expand Up @@ -113,7 +113,7 @@ var PlaceListItemView = Backbone.Marionette.Layout.extend({
});

module.exports = Backbone.Marionette.CompositeView.extend({
template: "#place-list",
template: Handlebars.templates["place-list"],
itemView: PlaceListItemView,
itemViewContainer: ".place-list",
ui: {
Expand Down Expand Up @@ -150,6 +150,8 @@ module.exports = Backbone.Marionette.CompositeView.extend({
collection.on("add", self.addModel, self);
});

console.log("!!!!", this.collection);

this.itemsPerPage = 10;
this.numItemsShown = this.itemsPerPage;

Expand Down
Loading

0 comments on commit 3aca097

Please sign in to comment.