diff --git a/src/release/utils/common.py b/src/release/utils/common.py
index a8a29c8..390a9cf 100644
--- a/src/release/utils/common.py
+++ b/src/release/utils/common.py
@@ -4,6 +4,7 @@
import os
import json
+onlineDesc = '《栩栩若生》在线阅读'
projectUrl = 'https://github.com/dnomd343/xxrs-crawler'
rootPath = os.path.join( # project root directory
diff --git a/src/release/utils/release.py b/src/release/utils/release.py
index ba2e385..1ea69d6 100644
--- a/src/release/utils/release.py
+++ b/src/release/utils/release.py
@@ -10,6 +10,7 @@ import subprocess
from .common import isRoot
from .common import rootPath
from .common import saveFile
+from .common import onlineDesc
from .common import projectUrl
from .common import releaseInfo
from .common import createFolder
@@ -36,7 +37,8 @@ def gitbookRelease(metadata: dict, content: dict) -> None:
createFolder(os.path.join(releaseInfo['gitbook'], './assets/'))
createFolder(os.path.join(releaseInfo['gitbook'], './chapter/'))
- cover = gitbookMetadata(metadata)
+ cover = '---\ndescription: 作者:%s\n---\n\n' % metadata['author']
+ cover += gitbookMetadata(metadata)
for (resName, resUrls) in resourceInfo.items():
cover += '{% hint style="success" %}\n' \
+ '### [%s](%s)([备用地址](%s))\n' % (resName, resUrls[1], resUrls[0]) \
@@ -57,7 +59,8 @@ def staticDepends(workDir: str, metadata: dict, content: dict) -> None:
createFolder(os.path.join(workDir, './assets/'))
createFolder(os.path.join(workDir, './chapter/'))
- cover = gitbookMetadata(metadata) + '
\n'
+ cover = '---\ndescription: %s\n---\n\n' % onlineDesc
+ cover += gitbookMetadata(metadata) + '
\n'
for (resName, resUrls) in resourceInfo.items():
cover += '\n{% hint style="none" %}\n' \
+ '#### [%s](%s)([备用地址](%s))\n' % (resName, resUrls[1], resUrls[0]) \
@@ -66,7 +69,6 @@ def staticDepends(workDir: str, metadata: dict, content: dict) -> None:
bookInfo = json.dumps({
'title': metadata['name'],
'author': metadata['author'],
- 'description': '《%s》在线阅读' % metadata['name'],
"language": "zh-hans",
'plugins': [
'-lunr', '-search', '-sharing', 'hints', 'github',
@@ -82,7 +84,8 @@ def staticDepends(workDir: str, metadata: dict, content: dict) -> None:
saveFile(os.path.join(workDir, 'README.md'), cover)
saveFile(os.path.join(workDir, 'book.json'), bookInfo)
saveFile(os.path.join(workDir, 'SUMMARY.md'), gitbookSummary(content))
- for (chapterPath, chapterContent) in gitbookChapters(content).items():
+ descHeader = '---\ndescription: %s\n---\n\n' % onlineDesc
+ for (chapterPath, chapterContent) in gitbookChapters(content, header = descHeader).items():
saveFile(os.path.join(workDir, chapterPath), chapterContent)
shutil.copy( # gitbook cover
os.path.join(rootPath, './assets/cover.jpg'),
diff --git a/src/release/utils/sequence.py b/src/release/utils/sequence.py
index 688f787..3139ebc 100644
--- a/src/release/utils/sequence.py
+++ b/src/release/utils/sequence.py
@@ -57,11 +57,13 @@ def htmlSerialize(metadata: dict, content: dict) -> str:
def gitbookMetadata(metadata: dict) -> str:
- return '---\ndescription: 作者:%s\n---\n\n# %s\n\n' % (
- metadata['author'], metadata['name']
- ) + '\n\n' % (
- 'text-align:center', 'assets/cover.jpg', metadata['name']
- ) + '\n>\n'.join(['> %s' % x for x in metadata['desc']]) + '\n\n'
+ return ''.join([
+ '# %s\n\n' % metadata['name'],
+ '\n\n' % metadata['name'],
+ '\n>\n'.join(['> %s' % x for x in metadata['desc']]) + '\n\n',
+ ])
def gitbookChapterPath(caption: str) -> str:
@@ -79,11 +81,11 @@ def gitbookSummary(chapters: dict) -> str:
return summary
-def gitbookChapters(chapters: dict) -> dict:
+def gitbookChapters(chapters: dict, header: str = '') -> dict:
result = {}
for (caption, content) in chapters.items():
content = [markdownTransfer(x) for x in content]
- result[gitbookChapterPath(caption)] = '# %s\n\n%s\n' % (
+ result[gitbookChapterPath(caption)] = header + '# %s\n\n%s\n' % (
caption, '\n\n'.join(content)
)
return result