338109c762
- added line to index.js to set node_env to development if it is not set - fixed a small bug with the persistent notifications and used them on debug page from server side - added 002 files to manage export and import for 002 - 002 import is somewhat smarter than 001, merging settings (except version), replacing user & clearing primary keys - added reset to models and migration, which does the down operation the same way that init does the up operation - import and reset clear session & redirect to login / signup - additional unit tests
87 lines
26 KiB
JavaScript
87 lines
26 KiB
JavaScript
// Use 'testing' Ghost config; unless we are running on travis (then show queries for debugging)
|
|
process.env.NODE_ENV = process.env.TRAVIS ? 'travis' : 'testing';
|
|
|
|
var knex = require('../../server/models/base').Knex,
|
|
when = require('when'),
|
|
migration = require("../../server/data/migration/"),
|
|
helpers,
|
|
samplePost,
|
|
sampleUser,
|
|
sampleUserRole;
|
|
|
|
samplePost = function (i, status, lang) {
|
|
return {
|
|
title: "Test Post " + i,
|
|
slug: "ghost-from-fiction-to-function-" + i,
|
|
content_raw: "Three days ago I released a <a title=\"Ghost\" href=\"http:\/\/john.onolan.org\/ghost\/\">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 <a href=\"http:\/\/news.ycombinator.com\/item?id=4743245\" onclick=\"javascript:_gaq.push(['_trackEvent','outbound-article','http:\/\/news.ycombinator.com']);\">Hacker News<\/a>. As of right now, the traffic count is just over <a href=\"http:\/\/john.onolan.org\/wp-content\/uploads\/2012\/11\/Screen-Shot-2012-11-09-at-17.51.21.png\" rel=\"lightbox\" class=\"cboxElement\">91,000 page views<\/a> - and Ghost has been featured all over the place. Notable mentions so far include Christina Warren from Mashable, who <a href=\"http:\/\/christina.is\/\" onclick=\"javascript:_gaq.push(['_trackEvent','outbound-article','http:\/\/christina.is']);\">wrote about it<\/a>. Michael Carney from PandoDaily <a href=\"http:\/\/pandodaily.com\/2012\/11\/07\/wordpress-guru-designs-a-concept-blogging-platform-that-doesnt-suck-gets-rave-reviews\/\" onclick=\"javascript:_gaq.push(['_trackEvent','outbound-article','http:\/\/pandodaily.com']);\">interviewed me about it<\/a>. Someone even <a href=\"http:\/\/www.voicens.com\/web\/?p=4425\" onclick=\"javascript:_gaq.push(['_trackEvent','outbound-article','http:\/\/www.voicens.com']);\">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.\n<h2>FAQ - Continued...<\/h2>\n\nThe most common question, bizarrely:\n<h5><em><strong>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\nThis 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 <em>tool<\/em> to write down my idea with text and images. If I used a sketchbook as a <em>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.\n\nHardware 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.\n\nLet's move on.\n<h5><em><strong>What? Why no comments? I need comments.<\/strong><\/em><\/h5>\n\nBecause 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.\n<h5><em><strong>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\n<a href=\"http:\/\/john.onolan.org\/wp-content\/uploads\/2012\/11\/newwp.png\" rel=\"lightbox[2102]\" title=\"newwp\" class=\"cboxElement\"><img class=\"alignnone size-large wp-image-2117\" title=\"newwp\" src=\"http:\/\/john.onolan.org\/wp-content\/uploads\/2012\/11\/newwp-550x210.png\" alt=\"\" width=\"550\" height=\"210\"><\/a>\n\nSorry, but Tumblr already did this - it's not the future of blogging, it's the past.\n\nGhost isn't about sharing \"Fuck Yeah [<a href=\"http:\/\/fuckyeahdogs.tumblr.com\/\" onclick=\"javascript:_gaq.push(['_trackEvent','outbound-article','http:\/\/fuckyeahdogs.tumblr.com']);\">Dogs<\/a>\/<a href=\"http:\/\/fuckyeahsharks.tumblr.com\/\" onclick=\"javascript:_gaq.push(['_trackEvent','outbound-article','http:\/\/fuckyeahsharks.tumblr.com']);\" rel=\"lightbox\" class=\"cboxElement\">Sharks<\/a>\/<a href=\"http:\/\/fuckyeahgirlswithtattoos.tumblr.com\/\" onclick=\"javascript:_gaq.push(['_trackEvent','outbound-article','http:\/\/fuckyeahgirlswithtattoos.tumblr.com']);\">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.\n\nTumblr, Pinterest and Facebook already have this locked down. It's not the future.\n<h5><em><strong>So... are you actually going to build this thing?<\/strong><\/em><\/h5>\n\nThe 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.\n<h5><em><strong>How can I find out when it's done? \/\/ SHUT UP AND TAKE MY MONEY<\/strong><\/em><\/h5>\n\nOk, ok - there's a holding page up on <a href=\"http:\/\/tryghost.org\" onclick=\"javascript:_gaq.push(['_trackEvent','outbound-article','http:\/\/tryghost.org']);\">http:\/\/TryGhost.org<\/a> - put your email address in.\n<hr>\n<h3>How are you going to do this?<\/h3>\n\nThere's three main ways of going about this, each has merits as well as drawbacks.\n\n<em><strong>1.) Build it from scratch<\/strong><\/em> - Many people (particularly the Hacker News crowd) expressed the sentiment that there was little point in forking WordPress. When you're going to strip out so much, you get to a point where you might as well start from scratch anyway. Take away the crutches of being stuck with older technologies and put together something which is as sophisticated in code as it is in UI\/UX.\n<ul>\n<li><em>Pros:<\/em> The idea of something completely new is exciting, opportunity to build something very sophisticated, complete control over everything.<\/li>\n<li><em>Cons:<\/em> Lose the WordPress ecosystem which includes millions of users and thousands of developers, potentially spend the next 6 months fighting over whether to use PHP\/RoR\/Django\/Python\/Node\/Whateverthefuck because everyone loves to evangelise the technology they know best.<\/li>\n<\/ul>\n\n<em><strong>2.) Fork WordPress<\/strong><\/em> - This was the original idea I put out. Take the WordPress codebase, as is, and modify it to turn it into something new. Initially the codebase is practically the same, which means developers already know it. Then it can change over time and evolve into its own thing.\n<ul>\n<li><em>Pros:<\/em> Easy start with existing codebase, potential to evolve, doesn't lose WordPress ecosystem initially.<\/li>\n<li><em>Cons:<\/em> Stuck with existing codebase - the good as well as the bad, eventually needs to be rewritten completely, less control, loses the WordPress ecosystem after a while anyway, makes it complicated to transition from legacy code to new code.<\/li>\n<\/ul>\n\n<em><strong>3.) Make it a plugin\/extension<\/strong><\/em> - Lots of people asked why Ghost couldn't just be a WordPress plugin. It would certainly be the easiest route of the 3, it's possible to completely remove \/wp-admin\/ and replace with with \/ghost\/ ... but I feel like it kind of misses the point. This route bolts Ghost on, but it's still WordPress under the hood. From a UI\/UX standpoint it would function - but it wouldn't revolutionise anything else. It makes WordPress itself about blogging again, rather than creating something new.\n<ul>\n<li><em>Pros:<\/em> Very easy development, very easy deployment, keeps WordPress ecosystem forever, doesn't force anyone to change.<\/li>\n<li><em>Cons:<\/em> The least exciting (for me, personally), much less control, it would be much harder to maintain something like this on a non-profit basis - which loses a piece of what Ghost is about.<\/li>\n<\/ul>\n<h3>What's the answer?<\/h3>\n\nI've spoken to a lot of smart people over the last few days. The one thing that everyone seems to agree on is that a fork is the worst of both worlds. So the one thing that I suggested as a way of making this happen, is the least likely to work in reality. Remember the foam prototype metaphor earlier? Learning and iterating - that's what happening now.\n\nThat leaves a choice between WordPress plugin or fresh build. The answer? Both.\n\nA WordPress plugin will act as a proof of concept and a working prototype, initially, because it's easier to leverage the existing WordPress ecosystem to create it than to go into a cave for 6 months trying to build this amazing thing that everyone will have forgotten about.\n\nThe plugin will not be perfect. It will add the Ghost UI\/UX and as much functionality as we can cram into it. It will completely remove \/wp-admin\/ and replace it with \/ghost\/ - effectively using WordPress core as a basic foundation to build on top of. It will give people who don't want to switch away from WordPress access to the Ghost UX which they want to have, and it will give people who want the full Ghost platform a taste of what's to come.\n\nIt will allow us to develop and learn and iterate on the concept pretty rapidly, which has a great deal of value.\n\nThis is step one. Assuming the plugin is actually used by people - it would then justify exploring building the standalone version of Ghost from the ground up. The plugin would subsequently serve as a great marketing tool for the platform. Think of it as an upgrade path. But that's a long way away. Having the idea is the easy part. Making it happen is what counts.\n\nHappily - amongst the thousands of people talking about Ghost for the last few days - several have been talking about how they've already built some working prototypes of my mockups and turned them into WordPress plugins or just local development sites. These will likely go on to be the starting point of the first Ghost plugin.<\/p>\n\nThere's a lot to do, and I'm amazed by the number of people who have offered their help with this. In the next few days I'll be kicking off work on the plugin properly and start putting together a more organised structure which explains how you can get involved and contribute to the project if you're interested. So... watch this space - and thanks for all your support so far.\n\n<a href=\"http:\/\/twitter.com\/TryGhost\" onclick=\"javascript:_gaq.push(['_trackEvent','outbound-article','http:\/\/twitter.com']);\" class=\"twitter-follow-button\">Follow @TryGhost<\/a>",
|
|
content: "<p>Three days ago I released a <a title=\"Ghost\" href=\"http:\/\/john.onolan.org\/ghost\/\">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<p>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 <a href=\"http:\/\/news.ycombinator.com\/item?id=4743245\" onclick=\"javascript:_gaq.push(['_trackEvent','outbound-article','http:\/\/news.ycombinator.com']);\">Hacker News<\/a>. As of right now, the traffic count is just over <a href=\"http:\/\/john.onolan.org\/wp-content\/uploads\/2012\/11\/Screen-Shot-2012-11-09-at-17.51.21.png\" rel=\"lightbox\" class=\"cboxElement\">91,000 page views<\/a> - and Ghost has been featured all over the place. Notable mentions so far include Christina Warren from Mashable, who <a href=\"http:\/\/christina.is\/\" onclick=\"javascript:_gaq.push(['_trackEvent','outbound-article','http:\/\/christina.is']);\">wrote about it<\/a>. Michael Carney from PandoDaily <a href=\"http:\/\/pandodaily.com\/2012\/11\/07\/wordpress-guru-designs-a-concept-blogging-platform-that-doesnt-suck-gets-rave-reviews\/\" onclick=\"javascript:_gaq.push(['_trackEvent','outbound-article','http:\/\/pandodaily.com']);\">interviewed me about it<\/a>. Someone even <a href=\"http:\/\/www.voicens.com\/web\/?p=4425\" onclick=\"javascript:_gaq.push(['_trackEvent','outbound-article','http:\/\/www.voicens.com']);\">wrote about it in Chinese<\/a>. That's pretty cool.\\n<p>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<h2>FAQ - Continued...<\/h2>\n<p>The most common question, bizarrely:<\/p>\n<h5><em><strong>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<p>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 <em>tool<\/em> to write down my idea with text and images. If I used a sketchbook as a <em>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<p>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<p>Let's move on.<\/p>\n<h5><em><strong>What? Why no comments? I need comments.<\/strong><\/em><\/h5>\n<p>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<h5><em><strong>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<p><a href=\"http:\/\/john.onolan.org\/wp-content\/uploads\/2012\/11\/newwp.png\" rel=\"lightbox[2102]\" title=\"newwp\" class=\"cboxElement\"><img class=\"alignnone size-large wp-image-2117\" title=\"newwp\" src=\"http:\/\/john.onolan.org\/wp-content\/uploads\/2012\/11\/newwp-550x210.png\" alt=\"\" width=\"550\" height=\"210\"><\/a><\/p>\n<p>Sorry, but Tumblr already did this - it's not the future of blogging, it's the past.<\/p>\n<p>Ghost isn't about sharing \"Fuck Yeah [<a href=\"http:\/\/fuckyeahdogs.tumblr.com\/\" onclick=\"javascript:_gaq.push(['_trackEvent','outbound-article','http:\/\/fuckyeahdogs.tumblr.com']);\">Dogs<\/a>\/<a href=\"http:\/\/fuckyeahsharks.tumblr.com\/\" onclick=\"javascript:_gaq.push(['_trackEvent','outbound-article','http:\/\/fuckyeahsharks.tumblr.com']);\" rel=\"lightbox\" class=\"cboxElement\">Sharks<\/a>\/<a href=\"http:\/\/fuckyeahgirlswithtattoos.tumblr.com\/\" onclick=\"javascript:_gaq.push(['_trackEvent','outbound-article','http:\/\/fuckyeahgirlswithtattoos.tumblr.com']);\">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<p>Tumblr, Pinterest and Facebook already have this locked down. It's not the future.<\/p>\n<h5><em><strong>So... are you actually going to build this thing?<\/strong><\/em><\/h5>\n<p>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>\n<h5><em><strong>How can I find out when it's done? \/\/ SHUT UP AND TAKE MY MONEY<\/strong><\/em><\/h5>\n<p>Ok, ok - there's a holding page up on <a href=\"http:\/\/tryghost.org\" onclick=\"javascript:_gaq.push(['_trackEvent','outbound-article','http:\/\/tryghost.org']);\">http:\/\/TryGhost.org<\/a> - put your email address in.<\/p>\n<hr>\n<h3>How are you going to do this?<\/h3>\n<p>There's three main ways of going about this, each has merits as well as drawbacks.<\/p>\n<p><em><strong>1.) Build it from scratch<\/strong><\/em> - Many people (particularly the Hacker News crowd) expressed the sentiment that there was little point in forking WordPress. When you're going to strip out so much, you get to a point where you might as well start from scratch anyway. Take away the crutches of being stuck with older technologies and put together something which is as sophisticated in code as it is in UI\/UX.<\/p>\n<ul>\n<li><em>Pros:<\/em> The idea of something completely new is exciting, opportunity to build something very sophisticated, complete control over everything.<\/li>\n<li><em>Cons:<\/em> Lose the WordPress ecosystem which includes millions of users and thousands of developers, potentially spend the next 6 months fighting over whether to use PHP\/RoR\/Django\/Python\/Node\/Whateverthefuck because everyone loves to evangelise the technology they know best.<\/li>\n<\/ul>\n<p><em><strong>2.) Fork WordPress<\/strong><\/em> - This was the original idea I put out. Take the WordPress codebase, as is, and modify it to turn it into something new. Initially the codebase is practically the same, which means developers already know it. Then it can change over time and evolve into its own thing.<\/p>\n<ul>\n<li><em>Pros:<\/em> Easy start with existing codebase, potential to evolve, doesn't lose WordPress ecosystem initially.<\/li>\n<li><em>Cons:<\/em> Stuck with existing codebase - the good as well as the bad, eventually needs to be rewritten completely, less control, loses the WordPress ecosystem after a while anyway, makes it complicated to transition from legacy code to new code.<\/li>\n<\/ul>\n<p><em><strong>3.) Make it a plugin\/extension<\/strong><\/em> - Lots of people asked why Ghost couldn't just be a WordPress plugin. It would certainly be the easiest route of the 3, it's possible to completely remove \/wp-admin\/ and replace with with \/ghost\/ ... but I feel like it kind of misses the point. This route bolts Ghost on, but it's still WordPress under the hood. From a UI\/UX standpoint it would function - but it wouldn't revolutionise anything else. It makes WordPress itself about blogging again, rather than creating something new.<\/p>\n<ul>\n<li><em>Pros:<\/em> Very easy development, very easy deployment, keeps WordPress ecosystem forever, doesn't force anyone to change.<\/li>\n<li><em>Cons:<\/em> The least exciting (for me, personally), much less control, it would be much harder to maintain something like this on a non-profit basis - which loses a piece of what Ghost is about.<\/li>\n<\/ul>\n<h3>What's the answer?<\/h3>\n<p>I've spoken to a lot of smart people over the last few days. The one thing that everyone seems to agree on is that a fork is the worst of both worlds. So the one thing that I suggested as a way of making this happen, is the least likely to work in reality. Remember the foam prototype metaphor earlier? Learning and iterating - that's what happening now.<\/p>\n<p>That leaves a choice between WordPress plugin or fresh build. The answer? Both.<\/p>\n<p>A WordPress plugin will act as a proof of concept and a working prototype, initially, because it's easier to leverage the existing WordPress ecosystem to create it than to go into a cave for 6 months trying to build this amazing thing that everyone will have forgotten about.<\/p>\n<p>The plugin will not be perfect. It will add the Ghost UI\/UX and as much functionality as we can cram into it. It will completely remove \/wp-admin\/ and replace it with \/ghost\/ - effectively using WordPress core as a basic foundation to build on top of. It will give people who don't want to switch away from WordPress access to the Ghost UX which they want to have, and it will give people who want the full Ghost platform a taste of what's to come.<\/p>\n<p>It will allow us to develop and learn and iterate on the concept pretty rapidly, which has a great deal of value.<\/p>\n<p>This is step one. Assuming the plugin is actually used by people - it would then justify exploring building the standalone version of Ghost from the ground up. The plugin would subsequently serve as a great marketing tool for the platform. Think of it as an upgrade path. But that's a long way away. Having the idea is the easy part. Making it happen is what counts.<\/p>\n<p>Happily - amongst the thousands of people talking about Ghost for the last few days - several have been talking about how they've already built some working prototypes of my mockups and turned them into WordPress plugins or just local development sites. These will likely go on to be the starting point of the first Ghost plugin.<\/p>\n<p>There's a lot to do, and I'm amazed by the number of people who have offered their help with this. In the next few days I'll be kicking off work on the plugin properly and start putting together a more organised structure which explains how you can get involved and contribute to the project if you're interested. So... watch this space - and thanks for all your support so far.<\/p>\n<p><a href=\"http:\/\/twitter.com\/TryGhost\" onclick=\"javascript:_gaq.push(['_trackEvent','outbound-article','http:\/\/twitter.com']);\" class=\"twitter-follow-button\">Follow @TryGhost<\/a><\/p>",
|
|
image: "ghostpost.jpg",
|
|
language: lang,
|
|
status: status,
|
|
featured: true,
|
|
updated_at: new Date(),
|
|
updated_by: 1,
|
|
created_at: new Date(),
|
|
created_by: 1
|
|
};
|
|
};
|
|
|
|
sampleUser = function (i) {
|
|
return {
|
|
email_address: "john_" + i + "@onolan.org",
|
|
password: "$2a$10$c5G9RS5.dXRt3UqvZ5wNgOLQLc7ZFc2DJo01du0oLT1YYOM67KJMe",
|
|
full_name: "John O'Nolan"
|
|
};
|
|
};
|
|
|
|
sampleUserRole = function (i) {
|
|
return {
|
|
role_id: i,
|
|
user_id: i
|
|
};
|
|
};
|
|
|
|
helpers = {
|
|
resetData: function () {
|
|
|
|
return this.clearData().then(function () {
|
|
return migration.init();
|
|
});
|
|
},
|
|
|
|
clearData: function () {
|
|
// we must always try to delete all tables
|
|
return migration.migrateDownFromVersion(migration.currentVersion);
|
|
},
|
|
|
|
|
|
insertMorePosts: function () {
|
|
var lang, status, posts, promises = [], i, j;
|
|
for (i = 0; i < 2; i += 1) {
|
|
posts = [];
|
|
lang = i % 2 ? 'en' : 'fr';
|
|
posts.push(samplePost(i, lang));
|
|
for (j = 0; j < 50; j += 1) {
|
|
status = j % 2 ? 'published' : 'draft';
|
|
posts.push(samplePost(j, status, lang));
|
|
}
|
|
promises.push(knex('posts').insert(posts));
|
|
}
|
|
return when.all(promises);
|
|
},
|
|
insertDefaultUser: function () {
|
|
|
|
var users = [],
|
|
userRoles = [],
|
|
u_promises = [];
|
|
|
|
users.push(sampleUser(1));
|
|
userRoles.push(sampleUserRole(1));
|
|
u_promises.push(knex('users').insert(users));
|
|
u_promises.push(knex('roles_users').insert(userRoles));
|
|
|
|
return when.all(u_promises);
|
|
}
|
|
};
|
|
|
|
module.exports = helpers; |