Ghost/ghost/admin/app/transforms/twitter-url-user.js
Aileen Nowak c8d0e25923 Structured Data 3.0
closes #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
2016-05-08 17:43:59 +02:00

22 lines
536 B
JavaScript

import Transform from 'ember-data/transform';
export default Transform.extend({
deserialize(serialized) {
if (serialized) {
let [ , user ] = serialized.match(/@?([^\/]*)/);
return `https://twitter.com/${user}`;
}
return serialized;
},
serialize(deserialized) {
if (deserialized) {
let [ , user] = deserialized.match(/(?:https:\/\/)(?:twitter\.com)\/(?:#!\/)?@?([^\/]*)/);
return `@${user}`;
}
return deserialized;
}
});