Skip to content

Commit

Permalink
πŸŽ‰ Init 'add-iscn-qr-code-to-epub' (#44)
Browse files Browse the repository at this point in the history
* πŸŽ‰ Init 'add-iscn-qr-code-to-epub'

* 🎨 Improve HTML items naming

* βž• Add archiver

* 🎨 Use `archiver` to zip to epub

* πŸ’„ Update ISCN QR code page style

* πŸ› Add `<!DOCTYPE html>`

---------

Co-authored-by: Ng Wing Tat, David <[email protected]>
  • Loading branch information
WeiJun0827 and nwingt authored Nov 9, 2023
1 parent d7936a3 commit d24e946
Show file tree
Hide file tree
Showing 12 changed files with 2,842 additions and 0 deletions.
1 change: 1 addition & 0 deletions add-iscn-qr-code-to-epub/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
output/
31 changes: 31 additions & 0 deletions add-iscn-qr-code-to-epub/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Add ISCN QR Code to EPUB

Add an ISCN QR code page to the end of EPUB files.

## Installation

Run with `node.js >= 16`, `npm >= 8`.

```bash
npm install
```

## Usage

1. Create ISCN for your eBooks. You can use [iscn-batch-uploader](../iscn-batch-uploader) to create ISCN in batch.

2. Put your .epub files in `./input` folder.

3. Update `./list.csv` with your eBook filename and ISCN ID.

4. Run the script with:
```bash
npm run start
```
5. The output files will be in `./output` folder.

## Configuration

Change the config in `./config.js`

You can set the text and `language` to show on the QR code page.
3 changes: 3 additions & 0 deletions add-iscn-qr-code-to-epub/asset/iscn-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions add-iscn-qr-code-to-epub/asset/iscn.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
body {
display: flex;
flex-direction: column;
height: 100vh;
font-family: sans-serif;
}

main {
display: flex;
flex-direction: column;
justify-content: flex-end;
flex-grow: 1;
padding: 0.5em 2vw 4em;
}

footer {
border-top: 1px solid #ccc;
padding: 0.5em;
}

#iscn-page-book-info {
margin-top: 16px;
font-size: 0.8em;
}

#iscn-page-book-info th,
#iscn-page-book-info td {
padding: 0.25em 2vw;
vertical-align: top;
}

#iscn-page-book-info th {
text-align: left;
white-space: nowrap;
}

#iscn-qr-code {
display: block;
margin-top: 0.5em;
}

#iscn-prefix {
font-family: monospace;
word-break: break-all;
}

#depub-disclaimer {
text-align: center;
}
24 changes: 24 additions & 0 deletions add-iscn-qr-code-to-epub/asset/iscn.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<head>
<title>ISCN on LikeCoin Chain</title>
<link href="iscn.css" type="text/css" rel="stylesheet" />
</head>

<body>
<main>
<table id="iscn-page-book-info">
<tr>
<th>ISCN: </th>
<td>
<a id="iscn-prefix" />
<img id="iscn-qr-code" width="250" height="250" src="iscn-qr-code.png" />
</td>
</tr>
</table>
</main>
<footer id="depub-disclaimer" />
</body>
</html>
42 changes: 42 additions & 0 deletions add-iscn-qr-code-to-epub/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import dayjs from 'dayjs';
import LocalizedFormat from 'dayjs/plugin/localizedFormat.js';
import 'dayjs/locale/en.js';
import 'dayjs/locale/zh-hk.js';
import 'dayjs/locale/zh-tw.js';

dayjs.extend(LocalizedFormat);

const language = 'en'; // en, zh-hk, zh-tw
dayjs.locale(language);

const config = {
'en': {
TITLE_LABEL: 'Title',
AUTHOR_LABEL: 'Author',
RELEASE_DATE_LABEL: 'Release date',
DATE_FORMAT: 'LL', // equals to 'MMMM D, YYYY' (August 16, 2018)
DEPUB_DISCLAIMER: 'This book is published on decentralized networks',
},
'zh-hk': {
TITLE_LABEL: '書名',
AUTHOR_LABEL: 'δ½œθ€…',
RELEASE_DATE_LABEL: 'η™Όθ‘Œζ—₯期',
DATE_FORMAT: 'LL', // YYYYεΉ΄M月Dζ—₯
DEPUB_DISCLAIMER: 'ζ­€ζ›ΈζŽ‘η”¨εˆ†ζ•£εΌε‡Ίη‰ˆ',
},
'zh-tw': {
TITLE_LABEL: '書名',
AUTHOR_LABEL: 'δ½œθ€…',
RELEASE_DATE_LABEL: 'η™Όθ‘Œζ—₯期',
DATE_FORMAT: 'LL', // YYYYεΉ΄M月Dζ—₯
DEPUB_DISCLAIMER: 'ζ­€ζ›ΈζŽ‘η”¨εˆ†ζ•£εΌε‡Ίη‰ˆ',
},
};

export const {
TITLE_LABEL,
AUTHOR_LABEL,
RELEASE_DATE_LABEL,
DATE_FORMAT,
DEPUB_DISCLAIMER,
} = config[language] || config.en;
Loading

0 comments on commit d24e946

Please sign in to comment.