This commit is contained in:
AJ ONeal 2015-01-11 23:22:55 -07:00
parent e9caff8e86
commit 93e493acbb
3 changed files with 15 additions and 12 deletions

View File

@ -9,6 +9,7 @@ angular.module('myApp.services', []).
reset: function () { reset: function () {
desi = {}; desi = {};
} }
, toDesiDate: Desi.toLocaleDate
, meta: function () { , meta: function () {
var d = $q.defer() var d = $q.defer()
; ;

View File

@ -42,15 +42,6 @@
return str; return str;
} }
/*
function toLocaleDate(d) {
return d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate()
+ ' '
+ (d.getHours() % 12) + ':' + pad(d.getMinutes()) + ':' + pad(d.getSeconds())
;
}
*/
function fromLocaleDate(str) { function fromLocaleDate(str) {
// handles ISO and ISO-ish dates // handles ISO and ISO-ish dates
var m = str.match(/(\d\d\d\d)-(\d{1,2})-(\d{1,2})([T\s](\d{1,2}):(\d{1,2})(:(\d{1,2}))?)?/) var m = str.match(/(\d\d\d\d)-(\d{1,2})-(\d{1,2})([T\s](\d{1,2}):(\d{1,2})(:(\d{1,2}))?)?/)
@ -215,6 +206,13 @@
function Desi() { function Desi() {
} }
Desi.toLocaleDate = function (d) {
return d.getFullYear() + '-' + pad(d.getMonth() + 1) + '-' + pad(d.getDate())
+ ' '
+ (d.getHours() % 12) + ':' + pad(d.getMinutes()) + ' ' + (d.getHours() - 12 >= 0 ? 'pm' : 'am')
;
};
// read config and such // read config and such
Desi.init = function (desi) { Desi.init = function (desi) {
// config.yml, data.yml, site.yml, authors // config.yml, data.yml, site.yml, authors

View File

@ -36,7 +36,7 @@ angular.module('myApp.post', ['ngRoute'])
title: "" title: ""
, description: "" , description: ""
, uuid: window.uuid.v4() , uuid: window.uuid.v4()
, date: "YYYY-MM-DD HH:MM pm" // TODO desirae , date: Desirae.toDesiDate(new Date())// "YYYY-MM-DD HH:MM pm" // TODO desirae
, permalink: "/article/new.md" , permalink: "/article/new.md"
, categories: [] , categories: []
, tags: [] , tags: []
@ -46,6 +46,7 @@ angular.module('myApp.post', ['ngRoute'])
} }
} }
}; };
scope.selected.date = scope.selected.post.yml.date;
scope.selected.post.frontmatter = window.jsyaml.dump(scope.selected.post.yml); scope.selected.post.frontmatter = window.jsyaml.dump(scope.selected.post.yml);
scope.onChange = function () { scope.onChange = function () {
@ -55,6 +56,9 @@ angular.module('myApp.post', ['ngRoute'])
scope.selected.permalink = '/articles/' + scope.selected.title.toLowerCase() scope.selected.permalink = '/articles/' + scope.selected.title.toLowerCase()
.replace(/["']/g, '') .replace(/["']/g, '')
.replace(/\W/g, '-') .replace(/\W/g, '-')
.replace(/^-/g, '')
.replace(/-$/g, '')
.replace(/--/g, '-')
+ '.' + scope.selected.format + '.' + scope.selected.format
; ;
scope.selected.post.yml.permalink = scope.selected.permalink; scope.selected.post.yml.permalink = scope.selected.permalink;
@ -69,13 +73,13 @@ angular.module('myApp.post', ['ngRoute'])
$timeout(function () { $timeout(function () {
if (scope.selected && scope.selected.date === scope.selected.post.yml.date) { if (scope.selected && scope.selected.date === scope.selected.post.yml.date) {
scope.selected.date = scope.selected.post.yml.date = new Date().toISOString(); scope.selected.date = scope.selected.post.yml.date = Desirae.toDesiDate(new Date());
} }
scope.onChange(); scope.onChange();
}, 60 * 1000); }, 60 * 1000);
scope.upsert = function () { scope.upsert = function () {
console.log(scope.selected.format) console.log(scope.selected.format);
var files = [] var files = []
; ;