From 1e77a4c915c0fc1429cc015df535ed75f2dae6b8 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Mon, 27 Jan 2020 09:51:45 +0000 Subject: [PATCH] Removed no issue - the count.ghost.org service is being shut down - replaced the fetch+poll component with a hardcoded figure --- .../admin/app/components/gh-download-count.js | 39 ------------------- .../components/gh-download-count.hbs | 5 --- ghost/admin/app/templates/setup/one.hbs | 2 +- ghost/admin/app/utils/ghost-paths.js | 1 - ghost/admin/mirage/config.js | 9 ----- ghost/admin/tests/acceptance/setup-test.js | 4 -- .../components/gh-download-count-test.js | 39 ------------------- 7 files changed, 1 insertion(+), 98 deletions(-) delete mode 100644 ghost/admin/app/components/gh-download-count.js delete mode 100644 ghost/admin/app/templates/components/gh-download-count.hbs delete mode 100644 ghost/admin/tests/integration/components/gh-download-count-test.js diff --git a/ghost/admin/app/components/gh-download-count.js b/ghost/admin/app/components/gh-download-count.js deleted file mode 100644 index ed04cb29c1..0000000000 --- a/ghost/admin/app/components/gh-download-count.js +++ /dev/null @@ -1,39 +0,0 @@ -import Component from '@ember/component'; -import config from 'ghost-admin/config/environment'; -import {inject as service} from '@ember/service'; -import {task, timeout} from 'ember-concurrency'; - -export default Component.extend({ - ajax: service(), - ghostPaths: service(), - - tagName: '', - count: '', - - didInsertElement() { - this._poll.perform(); - }, - - _poll: task(function* () { - let url = this.get('ghostPaths.count'); - let pattern = /(-?\d+)(\d{3})/; - - try { - let data = yield this.ajax.request(url); - let count = data.count.toString(); - - while (pattern.test(count)) { - count = count.replace(pattern, '$1,$2'); - } - - this.set('count', count); - - if (config.environment !== 'test') { - yield timeout(2000); - this._poll.perform(); - } - } catch (e) { - // no-op - we don't want to create noise for a failed download count - } - }) -}); diff --git a/ghost/admin/app/templates/components/gh-download-count.hbs b/ghost/admin/app/templates/components/gh-download-count.hbs deleted file mode 100644 index 15bb665fc9..0000000000 --- a/ghost/admin/app/templates/components/gh-download-count.hbs +++ /dev/null @@ -1,5 +0,0 @@ -{{#if hasBlock}} - {{yield this.count}} -{{else}} - {{this.count}} -{{/if}} diff --git a/ghost/admin/app/templates/setup/one.hbs b/ghost/admin/app/templates/setup/one.hbs index 5c2212983c..26475e20a2 100644 --- a/ghost/admin/app/templates/setup/one.hbs +++ b/ghost/admin/app/templates/setup/one.hbs @@ -1,6 +1,6 @@

Welcome to Ghost!

-

All over the world, people have started incredible sites with Ghost. Today, we’re starting yours.

+

All over the world, people have started 2,000,000+ incredible sites with Ghost. Today, we’re starting yours.

diff --git a/ghost/admin/app/utils/ghost-paths.js b/ghost/admin/app/utils/ghost-paths.js index fba2aa6431..944b301524 100644 --- a/ghost/admin/app/utils/ghost-paths.js +++ b/ghost/admin/app/utils/ghost-paths.js @@ -30,7 +30,6 @@ export default function () { apiRoot, subdir, blogRoot: `${subdir}/`, - count: 'https://count.ghost.org/', url: { admin() { diff --git a/ghost/admin/mirage/config.js b/ghost/admin/mirage/config.js index 241dedbcc4..ef90f61453 100644 --- a/ghost/admin/mirage/config.js +++ b/ghost/admin/mirage/config.js @@ -39,7 +39,6 @@ export default function () { this.passthrough(); // add any external domains to make sure those get passed through too - this.passthrough('https://count.ghost.org/'); this.passthrough('http://www.gravatar.com/**'); this.passthrough('https://cdn.jsdelivr.net/**'); this.passthrough('https://api.unsplash.com/**'); @@ -84,14 +83,6 @@ export function testConfig() { /* External sites ------------------------------------------------------- */ - let downloadCount = 0; - this.get('https://count.ghost.org/', function () { - downloadCount += 1; - return { - count: downloadCount - }; - }); - this.head('http://www.gravatar.com/avatar/:md5', function () { return ''; }, 200); diff --git a/ghost/admin/tests/acceptance/setup-test.js b/ghost/admin/tests/acceptance/setup-test.js index df3b4dae45..217bda74a5 100644 --- a/ghost/admin/tests/acceptance/setup-test.js +++ b/ghost/admin/tests/acceptance/setup-test.js @@ -73,10 +73,6 @@ describe('Acceptance: Setup', function () { expect(stepIcons[1], 'second step').to.not.have.class('active'); expect(stepIcons[2], 'third step').to.not.have.class('active'); - // it displays download count (count increments for each ajax call - // and polling is disabled in testing so our count should be "1" - expect(find('.gh-flow-content em').textContent.trim()).to.equal('1'); - await click('.gh-btn-green'); // it transitions to step two diff --git a/ghost/admin/tests/integration/components/gh-download-count-test.js b/ghost/admin/tests/integration/components/gh-download-count-test.js deleted file mode 100644 index 106d1552f5..0000000000 --- a/ghost/admin/tests/integration/components/gh-download-count-test.js +++ /dev/null @@ -1,39 +0,0 @@ -import Pretender from 'pretender'; -import hbs from 'htmlbars-inline-precompile'; -import {describe, it} from 'mocha'; -import {expect} from 'chai'; -import {render} from '@ember/test-helpers'; -import {setupRenderingTest} from 'ember-mocha'; - -describe('Integration: Component: gh-download-count', function () { - setupRenderingTest(); - - let server; - - beforeEach(function () { - server = new Pretender(); - server.get('https://count.ghost.org/', function () { - return [200, {}, JSON.stringify({count: 42})]; - }); - }); - - afterEach(function () { - server.shutdown(); - }); - - it('hits count endpoint and renders', async function () { - await render(hbs`{{gh-download-count}}`); - - expect(this.element).to.have.trimmed.text('42'); - }); - - it('renders with a block', async function () { - await render(hbs` - {{#gh-download-count as |count|}} - {{count}} downloads - {{/gh-download-count}} - `); - - expect(this.element).to.have.trimmed.text('42 downloads'); - }); -});