From 36357c4be349b594a648928bab9aae08c2ee86ba Mon Sep 17 00:00:00 2001 From: chai2010 Date: Tue, 13 Aug 2024 07:05:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D=E4=B8=BA=20wabook?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/mnbook.yml | 48 ------- .github/workflows/wabook.yml | 26 ++++ Makefile | 2 +- README-zh.md | 119 ++++++++++++++++++ README.md | 66 ++++++---- changelog.md | 9 ++ go.mod | 2 +- main.go | 2 +- pkg/cmd/_example_book/book.toml | 4 +- pkg/cmd/cmd_build.go | 6 +- pkg/cmd/main.go | 4 +- pkg/render/_static/.nojekyll | 2 +- .../FontAwesome/css/font-awesome.css | 0 .../FontAwesome/fonts/FontAwesome.ttf | Bin .../FontAwesome/fonts/fontawesome-webfont.eot | Bin .../FontAwesome/fonts/fontawesome-webfont.svg | 0 .../FontAwesome/fonts/fontawesome-webfont.ttf | Bin .../fonts/fontawesome-webfont.woff | Bin .../fonts/fontawesome-webfont.woff2 | Bin .../{mnbook => wabook}/ayu-highlight.css | 0 .../_static/static/{mnbook => wabook}/book.js | 10 +- .../{mnbook => wabook}/clipboard.min.js | 0 .../{mnbook => wabook}/cover-example.svg | 4 +- .../static/{mnbook => wabook}/css/chrome.css | 0 .../static/{mnbook => wabook}/css/general.css | 0 .../static/{mnbook => wabook}/css/print.css | 0 .../{mnbook => wabook}/css/variables.css | 0 .../fonts/OPEN-SANS-LICENSE.txt | 0 .../fonts/SOURCE-CODE-PRO-LICENSE.txt | 0 .../static/{mnbook => wabook}/fonts/fonts.css | 0 .../open-sans-v17-all-charsets-300.woff2 | Bin ...open-sans-v17-all-charsets-300italic.woff2 | Bin .../open-sans-v17-all-charsets-600.woff2 | Bin ...open-sans-v17-all-charsets-600italic.woff2 | Bin .../open-sans-v17-all-charsets-700.woff2 | Bin ...open-sans-v17-all-charsets-700italic.woff2 | Bin .../open-sans-v17-all-charsets-800.woff2 | Bin ...open-sans-v17-all-charsets-800italic.woff2 | Bin .../open-sans-v17-all-charsets-italic.woff2 | Bin .../open-sans-v17-all-charsets-regular.woff2 | Bin ...source-code-pro-v11-all-charsets-500.woff2 | Bin .../static/{mnbook => wabook}/highlight.css | 0 .../static/{mnbook => wabook}/highlight.js | 0 .../static/{mnbook => wabook}/mark.min.js | 0 .../{mnbook => wabook}/tomorrow-night.css | 0 pkg/render/api.go | 10 +- pkg/render/page.go | 20 +-- pkg/render/page_home.go | 2 +- pkg/render/slide.go | 2 +- pkg/render/static.go | 2 +- pkg/render/tmpl/page.html | 42 +++---- pkg/render/tmpl/print.html | 14 +-- pkg/{mnbook => wabook}/book.go | 2 +- pkg/{mnbook => wabook}/config.go | 2 +- pkg/{mnbook => wabook}/config_test.go | 8 +- pkg/{mnbook => wabook}/summary.go | 2 +- pkg/{mnbook => wabook}/summary_test.go | 2 +- pkg/{mnbook => wabook}/talk.go | 2 +- testdata/book.ini | 18 ++- testdata/cover.svg | 8 +- testdata/images/cover-logo.svg | 4 +- testdata/src/chapter_1.md | 2 +- 62 files changed, 288 insertions(+), 158 deletions(-) delete mode 100644 .github/workflows/mnbook.yml create mode 100644 .github/workflows/wabook.yml create mode 100644 README-zh.md create mode 100644 changelog.md rename pkg/render/_static/static/{mnbook => wabook}/FontAwesome/css/font-awesome.css (100%) rename pkg/render/_static/static/{mnbook => wabook}/FontAwesome/fonts/FontAwesome.ttf (100%) rename pkg/render/_static/static/{mnbook => wabook}/FontAwesome/fonts/fontawesome-webfont.eot (100%) rename pkg/render/_static/static/{mnbook => wabook}/FontAwesome/fonts/fontawesome-webfont.svg (100%) rename pkg/render/_static/static/{mnbook => wabook}/FontAwesome/fonts/fontawesome-webfont.ttf (100%) rename pkg/render/_static/static/{mnbook => wabook}/FontAwesome/fonts/fontawesome-webfont.woff (100%) rename pkg/render/_static/static/{mnbook => wabook}/FontAwesome/fonts/fontawesome-webfont.woff2 (100%) rename pkg/render/_static/static/{mnbook => wabook}/ayu-highlight.css (100%) rename pkg/render/_static/static/{mnbook => wabook}/book.js (98%) rename pkg/render/_static/static/{mnbook => wabook}/clipboard.min.js (100%) rename pkg/render/_static/static/{mnbook => wabook}/cover-example.svg (93%) rename pkg/render/_static/static/{mnbook => wabook}/css/chrome.css (100%) rename pkg/render/_static/static/{mnbook => wabook}/css/general.css (100%) rename pkg/render/_static/static/{mnbook => wabook}/css/print.css (100%) rename pkg/render/_static/static/{mnbook => wabook}/css/variables.css (100%) rename pkg/render/_static/static/{mnbook => wabook}/fonts/OPEN-SANS-LICENSE.txt (100%) rename pkg/render/_static/static/{mnbook => wabook}/fonts/SOURCE-CODE-PRO-LICENSE.txt (100%) rename pkg/render/_static/static/{mnbook => wabook}/fonts/fonts.css (100%) rename pkg/render/_static/static/{mnbook => wabook}/fonts/open-sans-v17-all-charsets-300.woff2 (100%) rename pkg/render/_static/static/{mnbook => wabook}/fonts/open-sans-v17-all-charsets-300italic.woff2 (100%) rename pkg/render/_static/static/{mnbook => wabook}/fonts/open-sans-v17-all-charsets-600.woff2 (100%) rename pkg/render/_static/static/{mnbook => wabook}/fonts/open-sans-v17-all-charsets-600italic.woff2 (100%) rename pkg/render/_static/static/{mnbook => wabook}/fonts/open-sans-v17-all-charsets-700.woff2 (100%) rename pkg/render/_static/static/{mnbook => wabook}/fonts/open-sans-v17-all-charsets-700italic.woff2 (100%) rename pkg/render/_static/static/{mnbook => wabook}/fonts/open-sans-v17-all-charsets-800.woff2 (100%) rename pkg/render/_static/static/{mnbook => wabook}/fonts/open-sans-v17-all-charsets-800italic.woff2 (100%) rename pkg/render/_static/static/{mnbook => wabook}/fonts/open-sans-v17-all-charsets-italic.woff2 (100%) rename pkg/render/_static/static/{mnbook => wabook}/fonts/open-sans-v17-all-charsets-regular.woff2 (100%) rename pkg/render/_static/static/{mnbook => wabook}/fonts/source-code-pro-v11-all-charsets-500.woff2 (100%) rename pkg/render/_static/static/{mnbook => wabook}/highlight.css (100%) rename pkg/render/_static/static/{mnbook => wabook}/highlight.js (100%) rename pkg/render/_static/static/{mnbook => wabook}/mark.min.js (100%) rename pkg/render/_static/static/{mnbook => wabook}/tomorrow-night.css (100%) rename pkg/{mnbook => wabook}/book.go (98%) rename pkg/{mnbook => wabook}/config.go (99%) rename pkg/{mnbook => wabook}/config_test.go (84%) rename pkg/{mnbook => wabook}/summary.go (99%) rename pkg/{mnbook => wabook}/summary_test.go (98%) rename pkg/{mnbook => wabook}/talk.go (97%) diff --git a/.github/workflows/mnbook.yml b/.github/workflows/mnbook.yml deleted file mode 100644 index 600f37b..0000000 --- a/.github/workflows/mnbook.yml +++ /dev/null @@ -1,48 +0,0 @@ -# @2023 凹语言 作者。保留所有权利。 - -name: MnBook -on: - pull_request: - push: - branches: - - main - - master - - "releases/*" -jobs: - build-and-test-ubuntu: - runs-on: ubuntu-latest - steps: - - name: Git checkout - uses: actions/checkout@v2 - - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: 1.21 - - - run: go version - - run: go env - - - run: go test ./... - - Publish: - runs-on: ubuntu-latest - if: ${{github.repository == 'wa-lang/mnbook'}} - needs: [Test] - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: 1.21 - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v4 - with: - distribution: goreleaser - version: latest - args: release --clean - env: - GITHUB_TOKEN: ${{ secrets.WA_DEPLOY }} diff --git a/.github/workflows/wabook.yml b/.github/workflows/wabook.yml new file mode 100644 index 0000000..0797544 --- /dev/null +++ b/.github/workflows/wabook.yml @@ -0,0 +1,26 @@ +# @2023 凹语言 作者。保留所有权利。 + +name: waBook +on: + pull_request: + push: + branches: + - main + - master + - "releases/*" +jobs: + build-and-test-ubuntu: + runs-on: ubuntu-latest + steps: + - name: Git checkout + uses: actions/checkout@v2 + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.21 + + - run: go version + - run: go env + + - run: go test ./... diff --git a/Makefile b/Makefile index 9100091..d0072ec 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ debug: -rm -rf ./testdata/_book go run main.go build ./testdata && cd ./testdata && mv book _book_go - cd ./testdata && mnbook build && mv book _book + cd ./testdata && wabook build && mv book _book cd ./testdata && mv _book_go book clean: diff --git a/README-zh.md b/README-zh.md new file mode 100644 index 0000000..e81f97a --- /dev/null +++ b/README-zh.md @@ -0,0 +1,119 @@ +
+

