From 260c05b3294689bc9b62d3d34557738a4307ec25 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Wed, 26 Jul 2017 16:50:21 -0500 Subject: [PATCH 01/11] Issue #1679. Add grunt-contrib-jst dependency to package.json --- package.json | 1 + webcompat/static/js/templates.js | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 webcompat/static/js/templates.js diff --git a/package.json b/package.json index 98e4d434c..59a88d73a 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "grunt-contrib-concat": "^1.0.0", "grunt-contrib-cssmin": "^2.0.0", "grunt-contrib-imagemin": "~1.0.1", + "grunt-contrib-jst": "^1.0.0", "grunt-contrib-uglify": "^2.3.0", "grunt-contrib-watch": "^1.0.0", "grunt-postcss": "^0.8.0", diff --git a/webcompat/static/js/templates.js b/webcompat/static/js/templates.js new file mode 100644 index 000000000..12f94f9ca --- /dev/null +++ b/webcompat/static/js/templates.js @@ -0,0 +1,29 @@ +this["wcTmpl"] = this["wcTmpl"] || {}; + +this["wcTmpl"]["issue/aside.jst"] = function(obj) {obj || (obj = {});var __t, __p = '', __e = _.escape;with (obj) {__p += '
\n
' +((__t = ( issueState )) == null ? '' : __t) +'
\n
#' +((__t = ( number )) == null ? '' : __t) +'
\n
\n
\n

\n ' +((__t = ( title )) == null ? '' : __t) +'\n

\n
\n
\n
Opened: ' +((__t = ( createdAt )) == null ? '' : __t) +'
\n
\n Reporter:\n \n ' +((__t = ( reporter )) == null ? '' : __t) +'\n \n
\n
Comments: ' +((__t = ( commentNumber )) == null ? '' : __t) +'
\n
';}return __p}; + +this["wcTmpl"]["issue/issue-comment-list.jst"] = function(obj) {obj || (obj = {});var __t, __p = '', __e = _.escape;with (obj) {__p += '
\n
\n \n
\n
\n ' +((__t = ( body )) == null ? '' : __t) +'\n
\n
\n
\n
';}return __p}; + +this["wcTmpl"]["issue/issue-labels-sub.jst"] = function(obj) {obj || (obj = {});var __t, __p = '', __e = _.escape, __j = Array.prototype.join;function print() { __p += __j.call(arguments, '') }with (obj) { _.each(labels, function(label) { ;__p += '\n \n ' +((__t = ( label.name )) == null ? '' : __t) +'\n \n'; }); ;}return __p}; + +this["wcTmpl"]["issue/issue-labels.jst"] = function(obj) {obj || (obj = {});var __t, __p = '', __e = _.escape, __j = Array.prototype.join;function print() { __p += __j.call(arguments, '') }with (obj) {__p += '
\n
\n Labels\n
\n '; if ($("body").data("username")) { ;__p += '\n \n \n \n '; } ;__p += '\n
\n
\n '; _.each(labels, function(label) { ;__p += '\n \n ' +((__t = ( label.name )) == null ? '' : __t) +'\n \n '; }); ;__p += '\n ';}return __p}; + +this["wcTmpl"]["issue/issue-report.jst"] = function(obj) {obj || (obj = {});var __t, __p = '', __e = _.escape;with (obj) {__p += '
\n
\n ' +((__t = ( reporter )) == null ? '' : __t) +'\n
\n
\n
\n \n
\n
\n ' +((__t = ( body )) == null ? '' : __t) +'\n
\n
\n
\n
\n
';}return __p}; + +this["wcTmpl"]["issue/metadata.jst"] = function(obj) {obj || (obj = {});var __t, __p = '', __e = _.escape;with (obj) {__p += '
\n
\n ' +((__t = ( body )) == null ? '' : __t) +'\n
\n
';}return __p}; + +this["wcTmpl"]["issue/state-button.jst"] = function(obj) {obj || (obj = {});var __t, __p = '', __e = _.escape;with (obj) {__p += '' +((__t = ( state )) == null ? '' : __t) +'';}return __p}; + +this["wcTmpl"]["issue/upload-image.jst"] = function(obj) {obj || (obj = {});var __t, __p = '', __e = _.escape;with (obj) {__p += '
\n \n
';}return __p}; + +this["wcTmpl"]["list-issue/dropdown.jst"] = function(obj) {obj || (obj = {});var __t, __p = '', __e = _.escape, __j = Array.prototype.join;function print() { __p += __j.call(arguments, '') }with (obj) {__p += '\n ';}return __p}; + +this["wcTmpl"]["list-issue/issuelist-issue.jst"] = function(obj) {obj || (obj = {});var __t, __p = '', __e = _.escape, __j = Array.prototype.join;function print() { __p += __j.call(arguments, '') }with (obj) { if (issues.length) { ;__p += '\n '; _.each(issues, function(issue) { ;__p += '\n \n '; }); ;__p += '\n'; } else { ;__p += '\n
\n
Sorry, no results were found.
\n
    \n
  • Check your spelling
  • \n
  • Try a more general search
  • \n
  • Search for popular labels
  • \n
  • \n \n
  • \n
\n
\n'; } ;__p += '\n

\n View issues on Github\n

\n

\n Shortcut: Press g on your keyboard to be taken to the GitHub view of this page.\n

