-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
184 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,18 @@ | ||
{ | ||
"scripts": { | ||
"zx-build": "zx ./scripts/build-wiki.mjs", | ||
"server": "npx cross-env TIDDLYWIKI_PLUGIN_PATH='./plugins' TIDDLYWIKI_THEME_PATH='./themes' TIDDLYWIKI_LANGUAGE_PATH='./languages' npx tiddlywiki +plugins/tiddlywiki/filesystem +plugins/tiddlywiki/tiddlyweb . --listen port=8080", | ||
"buildonline": "node -e \"require('./scripts/build').buildOnlineHTML('public-dist', 'index.html');\"", | ||
"buildoffline": "node -e \"require('./scripts/build').buildOfflineHTML('public-dist', 'offline.html');\"", | ||
"buildlibrary": "node -e \"require('./scripts/build').buildLibrary('[prefix[$:/]!prefix[$:/plugins/tiddlywiki/]!prefix[$:/themes/tiddlywiki/]!prefix[$:/languages/]!tag[$:/tags/PluginLibrary]!prefix[$:/plugins/kookma]]', 'public-dist/library');\"", | ||
"buildonline": "zx ./scripts/build-online.mjs", | ||
"buildoffline": "zx ./scripts/build-offline.mjs", | ||
"buildlibrary": "zx ./scripts/build-library.mjs", | ||
"clean": "rimraf public-dist" | ||
}, | ||
"dependencies": { | ||
"cross-env": "^7.0.3", | ||
"html-minifier-terser": "^7.2.0", | ||
"rimraf": "^5.0.5", | ||
"shx": "0.3.4", | ||
"tiddlywiki": "^5.3.3", | ||
"uglify-js": "^3.17.4", | ||
"workbox-cli": "7.0.0", | ||
"zx": "^8.0.1", | ||
"cross-spawn": "^7.0.3" | ||
"zx": "^8.0.1" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { fs, $ } from 'zx'; | ||
import path from 'path'; | ||
|
||
/** 项目路径 */ | ||
const repoFolder = path.join(path.dirname(__filename), '..'); | ||
const distDir = path.join(repoFolder, 'public-dist/library'); | ||
|
||
|
||
/** 设置环境变量,TW会同时在自己的源码路径以及环境变量定义的路径中寻找插件、主题和语言 | ||
* 如果不这样写,plugins、themes、languages和editions里的内容就无法被加载 | ||
*/ | ||
process.env.TIDDLYWIKI_PLUGIN_PATH = `${repoFolder}/plugins`; | ||
process.env.TIDDLYWIKI_THEME_PATH = `${repoFolder}/themes`; | ||
process.env.TIDDLYWIKI_LANGUAGE_PATH = `${repoFolder}/languages`; | ||
process.env.TIDDLYWIKI_EDITION_PATH = `${repoFolder}/editions`; | ||
|
||
|
||
const minify = true; | ||
// const pluginFilter = '[prefix[$:/plugins/]!prefix[$:/plugins/tiddlywiki/]!prefix[$:/languages/]!prefix[$:/themes/tiddlywiki/]!tag[$:/tags/PluginLibrary]]'; | ||
const pluginFilter = '[prefix[$:/]!prefix[$:/plugins/tiddlywiki/]!prefix[$:/themes/tiddlywiki/]!prefix[$:/languages/]!tag[$:/tags/PluginLibrary]!prefix[$:/plugins/kookma]]'; | ||
|
||
await $`npx tiddlywiki . \\ | ||
--output ${distDir} \\ | ||
--makelibrary $:/UpgradeLibrary \\ | ||
--savelibrarytiddlers $:/UpgradeLibrary ${pluginFilter} recipes/library/tiddlers/ $:/UpgradeLibrary/List \\ | ||
--savetiddler $:/UpgradeLibrary/List recipes/library/tiddlers.json \\ | ||
--rendertiddler $:/plugins/tiddlywiki/pluginlibrary/library.template.html index-raw.html text/plain \\ | ||
--deletetiddlers \'[[$:/UpgradeLibrary]] [[$:/UpgradeLibrary/List]]\' \\ | ||
`, { env: { TIDDLYWIKI_PLUGIN_PATH: path.resolve(distDir, '..', 'plugins') } }; | ||
|
||
// 最小化:HTML | ||
if (minify) { | ||
await $`npx html-minifier-terser -c scripts/html-minifier-terser.config.json -o ${distDir}/index.html ${distDir}/index-raw.html && rm ${distDir}/index-raw.html`; | ||
} else { | ||
await $`mv ${distDir}/index-raw.html ${distDir}/${htmlName}`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { fs, $ } from 'zx'; | ||
import path from 'path'; | ||
|
||
/** 项目路径 */ | ||
const repoFolder = path.join(path.dirname(__filename), '..'); | ||
const distDir = path.join(repoFolder, 'public-dist'); | ||
|
||
/** 设置环境变量,TW会同时在自己的源码路径以及环境变量定义的路径中寻找插件、主题和语言 | ||
* 如果不这样写,plugins、themes、languages和editions里的内容就无法被加载 | ||
*/ | ||
process.env.TIDDLYWIKI_PLUGIN_PATH = `${repoFolder}/plugins`; | ||
process.env.TIDDLYWIKI_THEME_PATH = `${repoFolder}/themes`; | ||
process.env.TIDDLYWIKI_LANGUAGE_PATH = `${repoFolder}/languages`; | ||
process.env.TIDDLYWIKI_EDITION_PATH = `${repoFolder}/editions`; | ||
|
||
const htmlName = 'offline.html'; | ||
const minify = true; | ||
const excludeFilter = '-[is[draft]]'; | ||
|
||
|
||
// 构建HTML | ||
await $`npx tiddlywiki . --output ${distDir} --build deletetiddlers \\ | ||
--rendertiddler $:/core/save/all index-raw.html text/plain "" publishFilter ${excludeFilter}`; | ||
|
||
// 最小化:HTML | ||
if (minify) { | ||
await $`npx html-minifier-terser -c scripts/html-minifier-terser.config.json -o ${distDir}/${htmlName} ${distDir}/index-raw.html && rm ${distDir}/index-raw.html`; | ||
} else { | ||
await $`mv ${distDir}/index-raw.html ${distDir}/${htmlName}`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { fs, $ } from 'zx'; | ||
import path from 'path'; | ||
|
||
/** 项目路径 */ | ||
const repoFolder = path.join(path.dirname(__filename), '..'); | ||
const distDir = path.join(repoFolder, 'public-dist'); | ||
async function getVersion() { | ||
const versionOutput = await $`npx tiddlywiki . --version`; | ||
const versionRegex = /^[0-9]+\.[0-9]+\.[0-9]+/; | ||
const match = versionOutput.stdout.match(versionRegex); | ||
|
||
if (match) { | ||
const version = match[0]; | ||
return version | ||
} else { | ||
throw new Error('无法解析版本号'); | ||
} | ||
} | ||
const tw_Version = await getVersion() | ||
/** 设置环境变量,TW会同时在自己的源码路径以及环境变量定义的路径中寻找插件、主题和语言 | ||
* 如果不这样写,plugins、themes、languages和editions里的内容就无法被加载 | ||
*/ | ||
process.env.TIDDLYWIKI_PLUGIN_PATH = `${repoFolder}/plugins`; | ||
process.env.TIDDLYWIKI_THEME_PATH = `${repoFolder}/themes`; | ||
process.env.TIDDLYWIKI_LANGUAGE_PATH = `${repoFolder}/languages`; | ||
process.env.TIDDLYWIKI_EDITION_PATH = `${repoFolder}/editions`; | ||
|
||
const htmlName = 'index.html'; | ||
const minify = true; | ||
const excludeFilter = '-[is[draft]]'; | ||
|
||
// 清空生成目标 | ||
await $`rm -rf ${distDir}`; | ||
|
||
// 静态资源拷贝 | ||
await $`cp -r public/ ${distDir} &> /dev/null`; | ||
await $`cp tiddlers/favicon.ico ${distDir}/favicon.ico &> /dev/null`; | ||
await $`cp vercel.json ${distDir}/vercel.json &> /dev/null`; | ||
|
||
// 构建HTML | ||
await $`npx tiddlywiki . \\ | ||
--output ${distDir} \\ | ||
--build deletetiddlers externalimages externaltext externaljs \\ | ||
--render $:/core/save/offline-external-js index-raw.html text/plain "" publishFilter ${excludeFilter} \\ | ||
`; | ||
|
||
// 最小化:核心JS和HTML | ||
// 最小化:核心JS和HTML | ||
const o_tw_core = `${distDir}/tiddlywikicore.js`; | ||
const r_tw_core = `${distDir}/tiddlywikicore-${tw_Version}.js`; | ||
if (minify) { | ||
await $`npx uglifyjs ${o_tw_core} -c -m --v8 --webkit --ie --output ${r_tw_core}`; | ||
await $`rm ${o_tw_core}`; | ||
await $`npx html-minifier-terser -c scripts/html-minifier-terser.config.json -o ${distDir}/${htmlName} ${distDir}/index-raw.html`; | ||
await $`rm ${distDir}/index-raw.html`; | ||
} else { | ||
await $`mv ${o_tw_core} ${r_tw_core}`; | ||
await $`mv ${distDir}/index-raw.html ${distDir}/${htmlName}`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
title: Hi 阿狸 | ||
type: text/vnd.tiddlywiki | ||
|
||
这是一只火狐狸 |
11 changes: 11 additions & 0 deletions
11
tiddlers/mConfigs/$__core_templates_canonical-uri-external-text.tid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
title: $:/core/templates/canonical-uri-external-text | ||
type: text/vnd.tiddlywiki | ||
|
||
<!-- | ||
|
||
This template is used to assign the ''_canonical_uri'' field to external text files. | ||
|
||
Change the `./text/` part to a different base URI. The URI can be relative or absolute. | ||
|
||
--> | ||
https://raw.githubusercontent.com/{{$:/GitHub/Repo}}/{{$:/GitHub/Branch}}/{{$:/config/linonetwo/github-external-image/tiddler-folder-name}}/<$view field="title" format="doubleurlencoded"/>.tid |
Oops, something went wrong.