mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-16 12:16:09 +03:00
Merge pull request #236 from cobbspur/posttime
closes #195 posts date on content page
This commit is contained in:
commit
57daf0b64c
16
core/admin/assets/js/helpers/index.js
Normal file
16
core/admin/assets/js/helpers/index.js
Normal file
@ -0,0 +1,16 @@
|
||||
/*globals Handlebars, moment
|
||||
*/
|
||||
(function () {
|
||||
"use strict";
|
||||
Handlebars.registerHelper('dateFormat', function (context, block) {
|
||||
var f = block.hash.format || "MMM Do, YYYY",
|
||||
timeago = block.hash.timeago,
|
||||
date;
|
||||
if (timeago) {
|
||||
date = moment(context).fromNow();
|
||||
} else {
|
||||
date = moment(context).format(f);
|
||||
}
|
||||
return date;
|
||||
});
|
||||
}());
|
@ -9,6 +9,10 @@
|
||||
},
|
||||
|
||||
parse: function (resp) {
|
||||
if (resp.status) {
|
||||
resp.published = !!(resp.status === "published");
|
||||
resp.draft = !!(resp.status === "draft");
|
||||
}
|
||||
if (resp.tags) {
|
||||
// TODO: parse tags into it's own collection on the model (this.tags)
|
||||
return resp;
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
blog: function () {
|
||||
var posts = new Ghost.Collections.Posts();
|
||||
posts.fetch({ data: { status: 'all' } }).then(function () {
|
||||
posts.fetch({ data: { status: 'all', orderBy: ['updated_at', 'DESC'] } }).then(function () {
|
||||
Ghost.currentView = new Ghost.Views.Blog({ el: '#main', collection: posts });
|
||||
});
|
||||
},
|
||||
|
6
core/admin/assets/lib/moment.js
Normal file
6
core/admin/assets/lib/moment.js
Normal file
File diff suppressed because one or more lines are too long
@ -1164,3 +1164,11 @@ main {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.status-draft {
|
||||
color: $red;
|
||||
}
|
||||
.status-scheduled {
|
||||
color: $orange;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,12 @@
|
||||
<a class="permalink{{#if featured}} featured{{/if}}" href="#">
|
||||
<h3 class="entry-title">{{title}}</h3>
|
||||
<section class="entry-meta">
|
||||
<time datetime="2013-01-04" class="date">5 minutes ago</time>
|
||||
<time datetime="2013-01-04" class="date">
|
||||
{{#if published}}Published
|
||||
{{#if updated_at}}{{dateFormat updated_at timeago="True"}}
|
||||
{{else}}{{dateFormat published_at timeago="True"}}{{/if}}
|
||||
{{else}}<span class="status-draft">Draft</span>{{/if}}
|
||||
</time>
|
||||
{{!<span class="views">1,934</span>}}
|
||||
</section>
|
||||
</a>
|
@ -3,7 +3,7 @@
|
||||
<span class="hidden">Star</span>
|
||||
</a>
|
||||
{{! TODO: JavaScript toggle featured/unfeatured}}
|
||||
<span class="status">Published</span>
|
||||
<span class="status">{{#if published}}Published{{else}}Written{{/if}}</span>
|
||||
<span class="normal">by</span>
|
||||
<span class="author">Joe Bloggs</span>
|
||||
<section class="post-controls">
|
||||
|
@ -53,6 +53,8 @@
|
||||
<script src="/core/admin/assets/js/admin-ui-temp.js"></script>
|
||||
<script src="/core/admin/assets/js/markdown-actions.js"></script>
|
||||
<script src="/core/admin/assets/js/tagui.js"></script>
|
||||
<script src="/core/admin/assets/lib/moment.js"></script>
|
||||
<script src="/core/admin/assets/js/helpers/index.js"></script>
|
||||
|
||||
<!-- // require '/core/admin/assets/js/models/*' -->
|
||||
<script src="/core/admin/assets/js/models/post.js"></script>
|
||||
|
@ -15,8 +15,15 @@ coreHelpers = function (ghost) {
|
||||
* @return {Object} A Moment time / date object
|
||||
*/
|
||||
ghost.registerThemeHelper('dateFormat', function (context, block) {
|
||||
var f = block.hash.format || "MMM Do, YYYY";
|
||||
return moment(context).format(f);
|
||||
var f = block.hash.format || "MMM Do, YYYY",
|
||||
timeago = block.hash.timeago,
|
||||
date;
|
||||
if (timeago) {
|
||||
date = moment(context).fromNow();
|
||||
} else {
|
||||
date = moment(context).format(f);
|
||||
}
|
||||
return date;
|
||||
});
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user