From 88e4f1b287e9fa6be12b5a2277073265d6732527 Mon Sep 17 00:00:00 2001
From: syuilo <syuilotan@yahoo.co.jp>
Date: Mon, 1 Jan 2018 02:08:41 +0900
Subject: [PATCH] :v:

---
 src/common/build/license.ts     | 13 +++++++++++++
 src/web/docs/license.en.pug     |  3 +++
 src/web/docs/license.ja.pug     |  3 +++
 src/web/docs/vars.ts            |  3 +++
 webpack/module/rules/license.ts |  9 ++-------
 5 files changed, 24 insertions(+), 7 deletions(-)
 create mode 100644 src/common/build/license.ts
 create mode 100644 src/web/docs/license.en.pug
 create mode 100644 src/web/docs/license.ja.pug

diff --git a/src/common/build/license.ts b/src/common/build/license.ts
new file mode 100644
index 000000000..e5c264df8
--- /dev/null
+++ b/src/common/build/license.ts
@@ -0,0 +1,13 @@
+import * as fs from 'fs';
+
+const license = fs.readFileSync(__dirname + '/../../../LICENSE', 'utf-8');
+
+const licenseHtml = license
+	.replace(/\r\n/g, '\n')
+	.replace(/(.)\n(.)/g, '$1 $2')
+	.replace(/(^|\n)(.*?)($|\n)/g, '<p>$2</p>');
+
+export {
+	license,
+	licenseHtml
+};
diff --git a/src/web/docs/license.en.pug b/src/web/docs/license.en.pug
new file mode 100644
index 000000000..240756e7e
--- /dev/null
+++ b/src/web/docs/license.en.pug
@@ -0,0 +1,3 @@
+h1 License
+
+div!= common.license
diff --git a/src/web/docs/license.ja.pug b/src/web/docs/license.ja.pug
new file mode 100644
index 000000000..1f44f3f5e
--- /dev/null
+++ b/src/web/docs/license.ja.pug
@@ -0,0 +1,3 @@
+h1 ライセンス
+
+div!= common.license
diff --git a/src/web/docs/vars.ts b/src/web/docs/vars.ts
index 65b224fbf..95ae9ee62 100644
--- a/src/web/docs/vars.ts
+++ b/src/web/docs/vars.ts
@@ -4,6 +4,7 @@ import * as yaml from 'js-yaml';
 
 import { fa } from '../../common/build/fa';
 import config from '../../conf';
+import { licenseHtml } from '../../common/build/license';
 const constants = require('../../const.json');
 
 export default function(): { [key: string]: any } {
@@ -42,5 +43,7 @@ export default function(): { [key: string]: any } {
 
 	vars['facss'] = fa.dom.css();
 
+	vars['license'] = licenseHtml;
+
 	return vars;
 }
diff --git a/webpack/module/rules/license.ts b/webpack/module/rules/license.ts
index 1795af960..de8b7d79f 100644
--- a/webpack/module/rules/license.ts
+++ b/webpack/module/rules/license.ts
@@ -2,13 +2,8 @@
  * Inject license
  */
 
-import * as fs from 'fs';
 const StringReplacePlugin = require('string-replace-webpack-plugin');
-
-const license = fs.readFileSync(__dirname + '/../../../LICENSE', 'utf-8')
-	.replace(/\r\n/g, '\n')
-	.replace(/(.)\n(.)/g, '$1 $2')
-	.replace(/(^|\n)(.*?)($|\n)/g, '<p>$2</p>');
+import { licenseHtml } from '../../../src/common/build/license';
 
 export default () => ({
 	enforce: 'pre',
@@ -16,7 +11,7 @@ export default () => ({
 	exclude: /node_modules/,
 	loader: StringReplacePlugin.replace({
 		replacements: [{
-			pattern: '%license%', replacement: () => license
+			pattern: '%license%', replacement: () => licenseHtml
 		}]
 	})
 });