├── web ├── .env.example ├── public │ ├── images │ │ └── favicon.ico │ ├── stylesheets │ │ └── style.css │ └── javascripts │ │ ├── addon.js │ │ ├── query.js │ │ └── zh_TW.js ├── views │ ├── error.pug │ ├── addon.pug │ ├── layout.pug │ └── index.pug ├── controllers │ ├── index.js │ └── translate.js ├── .gitignore ├── router.js ├── app.js └── bin │ └── www ├── browser_ext ├── .gitignore ├── shudu_intro.gif ├── icons │ ├── book_128.png │ └── book.svg ├── libs │ └── icon.css ├── Makefile ├── manifest-chrome.json ├── manifest-firefox.json ├── background.js ├── _locales │ ├── zh_TW │ │ └── messages.json │ └── zh │ │ └── messages.json ├── options.js ├── welcome.html ├── release_notes.html ├── shudu.js └── options.html ├── .jshintrc ├── .dockerignore ├── gui ├── FyneApp.toml ├── go.mod └── main.go ├── pm2.json ├── index.js ├── cli ├── go.mod ├── Makefile ├── main.go └── go.sum ├── Dockerfile ├── userscript.js ├── package.json ├── README.md ├── src ├── shudu.js ├── core.js └── pangu.js ├── .github └── workflows │ └── main.yml ├── dict └── dictionary_diff_v1.txt ├── .gitignore └── LICENSE /web/.env.example: -------------------------------------------------------------------------------- 1 | JSON_LIMIT=2mb 2 | -------------------------------------------------------------------------------- /browser_ext/.gitignore: -------------------------------------------------------------------------------- 1 | manifest.json 2 | *.zip 3 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "node": true, 3 | "esversion": 6 4 | } 5 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | **/node_modules 2 | *.tar.gz 3 | *.tar 4 | *.zip 5 | browser_ext 6 | .DS_Store 7 | -------------------------------------------------------------------------------- /browser_ext/shudu_intro.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JackKuo-tw/shudu/HEAD/browser_ext/shudu_intro.gif -------------------------------------------------------------------------------- /browser_ext/icons/book_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JackKuo-tw/shudu/HEAD/browser_ext/icons/book_128.png -------------------------------------------------------------------------------- /web/public/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JackKuo-tw/shudu/HEAD/web/public/images/favicon.ico -------------------------------------------------------------------------------- /web/views/error.pug: -------------------------------------------------------------------------------- 1 | extends layout 2 | 3 | block content 4 | h1= message 5 | h2= error.status 6 | pre #{error.stack} 7 | -------------------------------------------------------------------------------- /web/public/stylesheets/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding: 50px; 3 | font: 14px "Lucida Grande", Helvetica, Arial, sans-serif; 4 | } 5 | 6 | a { 7 | color: #00B7FF; 8 | } -------------------------------------------------------------------------------- /gui/FyneApp.toml: -------------------------------------------------------------------------------- 1 | Website = "https://shudu.jackkuo.org/" 2 | 3 | [Details] 4 | Icon = "Icon.png" 5 | Name = "Shudu" 6 | ID = "org.jackkuo.shudu.fyne" 7 | Version = "0.0.1" 8 | Build = 1 9 | -------------------------------------------------------------------------------- /web/controllers/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 3 | async index(req, res) { 4 | res.render('index'); 5 | }, 6 | 7 | async addon(req, res) { 8 | res.render('addon'); 9 | }, 10 | 11 | }; -------------------------------------------------------------------------------- /pm2.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "shudu", 3 | "script": "web/bin/www", 4 | "instances": "2", 5 | "env": { 6 | "NODE_ENV": "development" 7 | }, 8 | "env_production" : { 9 | "NODE_ENV": "production" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const shudu = require('./src/shudu.js'); 4 | 5 | var origin = shudu.getArgText(); // Get text for stdin 6 | shudu.convertText(origin).then(converted => { 7 | shudu.punctuate(converted).then((converted) => { 8 | console.log(`\n原始: ${origin}\n轉換: ${converted}`); 9 | }); 10 | }); 11 | -------------------------------------------------------------------------------- /web/.gitignore: -------------------------------------------------------------------------------- 1 | # OS X 2 | .DS_Store* 3 | Icon? 4 | ._* 5 | 6 | # Windows 7 | Thumbs.db 8 | ehthumbs.db 9 | Desktop.ini 10 | 11 | # Linux 12 | .directory 13 | *~ 14 | 15 | 16 | # npm 17 | node_modules 18 | package-lock.json 19 | *.log 20 | *.gz 21 | 22 | 23 | # Coveralls 24 | coverage 25 | 26 | # Benchmarking 27 | benchmarks/graphs 28 | 29 | -------------------------------------------------------------------------------- /web/router.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const cors = require('cors') 3 | const index = require('./controllers/index'); 4 | const translate = require('./controllers/translate'); 5 | 6 | const router = express.Router(); 7 | 8 | // index 9 | router.get('/', index.index); 10 | 11 | // addon 12 | router.get('/addon', index.addon); 13 | 14 | // translate 15 | router.post('/json', cors(), translate.translate); 16 | 17 | module.exports = router; -------------------------------------------------------------------------------- /cli/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/jackkuo-tw/shudu 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/liuzl/goutil v0.0.0-20210628080224-310b49755b5f 7 | github.com/longbridgeapp/opencc v0.1.0 8 | github.com/vinta/pangu v3.0.0+incompatible 9 | ) 10 | 11 | require ( 12 | github.com/eknkc/basex v1.0.1 // indirect 13 | github.com/liuzl/cedar-go v0.0.0-20170805034717-80a9c64b256d // indirect 14 | github.com/liuzl/da v0.0.0-20180704015230-14771aad5b1d // indirect 15 | ) 16 | -------------------------------------------------------------------------------- /cli/Makefile: -------------------------------------------------------------------------------- 1 | all: shudu 2 | 3 | shudu: main.go 4 | go build -o shudu 5 | cross: 6 | env GOOS=linux GOARCH=arm go build -o shudu_linux_arm 7 | env GOOS=linux GOARCH=arm64 go build -o shudu_linux_arm64 8 | env GOOS=linux GOARCH=amd64 go build -o shudu_linux_amd64 9 | env GOOS=darwin GOARCH=amd64 go build -o shudu_mac_amd64 10 | env GOOS=windows GOARCH=amd64 go build -o shudu_windows_amd64 11 | clean: 12 | rm shudu cli 13 | rm shudu_linux* shudu_mac* shudu_windows* 14 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:14-slim AS builder 2 | WORKDIR /root 3 | RUN apt-get update 4 | RUN apt-get install -y gcc g++ make python 5 | # Bundle APP files 6 | COPY . . 7 | # Install app dependencies 8 | ENV NPM_CONFIG_LOGLEVEL warn 9 | RUN npm install --production 10 | # Show current folder structure in logs 11 | RUN ls -al -R 12 | 13 | 14 | FROM node:14-slim AS executor 15 | WORKDIR /root 16 | RUN npm install pm2 -g 17 | COPY --from=builder /root ./ 18 | 19 | EXPOSE 3000 20 | CMD [ "pm2-runtime", "start", "pm2.json" ] 21 | -------------------------------------------------------------------------------- /web/views/addon.pug: -------------------------------------------------------------------------------- 1 | html 2 | head 3 | title="Shudu 舒讀" 4 | body 5 | div#detect 6 | h3 偵測中... 7 | div#not-support(style='display: none;') 8 | h1 很抱歉,此附加元件目前不支援您的瀏覽器 9 | p 10 | | 可以試試: 11 | a(href='https://addons.mozilla.org/zh-TW/firefox/addon/shudu/') Firefox 版本 12 | | 、 13 | a(href='https://chrome.google.com/webstore/detail/shudu-%E8%88%92%E8%AE%80/onbppgmmagapemlkoepbkcemidmgacpc') Chrome 版本 14 | script(src='/public/javascripts/addon.js') 15 | -------------------------------------------------------------------------------- /userscript.js: -------------------------------------------------------------------------------- 1 | a = document.getElementsByTagName('a') 2 | function trans(arr){ 3 | text = []; 4 | for(let i=0; i< arr.length;i++){ 5 | text.push(arr[i].text); 6 | } 7 | var data = {'origin': text, 'punctuation': 'fullWidth'}; 8 | fetch("https://shudu.jackkuo.org/json", { 9 | body: JSON.stringify(data), 10 | method: 'POST', 11 | mode: 'cors' 12 | } 13 | ).then((data) => 14 | { 15 | for(let i=0; i< arr.length;i++){ 16 | arr[i].text = data[i]; 17 | } 18 | }); 19 | }; 20 | trans(a); 21 | -------------------------------------------------------------------------------- /browser_ext/libs/icon.css: -------------------------------------------------------------------------------- 1 | /* fallback */ 2 | @font-face { 3 | font-family: 'Material Icons'; 4 | font-style: normal; 5 | font-weight: 400; 6 | src: url(https://fonts.gstatic.com/s/materialicons/v55/flUhRq6tzZclQEJ-Vdg-IuiaDsNcIhQ8tQ.woff2) format('woff2'); 7 | } 8 | 9 | .material-icons { 10 | font-family: 'Material Icons'; 11 | font-weight: normal; 12 | font-style: normal; 13 | font-size: 24px; 14 | line-height: 1; 15 | letter-spacing: normal; 16 | text-transform: none; 17 | display: inline-block; 18 | white-space: nowrap; 19 | word-wrap: normal; 20 | direction: ltr; 21 | -webkit-font-feature-settings: 'liga'; 22 | -webkit-font-smoothing: antialiased; 23 | } 24 | -------------------------------------------------------------------------------- /cli/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bufio" 5 | "flag" 6 | "fmt" 7 | "log" 8 | "os" 9 | 10 | "github.com/liuzl/goutil" 11 | "github.com/longbridgeapp/opencc" 12 | "github.com/vinta/pangu" 13 | ) 14 | 15 | var ( 16 | config = flag.String("config", "", "conversion config: s2twp, tw2sp") 17 | ) 18 | 19 | func main() { 20 | flag.Parse() 21 | if *config == "" { 22 | *config = "s2twp" 23 | } 24 | s2t, err := opencc.New(*config) 25 | if err != nil { 26 | log.Fatal(err) 27 | } 28 | 29 | var in = os.Stdin 30 | var out = os.Stdout 31 | 32 | br := bufio.NewReader(in) 33 | err = goutil.ForEachLine(br, func(line string) error { 34 | str, e := s2t.Convert(line) 35 | if e != nil { 36 | return e 37 | } 38 | str = pangu.SpacingText(str) 39 | fmt.Fprint(out, str+"\n") 40 | return nil 41 | }) 42 | 43 | } 44 | -------------------------------------------------------------------------------- /browser_ext/Makefile: -------------------------------------------------------------------------------- 1 | FIREFOX_VERSION := $(shell cat manifest-firefox.json | grep \"version\" | cut -d '"' -f4) 2 | CHROME_VERSION := $(shell cat manifest-chrome.json | grep \"version\" | cut -d '"' -f4) 3 | 4 | all: shudu_firefox.zip shudu_chrome.zip 5 | 6 | shudu_firefox.zip: 7 | cp manifest-firefox.json manifest.json 8 | zip -r shudu_firefox-$(FIREFOX_VERSION).zip _locales background.js browser_ext.zip icons libs manifest.json options.html options.js shudu.js release_notes.html shudu_intro.gif 9 | 10 | shudu_chrome.zip: 11 | cp manifest-chrome.json manifest.json 12 | zip -r shudu_chrome-$(CHROME_VERSION).zip _locales background.js browser_ext.zip icons libs manifest.json options.html options.js shudu.js release_notes.html shudu_intro.gif 13 | 14 | clean: 15 | rm -f shudu_firefox-$(FIREFOX_VERSION).zip shudu_chrome-$(CHROME_VERSION).zip 16 | -------------------------------------------------------------------------------- /browser_ext/manifest-chrome.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest_version": 2, 3 | "name": "Shudu 舒讀", 4 | "version": "1.3.1", 5 | "description": "__MSG_manifest_description__", 6 | "homepage_url": "https://shudu.jackkuo.org/", 7 | "default_locale": "zh_TW", 8 | 9 | "icons": { 10 | "128": "icons/book_128.png" 11 | }, 12 | 13 | "browser_action": { 14 | "default_title": "Shudu" 15 | }, 16 | 17 | "content_scripts": [{ 18 | "matches": [""], 19 | "exclude_matches": [ 20 | "*://docs.google.com/document/*" 21 | ], 22 | "js": ["shudu.js"], 23 | "run_at": "document_end" 24 | }], 25 | 26 | "background": { 27 | "scripts": ["background.js"] 28 | }, 29 | 30 | "options_page": "options.html", 31 | 32 | "permissions": [ 33 | "http://*/*", 34 | "https://*/*", 35 | "tabs", 36 | "activeTab", 37 | "storage" 38 | ] 39 | } 40 | -------------------------------------------------------------------------------- /web/app.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const path = require('path'); 3 | const cors = require('cors'); 4 | const indexRouter = require('./router'); 5 | const app = express(); 6 | require('dotenv').config(); 7 | 8 | // view engine setup 9 | app.set('views', path.join(__dirname, 'views')); 10 | app.set('view engine', 'pug'); 11 | 12 | app.use(express.json({ limit: (process.env.JSON_LIMIT || '2mb') })); 13 | app.use(express.urlencoded({ extended: false })); 14 | app.use('/public', express.static(path.join(__dirname, 'public'))); 15 | app.use(cors()); 16 | 17 | app.use('/', indexRouter); 18 | 19 | // catch 404 and forward to error handler 20 | app.use(function(req, res, next) { 21 | res.status(404).send('not found'); 22 | }); 23 | 24 | // error handler 25 | app.use(function(err, req, res, next) { 26 | // set locals, only providing error in development 27 | res.locals.message = err.message; 28 | res.locals.error = req.app.get('env') === 'development' ? err : {}; 29 | 30 | // render the error page 31 | res.status(err.status || 500); 32 | res.render('error'); 33 | }); 34 | 35 | module.exports = app -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "shudu", 3 | "version": "1.0.0", 4 | "description": "Read & write Chinese content in comfortable way.", 5 | "homepage": "https://github.com/JackKuo-tw/shudu#readme", 6 | "main": "index.js", 7 | "scripts": { 8 | "cli": "node index.js", 9 | "server": "node web/bin/www", 10 | "start": "node web/bin/www", 11 | "dev": "nodemon web/bin/www" 12 | }, 13 | "author": "JackKuo-tw", 14 | "license": "MIT", 15 | "repository": { 16 | "type": "git", 17 | "url": "https://github.com/JackKuo-tw/shudu.git" 18 | }, 19 | "dependencies": { 20 | "cors": "^2.8.5", 21 | "dotenv": "^8.2.0", 22 | "express": "^4.18.2", 23 | "opencc": "^1.1.2", 24 | "pug": "^3.0.1", 25 | "cookie-parser": "~1.4.4", 26 | "debug": "~2.6.9", 27 | "http-errors": "~1.6.3", 28 | "morgan": "~1.9.1" 29 | }, 30 | "jshintConfig": { 31 | "esversion": 6 32 | }, 33 | "devDependencies": { 34 | "eslint": "^6.8.0", 35 | "eslint-config-airbnb-base": "^14.1.0", 36 | "eslint-plugin-import": "^2.20.2" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Shudu 舒讀 2 | 3 | Shudu 為一個開源文字處理平台,目的是讓閱讀者能夠舒服的閱讀、輕鬆編寫文案。 4 | 5 | [網頁版](http://shudu.jackkuo.org/) 可以將「簡體字、中國用語」轉換成「繁體、台灣習慣用語」, 並且套用舒服的文案排版格式。(其他種轉換開發中) 6 | 7 | 此專案特別感謝 [pangu.js](https://github.com/vinta/pangu.js)、[OpenCC](https://github.com/BYVoid/OpenCC) 這兩個專案,沒有前輩們的貢獻不會有如此好用的工具。 8 | 9 | ## Installation 10 | 11 | ### From source code 12 | 13 | ```bash 14 | npm install 15 | ``` 16 | 17 | ### From Docker Hub 18 | 19 | Support x86_64, ARM, ARM64 20 | 21 | ```bash 22 | docker pull jackkuo/shudu 23 | docker run -it -d --name shudu -p 3000:3000 jackkuo/shudu 24 | ``` 25 | 26 | ## Usage 27 | 28 | ```shell 29 | $ node index.js 鼠标在手,光标跟我走! 30 | 31 | 原始: 鼠标在手,光标跟我走! 32 | 轉換: 滑鼠在手,游標跟我走! 33 | 34 | $ node index.js "泰勒絲(Taylor Swift)在20歲時即拿到Grammy Award" 35 | 36 | 原始: 泰勒絲(Taylor Swift)在20歲時即拿到Grammy Award 37 | 轉換: 泰勒絲 (Taylor Swift) 在 20 歲時即拿到 Grammy Award 38 | ``` 39 | 40 | ### go cli 41 | 42 | ```bash 43 | $ echo 執行個體 | ./shudu --config tw2sp 44 | 实例 45 | ``` 46 | 47 | 48 | ## TODO 49 | 50 | - [x] Web GUI Server 51 | - [x] JSON Server 52 | - [ ] Conversion Option 53 | - [ ] Fix Some Wrong Conversions 54 | - [x] Docker 55 | - [ ] Redis cache 56 | - [X] Firefox Addon 57 | - [X] Chrome Extension 58 | -------------------------------------------------------------------------------- /browser_ext/manifest-firefox.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest_version": 2, 3 | "name": "Shudu 舒讀", 4 | "version": "1.3.1", 5 | "description": "Shudu 為一個開源文字處理平台,目的是讓閱讀者能夠舒服的閱讀、編寫文案。", 6 | "homepage_url": "https://shudu.jackkuo.org/", 7 | "default_locale": "zh_TW", 8 | 9 | "applications": { 10 | "gecko": { 11 | "id": "{6eed3cfe-61f2-4057-a5e0-9898c1b668d8}", 12 | "strict_min_version": "60.0" 13 | } 14 | }, 15 | 16 | "icons": { 17 | "128": "icons/book_128.png" 18 | }, 19 | 20 | "browser_action": { 21 | "default_title": "Shudu" 22 | }, 23 | 24 | "content_scripts": [{ 25 | "matches": [""], 26 | "exclude_matches": [ 27 | "*://docs.google.com/document/*" 28 | ], 29 | "js": ["shudu.js"], 30 | "run_at": "document_end" 31 | }], 32 | 33 | "background": { 34 | "scripts": ["background.js"] 35 | }, 36 | 37 | "options_ui": { 38 | "page": "options.html" 39 | }, 40 | 41 | "permissions": [ 42 | "http://*/*", 43 | "https://*/*", 44 | "tabs", 45 | "activeTab", 46 | "storage" 47 | ] 48 | } 49 | -------------------------------------------------------------------------------- /web/controllers/translate.js: -------------------------------------------------------------------------------- 1 | const shudu = require('../../src/shudu'); 2 | 3 | function selectConf(conf) { 4 | switch (conf) { 5 | case 'tw2sp': 6 | return 'tw2sp.json'; 7 | default: 8 | return 's2twp.json'; 9 | } 10 | }; 11 | 12 | module.exports = { 13 | 14 | async translate(req, res) { 15 | const origin = req.body.origin; 16 | const punctuation = (req.body.punctuation === 'undefined') ? 'fullWidth' : req.body.punctuation; 17 | let convertConf = selectConf(req.body.translation || 's2twp'); 18 | 19 | if (origin == undefined || origin.length <= 0) return res.json({}); 20 | 21 | if (Array.isArray(origin)) { 22 | shudu.convertText(origin, convertConf).then(converted => { 23 | Promise.all(converted).then(r => { 24 | shudu.punctuate(r, punctuation).then((r) => { 25 | return Promise.all(r).then(r => { return res.json({ converted: r }); }); 26 | }); 27 | }); 28 | }); 29 | } else { 30 | shudu.convertText(origin, convertConf).then(converted => { 31 | shudu.punctuate(converted, punctuation).then((converted) => { 32 | return res.json({ converted }); 33 | }) 34 | }); 35 | }; 36 | }, 37 | 38 | }; 39 | -------------------------------------------------------------------------------- /src/shudu.js: -------------------------------------------------------------------------------- 1 | const OpenCC = require('opencc'); 2 | const pangu = require('./pangu'); 3 | 4 | module.exports = { 5 | getArgText() { 6 | const args = process.argv; 7 | if (args.length < 3) { 8 | console.log('\nUsage: node index.js 需要轉換的字串'); 9 | process.exit(); 10 | } 11 | 12 | return args[2]; 13 | }, 14 | 15 | async punctuate(origin, category = 'fullWidth') { 16 | // TODO: halfWidth 17 | let converted; 18 | if (category === 'fullWidth') { 19 | if (Array.isArray(origin)) { 20 | converted = origin.map(s => pangu.spacing(s)) 21 | } else { 22 | converted = pangu.spacing(origin); 23 | } 24 | 25 | } else if (category === 'default') { 26 | converted = origin; 27 | } else if (category === 'halfWidth') { 28 | converted = origin; 29 | } 30 | return converted; 31 | }, 32 | 33 | async convertText(text, conf = 's2twp.json') { 34 | // TODO: add other config 35 | // Load the default Simplified to Traditional (Taiwan Standard) config 36 | const openccInst = new OpenCC(conf); 37 | if (Array.isArray(text)) { 38 | converted = text.map(s => { return openccInst.convertPromise(s) }); 39 | } else { 40 | converted = openccInst.convertPromise(text); 41 | } 42 | return converted; 43 | }, 44 | }; -------------------------------------------------------------------------------- /browser_ext/background.js: -------------------------------------------------------------------------------- 1 | console.log(chrome.i18n.getMessage("background_running")) 2 | 3 | const browser = chrome 4 | const serverURL = "https://shudu.jackkuo.org/json"; 5 | 6 | browser.browserAction.onClicked.addListener(handler); 7 | browser.runtime.onMessage.addListener(sendText); 8 | 9 | function handler(tab) { 10 | browser.tabs.sendMessage(tab.id, 'shudu it'); 11 | } 12 | 13 | function sendText(msg) { 14 | const server = msg.server || serverURL; 15 | 16 | console.log('received data:', msg); 17 | chrome.tabs.query({ active: true, currentWindow: true }, function(tabs) { 18 | const tab = tabs[0]; 19 | 20 | fetch(server, { 21 | method: 'POST', 22 | headers: { 'Content-Type': 'application/json' }, 23 | body: JSON.stringify(msg.payload), 24 | }).then(res => { 25 | return res.json(); 26 | }) 27 | .then(resp => { 28 | console.log('resp:', resp); 29 | browser.tabs.sendMessage(tab.id, { status: 'success', resp }); 30 | }) 31 | .catch(err => { 32 | console.log('error:', err); 33 | browser.tabs.sendMessage(tab.id, { status: 'failure', resp: err.toString() }); 34 | }) 35 | }); 36 | } 37 | 38 | // release notes 39 | const version = 1.3; 40 | chrome.storage.sync.get({ 41 | whats_new: 'v0', 42 | }, function(item) { 43 | if (item.whats_new !== version) { 44 | chrome.tabs.create({ url: "release_notes.html" }); 45 | chrome.storage.sync.set({ whats_new: version }); 46 | } 47 | }); -------------------------------------------------------------------------------- /browser_ext/_locales/zh_TW/messages.json: -------------------------------------------------------------------------------- 1 | { 2 | "background_running": { 3 | "message": "background 正在執行中...", 4 | "description": "Indicate the background script is running" 5 | }, 6 | "manifest_description": { 7 | "message": "Shudu 為一個開源文字處理平台,目的是讓閱讀者能夠舒服的閱讀、編寫文案。" 8 | }, 9 | "options_title": { 10 | "message": "舒讀設定" 11 | }, 12 | "options_basic_setting": { 13 | "message": "基本設定" 14 | }, 15 | "options_traditional_chinese": { 16 | "message": "繁體中文" 17 | }, 18 | "options_simplified_chinese": { 19 | "message": "簡體中文" 20 | }, 21 | "options_preferred_language": { 22 | "message": "習慣語言" 23 | }, 24 | "options_comfortable": { 25 | "message": "舒適" 26 | }, 27 | "options_the_same": { 28 | "message": "維持原樣" 29 | }, 30 | "options_punctuation": { 31 | "message": "標點符號" 32 | }, 33 | "options_custom_server": { 34 | "message": "自訂轉換伺服器" 35 | }, 36 | "options_custom_server_description": { 37 | "message": "您可以自行指定其他轉換伺服器來進行客製化,或是避免資安疑慮" 38 | }, 39 | "options_server_url": { 40 | "message": "伺服器網址" 41 | }, 42 | "options_auto_translate": { 43 | "message": "頁面自動轉換" 44 | }, 45 | "options_needed_auto_tran_url": { 46 | "message": "需要自動轉換網址" 47 | }, 48 | "options_needed_auto_tran_description": { 49 | "message": "假設為 https://aaa.com/ 則為其底下所有網頁如 https://aaa.com/bbb 都會自動轉換" 50 | }, 51 | "shudu_settings": { 52 | "message": "舒讀設定" 53 | }, 54 | "release_notes": { 55 | "message": "舒讀版本資訊" 56 | } 57 | } -------------------------------------------------------------------------------- /browser_ext/_locales/zh/messages.json: -------------------------------------------------------------------------------- 1 | { 2 | "background_running": { 3 | "message": "background 正在运行中...", 4 | "description": "Indicate the background script is running" 5 | }, 6 | "manifest_description": { 7 | "message": "Shudu 为一个开源文本处理平台,目的是让阅读者能够舒服的阅读、编写文案。" 8 | }, 9 | "options_title": { 10 | "message": "舒读设置" 11 | }, 12 | "options_basic_setting": { 13 | "message": "基本设置" 14 | }, 15 | "options_traditional_chinese": { 16 | "message": "繁体中文" 17 | }, 18 | "options_simplified_chinese": { 19 | "message": "简体中文" 20 | }, 21 | "options_preferred_language": { 22 | "message": "习惯语言" 23 | }, 24 | "options_comfortable": { 25 | "message": "舒适" 26 | }, 27 | "options_the_same": { 28 | "message": "维持原样" 29 | }, 30 | "options_punctuation": { 31 | "message": "标点符号" 32 | }, 33 | "options_custom_server": { 34 | "message": "自订转换服务器" 35 | }, 36 | "options_custom_server_description": { 37 | "message": "您可以自行指定其他转换服务器来进行客制化,或是避免资安疑虑" 38 | }, 39 | "options_server_url": { 40 | "message": "服务器网址" 41 | }, 42 | "options_auto_translate": { 43 | "message": "页面自动转换" 44 | }, 45 | "options_needed_auto_tran_url": { 46 | "message": "需要自动转换网址" 47 | }, 48 | "options_needed_auto_tran_description": { 49 | "message": "假设为 https://aaa.com/ 则为其底下所有网页如 https://aaa.com/bbb 都会自动转换" 50 | }, 51 | "shudu_settings": { 52 | "message": "舒读设置" 53 | }, 54 | "release_notes": { 55 | "message": "舒读 Shudu 版本信息" 56 | } 57 | } -------------------------------------------------------------------------------- /web/public/javascripts/addon.js: -------------------------------------------------------------------------------- 1 | detectBrowser() 2 | 3 | function detectBrowser() { 4 | // Opera 8.0+ 5 | var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0; 6 | 7 | // Firefox 1.0+ 8 | var isFirefox = typeof InstallTrigger !== 'undefined'; 9 | 10 | // Safari 3.0+ "[object HTMLElementConstructor]" 11 | var isSafari = /constructor/i.test(window.HTMLElement) || (function(p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || (typeof safari !== 'undefined' && safari.pushNotification)); 12 | 13 | // Internet Explorer 6-11 14 | var isIE = /*@cc_on!@*/ false || !!document.documentMode; 15 | 16 | // Edge 20+ 17 | var isEdge = !isIE && !!window.StyleMedia; 18 | 19 | // Chrome 1 - 79 20 | var isChrome = !!window.chrome && (!!window.chrome.webstore || !!window.chrome.runtime); 21 | 22 | // Edge (based on chromium) detection 23 | var isEdgeChromium = !!window.chrome && (navigator.userAgent.indexOf("Edg") != -1); 24 | 25 | // Blink engine detection 26 | var isBlink = (isChrome || isOpera) && !!window.CSS; 27 | 28 | if (isFirefox) { 29 | loading('https://addons.mozilla.org/zh-TW/firefox/addon/shudu/'); 30 | } else if (isChrome || isEdgeChromium) { 31 | loading('https://chrome.google.com/webstore/detail/shudu-%E8%88%92%E8%AE%80/onbppgmmagapemlkoepbkcemidmgacpc'); 32 | } else { 33 | document.getElementById('detect').style.display = 'none'; 34 | document.getElementById('not-support').style.display = ''; 35 | } 36 | } 37 | 38 | function loading(url) { 39 | document.body.innerHTML = "頁面轉址中,請稍候..."; 40 | window.location.href = url; 41 | } 42 | -------------------------------------------------------------------------------- /web/views/layout.pug: -------------------------------------------------------------------------------- 1 | doctype html 2 | html 3 | head 4 | meta(name='viewport' content='width=device-width, initial-scale=1, shrink-to-fit=no') 5 | title="Shudu 舒讀" 6 | // Google tag (gtag.js) 7 | script(async='' src='https://www.googletagmanager.com/gtag/js?id=G-XNL8RVH47B') 8 | script. 9 | window.dataLayer = window.dataLayer || []; 10 | function gtag(){dataLayer.push(arguments);} 11 | gtag('js', new Date()); 12 | gtag('config', 'G-XNL8RVH47B'); 13 | 14 | script(async='' src='https://www.googletagmanager.com/gtag/js?id=UA-177543388-1') 15 | script. 16 | window.dataLayer = window.dataLayer || []; 17 | function gtag(){dataLayer.push(arguments);} 18 | gtag('js', new Date()); 19 | gtag('config', 'UA-177543388-1'); 20 | link(rel='icon' href='/public/images/favicon.ico') 21 | link(rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.0/css/bootstrap.min.css", integrity="sha384-SI27wrMjH3ZZ89r4o+fGIJtnzkAnFs3E4qz9DIYioCQ5l9Rd/7UAa8DHcaL8jkWt", crossorigin="anonymous") 22 | link(rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/open-iconic/1.1.1/font/css/open-iconic-bootstrap.min.css") 23 | body 24 | block content 25 | block javascripts 26 | script(src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js') 27 | script(src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.0/js/bootstrap.min.js", integrity="sha384-3qaqj0lc6sV/qpzrc1N5DC6i1VRn/HyX4qdPaiEFbn54VjQBEU341pvjz7Dv3n6P", crossorigin="anonymous") 28 | script(src='https://cdnjs.cloudflare.com/ajax/libs/tinymce/4.5.12/tinymce.min.js') 29 | script(src='https://shudu.jackkuo.org/public/javascripts/zh_TW.js') 30 | script(src='/public/javascripts/query.js') 31 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | # This is a basic workflow to help you get started with Actions 2 | 3 | name: CI to Docker Hub 4 | 5 | # Controls when the workflow will run 6 | on: 7 | # Triggers the workflow on push or pull request events but only for the master branch 8 | push: 9 | branches: [ master ] 10 | 11 | # Allows you to run this workflow manually from the Actions tab 12 | workflow_dispatch: 13 | 14 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 15 | jobs: 16 | # This workflow contains a single job called "build" 17 | build: 18 | # The type of runner that the job will run on 19 | runs-on: ubuntu-latest 20 | 21 | # Steps represent a sequence of tasks that will be executed as part of the job 22 | steps: 23 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 24 | - name: Check Out Repo 25 | uses: actions/checkout@v2 26 | 27 | - name: Login to Docker Hub 28 | uses: docker/login-action@v1 29 | with: 30 | username: ${{ secrets.DOCKER_HUB_USERNAME }} 31 | password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} 32 | 33 | - name: Set up QEMU 34 | uses: docker/setup-qemu-action@v1 35 | 36 | - name: Set up Docker Buildx 37 | id: buildx 38 | uses: docker/setup-buildx-action@v1 39 | 40 | - name: Build and push 41 | id: docker_build 42 | uses: docker/build-push-action@v2 43 | with: 44 | context: ./ 45 | platforms: linux/amd64,linux/arm64/v8,linux/arm/v7 46 | file: ./Dockerfile 47 | push: true 48 | tags: ${{ secrets.DOCKER_HUB_USERNAME }}/shudu:latest 49 | 50 | - name: Image digest 51 | run: echo ${{ steps.docker_build.outputs.digest }} 52 | -------------------------------------------------------------------------------- /web/bin/www: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /** 4 | * Module dependencies. 5 | */ 6 | 7 | const debug = require('debug')('web:server'); 8 | const http = require('http'); 9 | const app = require('../app'); 10 | 11 | /** 12 | * Get port from environment and store in Express. 13 | */ 14 | 15 | const port = normalizePort(process.env.PORT || '3000'); 16 | app.set('port', port); 17 | 18 | /** 19 | * Create HTTP server. 20 | */ 21 | 22 | const server = http.createServer(app); 23 | 24 | /** 25 | * Listen on provided port, on all network interfaces. 26 | */ 27 | 28 | server.listen(port); 29 | server.on('error', onError); 30 | server.on('listening', onListening); 31 | 32 | /** 33 | * Normalize a port into a number, string, or false. 34 | */ 35 | 36 | function normalizePort(val) { 37 | const port = parseInt(val, 10); 38 | 39 | if (isNaN(port)) { 40 | // named pipe 41 | return val; 42 | } 43 | 44 | if (port >= 0) { 45 | // port number 46 | return port; 47 | } 48 | 49 | return false; 50 | } 51 | 52 | /** 53 | * Event listener for HTTP server "error" event. 54 | */ 55 | 56 | function onError(error) { 57 | if (error.syscall !== 'listen') { 58 | throw error; 59 | } 60 | 61 | var bind = typeof port === 'string' ? 62 | 'Pipe ' + port : 63 | 'Port ' + port; 64 | 65 | // handle specific listen errors with friendly messages 66 | switch (error.code) { 67 | case 'EACCES': 68 | console.error(bind + ' requires elevated privileges'); 69 | process.exit(1); 70 | break; 71 | case 'EADDRINUSE': 72 | console.error(bind + ' is already in use'); 73 | process.exit(1); 74 | break; 75 | default: 76 | throw error; 77 | } 78 | } 79 | 80 | /** 81 | * Event listener for HTTP server "listening" event. 82 | */ 83 | 84 | function onListening() { 85 | const addr = server.address(); 86 | const bind = typeof addr === 'string' ? 87 | 'pipe ' + addr : 88 | 'port ' + addr.port; 89 | debug('Listening on ' + bind); 90 | } -------------------------------------------------------------------------------- /gui/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/jackkuo-tw/shudu 2 | 3 | go 1.17 4 | 5 | require ( 6 | fyne.io/fyne/v2 v2.3.1 7 | github.com/flopp/go-findfont v0.1.0 8 | github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 9 | github.com/longbridgeapp/opencc v0.1.0 10 | github.com/vinta/pangu v3.0.0+incompatible 11 | ) 12 | 13 | require ( 14 | fyne.io/systray v1.10.1-0.20230207085535-4a244dbb9d03 // indirect 15 | github.com/benoitkugler/textlayout v0.3.0 // indirect 16 | github.com/davecgh/go-spew v1.1.1 // indirect 17 | github.com/fredbi/uri v0.1.0 // indirect 18 | github.com/fsnotify/fsnotify v1.5.4 // indirect 19 | github.com/fyne-io/gl-js v0.0.0-20220119005834-d2da28d9ccfe // indirect 20 | github.com/fyne-io/glfw-js v0.0.0-20220120001248-ee7290d23504 // indirect 21 | github.com/fyne-io/image v0.0.0-20220602074514-4956b0afb3d2 // indirect 22 | github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 // indirect 23 | github.com/go-gl/glfw/v3.3/glfw v0.0.0-20221017161538-93cebf72946b // indirect 24 | github.com/go-text/typesetting v0.0.0-20221212183139-1eb938670a1f // indirect 25 | github.com/godbus/dbus/v5 v5.1.0 // indirect 26 | github.com/goki/freetype v0.0.0-20220119013949-7a161fd3728c // indirect 27 | github.com/gopherjs/gopherjs v1.17.2 // indirect 28 | github.com/jsummers/gobmp v0.0.0-20151104160322-e2ba15ffa76e // indirect 29 | github.com/liuzl/cedar-go v0.0.0-20170805034717-80a9c64b256d // indirect 30 | github.com/liuzl/da v0.0.0-20180704015230-14771aad5b1d // indirect 31 | github.com/pmezard/go-difflib v1.0.0 // indirect 32 | github.com/srwiley/oksvg v0.0.0-20220731023508-a61f04f16b76 // indirect 33 | github.com/srwiley/rasterx v0.0.0-20210519020934-456a8d69b780 // indirect 34 | github.com/stretchr/testify v1.8.0 // indirect 35 | github.com/tevino/abool v1.2.0 // indirect 36 | github.com/yuin/goldmark v1.4.0 // indirect 37 | golang.org/x/image v0.0.0-20220601225756-64ec528b34cd // indirect 38 | golang.org/x/mobile v0.0.0-20211207041440-4e6c2922fdee // indirect 39 | golang.org/x/net v0.7.0 // indirect 40 | golang.org/x/sys v0.5.0 // indirect 41 | golang.org/x/text v0.7.0 // indirect 42 | gopkg.in/yaml.v3 v3.0.1 // indirect 43 | honnef.co/go/js/dom v0.0.0-20210725211120-f030747120f2 // indirect 44 | ) 45 | -------------------------------------------------------------------------------- /dict/dictionary_diff_v1.txt: -------------------------------------------------------------------------------- 1 | diff --git a/dictionary/STPhrases.txt b/dictionary/STPhrases.txt 2 | index 5a57bdc..1fb9438 100644 3 | --- a/dictionary/STPhrases.txt 4 | +++ b/dictionary/STPhrases.txt 5 | @@ -1,3 +1,4 @@ 6 | +实例 執行個體 7 | 㓦划 㓦劃 8 | 一丝不挂 一絲不掛 9 | 一了心愿 一了心願 10 | @@ -49041,4 +49042,4 @@ 11 | 龚照胜 龔照勝 12 | 龚胜 龔勝 13 | 龟卜 龜卜 14 | -龟鉴 龜鑑 15 | +龟鉴 龜鑑 16 | \ No newline at end of file 17 | diff --git a/dictionary/TSPhrases.txt b/dictionary/TSPhrases.txt 18 | index dee9754..567e41e 100644 19 | --- a/dictionary/TSPhrases.txt 20 | +++ b/dictionary/TSPhrases.txt 21 | @@ -1,3 +1,4 @@ 22 | +執行個體 实例 23 | 一目瞭然 一目了然 24 | 上鍊 上链 25 | 不瞭解 不了解 26 | @@ -273,4 +274,4 @@ 27 | 顧藉 顾借 28 | 麼些族 麽些族 29 | 黄鍾公 黄锺公 30 | -龍鍾 龙钟 龙锺 31 | +龍鍾 龙钟 龙锺 32 | \ No newline at end of file 33 | diff --git a/dictionary/TWPhrases.txt b/dictionary/TWPhrases.txt 34 | index 36a3aa7..9c20327 100644 35 | --- a/dictionary/TWPhrases.txt 36 | +++ b/dictionary/TWPhrases.txt 37 | @@ -1,3 +1,4 @@ 38 | +實例 執行個體 39 | PN結 PN接面 40 | SQL注入 SQL隱碼攻擊 41 | SQL注入攻擊 SQL隱碼攻擊 42 | @@ -149,7 +150,6 @@ U盤 隨身碟 43 | 宏內核 單核心 44 | 寄存器 暫存器 45 | 密鑰 金鑰 46 | -實例 例項 實例 47 | 實模式 真實模式 48 | 審覈 稽覈 49 | 寫保護 防寫 50 | @@ -363,7 +363,7 @@ U盤 隨身碟 51 | 縮略圖 縮圖 52 | 縮進 縮排 53 | 總線 匯流排 54 | -缺省 預設 55 | +默認 預設 56 | 老撾 寮國 57 | 聖基茨和尼維斯 聖克里斯多福及尼維斯 58 | 聖文森特和格林納丁斯 聖文森及格瑞那丁 59 | diff --git a/dictionary/TWPhrasesRev.txt b/dictionary/TWPhrasesRev.txt 60 | index ca599aa..4f62738 100644 61 | --- a/dictionary/TWPhrasesRev.txt 62 | +++ b/dictionary/TWPhrasesRev.txt 63 | @@ -1,3 +1,4 @@ 64 | +執行個體 實例 65 | PN接面 PN結 66 | SQL隱碼攻擊 SQL注入 SQL注入攻擊 67 | 三極體 三極管 68 | @@ -31,7 +32,6 @@ SQL隱碼攻擊 SQL注入 SQL注入攻擊 69 | 使用者 用戶 70 | 使用者名稱 用戶名 71 | 來電轉駁 呼叫轉移 72 | -例項 實例 73 | 信號 信號 74 | 偵錯 調試 75 | 偵錯程式 調試器 76 | @@ -149,7 +149,7 @@ SQL隱碼攻擊 SQL注入 SQL注入攻擊 77 | 宕機 死機 78 | 定址 尋址 79 | 宣告 聲明 80 | -實例 實例 81 | +執行個體 實例 82 | 實體地址 物理地址 83 | 實體記憶體 物理內存 84 | 寬頻 寬帶 85 | @@ -496,7 +496,7 @@ SQL隱碼攻擊 SQL注入 SQL注入攻擊 86 | 音訊 音頻 87 | 頁尾 頁腳 88 | 頁首 頁眉 89 | -預設 缺省 默認 90 | +預設 默認 91 | 預設值 默認值 92 | 頻寬 帶寬 93 | 類别範本 類模板 94 | diff --git a/dictionary/TWVariantsRev.txt b/dictionary/TWVariantsRev.txt 95 | index f225aa7..b4a7591 100644 96 | --- a/dictionary/TWVariantsRev.txt 97 | +++ b/dictionary/TWVariantsRev.txt 98 | @@ -1,4 +1,4 @@ 99 | -么 幺 100 | +么 么 101 | 偽 僞 102 | 參 蔘 103 | 吃 喫 104 | -------------------------------------------------------------------------------- /gui/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | "fyne.io/fyne/v2" 6 | "fyne.io/fyne/v2/app" 7 | "fyne.io/fyne/v2/container" 8 | "fyne.io/fyne/v2/widget" 9 | "fyne.io/fyne/v2/dialog" 10 | "os" 11 | "fmt" 12 | "github.com/flopp/go-findfont" 13 | "github.com/golang/freetype/truetype" 14 | 15 | "github.com/longbridgeapp/opencc" 16 | "github.com/vinta/pangu" 17 | ) 18 | 19 | func init() { 20 | targetFont := "Arial Unicode.ttf" 21 | fontPath, err := findfont.Find(targetFont) 22 | if err != nil { 23 | panic(err) 24 | } 25 | fmt.Printf("Found '%s' in '%s'\n", targetFont, fontPath) 26 | 27 | fontData, err := os.ReadFile(fontPath) 28 | if err != nil { 29 | log.Fatal(err) 30 | panic(err) 31 | } 32 | _, err = truetype.Parse(fontData) 33 | if err != nil { 34 | log.Fatal(err) 35 | panic(err) 36 | } 37 | os.Setenv("FYNE_FONT", fontPath) 38 | } 39 | 40 | func convert(str string, config string) (string, error){ 41 | s2t, err := opencc.New(config) 42 | if err != nil { 43 | log.Fatal(err) 44 | return "", err 45 | } 46 | 47 | str, err2 := s2t.Convert(str) 48 | if err2 != nil { 49 | log.Fatal(err2) 50 | return "", err2 51 | } 52 | str = pangu.SpacingText(str) 53 | log.Println("converted result: ", str) 54 | return str, nil 55 | } 56 | 57 | func main() { 58 | shuduApp := app.New() 59 | mainWindow := shuduApp.NewWindow("Shudu 舒讀") 60 | mainWindow.Resize(fyne.NewSize(800, 600)); 61 | mainWindow.CenterOnScreen() 62 | 63 | inputEntry := widget.NewMultiLineEntry() 64 | inputEntry.SetPlaceHolder("請輸入欲轉換文字...") 65 | inputEntry.SetMinRowsVisible(20) 66 | 67 | s2twpStr := "繁體台灣用語" 68 | tw2spStr := "簡體中國用語" 69 | currentConfig := s2twpStr 70 | 71 | configRadioGroup := widget.NewRadioGroup([]string{s2twpStr, tw2spStr}, func(value string) { 72 | log.Println("Config set to: ", value) 73 | if value == s2twpStr { 74 | currentConfig = "s2twp" 75 | } else { 76 | currentConfig = "tw2sp" 77 | } 78 | }) 79 | configRadioGroup.SetSelected(s2twpStr) 80 | 81 | content := container.NewVBox(inputEntry, configRadioGroup, widget.NewButton("轉換", func() { 82 | log.Println("input text: ", inputEntry.Text) 83 | convertedStr, err := convert(inputEntry.Text, currentConfig) 84 | if err != nil { 85 | dialog.ShowError(err, mainWindow) 86 | } else { 87 | inputEntry.SetText(convertedStr) 88 | } 89 | })) 90 | 91 | mainWindow.SetContent(content) 92 | mainWindow.ShowAndRun() 93 | } 94 | -------------------------------------------------------------------------------- /web/views/index.pug: -------------------------------------------------------------------------------- 1 | extends layout 2 | 3 | block content 4 | .container 5 | .row 6 | h1= "Shudu 舒讀" 7 | a#addon(href='/addon', target="_blank" class='text badge badge-light float-right', style='color: #03a5fc;') 安裝擴充套件 8 | span.oi.oi-puzzle-piece 9 | .row 10 | p(class="p-3 mb-2 bg-success text-white") 11 | | 此網頁可以將「簡體字中國用語」與「繁體台灣用語」互相轉換, 12 | | 並且套用舒服的文案排版格式。(其他種轉換開發中...) 13 | 14 | .row 15 | #convert 16 | .form-group 17 | textarea#origin(name="origin",rows=10, class="form-control", placeholder="請輸入欲轉換之文字...") 18 | .form-row 19 | .form-group.col-sm-4 20 | label 標點符號: 21 | select#punctuation(name="punctuation", class="form-control") 22 | option(value='fullWidth') 舒適 23 | //- option(value='halfWidth') 半形 (UI 中使用,該功能尚未實作) 24 | option(value='default') 維持原樣 25 | .form-group.col-sm-4 26 | label 轉換成: 27 | select#translation(name="translation", class="form-control") 28 | option(value='s2twp') 繁體台灣用語 29 | option(value='tw2sp') 簡體中國用語 30 | .form-group.col-sm-4 31 | label   32 | button(type='submit', value='submit', class='btn btn-info form-control') 轉換 33 | hr 34 | br 35 | .container 36 | h3 範例 37 | .row.alert.alert-info 38 | .col-md-8 39 | p 原文: 40 | b 鼠标在手,光标跟我走! 41 | p 轉換: 42 | b 滑鼠在手,游標跟我走! 43 | .col-md-8 44 | ul 45 | li ❗️ 簡體 👉 繁體 46 | li ❗️ 中國用語 👉 台灣用語 47 | li ❗️ 半形標點 👉 全形標點 48 | .row.alert.alert-warning 49 | .col-md-8 50 | p 原文: 51 | b 泰勒絲(Taylor Swift)在20歲時即拿到Grammy Award 52 | p 轉換: 53 | b 泰勒絲 (Taylor Swift) 在 20 歲時即拿到 Grammy Award 54 | .col-md-8 55 | ul 56 | li ❗️ 在標點、數字、英文前面加入空格 57 | 58 | .container 59 | footer.page-footer.font-small.blue.pt-4 60 | .container-fluid.text-center.text-md-left 61 | .row 62 | .col-md-12.mt-md-0.mt-3 63 | p 64 | Shudu 舒讀為一個開源文字處理平台,目的是讓閱讀者能夠舒服的閱讀、輕鬆編寫文案。 65 | p 66 | | 此專案特別感謝 67 | a(href='https://github.com/vinta/pangu.js') pangu.js 68 | | 、 69 | a(href='https://github.com/BYVoid/OpenCC') OpenCC 70 | | 這兩個專案,沒有前輩們的貢獻不會有此工具。 71 | p 72 | | 歡迎參閱 73 | a(href='https://github.com/sparanoid/chinese-copywriting-guidelines') 中文文案排版指北 74 | p 75 | a(href='https://github.com/jackkuo-tw/shudu') 檢視 Shudu 原始碼 76 | 77 | -------------------------------------------------------------------------------- /cli/go.sum: -------------------------------------------------------------------------------- 1 | github.com/adamzy/cedar-go v0.0.0-20170805034717-80a9c64b256d h1:ir/IFJU5xbja5UaBEQLjcvn7aAU01nqU/NUyOBEU+ew= 2 | github.com/adamzy/cedar-go v0.0.0-20170805034717-80a9c64b256d/go.mod h1:PRWNwWq0yifz6XDPZu48aSld8BWwBfr2JKB2bGWiEd4= 3 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 4 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 5 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 6 | github.com/eknkc/basex v1.0.1 h1:TcyAkqh4oJXgV3WYyL4KEfCMk9W8oJCpmx1bo+jVgKY= 7 | github.com/eknkc/basex v1.0.1/go.mod h1:k/F/exNEHFdbs3ZHuasoP2E7zeWwZblG84Y7Z59vQRo= 8 | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 9 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 10 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 11 | github.com/liuzl/cedar-go v0.0.0-20170805034717-80a9c64b256d h1:qSmEGTgjkESUX5kPMSGJ4pcBUtYVDdkNzMrjQyvRvp0= 12 | github.com/liuzl/cedar-go v0.0.0-20170805034717-80a9c64b256d/go.mod h1:x7SghIWwLVcJObXbjK7S2ENsT1cAcdJcPl7dRaSFog0= 13 | github.com/liuzl/da v0.0.0-20180704015230-14771aad5b1d h1:hTRDIpJ1FjS9ULJuEzu69n3qTgc18eI+ztw/pJv47hs= 14 | github.com/liuzl/da v0.0.0-20180704015230-14771aad5b1d/go.mod h1:7xD3p0XnHvJFQ3t/stEJd877CSIMkH/fACVWen5pYnc= 15 | github.com/liuzl/goutil v0.0.0-20210628080224-310b49755b5f h1:VNfXzlrtFsryyprTrt3JhXG31DlWMpsW7Y9CXxB0wOE= 16 | github.com/liuzl/goutil v0.0.0-20210628080224-310b49755b5f/go.mod h1:bs5NOyZVxtkxzxw2wWhglhguMUE7PesJQ3TcaFNxWcU= 17 | github.com/longbridgeapp/assert v0.1.0/go.mod h1:ew3umReliXtk1bBG4weVURxdvR0tsN+rCEfjnA4YfxI= 18 | github.com/longbridgeapp/opencc v0.1.0 h1:GsMigoCywdOZoGh+GQrLC0bj3zFicqyIO1M8Kl/JLkg= 19 | github.com/longbridgeapp/opencc v0.1.0/go.mod h1:hGnb9DFcc+DS5J8I0tkr1PaC5ogFseq3vuvTKMFUIz0= 20 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 21 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 22 | github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= 23 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 24 | github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= 25 | github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= 26 | github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 27 | github.com/vinta/pangu v3.0.0+incompatible h1:kqW9Q5BrmWJkLJXLdxwbyPDjlizHUTpOCmHFCKfg1ZA= 28 | github.com/vinta/pangu v3.0.0+incompatible/go.mod h1:8n5gJh5l7U0Rbz6mjRK/09AiL0Bm+ugibEB+JhvxNNk= 29 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 30 | gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 31 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 32 | gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 33 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= 34 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 35 | -------------------------------------------------------------------------------- /browser_ext/options.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | localizeHtmlPage(); 3 | 4 | $('select').formSelect(); 5 | $('.tooltipped').tooltip(); 6 | $('#add-auto-translation-url').click(newTranslationURL) 7 | $('form').keydown(function() { 8 | saveOptions(); 9 | }) 10 | $(".delete-ctud").click(deteleCTUD); 11 | $('form').change(function() { 12 | saveOptions(); 13 | }) 14 | 15 | $("#custom-translation-server").change(function() { 16 | if (this.checked) { 17 | $("#translation-server-div").show(); 18 | } else { 19 | $("#translation-server-div").hide(); 20 | } 21 | }) 22 | 23 | loadOptions(); 24 | }) 25 | 26 | function loadOptions() { 27 | chrome.storage.sync.get({ 28 | lang: 'zh-TW', 29 | punctuation: 'fullWidth', 30 | customTranslationServer: 'false', 31 | customTranslationServerURL: '', 32 | autoTranslationURL: [], 33 | }, function(items) { 34 | // 習慣語言 35 | $('#lang').val(items.lang); 36 | $('#lang').formSelect(); 37 | 38 | // 標點符號 39 | $('#punctuation').val(items.punctuation); 40 | $('#punctuation').formSelect(); 41 | 42 | // 自訂轉換伺服器 43 | $('#custom-translation-server')[0].checked = (items.customTranslationServer != "false"); 44 | $("#custom-translation-server")[0].dispatchEvent(new Event('change')); 45 | 46 | $("#custom-translation-server-URL").val(items.customTranslationServerURL); 47 | 48 | // 頁面自動轉換 49 | items.autoTranslationURL.forEach((item) => { 50 | $('.atu:first').clone() 51 | .appendTo($('.custom-translation-url-div')) 52 | .children()[0].children[0].value = item; 53 | }) 54 | $('.atu:first').hide(); 55 | $(".delete-ctud").click(deteleCTUD); 56 | $('.tooltipped').tooltip(); 57 | }); 58 | } 59 | 60 | function saveOptions(e) { 61 | autoURL = new Set(); 62 | $(".auto-translation-url").each(function(index, item) { 63 | if (item.value.trim().length > 0) autoURL.add(item.value) 64 | }) 65 | 66 | chrome.storage.sync.set({ 67 | lang: $("#lang")[0].value, 68 | punctuation: $("#punctuation")[0].value, 69 | customTranslationServer: ($("#custom-translation-server")[0].checked ? "true" : "false"), 70 | customTranslationServerURL: $("#custom-translation-server-URL")[0].value, 71 | autoTranslationURL: Array.from(autoURL), 72 | }); 73 | } 74 | 75 | function newTranslationURL() { 76 | $('.atu:first').clone() 77 | .appendTo($('.custom-translation-url-div')) 78 | .show(); 79 | $(".delete-ctud").click(deteleCTUD); 80 | $('.tooltipped').tooltip(); 81 | } 82 | 83 | function deteleCTUD(e) { 84 | e.currentTarget.parentElement.parentElement.remove(); 85 | $('.tooltipped').tooltip(); 86 | saveOptions(); 87 | } 88 | 89 | function localizeHtmlPage() { 90 | //Localize by replacing __MSG_***__ meta tags 91 | var objects = document.getElementsByTagName('html'); 92 | for (var j = 0; j < objects.length; j++) { 93 | var obj = objects[j]; 94 | 95 | var valStrH = obj.innerHTML.toString(); 96 | var valNewH = valStrH.replace(/__MSG_(\w+)__/g, function(match, v1) { 97 | return v1 ? chrome.i18n.getMessage(v1) : ""; 98 | }); 99 | 100 | if (valNewH != valStrH) { 101 | obj.innerHTML = valNewH; 102 | } 103 | } 104 | } -------------------------------------------------------------------------------- /browser_ext/welcome.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | __MSG_release_notes__ 7 | 8 | 9 | 10 | 55 | 56 | 57 | 58 |
59 | 64 | 65 |
66 |
67 |
68 |

