]> git.ipfire.org Git - thirdparty/google/fonts.git/commitdiff
tags.html: Implement Evan feedback 8176/head
authorMarc Foley <m.foley.88@gmail.com>
Tue, 17 Sep 2024 12:46:11 +0000 (13:46 +0100)
committerMarc Foley <m.foley.88@gmail.com>
Tue, 17 Sep 2024 12:46:11 +0000 (13:46 +0100)
.ci/tags.html

index feae5bab9ef8c803804be6f633d29769cb542423..5480567f4e6ef2c61c7880e47286801a080394d6 100644 (file)
         this.Families = this.Families.filter((t) => t !== Family);
         this.history.push(`- ${Family.Family},${Family["Group/Tag"]},${Family.Weight}`);
       },
-      saveCSV() {
+      familiesToCSV() {
         this.Families = this.Families.filter((t) => t.Family !== "");
+        // The sorting function used is case sensitive.
+        // This means that "A" will come before "a".
         this.Families = Array.from(this.Families).sort((a, b) => {
           if (`${a.Family},${a['Group/Tag']}` < `${b.Family},${b['Group/Tag']}`) {
             return -1;
           }
           return 0;
         });
-        let csv = Papa.unparse(this.Families,
+        // Include a newline at the end to keep Evan's Vim happy.
+        return Papa.unparse(this.Families,
           {
             columns: ["Family", "Group/Tag", "Weight"],
             skipEmptyLines: true,
           }
-        );
-
+        ) + "\n";
+      },
+      saveCSV() {
+        let csv = this.familiesToCSV();
         const blob = new Blob([csv], { type: 'text/csv' });
         const url = URL.createObjectURL(blob);
         const a = document.createElement('a');
         URL.revokeObjectURL(url);
       },
       prCSV() {
-        this.Families = this.Families.filter((t) => t.Family !== "");
-        this.Families = Array.from(this.Families).sort((a, b) => {
-          if (`${a.Family},${a['Group/Tag']}` < `${b.Family},${b['Group/Tag']}`) {
-            return -1;
-          }
-          if (`${a.Family},${a['Group/Tag']}` > `${b.Family},${b['Group/Tag']}`) {
-            return 1;
-          }
-          return 0;
-        });
-        let csv = Papa.unparse(this.Families,
-          {
-            columns: ["Family", "Group/Tag", "Weight"],
-            skipEmptyLines: true,
-          }
-        );
+        let csv = this.familiesToCSV();
         alert("Tag data copied to clipboard. A github pull request page will open in a new tab. Please remove the old data and paste in the new.");
         navigator.clipboard.writeText(csv);
         window.open("https://github.com/google/fonts/edit/main/tags/all/families.csv")