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 Aug 17, 2017
1 parent 4762d01 commit 411ca96
Show file tree
Hide file tree
Showing 17 changed files with 14,854 additions and 194 deletions.
11,110 changes: 11,110 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

18 changes: 15 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"name": "smartercleanup-django-client",
"version": "3.19.1",
"description": "Standalone Shareabouts client and server package",
"engines" : { "node" : ">=8.0" },
"engines": {
"node": ">=8.0"
},
"main": "index.js",
"repository": {
"type": "git",
Expand All @@ -23,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 @@ -40,8 +42,10 @@
"esprima": "^3.1.3",
"glob": "^7.1.1",
"@mapseed/accessible-autocomplete": "https://github.com/mapseed/accessible-autocomplete.git#6dcaafbdf154d0cb8c46ff6e50c350ee313d3985",
"i": "^0.3.5",
"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 @@ -58,7 +62,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.

4 changes: 3 additions & 1 deletion src/base/static/js/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ Shareabouts.Util = Util;
});
_.each(configArrays.places, function(config) {
var collection = new PlaceCollection([], {
url: "/dataset/" + config.id + "/places",
//url: "/dataset/" + config.id + "/places",
url: options.datasetsConfig[config.id.toUpperCase() + "_SITE_URL"] + "/places"
});
self.places[config.id] = collection;
});
Expand All @@ -150,6 +151,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 411ca96

Please sign in to comment.