v1.3(當前版本)

69 |

更新了頁面解析演算法,解決了以往轉換完後部分按鈕無法點選、文字偏移問題,在轉換速度上也有大幅度的提升。

70 |
71 | 72 |
73 |

v1.2

74 |
    75 |
  1. 提供自定義伺服器網址
  2. 76 |
  3. 使用 i18n 以更方便支援多國語言
  4. 77 |
78 |
79 | 80 |
81 |

v1.1

82 |

提供基本設定(繁簡偏好、標點符號偏好,自動轉換網址)

83 |
84 | 85 |
86 |

v1.0

87 |

Hello World

88 |
89 |
90 |
91 |
92 | 93 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /browser_ext/release_notes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | __MSG_release_notes__ 7 | 8 | 9 | 10 | 57 | 58 | 59 | 60 |
61 | 66 | 67 |
68 |
69 |
70 |

v1.3(當前版本)

71 |

更新了頁面解析演算法,解決了以往轉換完後部分按鈕無法點選、文字偏移問題,在轉換速度上也有大幅度的提升。

72 |
73 | 74 |
75 |
76 | 77 | 78 |
79 |

v1.2

80 |
    81 |
  1. 提供自定義伺服器網址
  2. 82 |
  3. 使用 i18n 以更方便支援多國語言
  4. 83 |
