Removed <GhDownloadCount>

no issue

- the count.ghost.org service is being shut down
- replaced the fetch+poll component with a hardcoded figure
This commit is contained in:
Kevin Ansfield 2020-01-27 09:51:45 +00:00
parent c8625d6a42
commit 1e77a4c915
7 changed files with 1 additions and 98 deletions

View File

@ -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
}
})
});

View File

@ -1,5 +0,0 @@
{{#if hasBlock}}
{{yield this.count}}
{{else}}
{{this.count}}
{{/if}}

View File

@ -1,6 +1,6 @@
<header> <header>
<h1>Welcome to <strong>Ghost</strong>!</h1> <h1>Welcome to <strong>Ghost</strong>!</h1>
<p>All over the world, people have started <em><GhDownloadCount /></em> incredible sites with Ghost. Today, were starting yours.</p> <p>All over the world, people have started <em>2,000,000+</em> incredible sites with Ghost. Today, were starting yours.</p>
</header> </header>
<figure class="gh-flow-screenshot"> <figure class="gh-flow-screenshot">

View File

@ -30,7 +30,6 @@ export default function () {
apiRoot, apiRoot,
subdir, subdir,
blogRoot: `${subdir}/`, blogRoot: `${subdir}/`,
count: 'https://count.ghost.org/',
url: { url: {
admin() { admin() {

View File

@ -39,7 +39,6 @@ export default function () {
this.passthrough(); this.passthrough();
// add any external domains to make sure those get passed through too // 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('http://www.gravatar.com/**');
this.passthrough('https://cdn.jsdelivr.net/**'); this.passthrough('https://cdn.jsdelivr.net/**');
this.passthrough('https://api.unsplash.com/**'); this.passthrough('https://api.unsplash.com/**');
@ -84,14 +83,6 @@ export function testConfig() {
/* External sites ------------------------------------------------------- */ /* 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 () { this.head('http://www.gravatar.com/avatar/:md5', function () {
return ''; return '';
}, 200); }, 200);

View File

@ -73,10 +73,6 @@ describe('Acceptance: Setup', function () {
expect(stepIcons[1], 'second step').to.not.have.class('active'); expect(stepIcons[1], 'second step').to.not.have.class('active');
expect(stepIcons[2], 'third 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'); await click('.gh-btn-green');
// it transitions to step two // it transitions to step two

View File

@ -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');
});
});