From 0b649eaedd147304ced3a7c333e0a6f7c0031a5a Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Mon, 22 Jul 2019 11:05:52 +0100 Subject: [PATCH] Remove unused files no issue - `app/helpers/gh-format-html` is duplicated in `lib/koenig-editor/addon/helpers/sanitize-html` and is not used anywhere else - `app/helpers/gh-path` is not used anywhere - the API should be returning absolute URLs everywhere so path generation is no longer as necessary within templates - `app/helpers/is-equal` replaced with `{{eq}}` from `ember-truth-helpers` - `app/helpers/is-not` replaced with `{{not}}` from `ember-truth-helpers` - `app/utils/isFinite` is not used anywhere - `app/utils/titleize` is not used anywhere --- ghost/admin/app/helpers/gh-format-html.js | 25 -------- ghost/admin/app/helpers/gh-path.js | 60 ------------------- ghost/admin/app/helpers/is-equal.js | 11 ---- ghost/admin/app/helpers/is-not.js | 9 --- ghost/admin/app/utils/isFinite.js | 7 --- ghost/admin/app/utils/titleize.js | 18 ------ .../admin/tests/unit/helpers/is-equal-test.js | 17 ------ ghost/admin/tests/unit/helpers/is-not-test.js | 17 ------ 8 files changed, 164 deletions(-) delete mode 100644 ghost/admin/app/helpers/gh-format-html.js delete mode 100644 ghost/admin/app/helpers/gh-path.js delete mode 100644 ghost/admin/app/helpers/is-equal.js delete mode 100644 ghost/admin/app/helpers/is-not.js delete mode 100644 ghost/admin/app/utils/isFinite.js delete mode 100644 ghost/admin/app/utils/titleize.js delete mode 100644 ghost/admin/tests/unit/helpers/is-equal-test.js delete mode 100644 ghost/admin/tests/unit/helpers/is-not-test.js diff --git a/ghost/admin/app/helpers/gh-format-html.js b/ghost/admin/app/helpers/gh-format-html.js deleted file mode 100644 index 5d17300e29..0000000000 --- a/ghost/admin/app/helpers/gh-format-html.js +++ /dev/null @@ -1,25 +0,0 @@ -/* global html_sanitize*/ -import cajaSanitizers from 'ghost-admin/utils/caja-sanitizers'; -import {helper} from '@ember/component/helper'; -import {htmlSafe} from '@ember/string'; - -export default helper(function (params) { - if (!params || !params.length) { - return; - } - - let escapedhtml = params[0] || ''; - - // replace script and iFrame - escapedhtml = escapedhtml.replace(/)<[^<]*)*<\/script>/gi, - '
Embedded JavaScript
'); - escapedhtml = escapedhtml.replace(/)<[^<]*)*<\/iframe>/gi, - '
Embedded iFrame
'); - - // sanitize HTML - /* eslint-disable camelcase */ - escapedhtml = html_sanitize(escapedhtml, cajaSanitizers.url, cajaSanitizers.id); - /* eslint-enable camelcase */ - - return htmlSafe(escapedhtml); -}); diff --git a/ghost/admin/app/helpers/gh-path.js b/ghost/admin/app/helpers/gh-path.js deleted file mode 100644 index 0f608ab087..0000000000 --- a/ghost/admin/app/helpers/gh-path.js +++ /dev/null @@ -1,60 +0,0 @@ -import ghostPaths from 'ghost-admin/utils/ghost-paths'; -import {helper} from '@ember/component/helper'; -import {htmlSafe} from '@ember/string'; - -// Handlebars Helper {{gh-path}} -// Usage: Assume 'http://www.myghostblog.org/myblog/' -// {{gh-path}} or {{gh-path 'blog'}} for Ghost's root (/myblog/) -// {{gh-path 'admin'}} for Ghost's admin root (/myblog/ghost/) -// {{gh-path 'api'}} for Ghost's api root (/myblog/ghost/api/v0.1/) -// -// DO NOT USE - admin asset paths are now relative because we are using hash urls -// and the gh-path helper can get in the way of asset rewriting -// {{gh-path 'asset' '/img/hi.png'}} for resolved url (/myblog/ghost/assets/img/hi.png) - -export default helper(function (params) { - let paths = ghostPaths(); - let [path, url] = params; - let base; - - if (!path) { - path = 'blog'; - } - - if (!/^(blog|admin|asset|api)$/.test(path)) { - url = path; - path = 'blog'; - } - - switch (path.toString()) { - case 'blog': - base = paths.blogRoot; - break; - case 'admin': - base = paths.adminRoot; - break; - case 'asset': - base = paths.assetRoot; - break; - case 'api': - base = paths.apiRoot; - break; - default: - base = paths.blogRoot; - break; - } - - // handle leading and trailing slashes - - base = base[base.length - 1] !== '/' ? `${base}/` : base; - - if (url && url.length > 0) { - if (url[0] === '/') { - url = url.substr(1); - } - - base = base + url; - } - - return htmlSafe(base); -}); diff --git a/ghost/admin/app/helpers/is-equal.js b/ghost/admin/app/helpers/is-equal.js deleted file mode 100644 index 6090e900ff..0000000000 --- a/ghost/admin/app/helpers/is-equal.js +++ /dev/null @@ -1,11 +0,0 @@ -import {helper} from '@ember/component/helper'; - -export function isEqual(params) { - let [lhs, rhs] = params; - - return lhs === rhs; -} - -export default helper(function (params) { - return isEqual(params); -}); diff --git a/ghost/admin/app/helpers/is-not.js b/ghost/admin/app/helpers/is-not.js deleted file mode 100644 index 3f41d4ea8d..0000000000 --- a/ghost/admin/app/helpers/is-not.js +++ /dev/null @@ -1,9 +0,0 @@ -import {helper} from '@ember/component/helper'; - -export function isNot(params) { - return !params; -} - -export default helper(function (params) { - return isNot(params); -}); diff --git a/ghost/admin/app/utils/isFinite.js b/ghost/admin/app/utils/isFinite.js deleted file mode 100644 index 23e1dd9f42..0000000000 --- a/ghost/admin/app/utils/isFinite.js +++ /dev/null @@ -1,7 +0,0 @@ -/* globals window */ - -// isFinite function from lodash - -export default function (value) { - return window.isFinite(value) && !window.isNaN(parseFloat(value)); -} diff --git a/ghost/admin/app/utils/titleize.js b/ghost/admin/app/utils/titleize.js deleted file mode 100644 index 139a4ba830..0000000000 --- a/ghost/admin/app/utils/titleize.js +++ /dev/null @@ -1,18 +0,0 @@ -import {capitalize} from '@ember/string'; -const lowerWords = [ - 'of', 'a', 'the', 'and', 'an', 'or', 'nor', 'but', 'is', 'if', - 'then', 'else', 'when', 'at', 'from', 'by', 'on', 'off', 'for', - 'in', 'out', 'over', 'to', 'into', 'with' -]; - -export default function (input) { - let words = input.split(' ').map((word, index) => { - if (index === 0 || lowerWords.indexOf(word) === -1) { - word = capitalize(word); - } - - return word; - }); - - return words.join(' '); -} diff --git a/ghost/admin/tests/unit/helpers/is-equal-test.js b/ghost/admin/tests/unit/helpers/is-equal-test.js deleted file mode 100644 index 3fd11b5495..0000000000 --- a/ghost/admin/tests/unit/helpers/is-equal-test.js +++ /dev/null @@ -1,17 +0,0 @@ -import { - describe, - it -} from 'mocha'; -import {expect} from 'chai'; -import { - isEqual -} from 'ghost-admin/helpers/is-equal'; - -describe('Unit: Helper: is-equal', function () { - // Replace this with your real tests. - it('works', function () { - let result = isEqual([42, 42]); - - expect(result).to.be.ok; - }); -}); diff --git a/ghost/admin/tests/unit/helpers/is-not-test.js b/ghost/admin/tests/unit/helpers/is-not-test.js deleted file mode 100644 index a0f4a5fa1c..0000000000 --- a/ghost/admin/tests/unit/helpers/is-not-test.js +++ /dev/null @@ -1,17 +0,0 @@ -import { - describe, - it -} from 'mocha'; -import {expect} from 'chai'; -import { - isNot -} from 'ghost-admin/helpers/is-not'; - -describe('Unit: Helper: is-not', function () { - // Replace this with your real tests. - it('works', function () { - let result = isNot(false); - - expect(result).to.be.ok; - }); -});