waBook: 简单的 Markdown 图书构建工具.

+ +[简体中文](https://github.com/wa-lang/wabook/blob/master/README-zh.md) | [English](https://github.com/wa-lang/wabook/blob/master/README.md) + + +
+
+ +[![Build Status](https://github.com/wa-lang/waBook/workflows/CI/badge.svg?event=push)](https://github.com/wa-lang/waBook/actions?workflow=CI) +[![Coverage Status](https://coveralls.io/repos/github/wa-lang/wabook/badge.svg)](https://coveralls.io/github/wa-lang/wabook) +[![GitHub release](https://img.shields.io/github/v/tag/wa-lang/wabook.svg?label=release)](https://github.com/wa-lang/wabook/releases) +[![license](https://img.shields.io/github/license/wa-lang/wa.svg)](https://github.com/wa-lang/wa/blob/master/LICENSE) + +
+ +## 特性 + +- 支持 Markdown 格式的电子书构建 +- 支持 Markdown 格式的幻灯片构建 +- 支持基于 Github Discuss 的留言功能 +- 电子书支持自定义 页眉/页脚 + +## 案例 + +使用 [waBook](https://github.com/wa-lang/wabook) 构建的图书列表: + +- 《Go语言圣经》: https://gopl-zh.github.io +- 《Go语言高级编程》: https://github.com/chai2010/advanced-go-programming-book +- 《Go语言定制指南》: https://github.com/chai2010/go-ast-book +- 《µGo语言实现(从头开发一个迷你Go语言编译器)》: https://github.com/wa-lang/ugo-compiler-book +- 《凹语言手册》: https://wa-lang.org/man/ +- 《Wa-lang's Manual》: https://wa-lang.github.io/man/en/ +- 《VS Code插件开发》: https://chai2010.cn/vscode-extdev-book/ +- 《Go语言圣经读书笔记》: https://github.com/chai2010/gopl-notes-zh + +## 安装 + +``` +$ go install github.com/wa-lang/wabook@latest +``` + +## 命令行 + +``` +$ wabook +NAME: + wabook - A tool for build mini markdown book + +USAGE: + wabook [global options] command [command options] [arguments...] + +COMMANDS: + init Creates a new book + build Builds a book from its markdown files + serve Serves a book at http://localhost:3000 + clean Deletes a built book + +GLOBAL OPTIONS: + --help, -h show help + + See "https://github.com/wa-lang/wabook" for more information. +``` + +- init: 初始化一个 Book 基础版本 +- build: 将 Markdown 的 Book 构建为 html +- serve: 构建并启动服务, 方便本地查看效果 +- clean: 删除构建的 book 子目录 + +## `book.ini` 文件 + +不支持注释,不支持未定义属性: + +```ini +[book] +authors = ["chai2010"] +description = "" +language = "zh" +src = "." +title = "book title" + +[output.html] +git-repository-icon = "fa-github" +git-repository-url = "https://github.com/wa-lang/wabook" +edit-url-template = "https://github.com/wa-lang/wabook/edit/master/testdata/{path}" +``` + +## `SUMMARY.md` 文件 + +```md +# Summary + +[Preface](preface.md) + +- [Chapter 1](./src/chapter_1.md) + - [Chapter 1.1](./src/chapter_1.1.md) + - [Chapter 1.2](./src/chapter_1.2.md) + +- [Chapter 2](./src/chapter_2.md) + + +``` + +## Markdown 文件 + +```md +# Chapter 1 + +[Github Repo](https://github.com/wa-lang/wabook): `[Github Repo](https://github.com/wa-lang/wabook)` + + +Image: `![](../images/video-001.png)`: + +![](../images/video-001.png) + +OK! +``` + +不支持内联 HTML。 diff --git a/README.md b/README.md index 994edc3..d95894d 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,29 @@ -# Mini Markdown Book +
+

waBook: Create book/talk from markdown files.

-简单的 Markdown 图书构建工具。 +[简体中文](https://github.com/wa-lang/wabook/blob/master/README-zh.md) | [English](https://github.com/wa-lang/wabook/blob/master/README.md) -## 特性 -- 支持 Markdown 格式的电子书构建 -- 支持 Markdown 格式的幻灯片构建 -- 支持基于 Github Discuss 的留言功能 -- 电子书支持自定义 页眉/页脚 +
+
-## 案例 +[![Build Status](https://github.com/wa-lang/waBook/workflows/CI/badge.svg?event=push)](https://github.com/wa-lang/waBook/actions?workflow=CI) +[![Coverage Status](https://coveralls.io/repos/github/wa-lang/wabook/badge.svg)](https://coveralls.io/github/wa-lang/wabook) +[![GitHub release](https://img.shields.io/github/v/tag/wa-lang/wabook.svg?label=release)](https://github.com/wa-lang/wabook/releases) +[![license](https://img.shields.io/github/license/wa-lang/wa.svg)](https://github.com/wa-lang/wa/blob/master/LICENSE) -使用 [MNBook](https://github.com/wa-lang/mnbook) 构建的图书列表: +
+ +## Features + +- Create book from Markdown +- Create slide from Markdown +- Create book discuss based on Github Discuss +- Supports custom header/footer + +## Example + +Book list built using [waBook](https://github.com/wa-lang/wabook): - 《Go语言圣经》: https://gopl-zh.github.io - 《Go语言高级编程》: https://github.com/chai2010/advanced-go-programming-book @@ -22,21 +34,21 @@ - 《VS Code插件开发》: https://chai2010.cn/vscode-extdev-book/ - 《Go语言圣经读书笔记》: https://github.com/chai2010/gopl-notes-zh -## 安装 +## Install ``` -$ go install github.com/wa-lang/mnbook@latest +$ go install github.com/wa-lang/wabook@latest ``` ## 命令行 ``` -$ mnbook +$ wabook NAME: - mnbook - A tool for build mini markdown book + wabook - A tool for build mini markdown book USAGE: - mnbook [global options] command [command options] [arguments...] + wabook [global options] command [command options] [arguments...] COMMANDS: init Creates a new book @@ -47,17 +59,17 @@ COMMANDS: GLOBAL OPTIONS: --help, -h show help - See "https://github.com/wa-lang/mnbook" for more information. + See "https://github.com/wa-lang/wabook" for more information. ``` -- init: 初始化一个 Book 基础版本 -- build: 将 Markdown 的 Book 构建为 html -- serve: 构建并启动服务, 方便本地查看效果 -- clean: 删除构建的 book 子目录 +- init: Initialize a basic version of Book +- build: Build the Markdown Book into html +- serve: Build and start the service to facilitate local viewing of the effect +- clean: Delete the built book subdirectory -## `book.ini` 文件 +## `book.ini` file -不支持注释,不支持未定义属性: +No annotations supported, no undefined properties supported: ```ini [book] @@ -69,11 +81,11 @@ title = "book title" [output.html] git-repository-icon = "fa-github" -git-repository-url = "https://github.com/wa-lang/mnbook" -edit-url-template = "https://github.com/wa-lang/mnbook/edit/master/testdata/{path}" +git-repository-url = "https://github.com/wa-lang/wabook" +edit-url-template = "https://github.com/wa-lang/wabook/edit/master/testdata/{path}" ``` -## `SUMMARY.md` 文件 +## `SUMMARY.md` file ```md # Summary @@ -89,12 +101,12 @@ edit-url-template = "https://github.com/wa-lang/mnbook/edit/master/testdata/{pat ``` -## Markdown 文件 +## Markdown file ```md # Chapter 1 -[Github Repo](https://github.com/wa-lang/mnbook): `[Github Repo](https://github.com/wa-lang/mnbook)` +[Github Repo](https://github.com/wa-lang/wabook): `[Github Repo](https://github.com/wa-lang/wabook)` Image: `![](../images/video-001.png)`: @@ -104,4 +116,4 @@ Image: `![](../images/video-001.png)`: OK! ``` -不支持内联 HTML。 +Do not support inline HTML。 diff --git a/changelog.md b/changelog.md new file mode 100644 index 0000000..2919bc7 --- /dev/null +++ b/changelog.md @@ -0,0 +1,9 @@ +# 版本日志 + +- (dev) +- v1.0.0 (2024-08-13) + - 改名为 waBook, 正式发布 +- v0.1.0 (2024-08-08) + - 第一个预览版本, 支持 book/talk 构建, 支持留言功能, 支持自定义页眉/页脚 +- v0.0.1 (2023-10-11) + - 第一个Demo版本 diff --git a/go.mod b/go.mod index 6e4e7c7..30a6b4b 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/wa-lang/mnbook +module github.com/wa-lang/wabook go 1.21 diff --git a/main.go b/main.go index c2093ba..5a85993 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,6 @@ // A tool for build markdown book package main -import "github.com/wa-lang/mnbook/pkg/cmd" +import "github.com/wa-lang/wabook/pkg/cmd" func main() { cmd.Main() } diff --git a/pkg/cmd/_example_book/book.toml b/pkg/cmd/_example_book/book.toml index 749d69d..e029b39 100644 --- a/pkg/cmd/_example_book/book.toml +++ b/pkg/cmd/_example_book/book.toml @@ -7,5 +7,5 @@ title = "book title" [output.html] git-repository-icon = "fa-github" -git-repository-url = "https://github.com/wa-lang/mnbook" -edit-url-template = "https://github.com/wa-lang/mnbook/edit/master/testdata/{path}" +git-repository-url = "https://github.com/wa-lang/wabook" +edit-url-template = "https://github.com/wa-lang/wabook/edit/master/testdata/{path}" diff --git a/pkg/cmd/cmd_build.go b/pkg/cmd/cmd_build.go index 9daa90d..52f7374 100644 --- a/pkg/cmd/cmd_build.go +++ b/pkg/cmd/cmd_build.go @@ -10,8 +10,8 @@ import ( cli "github.com/urfave/cli/v2" - "github.com/wa-lang/mnbook/pkg/mnbook" - "github.com/wa-lang/mnbook/pkg/render" + "github.com/wa-lang/wabook/pkg/render" + "github.com/wa-lang/wabook/pkg/wabook" ) var CmdBuild = &cli.Command{ @@ -32,7 +32,7 @@ var CmdBuild = &cli.Command{ } func BuildBook(path string) error { - book, err := mnbook.LoadBook(path) + book, err := wabook.LoadBook(path) if err != nil { return fmt.Errorf("LoadBook: %w", err) } diff --git a/pkg/cmd/main.go b/pkg/cmd/main.go index 13099f7..b4e2694 100644 --- a/pkg/cmd/main.go +++ b/pkg/cmd/main.go @@ -15,7 +15,7 @@ import ( func Main() { cliApp := cli.NewApp() - cliApp.Name = "mnbook" + cliApp.Name = "wabook" cliApp.Usage = "A tool for build mini markdown book" cliApp.HideHelpCommand = true cliApp.Version = func() string { @@ -28,7 +28,7 @@ func Main() { }() cliApp.CustomAppHelpTemplate = cli.AppHelpTemplate + - "\n See \"https://github.com/wa-lang/mnbook\" for more information.\n" + "\n See \"https://github.com/wa-lang/wabook\" for more information.\n" cliApp.Action = func(ctx *cli.Context) error { if ctx.NArg() > 0 { diff --git a/pkg/render/_static/.nojekyll b/pkg/render/_static/.nojekyll index d3ad6c2..399b53f 100644 --- a/pkg/render/_static/.nojekyll +++ b/pkg/render/_static/.nojekyll @@ -1 +1 @@ -This file makes sure that Github Pages doesn't process mnbook's output. +This file makes sure that Github Pages doesn't process wabook's output. diff --git a/pkg/render/_static/static/mnbook/FontAwesome/css/font-awesome.css b/pkg/render/_static/static/wabook/FontAwesome/css/font-awesome.css similarity index 100% rename from pkg/render/_static/static/mnbook/FontAwesome/css/font-awesome.css rename to pkg/render/_static/static/wabook/FontAwesome/css/font-awesome.css diff --git a/pkg/render/_static/static/mnbook/FontAwesome/fonts/FontAwesome.ttf b/pkg/render/_static/static/wabook/FontAwesome/fonts/FontAwesome.ttf similarity index 100% rename from pkg/render/_static/static/mnbook/FontAwesome/fonts/FontAwesome.ttf rename to pkg/render/_static/static/wabook/FontAwesome/fonts/FontAwesome.ttf diff --git a/pkg/render/_static/static/mnbook/FontAwesome/fonts/fontawesome-webfont.eot b/pkg/render/_static/static/wabook/FontAwesome/fonts/fontawesome-webfont.eot similarity index 100% rename from pkg/render/_static/static/mnbook/FontAwesome/fonts/fontawesome-webfont.eot rename to pkg/render/_static/static/wabook/FontAwesome/fonts/fontawesome-webfont.eot diff --git a/pkg/render/_static/static/mnbook/FontAwesome/fonts/fontawesome-webfont.svg b/pkg/render/_static/static/wabook/FontAwesome/fonts/fontawesome-webfont.svg similarity index 100% rename from pkg/render/_static/static/mnbook/FontAwesome/fonts/fontawesome-webfont.svg rename to pkg/render/_static/static/wabook/FontAwesome/fonts/fontawesome-webfont.svg diff --git a/pkg/render/_static/static/mnbook/FontAwesome/fonts/fontawesome-webfont.ttf b/pkg/render/_static/static/wabook/FontAwesome/fonts/fontawesome-webfont.ttf similarity index 100% rename from pkg/render/_static/static/mnbook/FontAwesome/fonts/fontawesome-webfont.ttf rename to pkg/render/_static/static/wabook/FontAwesome/fonts/fontawesome-webfont.ttf diff --git a/pkg/render/_static/static/mnbook/FontAwesome/fonts/fontawesome-webfont.woff b/pkg/render/_static/static/wabook/FontAwesome/fonts/fontawesome-webfont.woff similarity index 100% rename from pkg/render/_static/static/mnbook/FontAwesome/fonts/fontawesome-webfont.woff rename to pkg/render/_static/static/wabook/FontAwesome/fonts/fontawesome-webfont.woff diff --git a/pkg/render/_static/static/mnbook/FontAwesome/fonts/fontawesome-webfont.woff2 b/pkg/render/_static/static/wabook/FontAwesome/fonts/fontawesome-webfont.woff2 similarity index 100% rename from pkg/render/_static/static/mnbook/FontAwesome/fonts/fontawesome-webfont.woff2 rename to pkg/render/_static/static/wabook/FontAwesome/fonts/fontawesome-webfont.woff2 diff --git a/pkg/render/_static/static/mnbook/ayu-highlight.css b/pkg/render/_static/static/wabook/ayu-highlight.css similarity index 100% rename from pkg/render/_static/static/mnbook/ayu-highlight.css rename to pkg/render/_static/static/wabook/ayu-highlight.css diff --git a/pkg/render/_static/static/mnbook/book.js b/pkg/render/_static/static/wabook/book.js similarity index 98% rename from pkg/render/_static/static/mnbook/book.js rename to pkg/render/_static/static/wabook/book.js index 9a74c4a..0a01ff2 100644 --- a/pkg/render/_static/static/mnbook/book.js +++ b/pkg/render/_static/static/wabook/book.js @@ -232,7 +232,7 @@ function playground_text(playground) { function get_theme() { var theme; - try { theme = localStorage.getItem('mnbook-theme'); } catch (e) { } + try { theme = localStorage.getItem('wabook-theme'); } catch (e) { } if (theme === null || theme === undefined) { return default_theme; } else { @@ -274,7 +274,7 @@ function playground_text(playground) { var previousTheme = get_theme(); if (store) { - try { localStorage.setItem('mnbook-theme', theme); } catch (e) { } + try { localStorage.setItem('wabook-theme', theme); } catch (e) { } } html.classList.remove(previousTheme); @@ -313,7 +313,7 @@ function playground_text(playground) { } }); - // Should not be needed, but it works around an issue on macOS & iOS: https://github.com/rust-lang/mnbook/issues/628 + // Should not be needed, but it works around an issue on macOS & iOS: https://github.com/rust-lang/wabook/issues/628 document.addEventListener('click', function(e) { if (themePopup.style.display === 'block' && !themeToggleButton.contains(e.target) && !themePopup.contains(e.target)) { hideThemes(); @@ -371,7 +371,7 @@ function playground_text(playground) { }); sidebarToggleButton.setAttribute('aria-expanded', true); sidebar.setAttribute('aria-hidden', false); - try { localStorage.setItem('mnbook-sidebar', 'visible'); } catch (e) { } + try { localStorage.setItem('wabook-sidebar', 'visible'); } catch (e) { } } @@ -393,7 +393,7 @@ function playground_text(playground) { }); sidebarToggleButton.setAttribute('aria-expanded', false); sidebar.setAttribute('aria-hidden', true); - try { localStorage.setItem('mnbook-sidebar', 'hidden'); } catch (e) { } + try { localStorage.setItem('wabook-sidebar', 'hidden'); } catch (e) { } } // Toggle sidebar diff --git a/pkg/render/_static/static/mnbook/clipboard.min.js b/pkg/render/_static/static/wabook/clipboard.min.js similarity index 100% rename from pkg/render/_static/static/mnbook/clipboard.min.js rename to pkg/render/_static/static/wabook/clipboard.min.js diff --git a/pkg/render/_static/static/mnbook/cover-example.svg b/pkg/render/_static/static/wabook/cover-example.svg similarity index 93% rename from pkg/render/_static/static/mnbook/cover-example.svg rename to pkg/render/_static/static/wabook/cover-example.svg index a629c7d..bfa0dee 100644 --- a/pkg/render/_static/static/mnbook/cover-example.svg +++ b/pkg/render/_static/static/wabook/cover-example.svg @@ -1,6 +1,6 @@ diff --git a/pkg/render/_static/static/mnbook/css/chrome.css b/pkg/render/_static/static/wabook/css/chrome.css similarity index 100% rename from pkg/render/_static/static/mnbook/css/chrome.css rename to pkg/render/_static/static/wabook/css/chrome.css diff --git a/pkg/render/_static/static/mnbook/css/general.css b/pkg/render/_static/static/wabook/css/general.css similarity index 100% rename from pkg/render/_static/static/mnbook/css/general.css rename to pkg/render/_static/static/wabook/css/general.css diff --git a/pkg/render/_static/static/mnbook/css/print.css b/pkg/render/_static/static/wabook/css/print.css similarity index 100% rename from pkg/render/_static/static/mnbook/css/print.css rename to pkg/render/_static/static/wabook/css/print.css diff --git a/pkg/render/_static/static/mnbook/css/variables.css b/pkg/render/_static/static/wabook/css/variables.css similarity index 100% rename from pkg/render/_static/static/mnbook/css/variables.css rename to pkg/render/_static/static/wabook/css/variables.css diff --git a/pkg/render/_static/static/mnbook/fonts/OPEN-SANS-LICENSE.txt b/pkg/render/_static/static/wabook/fonts/OPEN-SANS-LICENSE.txt similarity index 100% rename from pkg/render/_static/static/mnbook/fonts/OPEN-SANS-LICENSE.txt rename to pkg/render/_static/static/wabook/fonts/OPEN-SANS-LICENSE.txt diff --git a/pkg/render/_static/static/mnbook/fonts/SOURCE-CODE-PRO-LICENSE.txt b/pkg/render/_static/static/wabook/fonts/SOURCE-CODE-PRO-LICENSE.txt similarity index 100% rename from pkg/render/_static/static/mnbook/fonts/SOURCE-CODE-PRO-LICENSE.txt rename to pkg/render/_static/static/wabook/fonts/SOURCE-CODE-PRO-LICENSE.txt diff --git a/pkg/render/_static/static/mnbook/fonts/fonts.css b/pkg/render/_static/static/wabook/fonts/fonts.css similarity index 100% rename from pkg/render/_static/static/mnbook/fonts/fonts.css rename to pkg/render/_static/static/wabook/fonts/fonts.css diff --git a/pkg/render/_static/static/mnbook/fonts/open-sans-v17-all-charsets-300.woff2 b/pkg/render/_static/static/wabook/fonts/open-sans-v17-all-charsets-300.woff2 similarity index 100% rename from pkg/render/_static/static/mnbook/fonts/open-sans-v17-all-charsets-300.woff2 rename to pkg/render/_static/static/wabook/fonts/open-sans-v17-all-charsets-300.woff2 diff --git a/pkg/render/_static/static/mnbook/fonts/open-sans-v17-all-charsets-300italic.woff2 b/pkg/render/_static/static/wabook/fonts/open-sans-v17-all-charsets-300italic.woff2 similarity index 100% rename from pkg/render/_static/static/mnbook/fonts/open-sans-v17-all-charsets-300italic.woff2 rename to pkg/render/_static/static/wabook/fonts/open-sans-v17-all-charsets-300italic.woff2 diff --git a/pkg/render/_static/static/mnbook/fonts/open-sans-v17-all-charsets-600.woff2 b/pkg/render/_static/static/wabook/fonts/open-sans-v17-all-charsets-600.woff2 similarity index 100% rename from pkg/render/_static/static/mnbook/fonts/open-sans-v17-all-charsets-600.woff2 rename to pkg/render/_static/static/wabook/fonts/open-sans-v17-all-charsets-600.woff2 diff --git a/pkg/render/_static/static/mnbook/fonts/open-sans-v17-all-charsets-600italic.woff2 b/pkg/render/_static/static/wabook/fonts/open-sans-v17-all-charsets-600italic.woff2 similarity index 100% rename from pkg/render/_static/static/mnbook/fonts/open-sans-v17-all-charsets-600italic.woff2 rename to pkg/render/_static/static/wabook/fonts/open-sans-v17-all-charsets-600italic.woff2 diff --git a/pkg/render/_static/static/mnbook/fonts/open-sans-v17-all-charsets-700.woff2 b/pkg/render/_static/static/wabook/fonts/open-sans-v17-all-charsets-700.woff2 similarity index 100% rename from pkg/render/_static/static/mnbook/fonts/open-sans-v17-all-charsets-700.woff2 rename to pkg/render/_static/static/wabook/fonts/open-sans-v17-all-charsets-700.woff2 diff --git a/pkg/render/_static/static/mnbook/fonts/open-sans-v17-all-charsets-700italic.woff2 b/pkg/render/_static/static/wabook/fonts/open-sans-v17-all-charsets-700italic.woff2 similarity index 100% rename from pkg/render/_static/static/mnbook/fonts/open-sans-v17-all-charsets-700italic.woff2 rename to pkg/render/_static/static/wabook/fonts/open-sans-v17-all-charsets-700italic.woff2 diff --git a/pkg/render/_static/static/mnbook/fonts/open-sans-v17-all-charsets-800.woff2 b/pkg/render/_static/static/wabook/fonts/open-sans-v17-all-charsets-800.woff2 similarity index 100% rename from pkg/render/_static/static/mnbook/fonts/open-sans-v17-all-charsets-800.woff2 rename to pkg/render/_static/static/wabook/fonts/open-sans-v17-all-charsets-800.woff2 diff --git a/pkg/render/_static/static/mnbook/fonts/open-sans-v17-all-charsets-800italic.woff2 b/pkg/render/_static/static/wabook/fonts/open-sans-v17-all-charsets-800italic.woff2 similarity index 100% rename from pkg/render/_static/static/mnbook/fonts/open-sans-v17-all-charsets-800italic.woff2 rename to pkg/render/_static/static/wabook/fonts/open-sans-v17-all-charsets-800italic.woff2 diff --git a/pkg/render/_static/static/mnbook/fonts/open-sans-v17-all-charsets-italic.woff2 b/pkg/render/_static/static/wabook/fonts/open-sans-v17-all-charsets-italic.woff2 similarity index 100% rename from pkg/render/_static/static/mnbook/fonts/open-sans-v17-all-charsets-italic.woff2 rename to pkg/render/_static/static/wabook/fonts/open-sans-v17-all-charsets-italic.woff2 diff --git a/pkg/render/_static/static/mnbook/fonts/open-sans-v17-all-charsets-regular.woff2 b/pkg/render/_static/static/wabook/fonts/open-sans-v17-all-charsets-regular.woff2 similarity index 100% rename from pkg/render/_static/static/mnbook/fonts/open-sans-v17-all-charsets-regular.woff2 rename to pkg/render/_static/static/wabook/fonts/open-sans-v17-all-charsets-regular.woff2 diff --git a/pkg/render/_static/static/mnbook/fonts/source-code-pro-v11-all-charsets-500.woff2 b/pkg/render/_static/static/wabook/fonts/source-code-pro-v11-all-charsets-500.woff2 similarity index 100% rename from pkg/render/_static/static/mnbook/fonts/source-code-pro-v11-all-charsets-500.woff2 rename to pkg/render/_static/static/wabook/fonts/source-code-pro-v11-all-charsets-500.woff2 diff --git a/pkg/render/_static/static/mnbook/highlight.css b/pkg/render/_static/static/wabook/highlight.css similarity index 100% rename from pkg/render/_static/static/mnbook/highlight.css rename to pkg/render/_static/static/wabook/highlight.css diff --git a/pkg/render/_static/static/mnbook/highlight.js b/pkg/render/_static/static/wabook/highlight.js similarity index 100% rename from pkg/render/_static/static/mnbook/highlight.js rename to pkg/render/_static/static/wabook/highlight.js diff --git a/pkg/render/_static/static/mnbook/mark.min.js b/pkg/render/_static/static/wabook/mark.min.js similarity index 100% rename from pkg/render/_static/static/mnbook/mark.min.js rename to pkg/render/_static/static/wabook/mark.min.js diff --git a/pkg/render/_static/static/mnbook/tomorrow-night.css b/pkg/render/_static/static/wabook/tomorrow-night.css similarity index 100% rename from pkg/render/_static/static/mnbook/tomorrow-night.css rename to pkg/render/_static/static/wabook/tomorrow-night.css diff --git a/pkg/render/api.go b/pkg/render/api.go index c30c756..d50e3a0 100644 --- a/pkg/render/api.go +++ b/pkg/render/api.go @@ -4,7 +4,7 @@ package render -import "github.com/wa-lang/mnbook/pkg/mnbook" +import "github.com/wa-lang/wabook/pkg/wabook" var DefaultBookIgnores = []string{ ".git", "_git", @@ -13,7 +13,7 @@ var DefaultBookIgnores = []string{ } type BookRendor struct { - Book *mnbook.Book + Book *wabook.Book BookInfo *BookInfo PageInfos []*PageInfo SidebarItems []*SidebarItem @@ -25,8 +25,8 @@ type BookInfo struct { GitRepoIcon string GitRepoUrl string EditUrlTemplate string - Custom mnbook.CustomConfig - Giscus mnbook.GiscusConfig + Custom wabook.CustomConfig + Giscus wabook.GiscusConfig } type PageInfo struct { @@ -67,6 +67,6 @@ func New() *BookRendor { } } -func (p *BookRendor) Run(book *mnbook.Book) error { +func (p *BookRendor) Run(book *wabook.Book) error { return p.run(book) } diff --git a/pkg/render/page.go b/pkg/render/page.go index c432a86..9e131b9 100644 --- a/pkg/render/page.go +++ b/pkg/render/page.go @@ -18,7 +18,7 @@ import ( "github.com/yuin/goldmark" "github.com/yuin/goldmark/extension" - "github.com/wa-lang/mnbook/pkg/mnbook" + "github.com/wa-lang/wabook/pkg/wabook" ) //go:embed tmpl/page.html @@ -33,7 +33,7 @@ var tmplAction string //go:embed tmpl/print.html var tmplPrintPage string -func (p *BookRendor) run(book *mnbook.Book) (err error) { +func (p *BookRendor) run(book *wabook.Book) (err error) { if err := p.init(book); err != nil { return err } @@ -60,7 +60,7 @@ func (p *BookRendor) run(book *mnbook.Book) (err error) { return nil } -func (p *BookRendor) init(book *mnbook.Book) (err error) { +func (p *BookRendor) init(book *wabook.Book) (err error) { defer func() { if r := recover(); r != nil { err = fmt.Errorf("%v", r) @@ -215,7 +215,7 @@ func (p *BookRendor) buildSidebarNumbers() []string { return numbers } -func (p *BookRendor) buildSidebarItem(idx int, item mnbook.SummaryItem, sidebarNumbers []string) *SidebarItem { +func (p *BookRendor) buildSidebarItem(idx int, item wabook.SummaryItem, sidebarNumbers []string) *SidebarItem { sidebarItem := new(SidebarItem) sidebarItem.Prefix = item.Prefix sidebarItem.Number = sidebarNumbers[idx] @@ -228,7 +228,7 @@ func (p *BookRendor) buildSidebarItem(idx int, item mnbook.SummaryItem, sidebarN return sidebarItem } -func (p *BookRendor) buildPageInfo(idx int, item mnbook.SummaryItem) *PageInfo { +func (p *BookRendor) buildPageInfo(idx int, item wabook.SummaryItem) *PageInfo { page := new(PageInfo) page.Index = idx @@ -252,11 +252,11 @@ func (p *BookRendor) buildPageInfo(idx int, item mnbook.SummaryItem) *PageInfo { return page } -func (p *BookRendor) getPageLocalAbsPath(item mnbook.SummaryItem) string { +func (p *BookRendor) getPageLocalAbsPath(item wabook.SummaryItem) string { return filepath.Clean(filepath.Join(p.Book.Root, p.Book.Info.Book.Src, item.Location)) } -func (p *BookRendor) getPageRelPath(item mnbook.SummaryItem) string { +func (p *BookRendor) getPageRelPath(item wabook.SummaryItem) string { absPath := filepath.Clean(filepath.Join(p.Book.Root, p.Book.Info.Book.Src, item.Location)) relPath, err := filepath.Rel(p.Book.Root, absPath) if err != nil { @@ -265,7 +265,7 @@ func (p *BookRendor) getPageRelPath(item mnbook.SummaryItem) string { return relPath } -func (p *BookRendor) getPageRootPath(item mnbook.SummaryItem) string { +func (p *BookRendor) getPageRootPath(item wabook.SummaryItem) string { absPath := filepath.Clean(filepath.Join(p.Book.Root, p.Book.Info.Book.Src, filepath.Dir(item.Location))) relPath, err := filepath.Rel(absPath, p.Book.Root) @@ -275,11 +275,11 @@ func (p *BookRendor) getPageRootPath(item mnbook.SummaryItem) string { return relPath } -func (p *BookRendor) getPageTitle(item mnbook.SummaryItem) string { +func (p *BookRendor) getPageTitle(item wabook.SummaryItem) string { return fmt.Sprintf("%s - %s", item.Name, p.BookInfo.Title) } -func (p *BookRendor) loadPageContent(item mnbook.SummaryItem) string { +func (p *BookRendor) loadPageContent(item wabook.SummaryItem) string { localAbsPath := p.getPageLocalAbsPath(item) if _, err := os.Lstat(localAbsPath); errors.Is(err, os.ErrNotExist) { var buf bytes.Buffer diff --git a/pkg/render/page_home.go b/pkg/render/page_home.go index 1139602..9100973 100644 --- a/pkg/render/page_home.go +++ b/pkg/render/page_home.go @@ -10,5 +10,5 @@ import ( ) func (p *BookRendor) renderHomepage() error { - return os.WriteFile(filepath.Join(p.Book.Root, "book", "index.html"), []byte("hello mnbook"), 0666) + return os.WriteFile(filepath.Join(p.Book.Root, "book", "index.html"), []byte("hello wabook"), 0666) } diff --git a/pkg/render/slide.go b/pkg/render/slide.go index c7ed67b..0e4e7b6 100644 --- a/pkg/render/slide.go +++ b/pkg/render/slide.go @@ -11,7 +11,7 @@ import ( "path/filepath" "strings" - "github.com/wa-lang/mnbook/pkg/present" + "github.com/wa-lang/wabook/pkg/present" ) func (p *BookRendor) renderAllTalkPages() error { diff --git a/pkg/render/static.go b/pkg/render/static.go index 1de73e4..5f54d8d 100644 --- a/pkg/render/static.go +++ b/pkg/render/static.go @@ -16,7 +16,7 @@ var _staticFS embed.FS func (p *BookRendor) renderStaticFile() error { if p.Book.Info.Giscus.Enabled { - dst := filepath.Join(p.Book.Root, "book/static/mnbook/giscus.js") + dst := filepath.Join(p.Book.Root, "book/static/wabook/giscus.js") js, err := p.genGiscusJs() if err != nil { panic(err) diff --git a/pkg/render/tmpl/page.html b/pkg/render/tmpl/page.html index f4d820c..01f2ad3 100644 --- a/pkg/render/tmpl/page.html +++ b/pkg/render/tmpl/page.html @@ -1,7 +1,7 @@ {{$page := .}} - + {{$page.Title}} @@ -12,17 +12,17 @@ - - - - + + + + - - + + - - - + + + @@ -36,15 +36,15 @@ @@ -52,7 +52,7 @@ - - - - + + + + + {{end}} diff --git a/pkg/render/tmpl/print.html b/pkg/render/tmpl/print.html index 6b6bcd1..e84cf61 100644 --- a/pkg/render/tmpl/print.html +++ b/pkg/render/tmpl/print.html @@ -1,7 +1,7 @@ {{$page := .}} - + {{$page.Title}} @@ -36,15 +36,15 @@ @@ -52,7 +52,7 @@