diff --git a/.eslintrc b/.eslintrc index 39172a499..59d17b1e9 100644 --- a/.eslintrc +++ b/.eslintrc @@ -27,6 +27,7 @@ "Promise": true, "require": true, "wcEvents": true, + "wcTmpl": true, "WindowHelpers": true }, "rules": { diff --git a/.gitignore b/.gitignore index 3c6671352..7266f789c 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,7 @@ webcompat/static/js/issues.js webcompat/static/js/issue-list.js webcompat/static/js/user-activity.js webcompat/static/js/cssfixme.js +webcompat/static/js/templates.js webcompat/**/*.min.js webcompat/**/*.min.css webcompat/**/*.dev.css diff --git a/Gruntfile.js b/Gruntfile.js index 508d95d29..8641f2b07 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -5,6 +5,7 @@ module.exports = function(grunt) { grunt.initConfig({ pkg: grunt.file.readJSON("package.json"), + tmplPath: "webcompat/templates/", jsPath: "webcompat/static/js", cssPath: "webcompat/static/css", imgPath: "webcompat/static/img", @@ -24,6 +25,7 @@ module.exports = function(grunt) { // Default task. grunt.registerTask("default", [ "checkDependencies", + "jst", "concat", "uglify", "postcss", @@ -33,6 +35,7 @@ module.exports = function(grunt) { // Task used before doing a deploy (same as default, but does image optimization) grunt.registerTask("deploy", [ "checkDependencies", + "jst", "concat", "uglify", "postcss", diff --git a/docs/dev-env-setup.md b/docs/dev-env-setup.md index 0f4549057..66fbee70e 100644 --- a/docs/dev-env-setup.md +++ b/docs/dev-env-setup.md @@ -198,6 +198,7 @@ After certain kinds of changes are made, you need to build the project before se * CSS: a build will run cssnext, combine custom media queries, and concat all source files into webcompat.dev.css. You'll need to re-build the CSS to see any changes, so it's recommended to use a watch task (see `npm run watch`). * JS: a build will run eslint, minify and concat source files. +* JS templates (.jst files): if you are making changes to a Backbone template in a `.jst` file, you will need to re-run the `build` command to update the pre-compiled `templates.js` file before you will see the results. * HTML templates: the changes should be served from disk without the need for rebuilding * Python: the Flask local server will detect changes and restart automatically. No need to re-build. diff --git a/grunt-tasks/concat.js b/grunt-tasks/concat.js index cc3827dac..ca622612e 100644 --- a/grunt-tasks/concat.js +++ b/grunt-tasks/concat.js @@ -22,7 +22,8 @@ module.exports = function(grunt) { "<%= jsPath %>/vendor/backbone.mousetrap.js", "<%= jsPath %>/lib/flash-message.js", "<%= jsPath %>/lib/homepage.js", - "<%= jsPath %>/lib/bugform.js" + "<%= jsPath %>/lib/bugform.js", + "<%= jsPath %>/templates.js" ], dest: "<%= jsPath %>/<%= pkg.name %>.js" }, diff --git a/grunt-tasks/jst.js b/grunt-tasks/jst.js new file mode 100644 index 000000000..5c6087e57 --- /dev/null +++ b/grunt-tasks/jst.js @@ -0,0 +1,30 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +module.exports = function(grunt) { + grunt.config("jst", { + compile: { + options: { + namespace: "wcTmpl", + prettify: true, + processContent: function(src) { + // strip the opening and closing - + {% include "web_modules/issue-list.jst" %} +

View All

diff --git a/webcompat/templates/issue.html b/webcompat/templates/issue.html index 66d136d75..985219e6e 100644 --- a/webcompat/templates/issue.html +++ b/webcompat/templates/issue.html @@ -11,7 +11,7 @@ {% include "issue/issue-aside.html" %} {% include "issue/issue-information.html" %}
- {% include "issue/issue-comment-list.html" %} + {% include "issue/issue-comment-list.jst" %}
{% if session.user_id and session.avatar_url %}
diff --git a/webcompat/templates/issue/aside.jst b/webcompat/templates/issue/aside.jst new file mode 100644 index 000000000..52daf23ce --- /dev/null +++ b/webcompat/templates/issue/aside.jst @@ -0,0 +1,21 @@ + diff --git a/webcompat/templates/issue/issue-aside.html b/webcompat/templates/issue/issue-aside.html index 9f441b9da..6aa58e434 100644 --- a/webcompat/templates/issue/issue-aside.html +++ b/webcompat/templates/issue/issue-aside.html @@ -1,28 +1,9 @@ diff --git a/webcompat/templates/issue/issue-comment-list.html b/webcompat/templates/issue/issue-comment-list.jst similarity index 94% rename from webcompat/templates/issue/issue-comment-list.html rename to webcompat/templates/issue/issue-comment-list.jst index 53a54a45e..37807d3a2 100644 --- a/webcompat/templates/issue/issue-comment-list.html +++ b/webcompat/templates/issue/issue-comment-list.jst @@ -1,4 +1,4 @@ - + {% include "issue/upload-image.jst" %}
diff --git a/webcompat/templates/issue/issue-information.html b/webcompat/templates/issue/issue-information.html index 82f5688cf..01c6556af 100644 --- a/webcompat/templates/issue/issue-information.html +++ b/webcompat/templates/issue/issue-information.html @@ -1,11 +1,5 @@
- + {% include "issue/metadata.jst" %}
diff --git a/webcompat/templates/issue/issue-labels-sub.jst b/webcompat/templates/issue/issue-labels-sub.jst new file mode 100644 index 000000000..4b09a44ef --- /dev/null +++ b/webcompat/templates/issue/issue-labels-sub.jst @@ -0,0 +1,8 @@ + diff --git a/webcompat/templates/issue/issue-labels.html b/webcompat/templates/issue/issue-labels.jst similarity index 78% rename from webcompat/templates/issue/issue-labels.html rename to webcompat/templates/issue/issue-labels.jst index d7ba0593d..538698249 100644 --- a/webcompat/templates/issue/issue-labels.html +++ b/webcompat/templates/issue/issue-labels.jst @@ -1,14 +1,14 @@ - - -{% include "web_modules/label-editor.html" %} diff --git a/webcompat/templates/issue/issue-report.html b/webcompat/templates/issue/issue-report.jst similarity index 94% rename from webcompat/templates/issue/issue-report.html rename to webcompat/templates/issue/issue-report.jst index ad72226dd..bf453cf51 100644 --- a/webcompat/templates/issue/issue-report.html +++ b/webcompat/templates/issue/issue-report.jst @@ -1,4 +1,4 @@ - diff --git a/webcompat/templates/issue/state-button.jst b/webcompat/templates/issue/state-button.jst new file mode 100644 index 000000000..40a3d3cad --- /dev/null +++ b/webcompat/templates/issue/state-button.jst @@ -0,0 +1,3 @@ + diff --git a/webcompat/templates/issue/thanks.jst b/webcompat/templates/issue/thanks.jst new file mode 100644 index 000000000..4c9d42bd9 --- /dev/null +++ b/webcompat/templates/issue/thanks.jst @@ -0,0 +1,11 @@ + diff --git a/webcompat/templates/issue/upload-image.jst b/webcompat/templates/issue/upload-image.jst new file mode 100644 index 000000000..e82b00754 --- /dev/null +++ b/webcompat/templates/issue/upload-image.jst @@ -0,0 +1,19 @@ + diff --git a/webcompat/templates/layout.html b/webcompat/templates/layout.html index b4cb7587c..999c7f07f 100644 --- a/webcompat/templates/layout.html +++ b/webcompat/templates/layout.html @@ -58,6 +58,7 @@ + {%- if config['LOCALHOST'] -%} diff --git a/webcompat/templates/list-issue.html b/webcompat/templates/list-issue.html index be4c15925..ec3af4e9e 100644 --- a/webcompat/templates/list-issue.html +++ b/webcompat/templates/list-issue.html @@ -21,7 +21,9 @@
{% include "list-issue/search-issue-sorting.html" %}
- {% include "list-issue/issue-list.html" %} +
+ {% include "list-issue/issuelist-issue.jst" %} +
{% include "web_modules/pagination.html" %} diff --git a/webcompat/templates/list-issue/dropdown.jst b/webcompat/templates/list-issue/dropdown.jst new file mode 100644 index 000000000..08b7d607c --- /dev/null +++ b/webcompat/templates/list-issue/dropdown.jst @@ -0,0 +1,14 @@ + diff --git a/webcompat/templates/list-issue/issue-list.html b/webcompat/templates/list-issue/issue-list.html deleted file mode 100644 index 6a4a2f21d..000000000 --- a/webcompat/templates/list-issue/issue-list.html +++ /dev/null @@ -1,48 +0,0 @@ -
- -
diff --git a/webcompat/templates/list-issue/issuelist-issue.jst b/webcompat/templates/list-issue/issuelist-issue.jst new file mode 100644 index 000000000..c8b9cee28 --- /dev/null +++ b/webcompat/templates/list-issue/issuelist-issue.jst @@ -0,0 +1,66 @@ + diff --git a/webcompat/templates/list-issue/issuelist-search.jst b/webcompat/templates/list-issue/issuelist-search.jst new file mode 100644 index 000000000..f749ac71c --- /dev/null +++ b/webcompat/templates/list-issue/issuelist-search.jst @@ -0,0 +1,12 @@ + diff --git a/webcompat/templates/list-issue/issuelist-sorting.jst b/webcompat/templates/list-issue/issuelist-sorting.jst new file mode 100644 index 000000000..560f5ece6 --- /dev/null +++ b/webcompat/templates/list-issue/issuelist-sorting.jst @@ -0,0 +1,4 @@ + diff --git a/webcompat/templates/list-issue/search-issue-filter.html b/webcompat/templates/list-issue/search-issue-filter.html index 927d716e8..154d364aa 100644 --- a/webcompat/templates/list-issue/search-issue-filter.html +++ b/webcompat/templates/list-issue/search-issue-filter.html @@ -1,4 +1,3 @@ -{% from "web_modules/dropdown.html" import dropdown with context %} {% from "web_modules/tag.html" import tag with context %}
@@ -7,17 +6,4 @@ {% endfor %}
- +{% include "list-issue/dropdown.jst" %} diff --git a/webcompat/templates/list-issue/search-issue-search-form.html b/webcompat/templates/list-issue/search-issue-search-form.html index 5cd723b72..1c86f5821 100644 --- a/webcompat/templates/list-issue/search-issue-search-form.html +++ b/webcompat/templates/list-issue/search-issue-search-form.html @@ -1,7 +1,3 @@
- + {% include "list-issue/issuelist-search.jst" %}
diff --git a/webcompat/templates/list-issue/search-issue-sorting.html b/webcompat/templates/list-issue/search-issue-sorting.html index dff7b8da0..c8c540e13 100644 --- a/webcompat/templates/list-issue/search-issue-sorting.html +++ b/webcompat/templates/list-issue/search-issue-sorting.html @@ -1,13 +1,8 @@ -{% from "web_modules/dropdown.html" import dropdown with context %} -
- + {% include "list-issue/issuelist-sorting.jst" %}
diff --git a/webcompat/templates/user-activity.html b/webcompat/templates/user-activity.html index 14ed6e60b..052e27299 100644 --- a/webcompat/templates/user-activity.html +++ b/webcompat/templates/user-activity.html @@ -6,7 +6,9 @@
-

{{user}}'s activity

+

+ {{user}}'s activity +

diff --git a/webcompat/templates/user-activity/reported-by-user.html b/webcompat/templates/user-activity/reported-by-user.html index e2bdd0694..f8f7639a3 100644 --- a/webcompat/templates/user-activity/reported-by-user.html +++ b/webcompat/templates/user-activity/reported-by-user.html @@ -3,17 +3,9 @@

Issues reported by {{user}}

- {% include "web_modules/pagination.html" %} + {% include "web_modules/pagination.html" %}
- + {% include "web_modules/issue-list.jst" %}
diff --git a/webcompat/templates/user-activity/user-mentions.html b/webcompat/templates/user-activity/user-mentions.html index ea5036d76..c5d4899d7 100644 --- a/webcompat/templates/user-activity/user-mentions.html +++ b/webcompat/templates/user-activity/user-mentions.html @@ -6,14 +6,6 @@

Issues mentioning {{user}}

{% include "web_modules/pagination.html" %}
- + {% include "web_modules/issue-list.jst" %}
diff --git a/webcompat/templates/web_modules/dropdown.html b/webcompat/templates/web_modules/dropdown.html deleted file mode 100644 index b59632a5e..000000000 --- a/webcompat/templates/web_modules/dropdown.html +++ /dev/null @@ -1,3 +0,0 @@ -{% macro dropdown(config) %} -
-{% endmacro %} diff --git a/webcompat/templates/web_modules/issue-list.html b/webcompat/templates/web_modules/issue-list.html deleted file mode 100644 index 9323ab01f..000000000 --- a/webcompat/templates/web_modules/issue-list.html +++ /dev/null @@ -1,21 +0,0 @@ -
-
-
- - Issue <%= issue.number %>: <%- issue.title %> - -
-

- - -

-
-
- - <% _.each(issue.labels, function(label) { %> - <%= label.name %> - <% }); %> -
-
diff --git a/webcompat/templates/web_modules/issue-list.jst b/webcompat/templates/web_modules/issue-list.jst new file mode 100644 index 000000000..e93b3c16f --- /dev/null +++ b/webcompat/templates/web_modules/issue-list.jst @@ -0,0 +1,29 @@ + diff --git a/webcompat/templates/web_modules/issue-search.html b/webcompat/templates/web_modules/issue-search.html deleted file mode 100644 index 1bdf8589f..000000000 --- a/webcompat/templates/web_modules/issue-search.html +++ /dev/null @@ -1,8 +0,0 @@ -
- - - -
diff --git a/webcompat/templates/web_modules/label-editor.html b/webcompat/templates/web_modules/label-editor.jst similarity index 52% rename from webcompat/templates/web_modules/label-editor.html rename to webcompat/templates/web_modules/label-editor.jst index c97122c12..b25d3223e 100644 --- a/webcompat/templates/web_modules/label-editor.html +++ b/webcompat/templates/web_modules/label-editor.jst @@ -1,13 +1,20 @@ -