forked from TryGhost/Ghost
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Facebook and Twitter input fields in gen. settings
closes TryGhost#6534 - new input fields in general settings incl. validation - facebook and twitter as new models in settings.js - adds values for facebook and twitter to default-settings.js - adds blog helpers for facebook and twittter - rather than saving the whole URL, the Twitter username incl. '@' will be extracted from URL and saved in the settings. The User will still input the full URL. After saving the blog setting, the stored Twitter username will be parsed again as the full URL and available in the input field. A custom transform is used for this. - adding meta fields to be rendered in {{ghost_head}}: - '<meta property="article:publisher" content="https://www.facebook.com/page" />' and - '<meta name="twitter:site" content="@user"/>' - adds facebook and twitter to unit test for structured data - adds unit test for general settings - adds acceptance test for new input fields in general settings - adds a custom transform for twitter model to save only the username to the server - adds unit test for transform
- Loading branch information
Showing
13 changed files
with
258 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import Transform from 'ember-data/transform'; | ||
|
||
export default Transform.extend({ | ||
deserialize(serialized) { | ||
if (serialized) { | ||
let url = 'https://twitter.com/'; | ||
let modelVal = serialized; | ||
let [ , user ] = modelVal.match(/@?([^\/]*)/); | ||
|
||
url = modelVal ? url + user : modelVal; | ||
|
||
return url; | ||
} | ||
return serialized; | ||
}, | ||
|
||
serialize(deserialized) { | ||
if (deserialized) { | ||
let username = '@'; | ||
let [ , user] = deserialized.match(/(?:https:\/\/)(?:twitter\.com)\/(?:#!\/)?@?([^\/]*)/); | ||
username = username + user; | ||
|
||
return username; | ||
} | ||
return deserialized; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
core/client/tests/unit/transforms/twitter-url-user-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* jshint expr:true */ | ||
import { expect } from 'chai'; | ||
import { describeModule, it } from 'ember-mocha'; | ||
import Ember from 'ember'; | ||
|
||
const emberA = Ember.A; | ||
|
||
describeModule( | ||
'transform:twitter-url-user', | ||
'Unit: Transform: twitter-url-user', | ||
{ | ||
// Specify the other units that are required for this test. | ||
// needs: ['transform:foo'] | ||
}, | ||
function() { | ||
it('deserializes twitter url', function () { | ||
let transform = this.subject(); | ||
let serialized = '@testuser'; | ||
let result = transform.deserialize(serialized); | ||
|
||
expect(result).to.equal('https://twitter.com/testuser'); | ||
}); | ||
|
||
it('serializes url to twitter username', function () { | ||
let transform = this.subject(); | ||
let deserialized = 'https://twitter.com/testuser'; | ||
let result = transform.serialize(deserialized); | ||
|
||
expect(result).to.equal('@testuser'); | ||
}); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.