diff options
Diffstat (limited to 'module/web/static')
| -rw-r--r-- | module/web/static/js/libs/handlebars.l | 48 | ||||
| -rw-r--r-- | module/web/static/js/utils/initHB.js | 4 | ||||
| -rw-r--r-- | module/web/static/js/views/settingsView.js | 27 | 
3 files changed, 62 insertions, 17 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");              }          }); | 
