mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 22:43:30 +03:00
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:
parent
c8625d6a42
commit
1e77a4c915
@ -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
|
||||
}
|
||||
})
|
||||
});
|
@ -1,5 +0,0 @@
|
||||
{{#if hasBlock}}
|
||||
{{yield this.count}}
|
||||
{{else}}
|
||||
{{this.count}}
|
||||
{{/if}}
|
@ -1,6 +1,6 @@
|
||||
<header>
|
||||
<h1>Welcome to <strong>Ghost</strong>!</h1>
|
||||
<p>All over the world, people have started <em><GhDownloadCount /></em> incredible sites with Ghost. Today, we’re starting yours.</p>
|
||||
<p>All over the world, people have started <em>2,000,000+</em> incredible sites with Ghost. Today, we’re starting yours.</p>
|
||||
</header>
|
||||
|
||||
<figure class="gh-flow-screenshot">
|
||||
|
@ -30,7 +30,6 @@ export default function () {
|
||||
apiRoot,
|
||||
subdir,
|
||||
blogRoot: `${subdir}/`,
|
||||
count: 'https://count.ghost.org/',
|
||||
|
||||
url: {
|
||||
admin() {
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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');
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user