summaryrefslogtreecommitdiffstats
path: root/module/web
diff options
context:
space:
mode:
Diffstat (limited to 'module/web')
-rw-r--r--module/web/static/js/libs/handlebars.l48
-rw-r--r--module/web/static/js/utils/initHB.js4
-rw-r--r--module/web/static/js/views/settingsView.js27
-rw-r--r--module/web/templates/default/dashboard.html6
-rw-r--r--module/web/templates/default/settings.html24
5 files changed, 78 insertions, 31 deletions
diff --git a/module/web/static/js/libs/handlebars.l b/module/web/static/js/libs/handlebars.l
new file mode 100644
index 000000000..f0c04f91e
--- /dev/null
+++ b/module/web/static/js/libs/handlebars.l
@@ -0,0 +1,48 @@
+
+%x mu emu
+
+%%
+
+[^\x00]*?/("<%") {
+ if(yytext.slice(-1) !== "\\") this.begin("mu");
+ if(yytext.slice(-1) === "\\") yytext = yytext.substr(0,yyleng-1), this.begin("emu");
+ if(yytext) return 'CONTENT';
+ }
+
+[^\x00]+ { return 'CONTENT'; }
+
+<emu>[^\x00]{2,}?/("{{"|<<EOF>>) {
+ if(yytext.slice(-1) !== "\\") this.popState();
+ if(yytext.slice(-1) === "\\") yytext = yytext.substr(0,yyleng-1);
+ return 'CONTENT';
+ }
+
+<mu>"{{>" { return 'OPEN_PARTIAL'; }
+<mu>"<%=" { return 'OPEN_BLOCK'; }
+<mu>"<%/" { return 'OPEN_ENDBLOCK'; }
+<mu>"{{^" { return 'OPEN_INVERSE'; }
+<mu>"<%"\s*"else" { return 'OPEN_INVERSE'; }
+<mu>"{<%%" { return 'OPEN_UNESCAPED'; }
+<mu>"{{&" { return 'OPEN_UNESCAPED'; }
+<mu>"<%!"[\s\S]*?"%>" { yytext = yytext.substr(3,yyleng-5); this.popState(); return 'COMMENT'; }
+<mu>"<%" { return 'OPEN'; }
+
+<mu>"=" { return 'EQUALS'; }
+<mu>"."/[%} ] { return 'ID'; }
+<mu>".." { return 'ID'; }
+<mu>[\/.] { return 'SEP'; }
+<mu>\s+ { /*ignore whitespace*/ }
+<mu>"%%>" { this.popState(); return 'CLOSE'; }
+<mu>"%>" { this.popState(); return 'CLOSE'; }
+<mu>'"'("\\"["]|[^"])*'"' { yytext = yytext.substr(1,yyleng-2).replace(/\\"/g,'"'); return 'STRING'; }
+<mu>"'"("\\"[']|[^'])*"'" { yytext = yytext.substr(1,yyleng-2).replace(/\\"/g,'"'); return 'STRING'; }
+<mu>"@"[a-zA-Z]+ { yytext = yytext.substr(1); return 'DATA'; }
+<mu>"true"/[%}\s] { return 'BOOLEAN'; }
+<mu>"false"/[%}\s] { return 'BOOLEAN'; }
+<mu>[0-9]+/[%}\s] { return 'INTEGER'; }
+<mu>[a-zA-Z0-9_$-]+/[=%}\s\/.] { return 'ID'; }
+<mu>'['[^\]]*']' { yytext = yytext.substr(1, yyleng-2); return 'ID'; }
+<mu>. { return 'INVALID'; }
+
+<INITIAL,mu><<EOF>> { return 'EOF'; }
+
diff --git a/module/web/static/js/utils/initHB.js b/module/web/static/js/utils/initHB.js
index 6d9436835..784032ca0 100644
--- a/module/web/static/js/utils/initHB.js
+++ b/module/web/static/js/utils/initHB.js
@@ -1,8 +1,8 @@
// Loads all helper and set own handlebars rules
define(['underscore', 'handlebars', 'helpers/formatSize'],
function(_, Handlebars) {
- // TODO: create better lexer rules, these are just hacked
- Handlebars.Parser.lexer.rules = [/^(?:[^\x00]*?(?=(<%)))/, /^(?:[^\x00]+)/, /^(?:[^\x00]{2,}?(?=(<%|$)))/, /^(?:<%>)/, /^(?:<%#)/, /^(?:<%\/)/, /^(?:<%\^)/, /^(?:<%\s*else\b)/, /^(?:<%=)/, /^(?:<%&)/, /^(?:<%![\s\S]*?\}\})/, /^(?:<%)/, /^(?:=)/, /^(?:\.(?=[%> ]))/, /^(?:\.\.)/, /^(?:[\/.])/, /^(?:\s+)/, /^(?:=%>)/, /^(?:%>)/, /^(?:"(\\["]|[^"])*")/, /^(?:'(\\[']|[^'])*')/, /^(?:@[a-zA-Z]+)/, /^(?:true(?=[%>\s]))/, /^(?:false(?=[%>\s]))/, /^(?:[0-9]+(?=[%>\s]))/, /^(?:[a-zA-Z0-9_$-]+(?=[%>=}\s\/.]))/, /^(?:\[[^\]]*\])/, /^(?:.)/, /^(?:$)/];
+ // Replace with own lexer rules compiled from handlebars.l
+ Handlebars.Parser.lexer.rules = [/^(?:[^\x00]*?(?=(<%)))/, /^(?:[^\x00]+)/, /^(?:[^\x00]{2,}?(?=(\{\{|$)))/, /^(?:\{\{>)/, /^(?:<%=)/, /^(?:<%\/)/, /^(?:\{\{\^)/, /^(?:<%\s*else\b)/, /^(?:\{<%%)/, /^(?:\{\{&)/, /^(?:<%![\s\S]*?%>)/, /^(?:<%)/, /^(?:=)/, /^(?:\.(?=[%} ]))/, /^(?:\.\.)/, /^(?:[\/.])/, /^(?:\s+)/, /^(?:%%>)/, /^(?:%>)/, /^(?:"(\\["]|[^"])*")/, /^(?:'(\\[']|[^'])*')/, /^(?:@[a-zA-Z]+)/, /^(?:true(?=[%}\s]))/, /^(?:false(?=[%}\s]))/, /^(?:[0-9]+(?=[%}\s]))/, /^(?:[a-zA-Z0-9_$-]+(?=[=%}\s\/.]))/, /^(?:\[[^\]]*\])/, /^(?:.)/, /^(?:$)/];
_.compile = Handlebars.compile;
return Handlebars
diff --git a/module/web/static/js/views/settingsView.js b/module/web/static/js/views/settingsView.js
index c6fe535b9..1b7f5e356 100644
--- a/module/web/static/js/views/settingsView.js
+++ b/module/web/static/js/views/settingsView.js
@@ -5,10 +5,10 @@ define(['jquery', 'underscore', 'backbone'],
return Backbone.View.extend({
el: "#content",
-// template: _.compile($("#template-package").html()),
+ template_menu: _.compile($("#template-menu").html()),
events: {
-
+ 'click .settings-menu li > a': 'change_section'
},
menu: null,
@@ -18,24 +18,21 @@ define(['jquery', 'underscore', 'backbone'],
this.menu = $('.settings-menu');
var self = this;
- $.ajax("/api/getCoreConfig", {success: function(data) {
- self.data = data;
- self.render()
- }});
+// $.ajax("/api/getCoreConfig", {success: function(data) {
+// self.data = data;
+// self.render()
+// }});
// $.ajax("/api/getPluginConfig");
console.log("Settings initialized");
},
+ // TODO: this is only a showcase
render: function() {
- if (this.data != null) {
- var self = this;
- this.menu.empty();
- this.menu.append($('<li class="nav-header"><i class="icon-globe icon-white"></i>General</li>'));
-
- _.each(this.data, function(section) {
- self.menu.append($('<li><a href="#">' + section.label + '</a></li>'));
- })
- }
+ this.menu.html(this.template_menu({core:false}));
+ },
+
+ change_section: function(el) {
+ console.log("Section changed");
}
});
diff --git a/module/web/templates/default/dashboard.html b/module/web/templates/default/dashboard.html
index 0c20589af..875178931 100644
--- a/module/web/templates/default/dashboard.html
+++ b/module/web/templates/default/dashboard.html
@@ -18,15 +18,15 @@
<span class="checkbox"></span>
<i class="icon-folder-close icon-white"></i>&nbsp;
<span class="name">
- Package <%= pid %>: <%= name %>
+ Package <% pid %>: <% name %>
</span>
</div>
<div class="package-row second">
<span>
- <%= stats.linksdone %> / <%= stats.linkstotal %>
+ <% stats.linksdone %> / <% stats.linkstotal %>
</span>
<span class="pull-right">
- <%= formatSize stats.sizedone %> / <%= formatSize stats.sizetotal %>
+ <% formatSize stats.sizedone %> / <% formatSize stats.sizetotal %>
</span>
</div>
diff --git a/module/web/templates/default/settings.html b/module/web/templates/default/settings.html
index 591dbc30c..5fa34a40d 100644
--- a/module/web/templates/default/settings.html
+++ b/module/web/templates/default/settings.html
@@ -12,22 +12,24 @@
App.initSettingsView();
{% endblock %}
+{% block head %}
+ <script type="text/template" id="template-menu">
+ <%=if core%>
+ Core
+ <%/if%>
+ <li class="nav-header"><i class="icon-globe icon-white"></i> {{ _("General") }}</li>
+ <li class="divider"></li>
+ <li class="nav-header"><i class="icon-th-large icon-white"></i> {{ _("Addons") }}</li>
+ <li class="divider"></li>
+ <li class="nav-header"><i class="icon-th-list icon-white"></i> {{ _("Other") }}</li>
+ </script>
+{% endblock %}
+
{% block content %}
<div class="container-fluid">
<div class="row-fluid">
<div class="span2">
<ul class="nav nav-list well settings-menu">
- <li class="nav-header"><i class="icon-globe icon-white"></i> {{ _("General") }}</li>
- <li class="active"><a href="#">Example Settings</a></li>
- <li><a href="#">General blabla</a></li>
- <li><a href="#">General blabla</a></li>
- <li><a href="#">General blabla</a></li>
- <li><a href="#">General blabla</a></li>
- <li class="nav-header"><i class="icon-th-large icon-white"></i> {{ _("Addons") }}</li>
- <li><a href="#">Addons balba</a></li>
- <li><a href="#">Addons balbal</a></li>
- <li class="divider"></li>
- <li class="nav-header"><i class="icon-user icon-white"></i> {{ _("Accounts") }}</li>
</ul>
</div>
<!-- Info Popup -->