From 24957748918403a387fbae47f593001ce361891a Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Mon, 18 Apr 2016 19:59:56 -0700 Subject: [PATCH] Better tag rendering --- ext/bg/js/templates.js | 17 +++++++++++++---- ext/fg/css/popup.css | 17 ++++++++++++++++- util/compile.py | 8 ++++---- util/tmpl/term.html | 2 +- 4 files changed, 34 insertions(+), 10 deletions(-) diff --git a/ext/bg/js/templates.js b/ext/bg/js/templates.js index 1609cc97..ae7c4a0d 100644 --- a/ext/bg/js/templates.js +++ b/ext/bg/js/templates.js @@ -77,14 +77,23 @@ templates['term.html'] = template({"1":function(container,depth0,helpers,partial + ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.tags : depth0),{"name":"each","hash":{},"fn":container.program(11, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + "\n"; },"11":function(container,depth0,helpers,partials,data) { - var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; + var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; - return " " + alias4(((helper = (helper = helpers.key || (data && data.key)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"key","hash":{},"data":data}) : helper))) + "\n"; -},"13":function(container,depth0,helpers,partials,data) { +},"12":function(container,depth0,helpers,partials,data) { + var helper; + + return "tag-" + + container.escapeExpression(((helper = (helper = helpers["class"] || (depth0 != null ? depth0["class"] : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"class","hash":{},"data":data}) : helper))); +},"14":function(container,depth0,helpers,partials,data) { + return "tag-default"; +},"16":function(container,depth0,helpers,partials,data) { return "
  • " + container.escapeExpression(container.lambda(depth0, depth0)) + "
  • \n"; @@ -97,7 +106,7 @@ templates['term.html'] = template({"1":function(container,depth0,helpers,partial + "\n" + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.tags : depth0),{"name":"if","hash":{},"fn":container.program(10, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + "\n
    \n
      \n" - + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.glossary : depth0),{"name":"each","hash":{},"fn":container.program(13, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.glossary : depth0),{"name":"each","hash":{},"fn":container.program(16, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + "
    \n
    \n"; },"useData":true}); templates['term-list.html'] = template({"1":function(container,depth0,helpers,partials,data) { diff --git a/ext/fg/css/popup.css b/ext/fg/css/popup.css index 1c40bdfd..b10c06f2 100644 --- a/ext/fg/css/popup.css +++ b/ext/fg/css/popup.css @@ -43,7 +43,6 @@ body { } .tag { - background-color: #777; border-radius: 0.25em; color: #fff; cursor: default; @@ -57,6 +56,22 @@ body { white-space: nowrap; } +.tag-default { + background-color: #8a8a91; +} + +.tag-name { + background-color: #5cb85c; +} + +.tag-expression { + background-color: #f0ad4e; +} + +.tag-popular { + background-color: #0275d8; +} + ol { padding-left: 1.2em; } diff --git a/util/compile.py b/util/compile.py index 9c5a6bdd..d5a916fd 100755 --- a/util/compile.py +++ b/util/compile.py @@ -193,15 +193,15 @@ def parse_edict(path): for index, dfn in enumerate(filter(None, segments[1:])): dfn_match = re.search(r'^((?:\((?:[\w\-\,\:]*)*\)\s*)*)(.*)$', dfn) - gloss = dfn_match.group(2).strip() - if len(gloss) == 0: - continue - tags_raw = set(filter(None, re.split(r'[\s\(\),]', dfn_match.group(1)))) tags_raw = fixup_godan_verbs(tags_raw) tags_raw = tags_raw.intersection(set(PARSED_TAGS.keys())) tags = tags.union(tags_raw) + gloss = dfn_match.group(2).strip() + if len(gloss) == 0: + continue + if index == 0 or len(dfn_match.group(1)) > 0: defs.append([gloss]) else: diff --git a/util/tmpl/term.html b/util/tmpl/term.html index abcbb215..e97104f1 100644 --- a/util/tmpl/term.html +++ b/util/tmpl/term.html @@ -15,7 +15,7 @@ {{#if tags}}
    {{#each tags}} - {{@key}} + {{@key}} {{/each}}
    {{/if}}