';}return __p}; + +this["wcTmpl"]["list-issue/issuelist-search.jst"] = function(obj) {obj || (obj = {});var __t, __p = '', __e = _.escape;with (obj) {__p += '
\n
\n \n \n \n
\n
';}return __p}; + +this["wcTmpl"]["list-issue/issuelist-sorting.jst"] = function(obj) {obj || (obj = {});var __t, __p = '', __e = _.escape;with (obj) {__p += '
\n
';}return __p}; + +this["wcTmpl"]["web_modules/issue-list.jst"] = function(obj) {obj || (obj = {});var __t, __p = '', __e = _.escape, __j = Array.prototype.join;function print() { __p += __j.call(arguments, '') }with (obj) { if (issues.length) { ;__p += '\n '; _.each(issues, function(issue) { ;__p += '\n \n '; }); ;__p += '\n '; } else { ;__p += '\n

Nothing here currently, go report something!

\n'; } ;}return __p}; + +this["wcTmpl"]["web_modules/label-editor.jst"] = function(obj) {obj || (obj = {});var __t, __p = '', __e = _.escape, __j = Array.prototype.join;function print() { __p += __j.call(arguments, '') }with (obj) {__p += '
\n \n \n
\n
\n '; _.each(labels, function(label) { ;__p += '\n \n '; }); ;__p += '\n
';}return __p}; \ No newline at end of file From ed3f4304c805e489f22c5247c230626bc818dc56 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Wed, 26 Jul 2017 17:03:09 -0500 Subject: [PATCH 02/11] Issue #1679. Add jst grunt task and generate a templates.js as a result. --- .eslintrc | 1 + .gitignore | 1 + Gruntfile.js | 3 +++ grunt-tasks/concat.js | 3 ++- grunt-tasks/jst.js | 25 +++++++++++++++++++++++++ webcompat/templates/layout.html | 1 + 6 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 grunt-tasks/jst.js 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/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..81f35559d --- /dev/null +++ b/grunt-tasks/jst.js @@ -0,0 +1,25 @@ +/* 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 + {%- if config['LOCALHOST'] -%} From 0e510cf6889615456787f5087689de7b62c41aa6 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Wed, 26 Jul 2017 17:57:05 -0500 Subject: [PATCH 03/11] Issue #1679. Move inline templates into their own files, and import them accordingly. --- webcompat/static/js/lib/comments.js | 2 +- webcompat/static/js/lib/issue-list.js | 8 ++-- webcompat/static/js/lib/issues.js | 10 ++-- webcompat/static/js/lib/labels.js | 5 +- webcompat/static/js/lib/user-activity.js | 6 ++- .../templates/home-page/browse-issues.html | 10 +--- .../templates/home-page/needstriage.tmpl | 9 ++++ webcompat/templates/issue.html | 2 +- webcompat/templates/issue/aside.tmpl | 21 +++++++++ webcompat/templates/issue/issue-aside.html | 24 +--------- ...ment-list.html => issue-comment-list.tmpl} | 0 .../templates/issue/issue-comment-submit.html | 25 +--------- .../templates/issue/issue-information.html | 8 +--- .../{issue-labels.html => issue-labels.tmpl} | 2 +- .../{issue-report.html => issue-report.tmpl} | 2 +- webcompat/templates/issue/metadata.tmpl | 7 +++ webcompat/templates/issue/state-button.tmpl | 3 ++ webcompat/templates/issue/upload-image.tmpl | 19 ++++++++ webcompat/templates/list-issue/dropdown.tmpl | 14 ++++++ .../templates/list-issue/issue-list.html | 47 +------------------ .../templates/list-issue/issuelist-issue.tmpl | 46 ++++++++++++++++++ .../list-issue/issuelist-search.tmpl | 5 ++ .../list-issue/issuelist-sorting.tmpl | 4 ++ .../list-issue/search-issue-filter.html | 15 +----- .../list-issue/search-issue-search-form.html | 6 +-- .../list-issue/search-issue-sorting.html | 5 +- .../user-activity/issue-mentions.tmpl | 9 ++++ .../templates/user-activity/my-issues.tmpl | 9 ++++ .../user-activity/reported-by-user.html | 10 +--- .../user-activity/user-mentions.html | 10 +--- .../{label-editor.html => label-editor.tmpl} | 0 31 files changed, 178 insertions(+), 165 deletions(-) create mode 100644 webcompat/templates/home-page/needstriage.tmpl create mode 100644 webcompat/templates/issue/aside.tmpl rename webcompat/templates/issue/{issue-comment-list.html => issue-comment-list.tmpl} (100%) rename webcompat/templates/issue/{issue-labels.html => issue-labels.tmpl} (94%) rename webcompat/templates/issue/{issue-report.html => issue-report.tmpl} (94%) create mode 100644 webcompat/templates/issue/metadata.tmpl create mode 100644 webcompat/templates/issue/state-button.tmpl create mode 100644 webcompat/templates/issue/upload-image.tmpl create mode 100644 webcompat/templates/list-issue/dropdown.tmpl create mode 100644 webcompat/templates/list-issue/issuelist-issue.tmpl create mode 100644 webcompat/templates/list-issue/issuelist-search.tmpl create mode 100644 webcompat/templates/list-issue/issuelist-sorting.tmpl create mode 100644 webcompat/templates/user-activity/issue-mentions.tmpl create mode 100644 webcompat/templates/user-activity/my-issues.tmpl rename webcompat/templates/web_modules/{label-editor.html => label-editor.tmpl} (100%) diff --git a/webcompat/static/js/lib/comments.js b/webcompat/static/js/lib/comments.js index 5d9ea683c..88c2689bd 100644 --- a/webcompat/static/js/lib/comments.js +++ b/webcompat/static/js/lib/comments.js @@ -26,7 +26,7 @@ issues.CommentView = Backbone.View.extend({ id: function() { return this.model.get("commentLinkId"); }, - template: _.template($("#comment-tmpl").html()), + template: wcTmpl["webcompat/templates/issue/issue-comment-list.tmpl"], render: function() { this.$el.html(this.template(this.model.toJSON())); return this; diff --git a/webcompat/static/js/lib/issue-list.js b/webcompat/static/js/lib/issue-list.js index 9a29fdae2..ff4ec55a9 100644 --- a/webcompat/static/js/lib/issue-list.js +++ b/webcompat/static/js/lib/issue-list.js @@ -38,7 +38,7 @@ issueList.DropdownView = Backbone.View.extend({ _.bind(this.selectDropdownOption, this) ); }, - template: _.template($("#dropdown-tmpl").html()), + template: wcTmpl["webcompat/templates/list-issue/dropdown.tmpl"], render: function() { this.$el.html(this.template(this.model.toJSON())); return this; @@ -154,7 +154,7 @@ issueList.SearchView = Backbone.View.extend({ issueList.events.on("search:clear", _.bind(this.clearSearchBox, this)); issueList.events.on("search:current", _.bind(this.currentSearch, this)); }, - template: _.template($("#issuelist-search-tmpl").html()), + template: wcTmpl["webcompat/templates/list-issue/issuelist-search.tmpl"], render: function(cb) { this.$el.html(this.template()); this.input = this.$el.find("input"); @@ -245,7 +245,7 @@ issueList.SortingView = Backbone.View.extend({ model: this.sortModel }); }, - template: _.template($("#issuelist-sorting-tmpl").html()), + template: wcTmpl["webcompat/templates/list-issue/issuelist-sorting.tmpl"], render: function() { this.$el.html(this.template()); this.paginationDropdown @@ -290,7 +290,7 @@ issueList.IssueView = Backbone.View.extend( issuesPagination.initMixin(this, this.issues, $("main")); this.loadIssues(); }, - template: _.template($("#issuelist-issue-tmpl").html()), + template: wcTmpl["webcompat/templates/list-issue/issuelist-issue.tmpl"], loadIssues: function() { // Attemps to load model state from URL params, if present, // otherwise grab model defaults and load issues diff --git a/webcompat/static/js/lib/issues.js b/webcompat/static/js/lib/issues.js index 65098b8cf..50c3f06ce 100644 --- a/webcompat/static/js/lib/issues.js +++ b/webcompat/static/js/lib/issues.js @@ -100,7 +100,7 @@ issues.MetaDataView = Backbone.View.extend({ }, this) ); }, - template: _.template($("#metadata-tmpl").html()), + template: wcTmpl["webcompat/templates/issue/metadata.tmpl"], render: function() { this.$el.html(this.template(this.model.toJSON())); return this; @@ -117,7 +117,7 @@ issues.AsideView = Backbone.View.extend({ }, this) ); }, - template: _.template($("#aside-tmpl").html()), + template: wcTmpl["webcompat/templates/issue/aside.tmpl"], render: function() { this.$el.html(this.template(this.model.toJSON())); return this; @@ -127,7 +127,7 @@ issues.AsideView = Backbone.View.extend({ issues.BodyView = Backbone.View.extend({ el: $(".wc-Issue-report"), mainView: null, - template: _.template($("#issue-info-tmpl").html()), + template: wcTmpl["webcompat/templates/issue/issue-report.tmpl"], initialize: function(options) { this.mainView = options.mainView; }, @@ -184,7 +184,7 @@ issues.ImageUploadView = Backbone.View.extend({ }, _submitButton: $(".js-Issue-comment-button"), _loaderImage: $(".js-Upload-Loader"), - template: _.template($("#upload-input-tmpl").html()), + template: wcTmpl["webcompat/templates/issue/upload-image.tmpl"], render: function() { this.$el.html(this.template()).insertAfter($("textarea")); return this; @@ -352,7 +352,7 @@ issues.StateButtonView = Backbone.View.extend({ }, this) ); }, - template: _.template($("#state-button-tmpl").html()), + template: wcTmpl["webcompat/templates/issue/state-button.tmpl"], render: function() { var buttonText; if (this.model.get("state") === "open") { diff --git a/webcompat/static/js/lib/labels.js b/webcompat/static/js/lib/labels.js index 265b1d23b..696439d05 100644 --- a/webcompat/static/js/lib/labels.js +++ b/webcompat/static/js/lib/labels.js @@ -35,9 +35,10 @@ issues.LabelsView = Backbone.View.extend({ this.editLabels(); } }, - template: _.template($("#issue-labels-tmpl").html()), + template: wcTmpl["webcompat/templates/issue/issue-labels.tmpl"], // this subTemplate will need to be kept in sync with // relavant parts in $('#issue-labels-tmpl') + // TODO: put subTemplate in its own .tmpl file subTemplate: _.template( [ "<% _.each(labels, function(label) { %>", @@ -105,7 +106,7 @@ issues.LabelEditorView = Backbone.View.extend({ initialize: function(options) { this.issueView = options.issueView; }, - template: _.template($("#label-editor-tmpl").html()), + template: wcTmpl["webcompat/templates/web_modules/label-editor.tmpl"], render: function() { this.$el.html(this.template(this.model)); this.resizeEditorHeight(); diff --git a/webcompat/static/js/lib/user-activity.js b/webcompat/static/js/lib/user-activity.js index a2abe5902..e6698000e 100644 --- a/webcompat/static/js/lib/user-activity.js +++ b/webcompat/static/js/lib/user-activity.js @@ -36,7 +36,7 @@ issueList.MyIssuesView = Backbone.View.extend( ); this.fetchAndRenderIssues({ url: this.issues.url }); }, - template: _.template($("#my-issues-tmpl").html()), + template: wcTmpl["webcompat/templates/user-activity/my-issues.tmpl"], render: function() { this.$el.html( this.template({ @@ -107,7 +107,9 @@ issueList.IssueMentionsView = Backbone.View.extend( ); this.fetchAndRenderIssues({ url: this.issues.url }); }, - template: _.template($("#issue-mentions-tmpl").html()), + template: ["wcTmpl"][ + "webcompat/templates/user-activity/issue-mentions.tmpl" + ], render: function() { this.$el.html( this.template({ diff --git a/webcompat/templates/home-page/browse-issues.html b/webcompat/templates/home-page/browse-issues.html index 2476bbda5..aaeab2230 100644 --- a/webcompat/templates/home-page/browse-issues.html +++ b/webcompat/templates/home-page/browse-issues.html @@ -2,15 +2,7 @@

