From b5a0bc4cad2f770a0fca44c84f62754d314bb5e1 Mon Sep 17 00:00:00 2001 From: MarvNC <rotrobmin@gmail.com> Date: Thu, 11 Jul 2024 19:10:32 -0700 Subject: [PATCH] Rework footer --- assets/wikipedia-icon.png | Bin 0 -> 555 bytes src/constants.ts | 9 ++++++++- src/index.ts | 3 +++ src/yomitan/processLine.ts | 36 ++++++++++++++++++------------------ 4 files changed, 29 insertions(+), 19 deletions(-) create mode 100644 assets/wikipedia-icon.png diff --git a/assets/wikipedia-icon.png b/assets/wikipedia-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..4405b8d59ae181a457145da259ce983102029fdb GIT binary patch literal 555 zcmV+`0@VG9P)<h;3K|Lk000e1NJLTq001BW001Be1^@s6b9#F80005<Nkl<ZScUDE z(T&3(42JCv;T1eVX2=W~fE^ft6<8vZ<eeE<!oG)-5fDhP)m6ENL*gNIz@P2kR)f$j z5z+p)-&~K!1MBDV@M*_05WK^A4e_|calP=a=xyDefqwuH5nYx=5m5o4Y(&&;+f+nU zM3k8uI}vG&QAI>U2ueha-E1+&(^&v0cY`^|IV%wrkeqXIZreFmE;x>(v89w00F;?E zrF1&GZCi0%-wpLkA%x;!-}locIp+fCoNH|RzE95?01=%6gWiFqa#@z)Mc#WwL`B5r zGG^9wU5953JcMwv!N|e0ELf?$_a%BnJe8%sa}@m$z-SS18d0AGW^M%AZz4LCYzkoY zG6y3;)mgB2NAK0znAwK_DWw81i_A)eh|}mqzFT~j$ti${=(?`O!Kik1sb&DjaVR2A zJL3|-garUaY@^yD;#6SHxoI~&1+etZ92lVOzQrs<HWA+fFaeDmFta-6%7i1L#%|;J z>i(wyeVY5|Q%Yq713&{wM8m=JGC+*6q}kGG(f5KiNCO<{;$?t(JTvpKuWLPo5OiJF z%hr4eK%|{~v)N#Rwa%Fhp0@z%o}W#<TCi7x=Pdw{@1DMzjHZoegXe94oU?lGFNKv- t`jPVMef!_?|1YDz@o`$OPlNQI=U;n>y5V&4&%*!!002ovPDHLkV1nmA14aM< literal 0 HcmV?d00001 diff --git a/src/constants.ts b/src/constants.ts index ad78fdf..fea2f31 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,5 +1,12 @@ +import * as path from 'path'; export const languages = { ja: 'JA', zh: 'ZH', }; -export const linkCharacter = '⧉'; + +export const ASSETS_FOLDER = './assets'; +export const WIKIPEDIA_ICON_FILENAME = 'wikipedia-icon.png'; +export const WIKIPEDIA_ICON_FILEPATH = path.join( + ASSETS_FOLDER, + WIKIPEDIA_ICON_FILENAME +); diff --git a/src/index.ts b/src/index.ts index 41c4381..a907852 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,6 +5,7 @@ import { getVersion } from './util/getVersion'; import { downloadDumps } from './util/downloadDumps'; import { readArgs } from './util/readArgs'; import { readAndProcessLines } from './util/readAndProcessLines'; +import { WIKIPEDIA_ICON_FILEPATH } from './constants'; const outputZipName = (lang: string, date: string, version: string) => `${lang} Wikipedia [${date}] (v${version}).zip`; @@ -27,6 +28,8 @@ const OUT_DIRECTORY = './out'; fileName: outputZipName(lang, date, version), }); + dict.addFile(WIKIPEDIA_ICON_FILEPATH, WIKIPEDIA_ICON_FILEPATH); + const processedLines = await readAndProcessLines(filePath, dict, lang, dev); console.log(`Processed ${processedLines} lines, exporting zip...`); diff --git a/src/yomitan/processLine.ts b/src/yomitan/processLine.ts index b3fd74a..ee22651 100644 --- a/src/yomitan/processLine.ts +++ b/src/yomitan/processLine.ts @@ -4,7 +4,8 @@ import { StructuredContent, StructuredContentNode, } from 'yomichan-dict-builder/dist/types/yomitan/termbank'; -import { languages, linkCharacter } from '../constants'; +import * as path from 'path'; +import { WIKIPEDIA_ICON_FILEPATH } from '../constants'; /** * Reads a line and adds that term entry to the dictionary @@ -88,37 +89,36 @@ function createReadMoreNode( lang: string ): StructuredContentNode { const articleLink = `https://${lang.toLowerCase()}.wikipedia.org/wiki/${termSlug}`; - const readTheRest = getReadMoreText(lang); return { - tag: 'ul', + tag: 'div', content: [ { - tag: 'li', + tag: 'span', content: [ + { + tag: 'img', + path: WIKIPEDIA_ICON_FILEPATH, + collapsed: false, + collapsible: false, + height: 1, + width: 1, + sizeUnits: 'em', + verticalAlign: 'middle', + }, + ' ', { tag: 'a', href: articleLink, - content: readTheRest, + content: `Wikipedia`, }, ], }, ], data: { - wikipedia: 'continue-reading', + wikipedia: 'footer', }, style: { - listStyleType: `"${linkCharacter}"`, + textAlign: 'end', }, }; } - -function getReadMoreText(lang: string): string { - switch (lang) { - case languages.ja: - return '続きを読む'; - case languages.zh: - return '查看更多'; - default: - return 'Read more'; - } -}