[extensions-web] js: Port error reporting to mustache



commit 69e8f7057902a8d6a0f6eb44aacd5654169152a8
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Fri Mar 30 18:40:48 2012 -0400

    js: Port error reporting to mustache

 sweettooth/static/js/extensions.js                 |   26 +++----------------
 .../extensions/error_report_template.mustache      |   23 +++++++++++++++++
 sweettooth/static/js/templates/templatedata.js     |    2 +-
 3 files changed, 28 insertions(+), 23 deletions(-)
---
diff --git a/sweettooth/static/js/extensions.js b/sweettooth/static/js/extensions.js
index e4dcb88..82a4447 100644
--- a/sweettooth/static/js/extensions.js
+++ b/sweettooth/static/js/extensions.js
@@ -265,29 +265,11 @@ function($, messages, dbusProxy, extensionUtils, templates) {
             var $textarea = $form.find('textarea');
             dbusProxy.GetExtensionInfo(uuid).done(function(meta) {
                 dbusProxy.GetErrors($form.data('uuid')).done(function(errors) {
-                    var errorString;
-
-                    var versionInformation = "";
-                    versionInformation += "    Shell version: " + dbusProxy.ShellVersion + "\n";
-                    versionInformation += "    Extension version: ";
-                    if (meta && meta.version) {
-                        versionInformation += meta.version;
-                    } else {
-                        versionInformation += "Not found";
-                    }
-
-                    if (errors && errors.length) {
-                        errorString = errors.join('\n\n================\n\n');
-                    } else {
-                        errorString = "GNOME Shell Extensions did not detect any errors with this extension.";
-                    }
-
-                    var template = ("What's wrong?\n\n\n\n" +
-                                    "What have you tried?\n\n\n\n" +
-                                    "Automatically detected errors:\n\n" + errorString +
-                                    "\n\nVersion information:\n\n" + versionInformation);
+                    var context = { sv: dbusProxy.ShellVersion,
+                                    ev: (meta && meta.version) ? meta.version : null,
+                                    errors: errors };
 
-                    $textarea.text(template);
+                    $textarea.text(templates.extensions.error_report_template(context));
                 });
             });
         });
diff --git a/sweettooth/static/js/templates/extensions/error_report_template.mustache b/sweettooth/static/js/templates/extensions/error_report_template.mustache
new file mode 100644
index 0000000..fba4dab
--- /dev/null
+++ b/sweettooth/static/js/templates/extensions/error_report_template.mustache
@@ -0,0 +1,23 @@
+What's wrong?
+
+
+
+What have you tried?
+
+
+
+Automatically detected errors:
+
+{{#errors}}
+  {{.}}
+
+================
+{{/errors}}
+{{^errors}}
+GNOME Shell Extensions did not detect any errors with this extension.
+{{/errors}}
+
+Version information:
+
+    Shell version: {{sv}}
+    Extension version: {{#ev}}{{ev}}{{/ev}}{{^ev}}Unknown{{/ev}}
diff --git a/sweettooth/static/js/templates/templatedata.js b/sweettooth/static/js/templates/templatedata.js
index a652219..6b17a87 100644
--- a/sweettooth/static/js/templates/templatedata.js
+++ b/sweettooth/static/js/templates/templatedata.js
@@ -1,4 +1,4 @@
 
 "use strict";
 
-define({"paginator": {"loading_page": "<div class=\"loading-page\">\n  Loading page... please wait.\n</div>"}, "messages": {"cannot_list_errors": "GNOME Shell Extensions cannot automatically detect any errors.", "cannot_list_local": "GNOME Shell Extensions cannot list your installed extensions.", "dummy_proxy": "You do not appear to have an up to date version of GNOME3. You won't be able to install extensions from here. See the <a href=\"about/#old-version\">about page</a> for more information."}, "upgrade": {"need_upgrade": "You have version {{current_version}} of \"{{extension_name}}\". The latest version is version {{latest_version}}. Click here to upgrade.", "latest_version": "You have the latest version of {{extension_name}}."}, "extensions": {"uninstall": "You uninstalled <b>{{name}}. <a href=\"#\">Undo?</a>"}});
+define({"paginator": {"loading_page": "<div class=\"loading-page\">\n  Loading page... please wait.\n</div>"}, "messages": {"cannot_list_errors": "GNOME Shell Extensions cannot automatically detect any errors.", "cannot_list_local": "GNOME Shell Extensions cannot list your installed extensions.", "dummy_proxy": "You do not appear to have an up to date version of GNOME3. You won't be able to install extensions from here. See the <a href=\"about/#old-version\">about page</a> for more information."}, "upgrade": {"need_upgrade": "You have version {{current_version}} of \"{{extension_name}}\". The latest version is version {{latest_version}}. Click here to upgrade.", "latest_version": "You have the latest version of {{extension_name}}."}, "extensions": {"error_report_template": "What's wrong?\n\n\n\nWhat have you tried?\n\n\n\nAutomatically detected errors:\n\n{{#errors}}\n  {{.}}\n\n================\n{{/errors}}\n{{^errors}}\nGNOME Shell Extensions did not detect any errors with
  this extension.\n{{/errors}}\n\nVersion information:\n\n    Shell version: {{sv}}\n    Extension version: {{#ev}}{{ev}}{{/ev}}{{^ev}}Unknown{{/ev}}", "uninstall": "You uninstalled <b>{{name}}. <a href=\"#\">Undo?</a>"}});



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]