diff --git a/res/colors.less b/res/colors.less index a010051..ecd698f 100644 --- a/res/colors.less +++ b/res/colors.less @@ -19,3 +19,5 @@ @gray: #aaa; @black: #111; +// added a few for this usecase +@darkred: #860a03; diff --git a/res/main.less b/res/main.less index f8926ea..4a557ff 100644 --- a/res/main.less +++ b/res/main.less @@ -43,7 +43,7 @@ #headword { font-size: 1.2em; - color: @red; + color: @darkred; font-weight: bold; } @@ -126,7 +126,7 @@ .translation-text { display: inline; - color: @maroon; + color: @blue; .translation-element-margin(); } .translation-source { @@ -174,6 +174,17 @@ .example-text { ._hoverable(); + + .example-text-1 { + color: @black; + } + .example-text-2 { + color: @red; + } + .example-text-3 { + color: @red; + font-weight: bold; + } } .example-cluster, .example-logdice, .example-frequency { diff --git a/src/model/example.py b/src/model/example.py index 73cb520..1d517bb 100644 --- a/src/model/example.py +++ b/src/model/example.py @@ -66,6 +66,15 @@ class Example(Editable): def is_collocation(self): return type(self.inner) is CorpusExample + def get_view_type(self): + # as per the bosses, these are the rules for different colors + if type(self.inner) is CorpusExample: + return 1 + elif self.inner.type == "collocation": + return 2 + else: + return 3 + class CorpusExample: def __init__(self, example_xml): @@ -90,7 +99,7 @@ class CorpusExample: class MultiwordExample: def __init__(self, example_xml): self.other_attributes = {} - for oth_attr in ["type", "lexical_unit_id", "structure_id", "structureName", "audio", "frequency", "logDice"]: + for oth_attr in ["lexical_unit_id", "structure_id", "structureName", "audio", "frequency", "logDice"]: if example_xml.hasAttribute(oth_attr): self.other_attributes[oth_attr] = example_xml.getAttribute(oth_attr) @@ -99,6 +108,11 @@ class MultiwordExample: if example_xml.hasAttribute("cluster"): self.cluster_valid = True self.cluster = int(example_xml.getAttribute("cluster")) + + if example_xml.hasAttribute("type"): + self.type = example_xml.getAttribute(oth_attr) + else: + self.type = None def export(self, doc): result = doc.createElement("multiwordExample") @@ -109,6 +123,9 @@ class MultiwordExample: if self.cluster_valid: result.setAttribute("cluster", str(self.cluster)) + if self.type is not None: + result.setAttribute("type", self.type) + return result def get_cluster(self): diff --git a/src/view/view.py b/src/view/view.py index 56b6b8d..86e29f3 100644 --- a/src/view/view.py +++ b/src/view/view.py @@ -133,7 +133,8 @@ class View: if cluster is not None: example_content.append(h("span.example-cluster", {}, str(cluster))) - example_content.append(h("span.example-text-inner", {}, example.text())) + example_text_inner_tag = "span.example-text-{}".format(example.get_view_type()) + example_content.append(h(example_text_inner_tag, {}, example.text())) if "frequency" in example.other_attributes: example_content.append(h("span.example-frequency", {}, example.other_attributes["frequency"]))