Skip to content

Commit

Permalink
feat: add copyright (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaikoTan authored Feb 16, 2024
1 parent 326c134 commit 9386f7b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 7 deletions.
16 changes: 14 additions & 2 deletions src/i18n/zh-CN/macrodict.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,32 @@ commands:
hint: '你想找的是 {0} 吗?'
about: |
由 koishi-plugin-ffxiv-macrodict 生成
作者: 迷子 (@Maiko Tan)
作者: 迷子 (@MaikoTan)
about_html: |
<p>由
<code>koishi-plugin-ffxiv-macrodict</code>
生成</p>
<p>作者: 迷子 (@Maiko Tan)</p>
<p>作者: 迷子 (@MaikoTan)</p>
copyright: |
所有游戏数据均来自史克威尔艾尼克斯控股公司。
仅作学习交流之用。
FINAL FANTASY XIV © 2010 - 2022 SQUARE ENIX CO., LTD. All Rights Reserved.
copyright_html: |
<p>所有游戏数据均来自史克威尔艾尼克斯控股公司。</p>
<p>仅作学习交流之用。</p>
format: |
{name}
======
{description}
-----
{about}
{copyright}
setting:
image_mode: '已切换到图片模式'
text_mode: '已切换到文本模式'
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,13 @@ export async function apply(ctx: Context, config: Config): Promise<void> {
name: db.name,
description: parseMacroDescription(db.description, 'text'),
about: session?.text('.about'),
copyright: session?.text('.copyright'),
})
}
return await ctx.macrodict.render(db, session?.text('.about_html') ?? '', lang)
return await ctx.macrodict.render(
db,
{ about: session?.text('.about_html') ?? '', copyright: session?.text('.copyright_html') ?? '' },
lang,
)
})
}
23 changes: 19 additions & 4 deletions src/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class Search extends Service {
}
}

async render(macro: { name: string; description: string }, about: string, lang: string): Promise<Element> {
async render(macro: Macro, info: { about: string; copyright: string }, lang: string): Promise<Element> {
const { puppeteer } = this.ctx

if (!puppeteer) {
Expand All @@ -56,6 +56,8 @@ export class Search extends Service {

const page = await puppeteer.page()

const { about, copyright } = info

await page.setContent(`
<!DOCTYPE html>
<html lang=${lang}>
Expand Down Expand Up @@ -111,10 +113,17 @@ export class Search extends Service {
span.highlight {
color: #b2b23e;
}
footer {
padding: 10px 30px;
padding-bottom: 0;
}
footer > div {
display: flex;
justify-content: space-between;
}
footer > div #about {
text-align: right;
padding-right: 30px;
line-height: 0.8em;
}
</style>
Expand All @@ -129,7 +138,13 @@ export class Search extends Service {
<div id="macro-description">${descriptionHtml}</div>
</main>
<footer>
<div id="about">${about}</div>
<div>
<div id="copyright">${copyright}</div>
<div id="about">${about}</div>
</div>
<p>
FINAL FANTASY XIV © 2010 - 2023 SQUARE ENIX CO., LTD. All Rights Reserved.
</p>
</footer>
</body>
</html>
Expand Down

0 comments on commit 9386f7b

Please sign in to comment.