Latest Untriaged Issues

- + {% include "home-page/needstriage.tmpl" %}

View All diff --git a/webcompat/templates/home-page/needstriage.tmpl b/webcompat/templates/home-page/needstriage.tmpl new file mode 100644 index 000000000..b8e10ac4d --- /dev/null +++ b/webcompat/templates/home-page/needstriage.tmpl @@ -0,0 +1,9 @@ + diff --git a/webcompat/templates/issue.html b/webcompat/templates/issue.html index 66d136d75..3a405c706 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.tmpl" %}
{% if session.user_id and session.avatar_url %}
diff --git a/webcompat/templates/issue/aside.tmpl b/webcompat/templates/issue/aside.tmpl new file mode 100644 index 000000000..e97c300b5 --- /dev/null +++ b/webcompat/templates/issue/aside.tmpl @@ -0,0 +1,21 @@ + diff --git a/webcompat/templates/issue/issue-aside.html b/webcompat/templates/issue/issue-aside.html index 9f441b9da..e52bf3d70 100644 --- a/webcompat/templates/issue/issue-aside.html +++ b/webcompat/templates/issue/issue-aside.html @@ -1,28 +1,8 @@ diff --git a/webcompat/templates/issue/issue-comment-list.html b/webcompat/templates/issue/issue-comment-list.tmpl similarity index 100% rename from webcompat/templates/issue/issue-comment-list.html rename to webcompat/templates/issue/issue-comment-list.tmpl diff --git a/webcompat/templates/issue/issue-comment-submit.html b/webcompat/templates/issue/issue-comment-submit.html index 9a85c410e..4b90d3df7 100644 --- a/webcompat/templates/issue/issue-comment-submit.html +++ b/webcompat/templates/issue/issue-comment-submit.html @@ -13,32 +13,11 @@
- + {% include "issue/upload-image.tmpl" %}
diff --git a/webcompat/templates/issue/issue-information.html b/webcompat/templates/issue/issue-information.html index 82f5688cf..9be7a9302 100644 --- a/webcompat/templates/issue/issue-information.html +++ b/webcompat/templates/issue/issue-information.html @@ -1,11 +1,5 @@
- + {% include "issue/metadata.tmpl" %}
diff --git a/webcompat/templates/issue/issue-labels.html b/webcompat/templates/issue/issue-labels.tmpl similarity index 94% rename from webcompat/templates/issue/issue-labels.html rename to webcompat/templates/issue/issue-labels.tmpl index d7ba0593d..05ee66608 100644 --- a/webcompat/templates/issue/issue-labels.html +++ b/webcompat/templates/issue/issue-labels.tmpl @@ -19,4 +19,4 @@ -{% include "web_modules/label-editor.html" %} +{% include "web_modules/label-editor.tmpl" %} diff --git a/webcompat/templates/issue/issue-report.html b/webcompat/templates/issue/issue-report.tmpl similarity index 94% rename from webcompat/templates/issue/issue-report.html rename to webcompat/templates/issue/issue-report.tmpl index ad72226dd..10619ca6e 100644 --- a/webcompat/templates/issue/issue-report.html +++ b/webcompat/templates/issue/issue-report.tmpl @@ -1,4 +1,4 @@ - \ No newline at end of file diff --git a/webcompat/templates/issue/state-button.tmpl b/webcompat/templates/issue/state-button.tmpl new file mode 100644 index 000000000..e3d6f05ad --- /dev/null +++ b/webcompat/templates/issue/state-button.tmpl @@ -0,0 +1,3 @@ + diff --git a/webcompat/templates/issue/upload-image.tmpl b/webcompat/templates/issue/upload-image.tmpl new file mode 100644 index 000000000..14eab0b56 --- /dev/null +++ b/webcompat/templates/issue/upload-image.tmpl @@ -0,0 +1,19 @@ + diff --git a/webcompat/templates/list-issue/dropdown.tmpl b/webcompat/templates/list-issue/dropdown.tmpl new file mode 100644 index 000000000..d20375f44 --- /dev/null +++ b/webcompat/templates/list-issue/dropdown.tmpl @@ -0,0 +1,14 @@ + diff --git a/webcompat/templates/list-issue/issue-list.html b/webcompat/templates/list-issue/issue-list.html index 6a4a2f21d..902b34c10 100644 --- a/webcompat/templates/list-issue/issue-list.html +++ b/webcompat/templates/list-issue/issue-list.html @@ -1,48 +1,3 @@
- + {% include "list-issue/issuelist-issue.tmpl" %}
diff --git a/webcompat/templates/list-issue/issuelist-issue.tmpl b/webcompat/templates/list-issue/issuelist-issue.tmpl new file mode 100644 index 000000000..d9a174045 --- /dev/null +++ b/webcompat/templates/list-issue/issuelist-issue.tmpl @@ -0,0 +1,46 @@ + diff --git a/webcompat/templates/list-issue/issuelist-search.tmpl b/webcompat/templates/list-issue/issuelist-search.tmpl new file mode 100644 index 000000000..61cfad084 --- /dev/null +++ b/webcompat/templates/list-issue/issuelist-search.tmpl @@ -0,0 +1,5 @@ + diff --git a/webcompat/templates/list-issue/issuelist-sorting.tmpl b/webcompat/templates/list-issue/issuelist-sorting.tmpl new file mode 100644 index 000000000..3d42c4a5d --- /dev/null +++ b/webcompat/templates/list-issue/issuelist-sorting.tmpl @@ -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..8670019d7 100644 --- a/webcompat/templates/list-issue/search-issue-filter.html +++ b/webcompat/templates/list-issue/search-issue-filter.html @@ -7,17 +7,4 @@ {% endfor %}
- +{% include "list-issue/dropdown.tmpl" %} diff --git a/webcompat/templates/list-issue/search-issue-search-form.html b/webcompat/templates/list-issue/search-issue-search-form.html index 5cd723b72..e1e5e1d76 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/search-issue-search-form.html" %}
diff --git a/webcompat/templates/list-issue/search-issue-sorting.html b/webcompat/templates/list-issue/search-issue-sorting.html index dff7b8da0..f3fc5b402 100644 --- a/webcompat/templates/list-issue/search-issue-sorting.html +++ b/webcompat/templates/list-issue/search-issue-sorting.html @@ -4,10 +4,7 @@
- + {% include "list-issue/issuelist-sorting.tmpl" %}
diff --git a/webcompat/templates/user-activity/issue-mentions.tmpl b/webcompat/templates/user-activity/issue-mentions.tmpl new file mode 100644 index 000000000..a4ea18530 --- /dev/null +++ b/webcompat/templates/user-activity/issue-mentions.tmpl @@ -0,0 +1,9 @@ + diff --git a/webcompat/templates/user-activity/my-issues.tmpl b/webcompat/templates/user-activity/my-issues.tmpl new file mode 100644 index 000000000..d70f85e18 --- /dev/null +++ b/webcompat/templates/user-activity/my-issues.tmpl @@ -0,0 +1,9 @@ + diff --git a/webcompat/templates/user-activity/reported-by-user.html b/webcompat/templates/user-activity/reported-by-user.html index e2bdd0694..356277d70 100644 --- a/webcompat/templates/user-activity/reported-by-user.html +++ b/webcompat/templates/user-activity/reported-by-user.html @@ -6,14 +6,6 @@

