Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
⚡ ❓ Make AMP optional (#482)
Browse files Browse the repository at this point in the history
refs TryGhost/Ghost#7769
- adds a checkbox to disable AMP support in general settings.
  • Loading branch information
aileen authored and kevinansfield committed Jan 12, 2017
1 parent 3beb0e5 commit 0100b45
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 22 deletions.
51 changes: 31 additions & 20 deletions app/mirage/fixtures/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export default [
{
created_at: '2015-09-11T09:44:30.805Z',
created_by: 1,
id: 1,
id: 7,
key: 'title',
type: 'blog',
updated_at: '2015-10-04T16:26:05.195Z',
Expand All @@ -14,7 +14,7 @@ export default [
{
created_at: '2015-09-11T09:44:30.806Z',
created_by: 1,
id: 2,
id: 8,
key: 'description',
type: 'blog',
updated_at: '2015-10-04T16:26:05.198Z',
Expand All @@ -23,7 +23,7 @@ export default [
value: 'Thoughts, stories and ideas.'
},
{
id: 3,
id: 9,
uuid: '4339ce48-b485-418a-acc2-1d34cf17a5e3',
key: 'logo',
value: '/content/images/2013/Nov/logo.png',
Expand All @@ -34,7 +34,7 @@ export default [
updated_by: 1
},
{
id: 4,
id: 10,
uuid: 'e41b6c2a-7f72-45ea-96d8-ee016f06d78b',
key: 'cover',
value: '/content/images/2014/Feb/cover.jpg',
Expand All @@ -45,7 +45,7 @@ export default [
updated_by: 1
},
{
id: 5,
id: 11,
uuid: '4558457e-9f61-47a5-9d45-8b83829bf1cf',
key: 'defaultLang',
value: 'en_US',
Expand All @@ -58,7 +58,7 @@ export default [
{
created_at: '2015-09-11T09:44:30.809Z',
created_by: 1,
id: 6,
id: 12,
key: 'postsPerPage',
type: 'blog',
updated_at: '2015-10-04T16:26:05.211Z',
Expand All @@ -67,7 +67,7 @@ export default [
value: '5'
},
{
id: 7,
id: 14,
uuid: '3c93b240-d22b-473f-9063-537023e06c2d',
key: 'forceI18n',
value: 'true',
Expand All @@ -78,7 +78,7 @@ export default [
updated_by: 1
},
{
id: 8,
id: 28,
uuid: '4e58389f-f173-4387-b28c-0435623882ad',
key: 'activeTheme',
value: 'casper',
Expand All @@ -89,7 +89,7 @@ export default [
updated_by: 1
},
{
id: 9,
id: 15,
uuid: '8052c2bf-9c19-4d6c-8944-7465321d00be',
key: 'permalinks',
value: '/:slug/',
Expand All @@ -102,7 +102,7 @@ export default [
{
created_at: '2015-09-11T09:44:30.809Z',
created_by: 1,
id: 10,
id: 17,
key: 'ghost_head',
type: 'blog',
updated_at: '2015-09-23T13:32:49.858Z',
Expand All @@ -113,7 +113,7 @@ export default [
{
created_at: '2015-09-11T09:44:30.809Z',
created_by: 1,
id: 11,
id: 18,
key: 'ghost_foot',
type: 'blog',
updated_at: '2015-09-23T13:32:49.858Z',
Expand All @@ -122,7 +122,7 @@ export default [
value: ''
},
{
id: 12,
id: 21,
uuid: 'd806f358-7996-4c74-b153-8876959c4b70',
key: 'labs',
value: '{"subscribers":true,"internalTags":true}',
Expand All @@ -135,7 +135,7 @@ export default [
{
created_at: '2015-09-11T09:44:30.810Z',
created_by: 1,
id: 13,
id: 22,
key: 'navigation',
type: 'blog',
updated_at: '2015-09-23T13:32:49.868Z',
Expand All @@ -149,7 +149,7 @@ export default [
{
created_at: '2015-09-11T09:44:30.810Z',
created_by: 1,
id: 14,
id: 26,
key: 'isPrivate',
type: 'blog',
updated_at: '2015-09-23T13:32:49.868Z',
Expand All @@ -160,7 +160,7 @@ export default [
{
created_at: '2015-09-11T09:44:30.810Z',
created_by: 1,
id: 15,
id: 27,
key: 'password',
type: 'blog',
updated_at: '2015-09-23T13:32:49.868Z',
Expand All @@ -171,7 +171,7 @@ export default [
{
created_at: '2016-05-05T15:04:03.115Z',
created_by: 1,
id: 17,
id: 23,
key: 'slack',
type: 'blog',
updated_at: '2016-05-05T18:33:09.168Z',
Expand All @@ -182,7 +182,7 @@ export default [
{
created_at: '2016-05-05T15:40:12.133Z',
created_by: 1,
id: 23,
id: 19,
key: 'facebook',
type: 'blog',
updated_at: '2016-05-08T15:20:25.953Z',
Expand All @@ -193,7 +193,7 @@ export default [
{
created_at: '2016-05-05T15:40:12.134Z',
created_by: 1,
id: 24,
id: 20,
key: 'twitter',
type: 'blog',
updated_at: '2016-05-08T15:20:25.954Z',
Expand All @@ -204,17 +204,28 @@ export default [
{
created_at: '2015-09-11T09:44:30.810Z',
created_by: 1,
id: 16,
id: 13,
key: 'activeTimezone',
type: 'blog',
updated_at: '2015-09-23T13:32:49.868Z',
updated_by: 1,
uuid: '310c9169-9613-48b0-8bc4-d1e1c9be85b8',
value: 'Etc/UTC'
},
{
created_at: '2017-01-09T08:40:59.000Z',
created_by: 1,
id: 16,
key: 'amp',
type: 'blog',
updated_at: '2017-01-09T08:49:42.991Z',
updated_by: 1,
uuid: '27eb0ac8-a511-4b47-899b-4c1e408dfead',
value: 'true'
},
{
key: 'availableThemes',
id: 18,
id: 24,
value: [
{
name: 'casper',
Expand Down
3 changes: 2 additions & 1 deletion app/models/setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ export default Model.extend(ValidationEngine, {
navigation: attr('navigation-settings'),
isPrivate: attr('boolean'),
password: attr('string'),
slack: attr('slack-settings')
slack: attr('slack-settings'),
amp: attr('boolean')
});
9 changes: 9 additions & 0 deletions app/templates/settings/general.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@
availableTimezones=availableTimezones
update=(action "setTimezone")}}

<div class="form-group for-checkbox">
<label for="amp">AMP support</label>
<label class="checkbox" for="amp">
{{one-way-checkbox model.amp id="amp" name="general[amp]" type="checkbox" update=(action (mut model.amp))}}
<span class="input-toggle-component"></span>
<p>Enable AMP support for your blog posts</p>
</label>
</div>

<div class="form-group for-checkbox">
<label for="isPrivate">Make this blog private</label>
<label class="checkbox" for="isPrivate">
Expand Down
14 changes: 13 additions & 1 deletion tests/acceptance/settings/general-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ describe('Acceptance: Settings - General', function () {
});
});

it('handles private blog settings correctly', function () {
it('handles blog settings correctly', function () {
visit('/settings/general');

// handles private blog settings correctly
Expand Down Expand Up @@ -180,6 +180,18 @@ describe('Acceptance: Settings - General', function () {
.to.equal('');
});

// handles amp checkbox correctly

andThen(() => {
expect(find('input#amp').prop('checked'), 'AMP is enabled').to.be.true;
});

click('input#amp');

andThen(() => {
expect(find('input#amp').prop('checked'), 'AMP is disabled').to.be.false;
});

// validates a facebook url correctly

andThen(() => {
Expand Down

0 comments on commit 0100b45

Please sign in to comment.