84 |
85 | 86 |
87 |

v1.1

88 |

提供基本設定(繁簡偏好、標點符號偏好,自動轉換網址)

89 |
90 | 91 |
92 |

v1.0

93 |

Hello World

94 |
95 |
96 |
97 |
98 | 99 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | -------------------------------------------------------------------------------- /browser_ext/shudu.js: -------------------------------------------------------------------------------- 1 | var unconverted = []; 2 | var conv_dict = new Map(); 3 | var browser = chrome 4 | var isProcessing = false; 5 | 6 | browser.runtime.onMessage.addListener(handler); 7 | 8 | // 自動執行 shudu 判斷 9 | chrome.storage.sync.get({ 10 | autoTranslationURL: [], 11 | }, function(urls) { 12 | const href = window.location.href; 13 | if (urls.autoTranslationURL.some(item => href.includes(item))) { 14 | handler('shudu it'); 15 | } 16 | }) 17 | 18 | function handler(msg) { 19 | if (msg == 'shudu it') { 20 | // 避免上一次請求尚未完成仍發送請求 21 | if (isProcessing == true) return; 22 | isProcessing = true; 23 | console.log("receive 'shudu it'..."); 24 | sendWebSource(); 25 | } else { 26 | isProcessing = false; 27 | if (msg.status == 'success') { 28 | setContent(msg.resp); 29 | console.log("shudu done!"); 30 | } else if (msg.status == 'failure') { 31 | alert('舒讀: 轉換失敗\n\n' + msg.resp); 32 | } 33 | } 34 | } 35 | 36 | function sendWebSource() { 37 | if (getUnconvertedTextArray().length === 0) { 38 | console.log("nothing to shudu"); 39 | return; 40 | } 41 | 42 | // 取得設定檔 43 | chrome.storage.sync.get({ 44 | lang: 'zh-TW', 45 | punctuation: 'fullWidth', 46 | customTranslationServer: false, 47 | customTranslationServerURL: '', 48 | autoTranslationURL: [], 49 | }, function(options) { 50 | if (options.lang == 'zh') { options.lang = 'tw2sp'; } else { options.lang = 's2twp' } 51 | // 交由 background 處理 52 | browser.runtime.sendMessage({ 53 | server: (options.customTranslationServer && options.customTranslationServerURL) || null, 54 | payload: { 55 | origin: unconverted, 56 | punctuation: options.punctuation, 57 | translation: options.lang, 58 | } 59 | }); 60 | }) 61 | } 62 | 63 | function getUnconvertedTextArray() { 64 | parsePage(); 65 | for (let [key, value] of conv_dict) { 66 | if (value == undefined) { 67 | unconverted.push(key); 68 | } 69 | } 70 | return unconverted; 71 | } 72 | 73 | function setContent(msg) { 74 | unconverted.forEach((v, k) => { 75 | conv_dict.set(v, msg.converted[k]); 76 | conv_dict.set(msg.converted[k], msg.converted[k]); 77 | }); 78 | replaceText(); 79 | unconverted = []; 80 | }; 81 | 82 | function traverse(parentNode, handler) { 83 | for (let i in Object.keys(parentNode)) { 84 | let curNode = parentNode[i]; 85 | let curNodeName = curNode.nodeName; 86 | // exclude "style, script" 87 | if (curNodeName == 'STYLE' || curNodeName == 'SCRIPT') { 88 | continue; 89 | } 90 | // if it's #text node, parse it 91 | if (curNodeName == "#text") { 92 | curNodeText = curNode.textContent; 93 | handler(curNode, curNodeText); 94 | } 95 | // else if it has childNode, call traverse() recursively 96 | else if (curNode.hasChildNodes()) { 97 | traverse(curNode.childNodes, handler); 98 | } 99 | } 100 | } 101 | 102 | function parsePage() { 103 | traverse(document.body.childNodes, (curNode, curNodeText) => { 104 | if (curNodeText.trim().length > 0 && isCJK(curNodeText)) { 105 | if (!conv_dict.has(curNodeText)) { 106 | conv_dict.set(curNodeText, undefined); 107 | } 108 | } 109 | }); 110 | } 111 | 112 | function replaceText() { 113 | traverse(document.body.childNodes, (curNode, curNodeText) => { 114 | if (curNodeText.trim().length > 0 && isCJK(curNodeText)) { 115 | if (!conv_dict.has(curNodeText)) { 116 | conv_dict.set(curNodeText, undefined); 117 | } else { 118 | curNode.textContent = conv_dict.get(curNodeText); 119 | } 120 | } 121 | }); 122 | } 123 | 124 | // 判斷前後是否加空格 125 | // function spaceSurround(currentNode, converted, index) { 126 | // if (currentNode.parentNode.nodeName == 'A') { 127 | // if (converted[index].match(/[a-zA-Z]/) && ifCJK(converted[index - 1] || '')) { 128 | // converted[index] = ' ' + converted[index]; 129 | // } 130 | // if (converted[index].slice(-1).match(/[a-zA-Z]/) && ifCJK(converted[index + 1] || '')) { 131 | // converted[index] = converted[index] + ' '; 132 | // } 133 | // } 134 | // return converted[index]; 135 | // } 136 | 137 | function isCJK(text) { 138 | REGEX_CHINESE = /[\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff\uff66-\uff9f]/; 139 | hasChinese = text.match(REGEX_CHINESE); 140 | if (hasChinese == null) return false; 141 | return true; 142 | } 143 | 144 | // usage: if (isInsideTag(node, 'TEXTAREA', 'mce-container')) continue; 145 | // function isInsideTag(node, tagName, className = null) { 146 | // if (node.tagName == tagName || node.parentElement.tagName == tagName || node.parentElement.classList.contains(className)) return true; 147 | // if (node.parentElement.parentElement) { 148 | // return isInsideTag(node.parentElement, tagName, className) 149 | // } 150 | // return false; 151 | // } -------------------------------------------------------------------------------- /browser_ext/options.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | __MSG_shudu_settings__ 7 | 8 | 9 | 10 | 46 | 47 | 48 | 49 |
50 | 55 | 56 |
57 |
58 |
59 |

