const _ = require('lodash'); const uuid = require('uuid'); const ObjectId = require('bson-objectid'); const moment = require('moment'); const constants = require('@tryghost/constants'); const DataGenerator = {}; DataGenerator.markdownToMobiledoc = function markdownToMobiledoc(content) { const mobiledoc = { version: '0.3.1', markups: [], atoms: [], cards: [ ['markdown', { cardName: 'markdown', markdown: content || '' }] ], sections: [[10, 0]] }; return JSON.stringify(mobiledoc); }; DataGenerator.Content = { posts: [ { id: ObjectId.generate(), title: 'HTML Ipsum', slug: 'html-ipsum', mobiledoc: DataGenerator.markdownToMobiledoc('
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae
, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est.
#header h1 a{display: block;width: 300px;height: 80px;}
'),
published_at: new Date('2015-01-01'),
custom_excerpt: 'This is my custom excerpt!',
feature_image: 'https://example.com/super_photo.jpg'
},
{
id: ObjectId.generate(),
title: 'Ghostly Kitchen Sink',
slug: 'ghostly-kitchen-sink',
mobiledoc: DataGenerator.markdownToMobiledoc('Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae
, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est.
#header h1 a{display: block;width: 300px;height: 80px;}
'),
published_at: new Date('2015-01-02'),
feature_image: '/content/images/2018/hey.jpg'
},
{
id: ObjectId.generate(),
title: 'Short and Sweet',
slug: 'short-and-sweet',
mobiledoc: DataGenerator.markdownToMobiledoc('## testing\n\nmctesters\n\n- test\n- line\n- items'),
html: 'mctesters
\nPellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae
, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est.
#header h1 a{display: block;width: 300px;height: 80px;}
'),
status: 'draft',
uuid: 'd52c42ae-2755-455c-80ec-70b2ec55c903'
},
{
id: ObjectId.generate(),
title: 'Not so short, bit complex',
slug: 'not-so-short-bit-complex',
mobiledoc: DataGenerator.markdownToMobiledoc('Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.
1 | 2 | 3 | 4 |
---|---|---|---|
a | b | c | d |
e | f | g | h |
i | j | k | l |
Hopefully you don\'t find it a bore.
'), type: 'page' }, { id: ObjectId.generate(), title: 'This is a draft static page', slug: 'static-page-draft', mobiledoc: DataGenerator.markdownToMobiledoc('Hopefully you don\'t find it a bore.
'), type: 'page', status: 'draft' }, { id: ObjectId.generate(), title: 'This is a scheduled post!!', slug: 'scheduled-post', mobiledoc: DataGenerator.markdownToMobiledoc('Look! I\'m an email
', plaintext: 'Waba-daba-dab-da', submitted_at: moment().toDate() }, { id: ObjectId.generate(), uuid: '365daa11-4bf0-4614-ad43-6346387ffa00', status: 'failed', error: 'Everything went south', stats: '', email_count: 3, subject: 'You got mailed! Again!', html: 'What\'s that? Another email!
', plaintext: 'yes this is an email', submitted_at: moment().toDate() } ] }; // set up belongs_to relationships DataGenerator.Content.subscribers[0].post_id = DataGenerator.Content.posts[0].id; DataGenerator.Content.api_keys[0].integration_id = DataGenerator.Content.integrations[0].id; DataGenerator.Content.api_keys[1].integration_id = DataGenerator.Content.integrations[0].id; DataGenerator.Content.emails[0].post_id = DataGenerator.Content.posts[0].id; DataGenerator.Content.emails[1].post_id = DataGenerator.Content.posts[1].id; DataGenerator.Content.members_stripe_customers[0].member_id = DataGenerator.Content.members[2].id; DataGenerator.forKnex = (function () { function createBasic(overrides) { const newObj = _.cloneDeep(overrides); return _.defaults(newObj, { id: ObjectId.generate(), created_by: DataGenerator.Content.users[0].id, created_at: new Date(), updated_by: DataGenerator.Content.users[0].id, updated_at: new Date() }); } function createTag(overrides) { const newObj = _.cloneDeep(overrides); return _.defaults(newObj, { id: ObjectId.generate(), name: 'tag', slug: 'slug', feature_image: null, meta_title: null, meta_description: null, description: 'description', visibility: 'public', created_by: DataGenerator.Content.users[0].id, created_at: new Date(), updated_by: DataGenerator.Content.users[0].id, updated_at: new Date() }); } function createPost(overrides) { overrides = overrides || {}; const newObj = _.cloneDeep(overrides); let mobiledocObj; if (!newObj.mobiledoc) { newObj.mobiledoc = DataGenerator.markdownToMobiledoc('## markdown'); } if (!newObj.html) { mobiledocObj = JSON.parse(newObj.mobiledoc); newObj.html = mobiledocObj.cards && mobiledocObj.cards[0][1].markdown; } return _.defaults(newObj, { id: ObjectId.generate(), uuid: uuid.v4(), title: 'title', status: 'published', feature_image: null, featured: false, type: 'post', slug: 'slug', author_id: DataGenerator.Content.users[0].id, updated_at: new Date(), updated_by: DataGenerator.Content.users[0].id, created_at: new Date(), created_by: DataGenerator.Content.users[0].id, published_at: new Date(), published_by: DataGenerator.Content.users[0].id, visibility: 'public' }); } function createGenericPost(uniqueInteger, status, locale, author_id) { status = status || 'draft'; locale = locale || null; author_id = author_id || DataGenerator.Content.users[0].id; return createPost({ id: ObjectId.generate(), title: 'Test Post ' + uniqueInteger, slug: 'ghost-from-fiction-to-function-' + uniqueInteger, author_id: author_id, mobiledoc: DataGenerator.markdownToMobiledoc('Three days ago I released a concept page<\/a> for a lite version of WordPress that I\'ve been thinking about for a long time, called Ghost. I think it\'s fair to say that I didn\'t quite anticipate how strong the reaction would be - and I\'ve hardly had time to catch my breath in the last 72 hours.\n\nThe response was overwhelming, and overwhelmingly positive. In the first 6 hours my site got 35,000 page views after hitting the number 1 slot on Hacker News<\/a>. As of right now, the traffic count is just over 91,000 page views<\/a> - and Ghost has been featured all over the place. Notable mentions so far include Christina Warren from Mashable, who wrote about it<\/a>. Michael Carney from PandoDaily interviewed me about it<\/a>. Someone even wrote about it in Chinese<\/a>. That\'s pretty cool.\n\n\nThe feedback has been amazing, and while it\'s impossible to reply to all of the messages individually, I\'m getting to as many of them as I can and I want to thank each and every one of you who took the time to send me a message or share the concept because you liked it. Now that the initial storm has died down a bit, I wanted to take some time to answer some of the more common questions and talk about what\'s next.\nThree days ago I released a concept page<\/a> for a lite version of WordPress that I\'ve been thinking about for a long time, called Ghost. I think it\'s fair to say that I didn\'t quite anticipate how strong the reaction would be - and I\'ve hardly had time to catch my breath in the last 72 hours.<\/p>\n The response was overwhelming, and overwhelmingly positive. In the first 6 hours my site got 35,000 page views after hitting the number 1 slot on Hacker News<\/a>. As of right now, the traffic count is just over 91,000 page views<\/a> - and Ghost has been featured all over the place. Notable mentions so far include Christina Warren from Mashable, who wrote about it<\/a>. Michael Carney from PandoDaily interviewed me about it<\/a>. Someone even wrote about it in Chinese<\/a>. That\'s pretty cool.\\n The feedback has been amazing, and while it\'s impossible to reply to all of the messages individually, I\'m getting to as many of them as I can and I want to thank each and every one of you who took the time to send me a message or share the concept because you liked it. Now that the initial storm has died down a bit, I wanted to take some time to answer some of the more common questions and talk about what\'s next.<\/p>\n The most common question, bizarrely:<\/p>\n This was really the only negativity I got in response to the post, and it surprised me. I put together the concept page as... just that... a concept. It was a way for me to get the ideas out of my head and "down on paper" - or so to speak. I used photoshop as a tool<\/em> to write down my idea with text and images. If I used a sketchbook as a tool <\/em>to create images and handwritten notes, then uploaded scans of it, I doubt anyone would complain. The concept page was never supposed to be a finished product because I had no idea if there would be any interest in it. I had no motivation to waste hours coding a custom layout for something might only ever be read by a few people and then forgotten.<\/p>\n Hardware manufacturers make hundreds of foam cutout prototypes of products before they build one with working buttons and screens. I\'m aware of all the usability problems with a web page made of images, and equally, foam cutouts without buttons or screens aren\'t particularly user friendly either. They\'re not supposed to be.<\/p>\n Let\'s move on.<\/p>\n Because comments add a layer of complexity that is beyond the core focus of this platform, which is publishing. Again, that\'s not to say you couldn\'t have any comments. This could easily be added with a dedicated plugin where you own the data or (as mentioned) there are third party providers such as Disqus, IntenseDebate, Livefyre and Facebook who all have great platforms. The point of this isn\'t to say "you can\'t have comments" - it\'s to say "comments aren\'t on by default". It\'s about simplicity, more than anything else.<\/p>\n <\/a><\/p>\n Sorry, but Tumblr already did this - it\'s not the future of blogging, it\'s the past.<\/p>\n Ghost isn\'t about sharing "Fuck Yeah [Dogs<\/a>\/Sharks<\/a>\/Girls with Tattoos<\/a>]" - it\'s about publishing - which means writing - rather than mashing a few buttons to make sure that everyone can see and appreciate your latest funny picture\/status, which is surely the most funny picture\/status you\'ve ever posted.<\/p>\n Tumblr, Pinterest and Facebook already have this locked down. It\'s not the future.<\/p>\n The concept page was a way for me to test demand and interest. To see if anyone actually agreed with my frustrations and, more importantly, my solutions. I plucked a random figure of "10,000 pageviews" out of the air before I hit the publish button. If it got less than 10,000 pageviews, I would surrender to the fact that it would only ever be an idea. I\'ve now exceeded that goal 9 times over, so yes, I\'m looking at how Ghost can now be made into a reality.<\/p>\nFAQ - Continued...<\/h2>\n
Oh my god, why is that whole page made of images? What\'s wrong with you? \/\/ I can\'t take you seriously \/\/ Don\'t you know anything about the web? \/\/ You are literally Satan re-incarnate.<\/strong><\/em><\/h5>\n
What? Why no comments? I need comments.<\/strong><\/em><\/h5>\n
Yeah, but WordPress are already going to revise their dashboard, WordPress.com is experimenting with a potential simplified version... so why bother with this?<\/strong><\/em><\/h5>\n
So... are you actually going to build this thing?<\/strong><\/em><\/h5>\n
How can I find out when it\'s done? \/\/ SHUT UP AND TAKE MY MONEY<\/strong><\/em><\/h5>\n