Issues reported by {{user}}

{% include "web_modules/pagination.html" %}
- + {% include "user-activity/my-issues.tmpl" %}
diff --git a/webcompat/templates/user-activity/user-mentions.html b/webcompat/templates/user-activity/user-mentions.html index ea5036d76..fab4e9afa 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 "user-activity/issue-mentions.tmpl" %}
diff --git a/webcompat/templates/web_modules/label-editor.html b/webcompat/templates/web_modules/label-editor.tmpl similarity index 100% rename from webcompat/templates/web_modules/label-editor.html rename to webcompat/templates/web_modules/label-editor.tmpl From 2aa94906d187cd954fcd29d4b7632942acec5f09 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Thu, 27 Jul 2017 11:35:12 -0500 Subject: [PATCH 04/11] Issue #1679. Handle authenticated check via JS. --- webcompat/templates/issue/issue-labels.tmpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webcompat/templates/issue/issue-labels.tmpl b/webcompat/templates/issue/issue-labels.tmpl index 05ee66608..9b4449d3b 100644 --- a/webcompat/templates/issue/issue-labels.tmpl +++ b/webcompat/templates/issue/issue-labels.tmpl @@ -3,12 +3,12 @@
Labels
- {% if session.user_id and session.avatar_url %} + <% if ($("body").data("username")) { %> - {% endif %} + <% } %>
<% _.each(labels, function(label) { %> From 5206012312027e048885aeb4aaf3955bb0e289e4 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Thu, 27 Jul 2017 13:55:31 -0500 Subject: [PATCH 05/11] Issue #1679. Inline html includes into jst templates, and remove redundant files as a result. Unfortunately the pre-compiled template approach won't let us rely on the jinja2 parser to do interesting things with JS templates. --- webcompat/static/js/lib/diagnose.js | 2 +- webcompat/static/js/lib/user-activity.js | 4 +--- .../templates/home-page/browse-issues.html | 4 ++-- .../templates/home-page/needstriage.tmpl | 22 ++++++++++++++++++- webcompat/templates/list-issue.html | 4 +++- .../templates/list-issue/issue-list.html | 3 --- .../templates/list-issue/issuelist-issue.tmpl | 22 ++++++++++++++++++- .../list-issue/issuelist-search.tmpl | 9 +++++++- .../list-issue/issuelist-sorting.tmpl | 4 ++-- .../list-issue/search-issue-filter.html | 1 - .../list-issue/search-issue-search-form.html | 2 +- .../list-issue/search-issue-sorting.html | 2 -- webcompat/templates/user-activity.html | 4 +++- .../user-activity/issue-mentions.tmpl | 22 ++++++++++++++++++- .../templates/user-activity/my-issues.tmpl | 22 ++++++++++++++++++- .../user-activity/reported-by-user.html | 2 +- webcompat/templates/web_modules/dropdown.html | 3 --- .../templates/web_modules/issue-search.html | 8 ------- 18 files changed, 106 insertions(+), 34 deletions(-) delete mode 100644 webcompat/templates/list-issue/issue-list.html delete mode 100644 webcompat/templates/web_modules/dropdown.html delete mode 100644 webcompat/templates/web_modules/issue-search.html diff --git a/webcompat/static/js/lib/diagnose.js b/webcompat/static/js/lib/diagnose.js index 5f74d4f2e..21f23fe82 100644 --- a/webcompat/static/js/lib/diagnose.js +++ b/webcompat/static/js/lib/diagnose.js @@ -23,7 +23,7 @@ diagnose.NeedsTriageView = Backbone.View.extend({ }) .error(function() {}); }, - template: _.template($("#needstriage-tmpl").html()), + template: wcTmpl["webcompat/templates/home-page/needstriage.tmpl"], render: function() { this.$el.html( this.template({ diff --git a/webcompat/static/js/lib/user-activity.js b/webcompat/static/js/lib/user-activity.js index e6698000e..66dcd800f 100644 --- a/webcompat/static/js/lib/user-activity.js +++ b/webcompat/static/js/lib/user-activity.js @@ -107,9 +107,7 @@ issueList.IssueMentionsView = Backbone.View.extend( ); this.fetchAndRenderIssues({ url: this.issues.url }); }, - template: ["wcTmpl"][ - "webcompat/templates/user-activity/issue-mentions.tmpl" - ], + template: wcTmpl["webcompat/templates/user-activity/issue-mentions.tmpl"], render: function() { this.$el.html( this.template({ diff --git a/webcompat/templates/home-page/browse-issues.html b/webcompat/templates/home-page/browse-issues.html index aaeab2230..fe41803ac 100644 --- a/webcompat/templates/home-page/browse-issues.html +++ b/webcompat/templates/home-page/browse-issues.html @@ -2,8 +2,8 @@

Latest Untriaged Issues

- {% include "home-page/needstriage.tmpl" %} -
+ {% include "home-page/needstriage.tmpl" %} +

View All

diff --git a/webcompat/templates/home-page/needstriage.tmpl b/webcompat/templates/home-page/needstriage.tmpl index b8e10ac4d..ec5768a84 100644 --- a/webcompat/templates/home-page/needstriage.tmpl +++ b/webcompat/templates/home-page/needstriage.tmpl @@ -1,7 +1,27 @@ diff --git a/webcompat/templates/list-issue/issuelist-sorting.tmpl b/webcompat/templates/list-issue/issuelist-sorting.tmpl index 3d42c4a5d..40ab31489 100644 --- a/webcompat/templates/list-issue/issuelist-sorting.tmpl +++ b/webcompat/templates/list-issue/issuelist-sorting.tmpl @@ -1,4 +1,4 @@ diff --git a/webcompat/templates/list-issue/search-issue-filter.html b/webcompat/templates/list-issue/search-issue-filter.html index 8670019d7..921c84a75 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 %}
diff --git a/webcompat/templates/list-issue/search-issue-search-form.html b/webcompat/templates/list-issue/search-issue-search-form.html index e1e5e1d76..a4aeba4bf 100644 --- a/webcompat/templates/list-issue/search-issue-search-form.html +++ b/webcompat/templates/list-issue/search-issue-search-form.html @@ -1,3 +1,3 @@
- {% include "list-issue/search-issue-search-form.html" %} + {% include "list-issue/issuelist-search.tmpl" %}
diff --git a/webcompat/templates/list-issue/search-issue-sorting.html b/webcompat/templates/list-issue/search-issue-sorting.html index f3fc5b402..af24676cb 100644 --- a/webcompat/templates/list-issue/search-issue-sorting.html +++ b/webcompat/templates/list-issue/search-issue-sorting.html @@ -1,5 +1,3 @@ -{% from "web_modules/dropdown.html" import dropdown with context %} -
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/issue-mentions.tmpl b/webcompat/templates/user-activity/issue-mentions.tmpl index a4ea18530..dc4e55b4f 100644 --- a/webcompat/templates/user-activity/issue-mentions.tmpl +++ b/webcompat/templates/user-activity/issue-mentions.tmpl @@ -1,7 +1,27 @@ diff --git a/webcompat/templates/user-activity/my-issues.tmpl b/webcompat/templates/user-activity/my-issues.tmpl deleted file mode 100644 index 9f5836852..000000000 --- a/webcompat/templates/user-activity/my-issues.tmpl +++ /dev/null @@ -1,29 +0,0 @@ - diff --git a/webcompat/templates/user-activity/reported-by-user.html b/webcompat/templates/user-activity/reported-by-user.html index f8a1572e9..79a5315ee 100644 --- a/webcompat/templates/user-activity/reported-by-user.html +++ b/webcompat/templates/user-activity/reported-by-user.html @@ -6,6 +6,6 @@

Issues reported by {{user}}

{% include "web_modules/pagination.html" %}
- {% include "user-activity/my-issues.tmpl" %} + {% include "web_modules/issue-list.tmpl" %}
diff --git a/webcompat/templates/user-activity/user-mentions.html b/webcompat/templates/user-activity/user-mentions.html index fab4e9afa..0fce14753 100644 --- a/webcompat/templates/user-activity/user-mentions.html +++ b/webcompat/templates/user-activity/user-mentions.html @@ -6,6 +6,6 @@

Issues mentioning {{user}}

{% include "web_modules/pagination.html" %}
- {% include "user-activity/issue-mentions.tmpl" %} + {% include "web_modules/issue-list.tmpl" %}
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 @@ - diff --git a/webcompat/templates/home-page/needstriage.tmpl b/webcompat/templates/web_modules/issue-list.tmpl similarity index 91% rename from webcompat/templates/home-page/needstriage.tmpl rename to webcompat/templates/web_modules/issue-list.tmpl index ec5768a84..411932cdc 100644 --- a/webcompat/templates/home-page/needstriage.tmpl +++ b/webcompat/templates/web_modules/issue-list.tmpl @@ -1,4 +1,4 @@ - From 727f56a0acbee0fff5f25059af341cd5de2f6540 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Thu, 27 Jul 2017 15:17:50 -0500 Subject: [PATCH 07/11] Issue #1679. Rename tmpl to jst (to match configs), and use shorter path for convenience. --- grunt-tasks/jst.js | 7 ++++++- webcompat/static/js/lib/comments.js | 2 +- webcompat/static/js/lib/diagnose.js | 2 +- webcompat/static/js/lib/issue-list.js | 8 ++++---- webcompat/static/js/lib/issues.js | 10 +++++----- webcompat/static/js/lib/labels.js | 4 ++-- webcompat/static/js/lib/user-activity.js | 4 ++-- webcompat/templates/home-page/browse-issues.html | 2 +- webcompat/templates/issue.html | 2 +- webcompat/templates/issue/{aside.tmpl => aside.jst} | 2 +- webcompat/templates/issue/issue-aside.html | 4 ++-- ...{issue-comment-list.tmpl => issue-comment-list.jst} | 2 +- webcompat/templates/issue/issue-comment-submit.html | 4 ++-- webcompat/templates/issue/issue-information.html | 2 +- .../issue/{issue-labels.tmpl => issue-labels.jst} | 4 ++-- .../issue/{issue-report.tmpl => issue-report.jst} | 2 +- .../templates/issue/{metadata.tmpl => metadata.jst} | 4 ++-- .../issue/{state-button.tmpl => state-button.jst} | 2 +- .../issue/{upload-image.tmpl => upload-image.jst} | 2 +- webcompat/templates/list-issue.html | 2 +- .../list-issue/{dropdown.tmpl => dropdown.jst} | 2 +- .../{issuelist-issue.tmpl => issuelist-issue.jst} | 2 +- .../{issuelist-search.tmpl => issuelist-search.jst} | 2 +- .../{issuelist-sorting.tmpl => issuelist-sorting.jst} | 2 +- .../templates/list-issue/search-issue-filter.html | 2 +- .../templates/list-issue/search-issue-search-form.html | 2 +- .../templates/list-issue/search-issue-sorting.html | 2 +- .../templates/user-activity/reported-by-user.html | 2 +- webcompat/templates/user-activity/user-mentions.html | 2 +- .../web_modules/{issue-list.tmpl => issue-list.jst} | 2 +- .../{label-editor.tmpl => label-editor.jst} | 2 +- 31 files changed, 49 insertions(+), 44 deletions(-) rename webcompat/templates/issue/{aside.tmpl => aside.jst} (93%) rename webcompat/templates/issue/{issue-comment-list.tmpl => issue-comment-list.jst} (94%) rename webcompat/templates/issue/{issue-labels.tmpl => issue-labels.jst} (87%) rename webcompat/templates/issue/{issue-report.tmpl => issue-report.jst} (94%) rename webcompat/templates/issue/{metadata.tmpl => metadata.jst} (69%) rename webcompat/templates/issue/{state-button.tmpl => state-button.jst} (58%) rename webcompat/templates/issue/{upload-image.tmpl => upload-image.jst} (92%) rename webcompat/templates/list-issue/{dropdown.tmpl => dropdown.jst} (92%) rename webcompat/templates/list-issue/{issuelist-issue.tmpl => issuelist-issue.jst} (98%) rename webcompat/templates/list-issue/{issuelist-search.tmpl => issuelist-search.jst} (90%) rename webcompat/templates/list-issue/{issuelist-sorting.tmpl => issuelist-sorting.jst} (71%) rename webcompat/templates/web_modules/{issue-list.tmpl => issue-list.jst} (96%) rename webcompat/templates/web_modules/{label-editor.tmpl => label-editor.jst} (93%) diff --git a/grunt-tasks/jst.js b/grunt-tasks/jst.js index 81f35559d..5c6087e57 100644 --- a/grunt-tasks/jst.js +++ b/grunt-tasks/jst.js @@ -15,10 +15,15 @@ module.exports = function(grunt) { src = src.replace(/ -{% include "web_modules/label-editor.tmpl" %} +{% include "web_modules/label-editor.jst" %} diff --git a/webcompat/templates/issue/issue-report.tmpl b/webcompat/templates/issue/issue-report.jst similarity index 94% rename from webcompat/templates/issue/issue-report.tmpl rename to webcompat/templates/issue/issue-report.jst index 10619ca6e..bf453cf51 100644 --- a/webcompat/templates/issue/issue-report.tmpl +++ b/webcompat/templates/issue/issue-report.jst @@ -1,4 +1,4 @@ - \ No newline at end of file + diff --git a/webcompat/templates/issue/state-button.tmpl b/webcompat/templates/issue/state-button.jst similarity index 58% rename from webcompat/templates/issue/state-button.tmpl rename to webcompat/templates/issue/state-button.jst index e3d6f05ad..40a3d3cad 100644 --- a/webcompat/templates/issue/state-button.tmpl +++ b/webcompat/templates/issue/state-button.jst @@ -1,3 +1,3 @@ - diff --git a/webcompat/templates/issue/upload-image.tmpl b/webcompat/templates/issue/upload-image.jst similarity index 92% rename from webcompat/templates/issue/upload-image.tmpl rename to webcompat/templates/issue/upload-image.jst index 14eab0b56..e82b00754 100644 --- a/webcompat/templates/issue/upload-image.tmpl +++ b/webcompat/templates/issue/upload-image.jst @@ -1,4 +1,4 @@ - diff --git a/webcompat/templates/list-issue/search-issue-filter.html b/webcompat/templates/list-issue/search-issue-filter.html index 921c84a75..154d364aa 100644 --- a/webcompat/templates/list-issue/search-issue-filter.html +++ b/webcompat/templates/list-issue/search-issue-filter.html @@ -6,4 +6,4 @@ {% endfor %}
-{% include "list-issue/dropdown.tmpl" %} +{% 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 a4aeba4bf..1c86f5821 100644 --- a/webcompat/templates/list-issue/search-issue-search-form.html +++ b/webcompat/templates/list-issue/search-issue-search-form.html @@ -1,3 +1,3 @@
- {% include "list-issue/issuelist-search.tmpl" %} + {% 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 af24676cb..c8c540e13 100644 --- a/webcompat/templates/list-issue/search-issue-sorting.html +++ b/webcompat/templates/list-issue/search-issue-sorting.html @@ -2,7 +2,7 @@
- {% include "list-issue/issuelist-sorting.tmpl" %} + {% include "list-issue/issuelist-sorting.jst" %}
diff --git a/webcompat/templates/user-activity/reported-by-user.html b/webcompat/templates/user-activity/reported-by-user.html index 79a5315ee..f8f7639a3 100644 --- a/webcompat/templates/user-activity/reported-by-user.html +++ b/webcompat/templates/user-activity/reported-by-user.html @@ -6,6 +6,6 @@

Issues reported by {{user}}

{% include "web_modules/pagination.html" %}
- {% include "web_modules/issue-list.tmpl" %} + {% 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 0fce14753..c5d4899d7 100644 --- a/webcompat/templates/user-activity/user-mentions.html +++ b/webcompat/templates/user-activity/user-mentions.html @@ -6,6 +6,6 @@

Issues mentioning {{user}}

{% include "web_modules/pagination.html" %}
- {% include "web_modules/issue-list.tmpl" %} + {% include "web_modules/issue-list.jst" %}
diff --git a/webcompat/templates/web_modules/issue-list.tmpl b/webcompat/templates/web_modules/issue-list.jst similarity index 96% rename from webcompat/templates/web_modules/issue-list.tmpl rename to webcompat/templates/web_modules/issue-list.jst index 411932cdc..e93b3c16f 100644 --- a/webcompat/templates/web_modules/issue-list.tmpl +++ b/webcompat/templates/web_modules/issue-list.jst @@ -1,4 +1,4 @@ - diff --git a/webcompat/templates/issue/issue-labels.jst b/webcompat/templates/issue/issue-labels.jst index acab482b6..538698249 100644 --- a/webcompat/templates/issue/issue-labels.jst +++ b/webcompat/templates/issue/issue-labels.jst @@ -18,5 +18,3 @@ <% }); %> - -{% include "web_modules/label-editor.jst" %} diff --git a/webcompat/templates/web_modules/label-editor.jst b/webcompat/templates/web_modules/label-editor.jst index 1c74aab83..b25d3223e 100644 --- a/webcompat/templates/web_modules/label-editor.jst +++ b/webcompat/templates/web_modules/label-editor.jst @@ -1,13 +1,20 @@