__MSG_options_basic_setting__

60 |
61 |
62 | 66 | 67 |
68 | 69 |
70 | 74 | 75 |
76 | 77 |
78 |
79 | 80 | 86 |
87 |
88 |
89 | 90 | 91 |
92 | 93 |
94 |

__MSG_options_auto_translate__

95 |
96 |
97 |
98 | 99 | 100 | 101 |
102 |
103 | 104 |
105 |
106 |
107 | 108 |
109 |
110 |
111 |
112 |
113 | 114 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | -------------------------------------------------------------------------------- /web/public/javascripts/query.js: -------------------------------------------------------------------------------- 1 | var virtualBody, originalContent = { text: [], index: [] };; 2 | 3 | $(function() { 4 | $('#convert button[type="submit"]').click(function(e) { 5 | e.preventDefault(); 6 | tinyMCE.activeEditor.setProgressState(true) 7 | const data = { 8 | 'origin': getContent(), 9 | 'punctuation': $('#punctuation').val(), 10 | 'translation': $('#translation').val(), 11 | }; 12 | fetch("/json", { 13 | method: 'POST', 14 | headers: { 'Content-Type': 'application/json' }, 15 | body: JSON.stringify(data), 16 | }).then(res => { 17 | tinyMCE.activeEditor.setProgressState(false); 18 | return res.json(); 19 | }) 20 | .catch(err => { alert("轉換失敗"); }) 21 | .then(resp => { setContent(resp); }) 22 | }); 23 | 24 | tinymce.init({ 25 | selector: '#origin', 26 | branding: false, 27 | language: "zh_TW", 28 | language_url: '/public/javascripts/zh_TW.js' 29 | }); 30 | 31 | if (mobileCheck()) { 32 | document.getElementById('addon').style.display = 'none'; 33 | } 34 | }); 35 | 36 | function getContent() { 37 | const parsed = []; 38 | originalContent.text = parseHTML(tinyMCE.activeEditor.getContent({ format: 'raw' })); 39 | originalContent.text.forEach((text, index) => { 40 | if (ifCJK(text)) { 41 | parsed.push(text); 42 | originalContent.index.push(index); 43 | } 44 | }); 45 | console.log('parsed', parsed); 46 | return parsed; 47 | } 48 | 49 | function setContent(msg) { 50 | const original = originalContent.text; 51 | originalContent.index.forEach((index, i) => { 52 | original.splice(index, 1, msg.converted[i]); 53 | }); 54 | console.log('original', original); 55 | replaceText(original); 56 | originalContent.index = originalContent.text = []; 57 | tinyMCE.activeEditor.setContent(virtualBody.innerHTML, { format: 'html' }); 58 | }; 59 | 60 | function parseHTML(htmlContent) { 61 | virtualBody = document.createElement('body'); 62 | mappingElement = []; 63 | virtualBody.innerHTML = htmlContent; 64 | const treeWalker = document.createTreeWalker(virtualBody, 1 | 4, null, false); 65 | const stringArr = []; 66 | while (treeWalker.nextNode()) { 67 | const node = treeWalker.currentNode; 68 | switch (node.nodeName.toLowerCase()) { 69 | case '#text': 70 | stringArr.push(node.textContent); 71 | mappingElement.push(node); 72 | break; 73 | case 'option': 74 | stringArr.push(node.text); 75 | mappingElement.push(node); 76 | break; 77 | } 78 | } 79 | return stringArr; 80 | } 81 | 82 | function replaceText(converted) { 83 | const treeWalker = document.createTreeWalker(virtualBody, 1 | 4, null, false); 84 | let index = 0; 85 | while (treeWalker.nextNode()) { 86 | const node = treeWalker.currentNode; 87 | switch (node.nodeName.toLowerCase()) { 88 | case '#text': 89 | node.textContent = spaceSurround(node, converted, index); 90 | index += 1; 91 | break; 92 | case 'option': 93 | node.text = converted[index]; 94 | index += 1; 95 | break; 96 | } 97 | } 98 | } 99 | 100 | // 判斷前後是否加空格 101 | function spaceSurround(currentNode, converted, index) { 102 | if (currentNode.parentNode.nodeName == 'A') { 103 | if (converted[index].match(/[a-zA-Z]/) && ifCJK(converted[index - 1] || '')) { 104 | converted[index] = ' ' + converted[index]; 105 | } 106 | if (converted[index].slice(-1).match(/[a-zA-Z]/) && ifCJK(converted[index + 1] || '')) { 107 | converted[index] = converted[index] + ' '; 108 | } 109 | } 110 | return converted[index]; 111 | } 112 | 113 | function ifCJK(text) { 114 | REGEX_CHINESE = /[\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff\uff66-\uff9f]/; 115 | hasChinese = text.match(REGEX_CHINESE); 116 | if (hasChinese == null) return false; 117 | return true; 118 | } 119 | 120 | function mobileCheck() { 121 | let check = false; 122 | (function(a) { if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) check = true; })(navigator.userAgent || navigator.vendor || window.opera); 123 | return check; 124 | }; 125 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # binary 2 | shudu 3 | shudu_linux* 4 | shudu_mac* 5 | shudu_windows* 6 | 7 | # Created by https://www.toptal.com/developers/gitignore/api/macos,linux,windows,compression,vim,node 8 | # Edit at https://www.toptal.com/developers/gitignore?templates=macos,linux,windows,compression,vim,node 9 | 10 | ### Compression ### 11 | 12 | ### From https://en.wikipedia.org/wiki/List_of_archive_formats 13 | 14 | ## Compression only 15 | # An open source, patent- and royalty-free compression format. The compression algorithm is a Burrows-Wheeler transform followed by a move-to-front transform and finally Huffman coding 16 | *.bz2 17 | # Old compressor for QNX4 OS. The compression algorithm is a modified LZSS, with an adaptive Huffman coding. 18 | *.F 19 | # GNU Zip, the primary compression format used by Unix-like systems. The compression algorithm is DEFLATE. 20 | *.gz 21 | # An alternate LZMA algorithm implementation, with support for checksums and ident bytes. 22 | *.lz 23 | # The LZMA compression algorithm as used by 7-Zip 24 | *.lzma 25 | # An implementation of the LZO data compression algorithm 26 | *.lzo 27 | # A compression program designed to do particularly well on very large files containing long distance redundancy. 28 | *.rz 29 | # Windows compress/decompress- Linux and Mac OS X decompress only A compression program designed to do high compression on SF2 files (SoundFont) 30 | *.sfark 31 | # A compression format invented by Google and open-sourced in 2011. Snappy aims for very high speeds, reasonable compression, and maximum stability rather than maximum compression or compatibility with any other compression library. 32 | *.sz 33 | # Squeeze: A program which compressed files. A file which was "squeezed" had the middle initial of the name changed to "Q", so that a squeezed text file would end with .TQT, a squeezed executable would end with .CQM or .EQE. Typically used with .LBR archives, either by storing the squeezed files in the archive, or by storing the files decompressed and then compressing the archive, which would have a name ending in ".LQR". 34 | *.?Q? 35 | # A compression program written by Steven Greenberg implementing the LZW algorithm. For several years in the CP/M world when no implementation was available of ARC, CRUNCHed files stored in .LBR archives were very popular. CRUNCH's implementation of LZW had a somewhat unique feature of modifying and occasionally clearing the code table in memory when it became full, resulting in a few percent better compression on many files. 36 | *.?Z? 37 | # A compression format using LZMA2 to yield very high compression ratios. 38 | *.xz 39 | # The traditional Huffman coding compression format. 40 | *.z 41 | # The traditional LZW compression format. 42 | *.Z 43 | # Joke compression program, actually increasing file size 44 | *.infl 45 | # Compression format(s) used by some DOS and Windows install programs. MS-DOS includes expand.exe to decompress its install files. The compressed files are created with a matching compress.exe command. The compression algorithm is LZSS. 46 | *.??_ 47 | 48 | 49 | ### Linux ### 50 | *~ 51 | 52 | # temporary files which can be created if a process still has a handle open of a deleted file 53 | .fuse_hidden* 54 | 55 | # KDE directory preferences 56 | .directory 57 | 58 | # Linux trash folder which might appear on any partition or disk 59 | .Trash-* 60 | 61 | # .nfs files are created when an open file is removed but is still being accessed 62 | .nfs* 63 | 64 | ### macOS ### 65 | # General 66 | .DS_Store 67 | .AppleDouble 68 | .LSOverride 69 | 70 | # Icon must end with two \r 71 | Icon 72 | 73 | 74 | # Thumbnails 75 | ._* 76 | 77 | # Files that might appear in the root of a volume 78 | .DocumentRevisions-V100 79 | .fseventsd 80 | .Spotlight-V100 81 | .TemporaryItems 82 | .Trashes 83 | .VolumeIcon.icns 84 | .com.apple.timemachine.donotpresent 85 | 86 | # Directories potentially created on remote AFP share 87 | .AppleDB 88 | .AppleDesktop 89 | Network Trash Folder 90 | Temporary Items 91 | .apdisk 92 | 93 | ### Node ### 94 | # Logs 95 | logs 96 | *.log 97 | npm-debug.log* 98 | yarn-debug.log* 99 | yarn-error.log* 100 | lerna-debug.log* 101 | .pnpm-debug.log* 102 | 103 | # Diagnostic reports (https://nodejs.org/api/report.html) 104 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 105 | 106 | # Runtime data 107 | pids 108 | *.pid 109 | *.seed 110 | *.pid.lock 111 | 112 | # Directory for instrumented libs generated by jscoverage/JSCover 113 | lib-cov 114 | 115 | # Coverage directory used by tools like istanbul 116 | coverage 117 | *.lcov 118 | 119 | # nyc test coverage 120 | .nyc_output 121 | 122 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 123 | .grunt 124 | 125 | # Bower dependency directory (https://bower.io/) 126 | bower_components 127 | 128 | # node-waf configuration 129 | .lock-wscript 130 | 131 | # Compiled binary addons (https://nodejs.org/api/addons.html) 132 | build/Release 133 | 134 | # Dependency directories 135 | node_modules/ 136 | jspm_packages/ 137 | 138 | # Snowpack dependency directory (https://snowpack.dev/) 139 | web_modules/ 140 | 141 | # TypeScript cache 142 | *.tsbuildinfo 143 | 144 | # Optional npm cache directory 145 | .npm 146 | 147 | # Optional eslint cache 148 | .eslintcache 149 | 150 | # Microbundle cache 151 | .rpt2_cache/ 152 | .rts2_cache_cjs/ 153 | .rts2_cache_es/ 154 | .rts2_cache_umd/ 155 | 156 | # Optional REPL history 157 | .node_repl_history 158 | 159 | # Output of 'npm pack' 160 | *.tgz 161 | 162 | # Yarn Integrity file 163 | .yarn-integrity 164 | 165 | # dotenv environment variables file 166 | .env 167 | .env.test 168 | .env.production 169 | 170 | # parcel-bundler cache (https://parceljs.org/) 171 | .cache 172 | .parcel-cache 173 | 174 | # Next.js build output 175 | .next 176 | out 177 | 178 | # Nuxt.js build / generate output 179 | .nuxt 180 | dist 181 | 182 | # Gatsby files 183 | .cache/ 184 | # Comment in the public line in if your project uses Gatsby and not Next.js 185 | # https://nextjs.org/blog/next-9-1#public-directory-support 186 | # public 187 | 188 | # vuepress build output 189 | .vuepress/dist 190 | 191 | # Serverless directories 192 | .serverless/ 193 | 194 | # FuseBox cache 195 | .fusebox/ 196 | 197 | # DynamoDB Local files 198 | .dynamodb/ 199 | 200 | # TernJS port file 201 | .tern-port 202 | 203 | # Stores VSCode versions used for testing VSCode extensions 204 | .vscode-test 205 | 206 | # yarn v2 207 | .yarn/cache 208 | .yarn/unplugged 209 | .yarn/build-state.yml 210 | .yarn/install-state.gz 211 | .pnp.* 212 | 213 | ### Vim ### 214 | # Swap 215 | [._]*.s[a-v][a-z] 216 | !*.svg # comment out if you don't need vector files 217 | [._]*.sw[a-p] 218 | [._]s[a-rt-v][a-z] 219 | [._]ss[a-gi-z] 220 | [._]sw[a-p] 221 | 222 | # Session 223 | Session.vim 224 | Sessionx.vim 225 | 226 | # Temporary 227 | .netrwhist 228 | # Auto-generated tag files 229 | tags 230 | # Persistent undo 231 | [._]*.un~ 232 | 233 | ### Windows ### 234 | # Windows thumbnail cache files 235 | Thumbs.db 236 | Thumbs.db:encryptable 237 | ehthumbs.db 238 | ehthumbs_vista.db 239 | 240 | # Dump file 241 | *.stackdump 242 | 243 | # Folder config file 244 | [Dd]esktop.ini 245 | 246 | # Recycle Bin used on file shares 247 | $RECYCLE.BIN/ 248 | 249 | # Windows Installer files 250 | *.cab 251 | *.msi 252 | *.msix 253 | *.msm 254 | *.msp 255 | 256 | # Windows shortcuts 257 | *.lnk 258 | 259 | # End of https://www.toptal.com/developers/gitignore/api/macos,linux,windows,compression,vim,node 260 | -------------------------------------------------------------------------------- /src/core.js: -------------------------------------------------------------------------------- 1 | // CJK is an acronym for Chinese, Japanese, and Korean. 2 | // 3 | // CJK includes the following Unicode blocks: 4 | // \u2e80-\u2eff CJK Radicals Supplement 5 | // \u2f00-\u2fdf Kangxi Radicals 6 | // \u3040-\u309f Hiragana 7 | // \u30a0-\u30ff Katakana 8 | // \u3100-\u312f Bopomofo 9 | // \u3200-\u32ff Enclosed CJK Letters and Months 10 | // \u3400-\u4dbf CJK Unified Ideographs Extension A 11 | // \u4e00-\u9fff CJK Unified Ideographs 12 | // \uf900-\ufaff CJK Compatibility Ideographs 13 | // 14 | // For more information about Unicode blocks, see 15 | // http://unicode-table.com/en/ 16 | // https://github.com/vinta/pangu 17 | // 18 | // all J below does not include \u30fb 19 | const CJK = '\u2e80-\u2eff\u2f00-\u2fdf\u3040-\u309f\u30a0-\u30fa\u30fc-\u30ff\u3100-\u312f\u3200-\u32ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff'; 20 | 21 | // ANS is short for Alphabets, Numbers, and Symbols. 22 | // 23 | // A includes A-Za-z\u0370-\u03ff 24 | // N includes 0-9 25 | // S includes `~!@#$%^&*()-_=+[]{}\|;:'",<.>/? 26 | // 27 | // some S below does not include all symbols 28 | 29 | const ANY_CJK = new RegExp(`[${CJK}]`); 30 | 31 | // the symbol part only includes ~ ! ; : , . ? but . only matches one character 32 | const CONVERT_TO_FULLWIDTH_CJK_SYMBOLS_CJK = new RegExp(`([${CJK}])[ ]*([\\:]+|\\.)[ ]*([${CJK}])`, 'g'); 33 | const CONVERT_TO_FULLWIDTH_CJK_SYMBOLS = new RegExp(`([${CJK}])[ ]*([~\\!;,\\?]+)[ ]*`, 'g'); 34 | const DOTS_CJK = new RegExp(`([\\.]{2,}|\u2026)([${CJK}])`, 'g'); 35 | const FIX_CJK_COLON_ANS = new RegExp(`([${CJK}])\\:([A-Z0-9\\(\\)])`, 'g'); 36 | 37 | // the symbol part does not include ' 38 | const CJK_QUOTE = new RegExp(`([${CJK}])([\`"\u05f4])`, 'g'); 39 | const QUOTE_CJK = new RegExp(`([\`"\u05f4])([${CJK}])`, 'g'); 40 | const FIX_QUOTE_ANY_QUOTE = /([`"\u05f4]+)[ ]*(.+?)[ ]*([`"\u05f4]+)/g; 41 | 42 | const CJK_SINGLE_QUOTE_BUT_POSSESSIVE = new RegExp(`([${CJK}])('[^s])`, 'g'); 43 | const SINGLE_QUOTE_CJK = new RegExp(`(')([${CJK}])`, 'g'); 44 | const FIX_POSSESSIVE_SINGLE_QUOTE = new RegExp(`([A-Za-z0-9${CJK}])( )('s)`, 'g'); 45 | 46 | const HASH_ANS_CJK_HASH = new RegExp(`([${CJK}])(#)([${CJK}]+)(#)([${CJK}])`, 'g'); 47 | const CJK_HASH = new RegExp(`([${CJK}])(#([^ ]))`, 'g'); 48 | const HASH_CJK = new RegExp(`(([^ ])#)([${CJK}])`, 'g'); 49 | 50 | // the symbol part only includes + - * / = & | < > 51 | const CJK_OPERATOR_ANS = new RegExp(`([${CJK}])([\\+\\-\\*\\/=&\\|<>])([A-Za-z0-9])`, 'g'); 52 | const ANS_OPERATOR_CJK = new RegExp(`([A-Za-z0-9])([\\+\\-\\*\\/=&\\|<>])([${CJK}])`, 'g'); 53 | 54 | const FIX_SLASH_AS = /([/]) ([a-z\-_\./]+)/g; 55 | const FIX_SLASH_AS_SLASH = /([/\.])([A-Za-z\-_\./]+) ([/])/g; 56 | 57 | // the bracket part only includes ( ) [ ] { } < > “ ” 58 | const CJK_LEFT_BRACKET = new RegExp(`([${CJK}])([\\(\\[\\{<>\u201c])`, 'g'); 59 | const RIGHT_BRACKET_CJK = new RegExp(`([\\)\\]\\}<>\u201d])([${CJK}])`, 'g'); 60 | const FIX_LEFT_BRACKET_ANY_RIGHT_BRACKET = /([\(\[\{<\u201c]+)[ ]*(.+?)[ ]*([\)\]\}>\u201d]+)/; 61 | const ANS_CJK_LEFT_BRACKET_ANY_RIGHT_BRACKET = new RegExp(`([A-Za-z0-9${CJK}])[ ]*([\u201c])([A-Za-z0-9${CJK}\\-_ ]+)([\u201d])`, 'g'); 62 | const LEFT_BRACKET_ANY_RIGHT_BRACKET_ANS_CJK = new RegExp(`([\u201c])([A-Za-z0-9${CJK}\\-_ ]+)([\u201d])[ ]*([A-Za-z0-9${CJK}])`, 'g'); 63 | 64 | const AN_LEFT_BRACKET = /([A-Za-z0-9])([\(\[\{])/g; 65 | const RIGHT_BRACKET_AN = /([\)\]\}])([A-Za-z0-9])/g; 66 | 67 | const CJK_ANS = new RegExp(`([${CJK}])([A-Za-z\u0370-\u03ff0-9@\\$%\\^&\\*\\-\\+\\\\=\\|/\u00a1-\u00ff\u2150-\u218f\u2700—\u27bf])`, 'g'); 68 | const ANS_CJK = new RegExp(`([A-Za-z\u0370-\u03ff0-9~\\$%\\^&\\*\\-\\+\\\\=\\|/!;:,\\.\\?\u00a1-\u00ff\u2150-\u218f\u2700—\u27bf])([${CJK}])`, 'g'); 69 | 70 | const S_A = /(%)([A-Za-z])/g; 71 | 72 | const MIDDLE_DOT = /([ ]*)([\u00b7\u2022\u2027])([ ]*)/g; 73 | 74 | class Pangu { 75 | constructor() { 76 | this.version = '4.0.7'; 77 | } 78 | 79 | convertToFullwidth(symbols) { 80 | return symbols 81 | .replace(/~/g, '~') 82 | .replace(/!/g, '!') 83 | .replace(/;/g, ';') 84 | .replace(/:/g, ':') 85 | .replace(/,/g, ',') 86 | .replace(/\./g, '。') 87 | .replace(/\?/g, '?'); 88 | } 89 | 90 | spacing(text) { 91 | if (typeof text !== 'string') { 92 | console.warn(`spacing(text) only accepts string but got ${typeof text}`); // eslint-disable-line no-console 93 | return text; 94 | } 95 | 96 | if (text.length <= 1 || !ANY_CJK.test(text)) { 97 | return text; 98 | } 99 | 100 | const self = this; 101 | 102 | // DEBUG 103 | // String.prototype.rawReplace = String.prototype.replace; 104 | // String.prototype.replace = function(regexp, newSubstr) { 105 | // const oldText = this; 106 | // const newText = this.rawReplace(regexp, newSubstr); 107 | // if (oldText !== newText) { 108 | // console.log(`regexp: ${regexp}`); 109 | // console.log(`oldText: ${oldText}`); 110 | // console.log(`newText: ${newText}`); 111 | // } 112 | // return newText; 113 | // }; 114 | 115 | let newText = text; 116 | 117 | // https://stackoverflow.com/questions/4285472/multiple-regex-replace 118 | newText = newText.replace(CONVERT_TO_FULLWIDTH_CJK_SYMBOLS_CJK, (match, leftCjk, symbols, rightCjk) => { 119 | const fullwidthSymbols = self.convertToFullwidth(symbols); 120 | return `${leftCjk}${fullwidthSymbols}${rightCjk}`; 121 | }); 122 | 123 | newText = newText.replace(CONVERT_TO_FULLWIDTH_CJK_SYMBOLS, (match, cjk, symbols) => { 124 | const fullwidthSymbols = self.convertToFullwidth(symbols); 125 | return `${cjk}${fullwidthSymbols}`; 126 | }); 127 | 128 | newText = newText.replace(DOTS_CJK, '$1 $2'); 129 | newText = newText.replace(FIX_CJK_COLON_ANS, '$1:$2'); 130 | 131 | newText = newText.replace(CJK_QUOTE, '$1 $2'); 132 | newText = newText.replace(QUOTE_CJK, '$1 $2'); 133 | newText = newText.replace(FIX_QUOTE_ANY_QUOTE, '$1$2$3'); 134 | 135 | newText = newText.replace(CJK_SINGLE_QUOTE_BUT_POSSESSIVE, '$1 $2'); 136 | newText = newText.replace(SINGLE_QUOTE_CJK, '$1 $2'); 137 | newText = newText.replace(FIX_POSSESSIVE_SINGLE_QUOTE, "$1's"); // eslint-disable-line quotes 138 | 139 | newText = newText.replace(HASH_ANS_CJK_HASH, '$1 $2$3$4 $5'); 140 | newText = newText.replace(CJK_HASH, '$1 $2'); 141 | newText = newText.replace(HASH_CJK, '$1 $3'); 142 | 143 | newText = newText.replace(CJK_OPERATOR_ANS, '$1 $2 $3'); 144 | newText = newText.replace(ANS_OPERATOR_CJK, '$1 $2 $3'); 145 | 146 | newText = newText.replace(FIX_SLASH_AS, '$1$2'); 147 | newText = newText.replace(FIX_SLASH_AS_SLASH, '$1$2$3'); 148 | 149 | newText = newText.replace(CJK_LEFT_BRACKET, '$1 $2'); 150 | newText = newText.replace(RIGHT_BRACKET_CJK, '$1 $2'); 151 | newText = newText.replace(FIX_LEFT_BRACKET_ANY_RIGHT_BRACKET, '$1$2$3'); 152 | newText = newText.replace(ANS_CJK_LEFT_BRACKET_ANY_RIGHT_BRACKET, '$1 $2$3$4'); 153 | newText = newText.replace(LEFT_BRACKET_ANY_RIGHT_BRACKET_ANS_CJK, '$1$2$3 $4'); 154 | 155 | newText = newText.replace(AN_LEFT_BRACKET, '$1 $2'); 156 | newText = newText.replace(RIGHT_BRACKET_AN, '$1 $2'); 157 | 158 | newText = newText.replace(CJK_ANS, '$1 $2'); 159 | newText = newText.replace(ANS_CJK, '$1 $2'); 160 | 161 | newText = newText.replace(S_A, '$1 $2'); 162 | 163 | newText = newText.replace(MIDDLE_DOT, '・'); 164 | 165 | // DEBUG 166 | // String.prototype.replace = String.prototype.rawReplace; 167 | 168 | return newText; 169 | } 170 | 171 | spacingText(text, callback = () => {}) { 172 | let newText; 173 | try { 174 | newText = this.spacing(text); 175 | } catch (err) { 176 | callback(err); 177 | return; 178 | } 179 | callback(null, newText); 180 | } 181 | 182 | spacingTextSync(text) { 183 | return this.spacing(text); 184 | } 185 | } 186 | 187 | const pangu = new Pangu(); 188 | 189 | module.exports = pangu; 190 | module.exports.default = pangu; 191 | module.exports.Pangu = Pangu; 192 | -------------------------------------------------------------------------------- /browser_ext/icons/book.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/pangu.js: -------------------------------------------------------------------------------- 1 | const { Pangu } = require('./core'); 2 | 3 | function once(func) { 4 | let executed = false; 5 | return () => { 6 | if (executed) { 7 | return; 8 | } 9 | const self = this; 10 | executed = true; 11 | func.apply(self, arguments); 12 | }; 13 | } 14 | 15 | function debounce(func, delay, mustRunDelay) { 16 | let timer = null; 17 | let startTime = null; 18 | return () => { 19 | const self = this; 20 | const args = arguments; 21 | const currentTime = +new Date(); 22 | 23 | clearTimeout(timer); 24 | 25 | if (!startTime) { 26 | startTime = currentTime; 27 | } 28 | 29 | if (currentTime - startTime >= mustRunDelay) { 30 | func.apply(self, args); 31 | startTime = currentTime; 32 | } else { 33 | timer = setTimeout(() => { 34 | func.apply(self, args); 35 | }, delay); 36 | } 37 | }; 38 | } 39 | 40 | // https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType 41 | 42 | class BrowserPangu extends Pangu { 43 | constructor() { 44 | super(); 45 | 46 | this.blockTags = /^(div|p|h1|h2|h3|h4|h5|h6)$/i; 47 | this.ignoredTags = /^(script|code|pre|textarea)$/i; 48 | this.presentationalTags = /^(b|code|del|em|i|s|strong|kbd)$/i; 49 | this.spaceLikeTags = /^(br|hr|i|img|pangu)$/i; 50 | this.spaceSensitiveTags = /^(a|del|pre|s|strike|u)$/i; 51 | 52 | this.isAutoSpacingPageExecuted = false; 53 | 54 | // TODO 55 | // this.ignoredTags adds iframe|pangu 56 | // this.ignoreClasses 57 | // this.ignoreAttributes 58 | } 59 | 60 | isContentEditable(node) { 61 | return ((node.isContentEditable) || (node.getAttribute && node.getAttribute('g_editable') === 'true')); 62 | } 63 | 64 | isSpecificTag(node, tagRegex) { 65 | return (node && node.nodeName && node.nodeName.search(tagRegex) >= 0); 66 | } 67 | 68 | isInsideSpecificTag(node, tagRegex, checkCurrent = false) { 69 | let currentNode = node; 70 | if (checkCurrent) { 71 | if (this.isSpecificTag(currentNode, tagRegex)) { 72 | return true; 73 | } 74 | } 75 | while (currentNode.parentNode) { 76 | currentNode = currentNode.parentNode; 77 | if (this.isSpecificTag(currentNode, tagRegex)) { 78 | return true; 79 | } 80 | } 81 | return false; 82 | } 83 | 84 | canIgnoreNode(node) { 85 | let currentNode = node; 86 | if (currentNode && (this.isSpecificTag(currentNode, this.ignoredTags) || this.isContentEditable(currentNode))) { 87 | return true; 88 | } 89 | while (currentNode.parentNode) { 90 | currentNode = currentNode.parentNode; 91 | if (currentNode && (this.isSpecificTag(currentNode, this.ignoredTags) || this.isContentEditable(currentNode))) { 92 | return true; 93 | } 94 | } 95 | return false; 96 | } 97 | 98 | isFirstTextChild(parentNode, targetNode) { 99 | const { childNodes } = parentNode; 100 | 101 | // 只判斷第一個含有 text 的 node 102 | for (let i = 0; i < childNodes.length; i++) { 103 | const childNode = childNodes[i]; 104 | if (childNode.nodeType !== Node.COMMENT_NODE && childNode.textContent) { 105 | return childNode === targetNode; 106 | } 107 | } 108 | return false; 109 | } 110 | 111 | isLastTextChild(parentNode, targetNode) { 112 | const { childNodes } = parentNode; 113 | 114 | // 只判斷倒數第一個含有 text 的 node 115 | for (let i = childNodes.length - 1; i > -1; i--) { 116 | const childNode = childNodes[i]; 117 | if (childNode.nodeType !== Node.COMMENT_NODE && childNode.textContent) { 118 | return childNode === targetNode; 119 | } 120 | } 121 | return false; 122 | } 123 | 124 | spacingNodeByXPath(xPathQuery, contextNode) { 125 | if (!(contextNode instanceof Node) || (contextNode instanceof DocumentFragment)) { 126 | return; 127 | } 128 | 129 | // 因為 xPathQuery 會是用 text() 結尾,所以這些 nodes 會是 text 而不是 DOM element 130 | // snapshotLength 要配合 XPathResult.ORDERED_NODE_SNAPSHOT_TYPE 使用 131 | // https://developer.mozilla.org/en-US/docs/DOM/document.evaluate 132 | // https://developer.mozilla.org/en-US/docs/Web/API/XPathResult 133 | const textNodes = document.evaluate(xPathQuery, contextNode, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); 134 | 135 | let currentTextNode; 136 | let nextTextNode; 137 | 138 | // 從最下面、最裡面的節點開始,所以是倒序的 139 | for (let i = textNodes.snapshotLength - 1; i > -1; --i) { 140 | currentTextNode = textNodes.snapshotItem(i); 141 | 142 | if (this.isSpecificTag(currentTextNode.parentNode, this.presentationalTags) && !this.isInsideSpecificTag(currentTextNode.parentNode, this.ignoredTags)) { 143 | const elementNode = currentTextNode.parentNode; 144 | 145 | if (elementNode.previousSibling) { 146 | const { previousSibling } = elementNode; 147 | if (previousSibling.nodeType === Node.TEXT_NODE) { 148 | const testText = previousSibling.data.substr(-1) + currentTextNode.data.toString().charAt(0); 149 | const testNewText = this.spacing(testText); 150 | if (testText !== testNewText) { 151 | previousSibling.data = `${previousSibling.data} `; 152 | } 153 | } 154 | } 155 | 156 | if (elementNode.nextSibling) { 157 | const { nextSibling } = elementNode; 158 | if (nextSibling.nodeType === Node.TEXT_NODE) { 159 | const testText = currentTextNode.data.substr(-1) + nextSibling.data.toString().charAt(0); 160 | const testNewText = this.spacing(testText); 161 | if (testText !== testNewText) { 162 | nextSibling.data = ` ${nextSibling.data}`; 163 | } 164 | } 165 | } 166 | } 167 | 168 | if (this.canIgnoreNode(currentTextNode)) { 169 | nextTextNode = currentTextNode; 170 | continue; 171 | } 172 | 173 | const newText = this.spacing(currentTextNode.data); 174 | if (currentTextNode.data !== newText) { 175 | currentTextNode.data = newText; 176 | } 177 | 178 | // 處理嵌套的 中的文字 179 | if (nextTextNode) { 180 | // TODO 181 | // 現在只是簡單地判斷相鄰的下一個 node 是不是
182 | // 萬一遇上嵌套的標籤就不行了 183 | if (currentTextNode.nextSibling && currentTextNode.nextSibling.nodeName.search(this.spaceLikeTags) >= 0) { 184 | nextTextNode = currentTextNode; 185 | continue; 186 | } 187 | 188 | // currentTextNode 的最後一個字 + nextTextNode 的第一個字 189 | const testText = currentTextNode.data.toString().substr(-1) + nextTextNode.data.toString().substr(0, 1); 190 | const testNewText = this.spacing(testText); 191 | if (testNewText !== testText) { 192 | // 往上找 nextTextNode 的 parent node 193 | // 直到遇到 spaceSensitiveTags 194 | // 而且 nextTextNode 必須是第一個 text child 195 | // 才能把空格加在 nextTextNode 的前面 196 | let nextNode = nextTextNode; 197 | while (nextNode.parentNode && nextNode.nodeName.search(this.spaceSensitiveTags) === -1 && this.isFirstTextChild(nextNode.parentNode, nextNode)) { 198 | nextNode = nextNode.parentNode; 199 | } 200 | 201 | let currentNode = currentTextNode; 202 | while (currentNode.parentNode && currentNode.nodeName.search(this.spaceSensitiveTags) === -1 && this.isLastTextChild(currentNode.parentNode, currentNode)) { 203 | currentNode = currentNode.parentNode; 204 | } 205 | 206 | if (currentNode.nextSibling) { 207 | if (currentNode.nextSibling.nodeName.search(this.spaceLikeTags) >= 0) { 208 | nextTextNode = currentTextNode; 209 | continue; 210 | } 211 | } 212 | 213 | if (currentNode.nodeName.search(this.blockTags) === -1) { 214 | if (nextNode.nodeName.search(this.spaceSensitiveTags) === -1) { 215 | if ((nextNode.nodeName.search(this.ignoredTags) === -1) && (nextNode.nodeName.search(this.blockTags) === -1)) { 216 | if (nextTextNode.previousSibling) { 217 | if (nextTextNode.previousSibling.nodeName.search(this.spaceLikeTags) === -1) { 218 | nextTextNode.data = ` ${nextTextNode.data}`; 219 | } 220 | } else { 221 | // dirty hack 222 | if (!this.canIgnoreNode(nextTextNode)) { 223 | nextTextNode.data = ` ${nextTextNode.data}`; 224 | } 225 | } 226 | } 227 | } else if (currentNode.nodeName.search(this.spaceSensitiveTags) === -1) { 228 | currentTextNode.data = `${currentTextNode.data} `; 229 | } else { 230 | const panguSpace = document.createElement('pangu'); 231 | panguSpace.innerHTML = ' '; 232 | 233 | // 避免一直被加空格 234 | if (nextNode.previousSibling) { 235 | if (nextNode.previousSibling.nodeName.search(this.spaceLikeTags) === -1) { 236 | nextNode.parentNode.insertBefore(panguSpace, nextNode); 237 | } 238 | } else { 239 | nextNode.parentNode.insertBefore(panguSpace, nextNode); 240 | } 241 | 242 | // TODO 243 | // 主要是想要避免在元素(通常都是
  • )的開頭加空格 244 | // 這個做法有點蠢,但是不管還是先硬上 245 | if (!panguSpace.previousElementSibling) { 246 | if (panguSpace.parentNode) { 247 | panguSpace.parentNode.removeChild(panguSpace); 248 | } 249 | } 250 | } 251 | } 252 | } 253 | } 254 | 255 | nextTextNode = currentTextNode; 256 | } 257 | } 258 | 259 | spacingNode(contextNode) { 260 | let xPathQuery = './/*/text()[normalize-space(.)]'; 261 | if (contextNode.children && contextNode.children.length === 0) { 262 | xPathQuery = './/text()[normalize-space(.)]'; 263 | } 264 | this.spacingNodeByXPath(xPathQuery, contextNode); 265 | } 266 | 267 | spacingElementById(idName) { 268 | const xPathQuery = `id("${idName}")//text()`; 269 | this.spacingNodeByXPath(xPathQuery, document); 270 | } 271 | 272 | spacingElementByClassName(className) { 273 | const xPathQuery = `//*[contains(concat(" ", normalize-space(@class), " "), "${className}")]//text()`; 274 | this.spacingNodeByXPath(xPathQuery, document); 275 | } 276 | 277 | spacingElementByTagName(tagName) { 278 | const xPathQuery = `//${tagName}//text()`; 279 | this.spacingNodeByXPath(xPathQuery, document); 280 | } 281 | 282 | spacingPageTitle() { 283 | const xPathQuery = '/html/head/title/text()'; 284 | this.spacingNodeByXPath(xPathQuery, document); 285 | } 286 | 287 | spacingPageBody() { 288 | // // >> 任意位置的節點 289 | // . >> 當前節點 290 | // .. >> 父節點 291 | // [] >> 條件 292 | // text() >> 節點的文字內容,例如 hello 之於 hello 293 | // https://www.w3schools.com/xml/xpath_syntax.asp 294 | // 295 | // [@contenteditable] 296 | // 帶有 contenteditable 屬性的節點 297 | // 298 | // normalize-space(.) 299 | // 當前節點的頭尾的空白字元都會被移除,大於兩個以上的空白字元會被置換成單一空白 300 | // https://developer.mozilla.org/en-US/docs/Web/XPath/Functions/normalize-space 301 | // 302 | // name(..) 303 | // 父節點的名稱 304 | // https://developer.mozilla.org/en-US/docs/Web/XPath/Functions/name 305 | // 306 | // translate(string, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz") 307 | // 將 string 轉換成小寫,因為 XML 是 case-sensitive 的 308 | // https://developer.mozilla.org/en-US/docs/Web/XPath/Functions/translate 309 | // 310 | // 1. 處理 311 | // 2. 處理 <body> 底下的節點 312 | // 3. 略過 contentEditable 的節點 313 | // 4. 略過特定節點,例如 <script> 和 <style> 314 | // 315 | // 注意,以下的 query 只會取出各節點的 text 內容! 316 | let xPathQuery = '/html/body//*/text()[normalize-space(.)]'; 317 | ['script', 'style', 'textarea'].forEach((tag) => { 318 | // 理論上這幾個 tag 裡面不會包含其他 tag 319 | // 所以可以直接用 .. 取父節點 320 | // ex: [translate(name(..), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz") != "script"] 321 | xPathQuery = `${xPathQuery}[translate(name(..),"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")!="${tag}"]`; 322 | }); 323 | this.spacingNodeByXPath(xPathQuery, document); 324 | } 325 | 326 | // TODO: 支援 callback 和 promise 327 | spacingPage() { 328 | this.spacingPageTitle(); 329 | this.spacingPageBody(); 330 | } 331 | 332 | autoSpacingPage(pageDelay = 1000, nodeDelay = 500, nodeMaxWait = 2000) { 333 | if (!(document.body instanceof Node)) { 334 | return; 335 | } 336 | 337 | if (this.isAutoSpacingPageExecuted) { 338 | return; 339 | } 340 | this.isAutoSpacingPageExecuted = true; 341 | 342 | const self = this; 343 | 344 | const onceSpacingPage = once(() => { 345 | self.spacingPage(); 346 | }); 347 | 348 | // TODO 349 | // this is a dirty hack for https://github.com/vinta/pangu.js/issues/117 350 | const videos = document.getElementsByTagName('video'); 351 | if (videos.length === 0) { 352 | setTimeout(() => { 353 | onceSpacingPage(); 354 | }, pageDelay); 355 | } else { 356 | for (let i = 0; i < videos.length; i++) { 357 | const video = videos[i]; 358 | if (video.readyState === 4) { 359 | setTimeout(() => { 360 | onceSpacingPage(); 361 | }, 3000); 362 | break; 363 | } 364 | video.addEventListener('loadeddata', () => { 365 | setTimeout(() => { 366 | onceSpacingPage(); 367 | }, 4000); 368 | }); 369 | } 370 | } 371 | 372 | const queue = []; 373 | 374 | // it's possible that multiple workers process the queue at the same time 375 | const debouncedSpacingNodes = debounce(() => { 376 | // a single node could be very big which contains a lot of child nodes 377 | while (queue.length) { 378 | const node = queue.shift(); 379 | if (node) { 380 | self.spacingNode(node); 381 | } 382 | } 383 | }, nodeDelay, {'maxWait': nodeMaxWait}); 384 | 385 | // https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver 386 | const mutationObserver = new MutationObserver((mutations, observer) => { 387 | // Element: https://developer.mozilla.org/en-US/docs/Web/API/Element 388 | // Text: https://developer.mozilla.org/en-US/docs/Web/API/Text 389 | mutations.forEach((mutation) => { 390 | switch (mutation.type) { /* eslint-disable indent */ 391 | case 'childList': 392 | mutation.addedNodes.forEach((node) => { 393 | if (node.nodeType === Node.ELEMENT_NODE) { 394 | queue.push(node); 395 | } else if (node.nodeType === Node.TEXT_NODE) { 396 | queue.push(node.parentNode); 397 | } 398 | }); 399 | break; 400 | case 'characterData': 401 | const { target: node } = mutation; 402 | if (node.nodeType === Node.TEXT_NODE) { 403 | queue.push(node.parentNode); 404 | } 405 | break; 406 | default: 407 | break; 408 | } 409 | }); 410 | 411 | debouncedSpacingNodes(); 412 | }); 413 | mutationObserver.observe(document.body, { 414 | characterData: true, 415 | childList: true, 416 | subtree: true, 417 | }); 418 | } 419 | } 420 | 421 | const pangu = new BrowserPangu(); 422 | 423 | module.exports = pangu; 424 | module.exports.default = pangu; 425 | module.exports.Pangu = BrowserPangu; 426 | -------------------------------------------------------------------------------- /web/public/javascripts/zh_TW.js: -------------------------------------------------------------------------------- 1 | tinymce.addI18n('zh_TW',{ 2 | "Redo": "\u91cd\u505a", 3 | "Undo": "\u64a4\u92b7", 4 | "Cut": "\u526a\u4e0b", 5 | "Copy": "\u8907\u88fd", 6 | "Paste": "\u8cbc\u4e0a", 7 | "Select all": "\u5168\u9078", 8 | "New document": "\u65b0\u6587\u4ef6", 9 | "Ok": "\u78ba\u5b9a", 10 | "Cancel": "\u53d6\u6d88", 11 | "Visual aids": "\u5c0f\u5e6b\u624b", 12 | "Bold": "\u7c97\u9ad4", 13 | "Italic": "\u659c\u9ad4", 14 | "Underline": "\u4e0b\u5283\u7dda", 15 | "Strikethrough": "\u522a\u9664\u7dda", 16 | "Superscript": "\u4e0a\u6a19", 17 | "Subscript": "\u4e0b\u6a19", 18 | "Clear formatting": "\u6e05\u9664\u683c\u5f0f", 19 | "Align left": "\u5de6\u908a\u5c0d\u9f4a", 20 | "Align center": "\u4e2d\u9593\u5c0d\u9f4a", 21 | "Align right": "\u53f3\u908a\u5c0d\u9f4a", 22 | "Justify": "\u5de6\u53f3\u5c0d\u9f4a", 23 | "Bullet list": "\u9805\u76ee\u6e05\u55ae", 24 | "Numbered list": "\u6578\u5b57\u6e05\u55ae", 25 | "Decrease indent": "\u6e1b\u5c11\u7e2e\u6392", 26 | "Increase indent": "\u589e\u52a0\u7e2e\u6392", 27 | "Close": "\u95dc\u9589", 28 | "Formats": "\u683c\u5f0f", 29 | "Your browser doesn't support direct access to the clipboard. Please use the Ctrl+X\/C\/V keyboard shortcuts instead.": "\u60a8\u7684\u700f\u89bd\u5668\u4e0d\u652f\u63f4\u5b58\u53d6\u526a\u8cbc\u7c3f\uff0c\u53ef\u4ee5\u4f7f\u7528\u5feb\u901f\u9375 Ctrl + X\/C\/V \u4ee3\u66ff\u526a\u4e0b\u3001\u8907\u88fd\u8207\u8cbc\u4e0a\u3002", 30 | "Headers": "\u6a19\u984c", 31 | "Header 1": "\u6a19\u984c 1", 32 | "Header 2": "\u6a19\u984c 2", 33 | "Header 3": "\u6a19\u984c 3", 34 | "Header 4": "\u6a19\u984c 4", 35 | "Header 5": "\u6a19\u984c 5", 36 | "Header 6": "\u6a19\u984c 6", 37 | "Headings": "\u6a19\u984c", 38 | "Heading 1": "\u6a19\u984c1", 39 | "Heading 2": "\u6a19\u984c2", 40 | "Heading 3": "\u6a19\u984c3", 41 | "Heading 4": "\u6a19\u984c4", 42 | "Heading 5": "\u6a19\u984c5", 43 | "Heading 6": "\u6a19\u984c6", 44 | "Preformatted": "\u9810\u5148\u683c\u5f0f\u5316\u7684", 45 | "Div": "Div", 46 | "Pre": "Pre", 47 | "Code": "\u4ee3\u78bc", 48 | "Paragraph": "\u6bb5\u843d", 49 | "Blockquote": "\u5f15\u6587\u5340\u584a", 50 | "Inline": "\u5167\u806f", 51 | "Blocks": "\u57fa\u584a", 52 | "Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.": "\u76ee\u524d\u5c07\u4ee5\u7d14\u6587\u5b57\u7684\u6a21\u5f0f\u8cbc\u4e0a\uff0c\u60a8\u53ef\u4ee5\u518d\u9ede\u9078\u4e00\u6b21\u53d6\u6d88\u3002", 53 | "Fonts": "\u5b57\u578b", 54 | "Font Sizes": "\u5b57\u578b\u5927\u5c0f", 55 | "Class": "\u985e\u578b", 56 | "Browse for an image": "\u5f9e\u5716\u7247\u4e2d\u700f\u89bd", 57 | "OR": "\u6216", 58 | "Drop an image here": "\u62d6\u66f3\u5716\u7247\u81f3\u6b64", 59 | "Upload": "\u4e0a\u50b3", 60 | "Block": "\u5340\u584a", 61 | "Align": "\u5c0d\u9f4a", 62 | "Default": "\u9810\u8a2d", 63 | "Circle": "\u7a7a\u5fc3\u5713", 64 | "Disc": "\u5be6\u5fc3\u5713", 65 | "Square": "\u6b63\u65b9\u5f62", 66 | "Lower Alpha": "\u5c0f\u5beb\u82f1\u6587\u5b57\u6bcd", 67 | "Lower Greek": "\u5e0c\u81d8\u5b57\u6bcd", 68 | "Lower Roman": "\u5c0f\u5beb\u7f85\u99ac\u6578\u5b57", 69 | "Upper Alpha": "\u5927\u5beb\u82f1\u6587\u5b57\u6bcd", 70 | "Upper Roman": "\u5927\u5beb\u7f85\u99ac\u6578\u5b57", 71 | "Anchor...": "\u9328\u9ede...", 72 | "Name": "\u540d\u7a31", 73 | "Id": "Id", 74 | "Id should start with a letter, followed only by letters, numbers, dashes, dots, colons or underscores.": "Id\u61c9\u4ee5\u5b57\u6bcd\u958b\u982d\uff0c\u5f8c\u9762\u63a5\u8457\u5b57\u6bcd\uff0c\u6578\u5b57\uff0c\u7834\u6298\u865f\uff0c\u9ede\u6578\uff0c\u5192\u865f\u6216\u4e0b\u5283\u7dda\u3002", 75 | "You have unsaved changes are you sure you want to navigate away?": "\u7de8\u8f2f\u5c1a\u672a\u88ab\u5132\u5b58\uff0c\u4f60\u78ba\u5b9a\u8981\u96e2\u958b\uff1f", 76 | "Restore last draft": "\u8f09\u5165\u4e0a\u4e00\u6b21\u7de8\u8f2f\u7684\u8349\u7a3f", 77 | "Special character...": "\u7279\u6b8a\u5b57\u5143......", 78 | "Source code": "\u539f\u59cb\u78bc", 79 | "Insert\/Edit code sample": "\u63d2\u5165\/\u7de8\u8f2f \u7a0b\u5f0f\u78bc\u7bc4\u4f8b", 80 | "Language": "\u8a9e\u8a00", 81 | "Code sample...": "\u7a0b\u5f0f\u78bc\u7bc4\u4f8b...", 82 | "Color Picker": "\u9078\u8272\u5668", 83 | "R": "\u7d05", 84 | "G": "\u7da0", 85 | "B": "\u85cd", 86 | "Left to right": "\u5f9e\u5de6\u5230\u53f3", 87 | "Right to left": "\u5f9e\u53f3\u5230\u5de6", 88 | "Emoticons...": "\u8868\u60c5\u7b26\u865f\u2026", 89 | "Metadata and Document Properties": "\u5f8c\u8a2d\u8cc7\u6599\u8207\u6587\u4ef6\u5c6c\u6027", 90 | "Title": "\u6a19\u984c", 91 | "Keywords": "\u95dc\u9375\u5b57", 92 | "Description": "\u63cf\u8ff0", 93 | "Robots": "\u6a5f\u5668\u4eba", 94 | "Author": "\u4f5c\u8005", 95 | "Encoding": "\u7de8\u78bc", 96 | "Fullscreen": "\u5168\u87a2\u5e55", 97 | "Action": "\u52d5\u4f5c", 98 | "Shortcut": "\u5feb\u901f\u9375", 99 | "Help": "\u5e6b\u52a9", 100 | "Address": "\u5730\u5740", 101 | "Focus to menubar": "\u8df3\u81f3\u9078\u55ae\u5217", 102 | "Focus to toolbar": "\u8df3\u81f3\u5de5\u5177\u5217", 103 | "Focus to element path": "\u8df3\u81f3HTML\u5143\u7d20\u5217", 104 | "Focus to contextual toolbar": "\u8df3\u81f3\u5feb\u6377\u9078\u55ae", 105 | "Insert link (if link plugin activated)": "\u65b0\u589e\u6377\u5f91 (\u6377\u5f91\u5916\u639b\u555f\u7528\u6642)", 106 | "Save (if save plugin activated)": "\u5132\u5b58 (\u5132\u5b58\u5916\u639b\u555f\u7528\u6642)", 107 | "Find (if searchreplace plugin activated)": "\u5c0b\u627e (\u5c0b\u627e\u53d6\u4ee3\u5916\u639b\u555f\u7528\u6642)", 108 | "Plugins installed ({0}):": "({0}) \u500b\u5916\u639b\u5df2\u5b89\u88dd\uff1a", 109 | "Premium plugins:": "\u52a0\u503c\u5916\u639b\uff1a", 110 | "Learn more...": "\u4e86\u89e3\u66f4\u591a...", 111 | "You are using {0}": "\u60a8\u6b63\u5728\u4f7f\u7528 {0}", 112 | "Plugins": "\u5916\u639b", 113 | "Handy Shortcuts": "\u5feb\u901f\u9375", 114 | "Horizontal line": "\u6c34\u5e73\u7dda", 115 | "Insert\/edit image": "\u63d2\u5165\/\u7de8\u8f2f \u5716\u7247", 116 | "Image description": "\u5716\u7247\u63cf\u8ff0", 117 | "Source": "\u5716\u7247\u7db2\u5740", 118 | "Dimensions": "\u5c3a\u5bf8", 119 | "Constrain proportions": "\u7b49\u6bd4\u4f8b\u7e2e\u653e", 120 | "General": "\u4e00\u822c", 121 | "Advanced": "\u9032\u968e", 122 | "Style": "\u6a23\u5f0f", 123 | "Vertical space": "\u9ad8\u5ea6", 124 | "Horizontal space": "\u5bec\u5ea6", 125 | "Border": "\u908a\u6846", 126 | "Insert image": "\u63d2\u5165\u5716\u7247", 127 | "Image...": "\u5716\u7247......", 128 | "Image list": "\u5716\u7247\u6e05\u55ae", 129 | "Rotate counterclockwise": "\u9006\u6642\u91dd\u65cb\u8f49", 130 | "Rotate clockwise": "\u9806\u6642\u91dd\u65cb\u8f49", 131 | "Flip vertically": "\u5782\u76f4\u7ffb\u8f49", 132 | "Flip horizontally": "\u6c34\u5e73\u7ffb\u8f49", 133 | "Edit image": "\u7de8\u8f2f\u5716\u7247", 134 | "Image options": "\u5716\u7247\u9078\u9805", 135 | "Zoom in": "\u653e\u5927", 136 | "Zoom out": "\u7e2e\u5c0f", 137 | "Crop": "\u88c1\u526a", 138 | "Resize": "\u8abf\u6574\u5927\u5c0f", 139 | "Orientation": "\u65b9\u5411", 140 | "Brightness": "\u4eae\u5ea6", 141 | "Sharpen": "\u92b3\u5316", 142 | "Contrast": "\u5c0d\u6bd4", 143 | "Color levels": "\u984f\u8272\u5c64\u6b21", 144 | "Gamma": "\u4f3d\u99ac\u503c", 145 | "Invert": "\u53cd\u8f49", 146 | "Apply": "\u61c9\u7528", 147 | "Back": "\u5f8c\u9000", 148 | "Insert date\/time": "\u63d2\u5165 \u65e5\u671f\/\u6642\u9593", 149 | "Date\/time": "\u65e5\u671f\/\u6642\u9593", 150 | "Insert\/Edit Link": "\u63d2\u5165\/\u7de8\u8f2f\u9023\u7d50", 151 | "Insert\/edit link": "\u63d2\u5165\/\u7de8\u8f2f\u9023\u7d50", 152 | "Text to display": "\u986f\u793a\u6587\u5b57", 153 | "Url": "\u7db2\u5740", 154 | "Open link in...": "\u958b\u555f\u9023\u7d50\u65bc...", 155 | "Current window": "\u76ee\u524d\u8996\u7a97", 156 | "None": "\u7121", 157 | "New window": "\u53e6\u958b\u8996\u7a97", 158 | "Remove link": "\u79fb\u9664\u9023\u7d50", 159 | "Anchors": "\u52a0\u5165\u9328\u9ede", 160 | "Link...": "\u9023\u7d50...", 161 | "Paste or type a link": "\u8cbc\u4e0a\u6216\u8f38\u5165\u9023\u7d50", 162 | "The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?": "\u4f60\u6240\u586b\u5beb\u7684URL\u70ba\u96fb\u5b50\u90f5\u4ef6\uff0c\u9700\u8981\u52a0\u4e0amailto:\u524d\u7db4\u55ce\uff1f", 163 | "The URL you entered seems to be an external link. Do you want to add the required http:\/\/ prefix?": "\u4f60\u6240\u586b\u5beb\u7684URL\u5c6c\u65bc\u5916\u90e8\u93c8\u63a5\uff0c\u9700\u8981\u52a0\u4e0ahttp:\/\/:\u524d\u7db4\u55ce\uff1f", 164 | "Link list": "\u9023\u7d50\u6e05\u55ae", 165 | "Insert video": "\u63d2\u5165\u5f71\u97f3", 166 | "Insert\/edit video": "\u63d2\u4ef6\/\u7de8\u8f2f \u5f71\u97f3", 167 | "Insert\/edit media": "\u63d2\u5165\/\u7de8\u8f2f \u5a92\u9ad4", 168 | "Alternative source": "\u66ff\u4ee3\u5f71\u97f3", 169 | "Alternative source URL": "\u66ff\u4ee3\u4f86\u6e90URL", 170 | "Media poster (Image URL)": "\u5a92\u9ad4\u6d77\u5831\uff08\u5f71\u50cfImage URL\uff09", 171 | "Paste your embed code below:": "\u8acb\u5c07\u60a8\u7684\u5d4c\u5165\u5f0f\u7a0b\u5f0f\u78bc\u8cbc\u5728\u4e0b\u9762:", 172 | "Embed": "\u5d4c\u5165\u78bc", 173 | "Media...": "\u5a92\u9ad4...", 174 | "Nonbreaking space": "\u4e0d\u5206\u884c\u7684\u7a7a\u683c", 175 | "Page break": "\u5206\u9801", 176 | "Paste as text": "\u4ee5\u7d14\u6587\u5b57\u8cbc\u4e0a", 177 | "Preview": "\u9810\u89bd", 178 | "Print...": "\u5217\u5370...", 179 | "Save": "\u5132\u5b58", 180 | "Find": "\u641c\u5c0b", 181 | "Replace with": "\u66f4\u63db", 182 | "Replace": "\u66ff\u63db", 183 | "Replace all": "\u66ff\u63db\u5168\u90e8", 184 | "Previous": "\u4e0a\u4e00\u500b", 185 | "Next": "\u4e0b\u4e00\u500b", 186 | "Find and replace...": "\u5c0b\u627e\u53ca\u53d6\u4ee3...", 187 | "Could not find the specified string.": "\u7121\u6cd5\u67e5\u8a62\u5230\u6b64\u7279\u5b9a\u5b57\u4e32", 188 | "Match case": "\u76f8\u5339\u914d\u6848\u4ef6", 189 | "Find whole words only": "\u50c5\u627e\u51fa\u5b8c\u6574\u5b57\u532f", 190 | "Spell check": "\u62fc\u5beb\u6aa2\u67e5", 191 | "Ignore": "\u5ffd\u7565", 192 | "Ignore all": "\u5ffd\u7565\u6240\u6709", 193 | "Finish": "\u5b8c\u6210", 194 | "Add to Dictionary": "\u52a0\u5165\u5b57\u5178\u4e2d", 195 | "Insert table": "\u63d2\u5165\u8868\u683c", 196 | "Table properties": "\u8868\u683c\u5c6c\u6027", 197 | "Delete table": "\u522a\u9664\u8868\u683c", 198 | "Cell": "\u5132\u5b58\u683c", 199 | "Row": "\u5217", 200 | "Column": "\u884c", 201 | "Cell properties": "\u5132\u5b58\u683c\u5c6c\u6027", 202 | "Merge cells": "\u5408\u4f75\u5132\u5b58\u683c", 203 | "Split cell": "\u5206\u5272\u5132\u5b58\u683c", 204 | "Insert row before": "\u63d2\u5165\u5217\u5728...\u4e4b\u524d", 205 | "Insert row after": "\u63d2\u5165\u5217\u5728...\u4e4b\u5f8c", 206 | "Delete row": "\u522a\u9664\u5217", 207 | "Row properties": "\u5217\u5c6c\u6027", 208 | "Cut row": "\u526a\u4e0b\u5217", 209 | "Copy row": "\u8907\u88fd\u5217", 210 | "Paste row before": "\u8cbc\u4e0a\u5217\u5728...\u4e4b\u524d", 211 | "Paste row after": "\u8cbc\u4e0a\u5217\u5728...\u4e4b\u5f8c", 212 | "Insert column before": "\u63d2\u5165\u6b04\u4f4d\u5728...\u4e4b\u524d", 213 | "Insert column after": "\u63d2\u5165\u6b04\u4f4d\u5728...\u4e4b\u5f8c", 214 | "Delete column": "\u522a\u9664\u884c", 215 | "Cols": "\u6b04\u4f4d\u6bb5", 216 | "Rows": "\u5217", 217 | "Width": "\u5bec\u5ea6", 218 | "Height": "\u9ad8\u5ea6", 219 | "Cell spacing": "\u5132\u5b58\u683c\u5f97\u9593\u8ddd", 220 | "Cell padding": "\u5132\u5b58\u683c\u7684\u908a\u8ddd", 221 | "Show caption": "\u986f\u793a\u6a19\u984c", 222 | "Left": "\u5de6\u908a", 223 | "Center": "\u4e2d\u9593", 224 | "Right": "\u53f3\u908a", 225 | "Cell type": "\u5132\u5b58\u683c\u7684\u985e\u578b", 226 | "Scope": "\u7bc4\u570d", 227 | "Alignment": "\u5c0d\u9f4a", 228 | "H Align": "\u6c34\u5e73\u4f4d\u7f6e", 229 | "V Align": "\u5782\u76f4\u4f4d\u7f6e", 230 | "Top": "\u7f6e\u9802", 231 | "Middle": "\u7f6e\u4e2d", 232 | "Bottom": "\u7f6e\u5e95", 233 | "Header cell": "\u6a19\u982d\u5132\u5b58\u683c", 234 | "Row group": "\u5217\u7fa4\u7d44", 235 | "Column group": "\u6b04\u4f4d\u7fa4\u7d44", 236 | "Row type": "\u884c\u7684\u985e\u578b", 237 | "Header": "\u6a19\u982d", 238 | "Body": "\u4e3b\u9ad4", 239 | "Footer": "\u9801\u5c3e", 240 | "Border color": "\u908a\u6846\u984f\u8272", 241 | "Insert template...": "\u63d2\u5165\u6a23\u7248...", 242 | "Templates": "\u6a23\u7248", 243 | "Template": "\u6a23\u677f", 244 | "Text color": "\u6587\u5b57\u984f\u8272", 245 | "Background color": "\u80cc\u666f\u984f\u8272", 246 | "Custom...": "\u81ea\u8a02", 247 | "Custom color": "\u81ea\u8a02\u984f\u8272", 248 | "No color": "No color", 249 | "Remove color": "\u79fb\u9664\u984f\u8272", 250 | "Table of Contents": "\u76ee\u9304", 251 | "Show blocks": "\u986f\u793a\u5340\u584a\u8cc7\u8a0a", 252 | "Show invisible characters": "\u986f\u793a\u96b1\u85cf\u5b57\u5143", 253 | "Word count": "\u8a08\u7b97\u5b57\u6578", 254 | "Count": "\u8a08\u7b97", 255 | "Document": "\u6587\u4ef6", 256 | "Selection": "\u9078\u9805", 257 | "Words": "\u5b57\u6578", 258 | "Words: {0}": "\u5b57\u6578\uff1a{0}", 259 | "{0} words": "{0} \u5b57\u5143", 260 | "File": "\u6a94\u6848", 261 | "Edit": "\u7de8\u8f2f", 262 | "Insert": "\u63d2\u5165", 263 | "View": "\u6aa2\u8996", 264 | "Format": "\u683c\u5f0f", 265 | "Table": "\u8868\u683c", 266 | "Tools": "\u5de5\u5177", 267 | "Powered by {0}": "\u7531 {0} \u63d0\u4f9b", 268 | "Rich Text Area. Press ALT-F9 for menu. Press ALT-F10 for toolbar. Press ALT-0 for help": "\u8c50\u5bcc\u7684\u6587\u672c\u5340\u57df\u3002\u6309ALT-F9\u524d\u5f80\u4e3b\u9078\u55ae\u3002\u6309ALT-F10\u547c\u53eb\u5de5\u5177\u6b04\u3002\u6309ALT-0\u5c0b\u6c42\u5e6b\u52a9", 269 | "Image title": "\u5716\u7247\u6a19\u984c", 270 | "Border width": "\u6846\u7dda\u5bec\u5ea6", 271 | "Border style": "\u6846\u7dda\u6a23\u5f0f", 272 | "Error": "\u932f\u8aa4", 273 | "Warn": "\u8b66\u544a", 274 | "Valid": "\u6709\u6548", 275 | "To open the popup, press Shift+Enter": "\u8981\u958b\u555f\u5f48\u51fa\u8996\u7a97\uff0c\u8acb\u6309Shift+Enter", 276 | "Rich Text Area. Press ALT-0 for help.": "\u5bcc\u6587\u672c\u5340\u57df\u3002\u8acb\u6309ALT-0\u5c0b\u6c42\u5354\u52a9\u3002", 277 | "System Font": "\u7cfb\u7d71\u5b57\u578b", 278 | "Failed to upload image: {0}": "\u7121\u6cd5\u4e0a\u50b3\u5f71\u50cf\uff1a{0}", 279 | "Failed to load plugin: {0} from url {1}": "\u7121\u6cd5\u4e0a\u50b3\u63d2\u4ef6\uff1a{0}\u81eaurl{1}", 280 | "Failed to load plugin url: {0}": "\u7121\u6cd5\u4e0a\u50b3\u63d2\u4ef6\uff1a{0}", 281 | "Failed to initialize plugin: {0}": "\u7121\u6cd5\u555f\u52d5\u63d2\u4ef6\uff1a{0}", 282 | "example": "\u7bc4\u4f8b", 283 | "Search": "\u641c\u7d22", 284 | "All": "\u5168\u90e8", 285 | "Currency": "\u8ca8\u5e63", 286 | "Text": "\u6587\u672c", 287 | "Quotations": "\u5f15\u7528", 288 | "Mathematical": "\u6578\u5b78", 289 | "Extended Latin": "\u62c9\u4e01\u5b57\u6bcd\u64f4\u5145", 290 | "Symbols": "\u7b26\u865f", 291 | "Arrows": "\u7bad\u982d", 292 | "User Defined": "\u4f7f\u7528\u8005\u5df2\u5b9a\u7fa9", 293 | "dollar sign": "\u7f8e\u5143\u7b26\u865f", 294 | "currency sign": "\u8ca8\u5e63\u7b26\u865f", 295 | "euro-currency sign": "\u6b50\u5143\u7b26\u865f", 296 | "colon sign": "\u79d1\u6717\u7b26\u865f", 297 | "cruzeiro sign": "\u514b\u9b6f\u8cfd\u7f85\u7b26\u865f", 298 | "french franc sign": "\u6cd5\u6717\u7b26\u865f", 299 | "lira sign": "\u91cc\u62c9\u7b26\u865f", 300 | "mill sign": "\u6587\u7b26\u865f", 301 | "naira sign": "\u5948\u62c9\u7b26\u865f", 302 | "peseta sign": "\u6bd4\u585e\u5854\u7b26\u865f", 303 | "rupee sign": "\u76e7\u6bd4\u7b26\u865f", 304 | "won sign": "\u97d3\u571c\u7b26\u865f", 305 | "new sheqel sign": "\u65b0\u8b1d\u514b\u723e\u7b26\u865f", 306 | "dong sign": "\u8d8a\u5357\u76fe\u7b26\u865f", 307 | "kip sign": "\u8001\u64be\u5e63\u7b26\u865f", 308 | "tugrik sign": "\u8499\u53e4\u5e63\u7b26\u865f", 309 | "drachma sign": "\u5fb7\u514b\u62c9\u99ac\u7b26\u865f", 310 | "german penny symbol": "\u5fb7\u570b\u5206\u7b26\u865f", 311 | "peso sign": "\u62ab\u7d22\u7b26\u865f", 312 | "guarani sign": "\u5df4\u62c9\u572d\u5e63\u7b26\u865f", 313 | "austral sign": "\u963f\u6839\u5ef7\u5e63\u7b26\u865f", 314 | "hryvnia sign": "\u70cf\u514b\u862d\u5e63\u7b26\u865f", 315 | "cedi sign": "\u8fe6\u7d0d\u5e63\u7b26\u865f", 316 | "livre tournois sign": "\u91cc\u5f17\u723e\u7b26\u865f", 317 | "spesmilo sign": "\u570b\u969b\u5e63\u7b26\u865f", 318 | "tenge sign": "\u54c8\u85a9\u514b\u5e63\u7b26\u865f", 319 | "indian rupee sign": "\u5370\u5ea6\u76e7\u6bd4\u7b26\u865f", 320 | "turkish lira sign": "\u571f\u8033\u5176\u91cc\u62c9\u7b26\u865f", 321 | "nordic mark sign": "\u5317\u6b50\u99ac\u514b\u7b26\u865f", 322 | "manat sign": "\u4e9e\u585e\u62dc\u7136\u5e63\u7b26\u865f", 323 | "ruble sign": "\u76e7\u5e03\u7b26\u865f", 324 | "yen character": "\u65e5\u5713\u7b26\u865f", 325 | "yuan character": "\u4eba\u6c11\u5e63\u7b26\u865f", 326 | "yuan character, in hong kong and taiwan": "\u6e2f\u5143\u8207\u53f0\u5e63\u7b26\u865f", 327 | "yen\/yuan character variant one": "\u65e5\u5713\/\u4eba\u6c11\u5e63\u7b26\u865f\u8b8a\u5316\u578b", 328 | "Loading emoticons...": "\u8f09\u5165\u8868\u60c5\u7b26\u865f\u2026", 329 | "Could not load emoticons": "\u7121\u6cd5\u8f09\u5165\u8868\u60c5\u7b26\u865f", 330 | "People": "\u4eba", 331 | "Animals and Nature": "\u52d5\u7269\u8207\u81ea\u7136", 332 | "Food and Drink": "\u98f2\u98df", 333 | "Activity": "\u6d3b\u52d5", 334 | "Travel and Places": "\u65c5\u884c\u8207\u5730\u9ede", 335 | "Objects": "\u7269\u4ef6", 336 | "Flags": "\u65d7\u6a19", 337 | "Characters": "\u5b57\u5143", 338 | "Characters (no spaces)": "\u5b57\u5143\uff08\u7121\u7a7a\u683c\uff09", 339 | "{0} characters": "{0}\u5b57\u5143", 340 | "Error: Form submit field collision.": "\u932f\u8aa4\uff1a\u8868\u683c\u905e\u4ea4\u6b04\u4f4d\u885d\u7a81\u3002", 341 | "Error: No form element found.": "\u932f\u8aa4\uff1a\u627e\u4e0d\u5230\u8868\u683c\u5143\u7d20\u3002", 342 | "Update": "\u66f4\u65b0", 343 | "Color swatch": "\u8272\u5f69\u6a23\u672c", 344 | "Turquoise": "\u571f\u8033\u5176\u85cd", 345 | "Green": "\u7da0\u8272", 346 | "Blue": "\u85cd\u8272", 347 | "Purple": "\u7d2b\u8272", 348 | "Navy Blue": "\u6df1\u85cd\u8272", 349 | "Dark Turquoise": "\u6df1\u571f\u8033\u5176\u85cd", 350 | "Dark Green": "\u6df1\u7da0\u8272", 351 | "Medium Blue": "\u4e2d\u85cd\u8272", 352 | "Medium Purple": "\u4e2d\u7d2b\u8272", 353 | "Midnight Blue": "\u9ed1\u85cd\u8272", 354 | "Yellow": "\u9ec3\u8272", 355 | "Orange": "\u6a59\u8272", 356 | "Red": "\u7d05\u8272", 357 | "Light Gray": "\u6dfa\u7070\u8272", 358 | "Gray": "\u7070\u8272", 359 | "Dark Yellow": "\u6df1\u9ec3\u8272", 360 | "Dark Orange": "\u6df1\u6a59\u8272", 361 | "Dark Red": "\u6697\u7d05\u8272", 362 | "Medium Gray": "\u4e2d\u7070\u8272", 363 | "Dark Gray": "\u6df1\u7070\u8272", 364 | "Light Green": "\u6de1\u7da0\u8272", 365 | "Light Yellow": "\u6dfa\u9ec3\u8272", 366 | "Light Red": "\u6dfa\u7d05\u8272", 367 | "Light Purple": "\u6dfa\u7d2b\u8272", 368 | "Light Blue": "\u6dfa\u85cd\u8272", 369 | "Dark Purple": "\u6df1\u7d2b\u8272", 370 | "Dark Blue": "\u6df1\u85cd\u8272", 371 | "Black": "\u9ed1\u8272", 372 | "White": "\u767d\u8272", 373 | "Switch to or from fullscreen mode": "\u8f49\u63db\u81ea\/\u81f3\u5168\u87a2\u5e55\u6a21\u5f0f", 374 | "Open help dialog": "\u958b\u555f\u5354\u52a9\u5c0d\u8a71", 375 | "history": "\u6b77\u53f2", 376 | "styles": "\u6a23\u5f0f", 377 | "formatting": "\u683c\u5f0f", 378 | "alignment": "\u5c0d\u9f4a", 379 | "indentation": "\u7e2e\u6392", 380 | "permanent pen": "\u6c38\u4e45\u6027\u7b46", 381 | "comments": "\u8a3b\u89e3", 382 | "Format Painter": "\u8907\u88fd\u683c\u5f0f", 383 | "Insert\/edit iframe": "\u63d2\u5165\/\u7de8\u8f2fiframe", 384 | "Capitalization": "\u5927\u5beb", 385 | "lowercase": "\u5c0f\u5beb", 386 | "UPPERCASE": "\u5927\u5beb", 387 | "Title Case": "\u5b57\u9996\u5927\u5beb", 388 | "Permanent Pen Properties": "\u6c38\u4e45\u6a19\u8a18\u5c6c\u6027", 389 | "Permanent pen properties...": "\u6c38\u4e45\u6a19\u8a18\u5c6c\u6027......", 390 | "Font": "\u5b57\u578b", 391 | "Size": "\u5b57\u5f62\u5927\u5c0f", 392 | "More...": "\u66f4\u591a\u8cc7\u8a0a......", 393 | "Spellcheck Language": "\u62fc\u5beb\u8a9e\u8a00", 394 | "Select...": "\u9078\u64c7......", 395 | "Preferences": "\u9996\u9078\u9805", 396 | "Yes": "\u662f", 397 | "No": "\u5426", 398 | "Keyboard Navigation": "\u9375\u76e4\u5c0e\u822a", 399 | "Version": "\u7248\u672c", 400 | "Anchor": "\u52a0\u5165\u9328\u9ede", 401 | "Special character": "\u7279\u6b8a\u5b57\u5143", 402 | "Code sample": "\u7a0b\u5f0f\u78bc\u7bc4\u4f8b", 403 | "Color": "\u984f\u8272", 404 | "Emoticons": "\u8868\u60c5", 405 | "Document properties": "\u6587\u4ef6\u7684\u5c6c\u6027", 406 | "Image": "\u5716\u7247", 407 | "Insert link": "\u63d2\u5165\u9023\u7d50", 408 | "Target": "\u958b\u555f\u65b9\u5f0f", 409 | "Link": "\u9023\u7d50", 410 | "Poster": "\u9810\u89bd\u5716\u7247", 411 | "Media": "\u5a92\u9ad4", 412 | "Print": "\u5217\u5370", 413 | "Prev": "\u4e0a\u4e00\u500b", 414 | "Find and replace": "\u5c0b\u627e\u53ca\u53d6\u4ee3", 415 | "Whole words": "\u6574\u500b\u55ae\u5b57", 416 | "Spellcheck": "\u62fc\u5b57\u6aa2\u67e5", 417 | "Caption": "\u8868\u683c\u6a19\u984c", 418 | "Insert template": "\u63d2\u5165\u6a23\u7248" 419 | }); 420 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | <one line to give the program's name and a brief idea of what it does.> 633 | Copyright (C) <year> <name of author> 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published by 637 | the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see <https://www.gnu.org/licenses/>. 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | <https://www.gnu.org/licenses/>. 662 | --------------------------------------------------------------------------------