diff --git a/core/client/app.js b/core/client/app.js index 3df79d1e80ef..e40b0f9ce67b 100755 --- a/core/client/app.js +++ b/core/client/app.js @@ -1,6 +1,5 @@ -/*global Ember, ic */ - import Resolver from 'ember/resolver'; +import initFixtures from 'ghost/fixtures/init'; var App = Ember.Application.extend({ /** @@ -15,6 +14,7 @@ var App = Ember.Application.extend({ Resolver: Resolver['default'] }); +initFixtures(); // TODO move into ext/route.js // needed to add body class depending on current route @@ -39,36 +39,4 @@ Ember.Route.reopen({ } }); - -ic.ajax.defineFixture('/ghost/api/v0.1/posts', { - response: { - "posts": [ - { - "id": 2, - "title": "Ghost Ember Demo Post", - "markdown": "Lorem **ipsum** dolor sit amet, consectetur adipiscing elit. Fusce id felis nec est suscipit scelerisque vitae eu arcu. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Aliquam erat volutpat. Sed pellentesque metus vel velit tincidunt aliquet. Nunc condimentum tempus convallis. Sed tincidunt, leo et congue blandit, lorem tortor imperdiet sapien, et porttitor turpis nisl sed tellus. In ultrices urna sit amet mauris suscipit adipiscing.", - "html": "
Lorem ipsum<\/strong> dolor sit amet, consectetur adipiscing elit. Fusce id felis nec est suscipit scelerisque vitae eu arcu. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Aliquam erat volutpat. Sed pellentesque metus vel velit tincidunt aliquet. Nunc condimentum tempus convallis. Sed tincidunt, leo et congue blandit, lorem tortor imperdiet sapien, et porttitor turpis nisl sed tellus. In ultrices urna sit amet mauris suscipit adipiscing.<\/p>",
- "status": "draft",
- "author": {
- "id": 1,
- "name": "manuel_mitasch",
- },
- },
- {
- "id": 1,
- "title": "Welcome to Ghost",
- "markdown": "You're live! Nice. We've put together a little post to introduce you to the Ghost editor and get you started. You can manage your content by signing in to the admin area at ` You're live! Nice. We've put together a little post to introduce you to the Ghost editor and get you started. You can manage your content by signing in to the admin area at Ghost uses something called Markdown for writing. Essentially, it's a shorthand way to manage your post formatting as you write!<\/p>\n\n Writing in Markdown is really easy. In the left hand panel of Ghost, you simply write as you normally would. Where appropriate, you can use shortcuts<\/em> to style<\/strong> your content. For example, a list:<\/p>\n\n or with numbers!<\/p>\n\n Want to link to a source? No problem. If you paste in url, like http:\/\/ghost.org<\/a> - it'll automatically be linked up. But if you want to customise your anchor text, you can do that too! Here's a link to the Ghost website<\/a>. Neat.<\/p>\n\n Images work too! Already know the URL of the image you want to include in your article? Simply paste it in like this to make it show up:<\/p>\n\n <\/p>\n\n Not sure which image you want to use yet? That's ok too. Leave yourself a descriptive placeholder and keep writing. Come back later and drag and drop the image in to upload:<\/p>\n\n Sometimes a link isn't enough, you want to quote someone on what they've said. It was probably very wisdomous. Is wisdomous a word? Find out in a future release when we introduce spellcheck! For now - it's definitely a word.<\/p>\n\n Wisdomous - it's definitely a word.<\/p>\n<\/blockquote>\n\n Got a streak of geek? We've got you covered there, too. You can write inline Throw 3 or more dashes down on any new line and you've got yourself a fancy new divider. Aw yeah.<\/p>\n\n There's one fantastic secret about Markdown. If you want, you can write plain old HTML and it'll still work! Very flexible.<\/p>\n\n <\/p>\n\n That should be enough to get you started. Have fun - and let us know what you think :)<\/p>",
- "status": "published",
- "author": {
- "id": 1,
- "name": "manuel_mitasch",
- },
- }
- ],
- },
- jqXHR: {},
- textStatus: 'success'
-});
-
export default App;
diff --git a/core/client/controllers/post.js b/core/client/controllers/posts/post.js
similarity index 100%
rename from core/client/controllers/post.js
rename to core/client/controllers/posts/post.js
diff --git a/core/client/fixtures/init.js b/core/client/fixtures/init.js
new file mode 100644
index 000000000000..976f7b81d75a
--- /dev/null
+++ b/core/client/fixtures/init.js
@@ -0,0 +1,24 @@
+/*global ic */
+import postFixtures from 'ghost/fixtures/posts';
+
+var post = function (id) {
+ return {
+ response: postFixtures.findBy('id', id),
+ jqXHR: {},
+ textStatus: 'success'
+ };
+};
+
+var posts = function () {
+ return {
+ response: postFixtures,
+ jqXHR: {},
+ textStatus: 'success'
+ };
+};
+
+export default function () {
+ ic.ajax.defineFixture('/ghost/api/v0.1/posts', posts());
+ ic.ajax.defineFixture('/ghost/api/v0.1/posts/1', post(1));
+ ic.ajax.defineFixture('/ghost/api/v0.1/posts/2', post(2));
+}
diff --git a/core/client/fixtures/posts.js b/core/client/fixtures/posts.js
new file mode 100644
index 000000000000..3c40e103e24a
--- /dev/null
+++ b/core/client/fixtures/posts.js
@@ -0,0 +1,24 @@
+export default [
+ {
+ "id": 2,
+ "title": "Ghost Ember Demo Post",
+ "markdown": "Lorem **ipsum** dolor sit amet, consectetur adipiscing elit. Fusce id felis nec est suscipit scelerisque vitae eu arcu. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Aliquam erat volutpat. Sed pellentesque metus vel velit tincidunt aliquet. Nunc condimentum tempus convallis. Sed tincidunt, leo et congue blandit, lorem tortor imperdiet sapien, et porttitor turpis nisl sed tellus. In ultrices urna sit amet mauris suscipit adipiscing.",
+ "html": " Lorem ipsum<\/strong> dolor sit amet, consectetur adipiscing elit. Fusce id felis nec est suscipit scelerisque vitae eu arcu. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Aliquam erat volutpat. Sed pellentesque metus vel velit tincidunt aliquet. Nunc condimentum tempus convallis. Sed tincidunt, leo et congue blandit, lorem tortor imperdiet sapien, et porttitor turpis nisl sed tellus. In ultrices urna sit amet mauris suscipit adipiscing.<\/p>",
+ "status": "draft",
+ "author": {
+ "id": 1,
+ "name": "manuel_mitasch"
+ }
+ },
+ {
+ "id": 1,
+ "title": "Welcome to Ghost",
+ "markdown": "You're live! Nice. We've put together a little post to introduce you to the Ghost editor and get you started. You can manage your content by signing in to the admin area at ` You're live! Nice. We've put together a little post to introduce you to the Ghost editor and get you started. You can manage your content by signing in to the admin area at Ghost uses something called Markdown for writing. Essentially, it's a shorthand way to manage your post formatting as you write!<\/p>\n\n Writing in Markdown is really easy. In the left hand panel of Ghost, you simply write as you normally would. Where appropriate, you can use shortcuts<\/em> to style<\/strong> your content. For example, a list:<\/p>\n\n or with numbers!<\/p>\n\n Want to link to a source? No problem. If you paste in url, like http:\/\/ghost.org<\/a> - it'll automatically be linked up. But if you want to customise your anchor text, you can do that too! Here's a link to the Ghost website<\/a>. Neat.<\/p>\n\n Images work too! Already know the URL of the image you want to include in your article? Simply paste it in like this to make it show up:<\/p>\n\n <\/p>\n\n Not sure which image you want to use yet? That's ok too. Leave yourself a descriptive placeholder and keep writing. Come back later and drag and drop the image in to upload:<\/p>\n\n Sometimes a link isn't enough, you want to quote someone on what they've said. It was probably very wisdomous. Is wisdomous a word? Find out in a future release when we introduce spellcheck! For now - it's definitely a word.<\/p>\n\n Wisdomous - it's definitely a word.<\/p>\n<\/blockquote>\n\n Got a streak of geek? We've got you covered there, too. You can write inline Throw 3 or more dashes down on any new line and you've got yourself a fancy new divider. Aw yeah.<\/p>\n\n There's one fantastic secret about Markdown. If you want, you can write plain old HTML and it'll still work! Very flexible.<\/p>\n\n <\/p>\n\n That should be enough to get you started. Have fun - and let us know what you think :)<\/p>",
+ "status": "published",
+ "author": {
+ "id": 1,
+ "name": "manuel_mitasch"
+ }
+ }
+];
\ No newline at end of file
diff --git a/core/client/models/.gitkeep b/core/client/models/.gitkeep
deleted file mode 100644
index e69de29bb2d1..000000000000
diff --git a/core/client/models/post.js b/core/client/models/post.js
new file mode 100644
index 000000000000..1c101ee55f81
--- /dev/null
+++ b/core/client/models/post.js
@@ -0,0 +1,5 @@
+var PostModel = Ember.Object.extend({
+
+});
+
+export default PostModel;
\ No newline at end of file
diff --git a/core/client/router.js b/core/client/router.js
index b9f94b275248..485b96ca41fa 100755
--- a/core/client/router.js
+++ b/core/client/router.js
@@ -10,7 +10,7 @@ Router.reopen({
Router.map(function () {
this.resource('posts', { path: '/' }, function () {
- this.resource('post', { path: '/:post_id' });
+ this.route('post', { path: ':post_id' });
});
this.resource('editor', { path: '/editor/:post_id' });
this.route('new', { path: '/editor' });
diff --git a/core/client/routes/posts/index.js b/core/client/routes/posts/index.js
index d50b1cae2dac..d70f3fb70d3b 100644
--- a/core/client/routes/posts/index.js
+++ b/core/client/routes/posts/index.js
@@ -1,10 +1,10 @@
export default Ember.Route.extend({
// redirect to first post subroute
redirect: function () {
- var firstPost = this.modelFor('posts').posts[0];
+ var firstPost = (this.modelFor('posts') || []).get('firstObject');
if (firstPost) {
- this.transitionTo('post', firstPost);
+ this.transitionTo('posts.post', firstPost);
}
}
});
\ No newline at end of file
diff --git a/core/client/routes/posts/post.js b/core/client/routes/posts/post.js
new file mode 100644
index 000000000000..cfb4d7b0f56d
--- /dev/null
+++ b/core/client/routes/posts/post.js
@@ -0,0 +1,7 @@
+/*global ajax */
+
+export default Ember.Route.extend({
+ model: function (params) {
+ return ajax("/ghost/api/v0.1/posts/" + params.post_id);
+ }
+});
\ No newline at end of file
diff --git a/core/client/templates/posts.hbs b/core/client/templates/posts.hbs
index 1b2de6ec4e79..323742203ed7 100644
--- a/core/client/templates/posts.hbs
+++ b/core/client/templates/posts.hbs
@@ -8,9 +8,9 @@
` blocks really easily with back ticks. Want to show off something more comprehensive? 4 spaces of indentation gets you there.\n\n .awesome-thing {\n display: block;\n width: 100%;\n }\n\n### Ready for a Break? \n\nThrow 3 or more dashes down on any new line and you've got yourself a fancy new divider. Aw yeah.\n\n---\n\n### Advanced Usage\n\nThere's one fantastic secret about Markdown. If you want, you can write plain old HTML and it'll still work! Very flexible.\n\n\n\nThat should be enough to get you started. Have fun - and let us know what you think :)",
- "html": "
<your blog URL>\/ghost\/<\/code>. When you arrive, you can select this post from a list on the left and see a preview of it on the right. Click the little pencil icon at the top of the preview to edit this post and read the next section!<\/p>\n\n
Getting Started<\/h2>\n\n
\n
\n
Links<\/h3>\n\n
What about Images?<\/h3>\n\n
Quoting<\/h3>\n\n
\n
Working with Code<\/h3>\n\n
<code><\/code> blocks really easily with back ticks. Want to show off something more comprehensive? 4 spaces of indentation gets you there.<\/p>\n\n
.awesome-thing {\n display: block;\n width: 100%;\n}\n<\/code><\/pre>\n\n
Ready for a Break?<\/h3>\n\n
\n\nAdvanced Usage<\/h3>\n\n
` blocks really easily with back ticks. Want to show off something more comprehensive? 4 spaces of indentation gets you there.\n\n .awesome-thing {\n display: block;\n width: 100%;\n }\n\n### Ready for a Break? \n\nThrow 3 or more dashes down on any new line and you've got yourself a fancy new divider. Aw yeah.\n\n---\n\n### Advanced Usage\n\nThere's one fantastic secret about Markdown. If you want, you can write plain old HTML and it'll still work! Very flexible.\n\n\n\nThat should be enough to get you started. Have fun - and let us know what you think :)",
+ "html": "
<your blog URL>\/ghost\/<\/code>. When you arrive, you can select this post from a list on the left and see a preview of it on the right. Click the little pencil icon at the top of the preview to edit this post and read the next section!<\/p>\n\n
Getting Started<\/h2>\n\n
\n
\n
Links<\/h3>\n\n
What about Images?<\/h3>\n\n
Quoting<\/h3>\n\n
\n
Working with Code<\/h3>\n\n
<code><\/code> blocks really easily with back ticks. Want to show off something more comprehensive? 4 spaces of indentation gets you there.<\/p>\n\n
.awesome-thing {\n display: block;\n width: 100%;\n}\n<\/code><\/pre>\n\n
Ready for a Break?<\/h3>\n\n
\n\nAdvanced Usage<\/h3>\n\n
- {{#each posts itemController="post"}}
+ {{#each itemController="posts/post"}}
{{#view "post-item-view" tagName="li" post=this}}
- {{#link-to 'post' this class="permalink" title="Edit this post"}}
+ {{#link-to 'posts.post' this class="permalink" title="Edit this post"}}
{{title}}