summaryrefslogtreecommitdiff
path: root/src/common/build
diff options
context:
space:
mode:
authorAkihiko Odaki <nekomanma@pixiv.co.jp>2018-03-29 01:20:40 +0900
committerAkihiko Odaki <nekomanma@pixiv.co.jp>2018-03-29 01:54:41 +0900
commit90f8fe7e538bb7e52d2558152a0390e693f39b11 (patch)
tree0f830887053c8f352b1cd0c13ca715fd14c1f030 /src/common/build
parentImplement remote account resolution (diff)
downloadmisskey-90f8fe7e538bb7e52d2558152a0390e693f39b11.tar.gz
misskey-90f8fe7e538bb7e52d2558152a0390e693f39b11.tar.bz2
misskey-90f8fe7e538bb7e52d2558152a0390e693f39b11.zip
Introduce processor
Diffstat (limited to 'src/common/build')
-rw-r--r--src/common/build/fa.ts57
-rw-r--r--src/common/build/i18n.ts57
-rw-r--r--src/common/build/license.ts13
3 files changed, 0 insertions, 127 deletions
diff --git a/src/common/build/fa.ts b/src/common/build/fa.ts
deleted file mode 100644
index 0c21be9504..0000000000
--- a/src/common/build/fa.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * Replace fontawesome symbols
- */
-
-import * as fontawesome from '@fortawesome/fontawesome';
-import * as regular from '@fortawesome/fontawesome-free-regular';
-import * as solid from '@fortawesome/fontawesome-free-solid';
-import * as brands from '@fortawesome/fontawesome-free-brands';
-
-// Add icons
-fontawesome.library.add(regular);
-fontawesome.library.add(solid);
-fontawesome.library.add(brands);
-
-export const pattern = /%fa:(.+?)%/g;
-
-export const replacement = (_, key) => {
- const args = key.split(' ');
- let prefix = 'fas';
- const classes = [];
- let transform = '';
- let name;
-
- args.forEach(arg => {
- if (arg == 'R' || arg == 'S' || arg == 'B') {
- prefix =
- arg == 'R' ? 'far' :
- arg == 'S' ? 'fas' :
- arg == 'B' ? 'fab' :
- '';
- } else if (arg[0] == '.') {
- classes.push('fa-' + arg.substr(1));
- } else if (arg[0] == '-') {
- transform = arg.substr(1).split('|').join(' ');
- } else {
- name = arg;
- }
- });
-
- const icon = fontawesome.icon({ prefix, iconName: name }, {
- classes: classes
- });
-
- if (icon) {
- icon.transform = fontawesome.parse.transform(transform);
- return `<i data-fa class="${name}">${icon.html[0]}</i>`;
- } else {
- console.warn(`'${name}' not found in fa`);
- return '';
- }
-};
-
-export default (src: string) => {
- return src.replace(pattern, replacement);
-};
-
-export const fa = fontawesome;
diff --git a/src/common/build/i18n.ts b/src/common/build/i18n.ts
deleted file mode 100644
index 5e3c0381a9..0000000000
--- a/src/common/build/i18n.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * Replace i18n texts
- */
-
-import locale from '../../../locales';
-
-export default class Replacer {
- private lang: string;
-
- public pattern = /"%i18n:(.+?)%"|'%i18n:(.+?)%'|%i18n:(.+?)%/g;
-
- constructor(lang: string) {
- this.lang = lang;
-
- this.get = this.get.bind(this);
- this.replacement = this.replacement.bind(this);
- }
-
- private get(key: string) {
- const texts = locale[this.lang];
-
- if (texts == null) {
- console.warn(`lang '${this.lang}' is not supported`);
- return key; // Fallback
- }
-
- let text = texts;
-
- // Check the key existance
- const error = key.split('.').some(k => {
- if (text.hasOwnProperty(k)) {
- text = text[k];
- return false;
- } else {
- return true;
- }
- });
-
- if (error) {
- console.warn(`key '${key}' not found in '${this.lang}'`);
- return key; // Fallback
- } else {
- return text;
- }
- }
-
- public replacement(match, a, b, c) {
- const key = a || b || c;
- if (match[0] == '"') {
- return '"' + this.get(key).replace(/"/g, '\\"') + '"';
- } else if (match[0] == "'") {
- return '\'' + this.get(key).replace(/'/g, '\\\'') + '\'';
- } else {
- return this.get(key);
- }
- }
-}
diff --git a/src/common/build/license.ts b/src/common/build/license.ts
deleted file mode 100644
index e5c264df8a..0000000000
--- a/src/common/build/license.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-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
-};