Better tag rendering
This commit is contained in:
parent
c4e35fbf54
commit
2495774891
@ -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 : "")
|
+ ((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 : "")
|
||||||
+ "</div>\n";
|
+ "</div>\n";
|
||||||
},"11":function(container,depth0,helpers,partials,data) {
|
},"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 " <span class=\"tag\" title=\""
|
return " <span class=\"tag "
|
||||||
|
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0["class"] : depth0),{"name":"if","hash":{},"fn":container.program(12, data, 0),"inverse":container.program(14, data, 0),"data":data})) != null ? stack1 : "")
|
||||||
|
+ "\" title=\""
|
||||||
+ alias4(((helper = (helper = helpers.desc || (depth0 != null ? depth0.desc : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"desc","hash":{},"data":data}) : helper)))
|
+ alias4(((helper = (helper = helpers.desc || (depth0 != null ? depth0.desc : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"desc","hash":{},"data":data}) : helper)))
|
||||||
+ "\">"
|
+ "\">"
|
||||||
+ alias4(((helper = (helper = helpers.key || (data && data.key)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"key","hash":{},"data":data}) : helper)))
|
+ alias4(((helper = (helper = helpers.key || (data && data.key)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"key","hash":{},"data":data}) : helper)))
|
||||||
+ "</span>\n";
|
+ "</span>\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 " <li><span>"
|
return " <li><span>"
|
||||||
+ container.escapeExpression(container.lambda(depth0, depth0))
|
+ container.escapeExpression(container.lambda(depth0, depth0))
|
||||||
+ "</span></li>\n";
|
+ "</span></li>\n";
|
||||||
@ -97,7 +106,7 @@ templates['term.html'] = template({"1":function(container,depth0,helpers,partial
|
|||||||
+ "\n"
|
+ "\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 : "")
|
+ ((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<div class=\"glossary\">\n <ol>\n"
|
+ "\n<div class=\"glossary\">\n <ol>\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 : "")
|
||||||
+ " </ol>\n</div>\n";
|
+ " </ol>\n</div>\n";
|
||||||
},"useData":true});
|
},"useData":true});
|
||||||
templates['term-list.html'] = template({"1":function(container,depth0,helpers,partials,data) {
|
templates['term-list.html'] = template({"1":function(container,depth0,helpers,partials,data) {
|
||||||
|
@ -43,7 +43,6 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.tag {
|
.tag {
|
||||||
background-color: #777;
|
|
||||||
border-radius: 0.25em;
|
border-radius: 0.25em;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
cursor: default;
|
cursor: default;
|
||||||
@ -57,6 +56,22 @@ body {
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tag-default {
|
||||||
|
background-color: #8a8a91;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-name {
|
||||||
|
background-color: #5cb85c;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-expression {
|
||||||
|
background-color: #f0ad4e;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-popular {
|
||||||
|
background-color: #0275d8;
|
||||||
|
}
|
||||||
|
|
||||||
ol {
|
ol {
|
||||||
padding-left: 1.2em;
|
padding-left: 1.2em;
|
||||||
}
|
}
|
||||||
|
@ -193,15 +193,15 @@ def parse_edict(path):
|
|||||||
for index, dfn in enumerate(filter(None, segments[1:])):
|
for index, dfn in enumerate(filter(None, segments[1:])):
|
||||||
dfn_match = re.search(r'^((?:\((?:[\w\-\,\:]*)*\)\s*)*)(.*)$', dfn)
|
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 = set(filter(None, re.split(r'[\s\(\),]', dfn_match.group(1))))
|
||||||
tags_raw = fixup_godan_verbs(tags_raw)
|
tags_raw = fixup_godan_verbs(tags_raw)
|
||||||
tags_raw = tags_raw.intersection(set(PARSED_TAGS.keys()))
|
tags_raw = tags_raw.intersection(set(PARSED_TAGS.keys()))
|
||||||
tags = tags.union(tags_raw)
|
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:
|
if index == 0 or len(dfn_match.group(1)) > 0:
|
||||||
defs.append([gloss])
|
defs.append([gloss])
|
||||||
else:
|
else:
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
{{#if tags}}
|
{{#if tags}}
|
||||||
<div class="tags">
|
<div class="tags">
|
||||||
{{#each tags}}
|
{{#each tags}}
|
||||||
<span class="tag" title="{{desc}}">{{@key}}</span>
|
<span class="tag {{#if class}}tag-{{class}}{{else}}tag-default{{/if}}" title="{{desc}}">{{@key}}</span>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
Loading…
Reference in New Issue
Block a user