From: Simon Cozens Date: Wed, 16 Jul 2025 10:49:50 +0000 (+0100) Subject: Plug linter into tag tool X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d34ff521a0a7053f5285d603c43c3a0ebec4512a;p=thirdparty%2Fgoogle%2Ffonts.git Plug linter into tag tool --- diff --git a/tagger2/TagsByFont.js b/tagger2/TagsByFont.js index 496811028..4844b4dab 100644 --- a/tagger2/TagsByFont.js +++ b/tagger2/TagsByFont.js @@ -7,6 +7,9 @@ export default { }, similarFamilies() { return this.$root.gf.similarFamilies(this.font, 10); + }, + lintErrors() { + return this.$root.gf.linter(this.$root.gf.lintRules, this.font, this.filteredTags); } }, methods: { @@ -37,6 +40,9 @@ export default {
  • {{ family }}
  • +
  • + {{ error.description }} +
  • ` diff --git a/tagger2/index.html b/tagger2/index.html index 718f761b7..4e4ac1c2e 100644 --- a/tagger2/index.html +++ b/tagger2/index.html @@ -2,6 +2,7 @@ +
    @@ -33,6 +34,7 @@ import AddTags from "./AddTags.js"; import AddCategory from "./AddCategory.js"; import VFView from "./VFView.js"; + import { linter } from "./linter.js"; Vue.component('tags-by-font', TagsByFont); Vue.component('tags-by-categories', TagsByCategories); @@ -93,7 +95,9 @@ // Load the GF and Tags classes this.gf = new GF(); await this.gf.getFamilyData(); + await this.gf.getLintRules(); this.gf.loadFamilies(); + this.gf.linter = linter; this.tags = new Tags(this.gf); this.tags.sortCategories(); this.$root.$on("remove-tag", this.removeTag); diff --git a/tagger2/models.js b/tagger2/models.js index 40816a5bd..9e41fdaec 100644 --- a/tagger2/models.js +++ b/tagger2/models.js @@ -97,6 +97,7 @@ export class GF { constructor() { this.familyData = {}; this.families = []; + this.lintRules = []; } async getFamilyData() { let data = await loadText('family_data.json'); @@ -111,6 +112,26 @@ export class GF { } }); } + async getLintRules() { + let data = await loadText('tag_rules.csv'); + const lines = data.split('\n'); + for (let line of lines) { + if (line.startsWith('#') || line.trim() === '') { + continue; + } + let [rule, severity, description] = line.split(','); + description = description.replace(/^"(.*)"$/, '$1'); + if (!rule || !description || !severity) { + console.warn("Skipping line due to missing fields:", line); + continue; + } + this.lintRules.push({ + rule: rule.trim(), + description: description.trim(), + severity: severity.trim() + }); + } + } loadFamilies() { for (let familyName in this.familyData) { const axes = [] diff --git a/tagger2/style.css b/tagger2/style.css new file mode 100644 index 000000000..a82bc3615 --- /dev/null +++ b/tagger2/style.css @@ -0,0 +1,9 @@ +body { + font-family: sans-serif; + margin: 0; +} + +.tag-error { background-color: #f88f7e; padding: 2px; } +.tag-warn { color: #c0a007; } +.tag-fail { color: #c02007; } +.tag-info { color: #007ac0; } \ No newline at end of file