fix redirect

This commit is contained in:
AJ ONeal 2015-01-13 04:55:16 -07:00
parent a688be6221
commit 9bb3079b61
3 changed files with 20 additions and 16 deletions

@ -1 +1 @@
Subproject commit f023315cfc91001e608b00892de5379e9b2c0eee Subproject commit 574ab2045361ce2980f9f4b71e5fb12430a1fffb

View File

@ -17,20 +17,14 @@ angular.module('myApp.build', ['ngRoute'])
; ;
function init() { function init() {
console.log('desi loading');
DesiraeService.meta().then(function (desi) { DesiraeService.meta().then(function (desi) {
scope.blogdir = desi.blogdir.path.replace(/^\/(Users|home)\/[^\/]+\//, '~/'); scope.blogdir = desi.blogdir.path.replace(/^\/(Users|home)\/[^\/]+\//, '~/');
scope.site = desi.site; scope.site = desi.site;
console.log(desi.site.base_url);
console.log(desi.site.base_path);
scope.production_url = desi.site.base_url + path.join('/', desi.site.base_path); scope.production_url = desi.site.base_url + path.join('/', desi.site.base_path);
console.log(scope.production_url);
// this is the responsibility of the build system (Dear Desi), not the library (Desirae) // this is the responsibility of the build system (Dear Desi), not the library (Desirae)
scope.development_url = location.href.replace(/\/(#.*)?$/, '') + path.join('/', 'compiled_dev'); scope.development_url = location.href.replace(/\/(#.*)?$/, '') + path.join('/', 'compiled_dev');
console.log(scope.development_url);
}).catch(function (e) { }).catch(function (e) {
window.alert("An Error Occured. Most errors that occur in the init phase are parse errors in the config files or permissions errors on files or directories, but check the error console for details."); window.alert("An Error Occured. Most errors that occur in the init phase are parse errors in the config files or permissions errors on files or directories, but check the error console for details.");
console.error(e); console.error(e);
@ -58,7 +52,7 @@ angular.module('myApp.build', ['ngRoute'])
if ('production' === envstr) { if ('production' === envstr) {
env = { env = {
url: scope.production_url url: scope.production_url
, base_url: scope.development_url.replace(/(https?:\/\/[^\/#?]+)/, '$1') , base_url: scope.development_url.replace(/(https?:\/\/[^\/#?]+).*/, '$1')
, compiled_path: 'compiled' , compiled_path: 'compiled'
, since: 0 , since: 0
, onError: scope.onError , onError: scope.onError
@ -66,7 +60,7 @@ angular.module('myApp.build', ['ngRoute'])
} else { } else {
env = { env = {
url: scope.development_url url: scope.development_url
, base_url: scope.development_url.replace(/(https?:\/\/[^\/#?]+)/, '$1') , base_url: scope.development_url.replace(/(https?:\/\/[^\/#?]+).*/, '$1')
, base_path: scope.development_url.replace(/https?:\/\/[^\/#?]+/, '') , base_path: scope.development_url.replace(/https?:\/\/[^\/#?]+/, '')
, compiled_path: 'compiled_dev' , compiled_path: 'compiled_dev'
, since: 0 , since: 0

View File

@ -15,7 +15,6 @@ angular.module('myApp.post', ['ngRoute'])
; ;
function init() { function init() {
console.log('desi loading');
Desirae.meta().then(function (desi) { Desirae.meta().then(function (desi) {
scope.blogdir = desi.blogdir.path.replace(/^\/(Users|home)\/[^\/]+\//, '~/'); scope.blogdir = desi.blogdir.path.replace(/^\/(Users|home)\/[^\/]+\//, '~/');
scope.site = desi.site; scope.site = desi.site;
@ -34,13 +33,13 @@ angular.module('myApp.post', ['ngRoute'])
function newPost() { function newPost() {
scope.selected = { scope.selected = {
format: 'md' format: 'md'
, permalink: "/article/new.md" , permalink: "/article/new.html"
, uuid: window.uuid.v4() , uuid: window.uuid.v4()
, abspath: scope.blogdir , abspath: scope.blogdir
, post: { , post: {
yml: { yml: {
title: "" title: ""
, permalink: "/article/new.md" , permalink: "/article/new.html"
, date: Desirae.toDesiDate(new Date())// "YYYY-MM-DD HH:MM pm" // TODO desirae , date: Desirae.toDesiDate(new Date())// "YYYY-MM-DD HH:MM pm" // TODO desirae
, updated: null , updated: null
, description: "" , description: ""
@ -71,23 +70,29 @@ angular.module('myApp.post', ['ngRoute'])
.replace(/^-+/g, '') .replace(/^-+/g, '')
.replace(/-+$/g, '') .replace(/-+$/g, '')
.replace(/--/g, '-') .replace(/--/g, '-')
+ '.' + selected.format + '/' // + '.html' //+ selected.format
; ;
post.yml.permalink = selected.permalink; post.yml.permalink = selected.permalink;
} }
/*
if (window.path.extname(post.yml.permalink) !== '.' + selected.format) { if (window.path.extname(post.yml.permalink) !== '.' + selected.format) {
post.yml.permalink = post.yml.permalink.replace(/\.\w+$/, '.' + selected.format); post.yml.permalink = post.yml.permalink.replace(/\.\w+$/, '.' + selected.format);
} }
*/
post.frontmatter = window.jsyaml.dump(post.yml).trim(); post.frontmatter = window.jsyaml.dump(post.yml).trim();
// TODO use some sort of filepath pattern in config.yml // TODO use some sort of filepath pattern in config.yml
selected.path = window.path.join((selected.collection || 'posts'), window.path.basename(post.yml.permalink)); selected.path = window.path.join((selected.collection || 'posts'), window.path.basename(post.yml.permalink));
if (!/\.html?$/.test(selected.path)) {
selected.path = window.path.join(selected.path, 'index.html');
}
selected.abspath = window.path.join(scope.blogdir, selected.path); selected.abspath = window.path.join(scope.blogdir, selected.path);
}; };
scope.onFrontmatterChange = function () { scope.onFrontmatterChange = function () {
var data var data
, post
; ;
try { try {
@ -95,11 +100,17 @@ angular.module('myApp.post', ['ngRoute'])
throw new Error('deleted frontmatter'); throw new Error('deleted frontmatter');
} }
data = window.jsyaml.load(scope.selected.post.frontmatter); data = window.jsyaml.load(scope.selected.post.frontmatter);
scope.selected.format = data.permalink.replace(/.*\.(\w+$)/, '$1'); //scope.selected.format = data.permalink.replace(/.*\.(\w+$)/, '$1');
if (!data.permalink) { if (!data.permalink) {
data = scope.selected.permalink; data = scope.selected.permalink;
} }
scope.selected.post.yml = data; scope.selected.post.yml = data;
post = scope.selected.post;
scope.selected.path = window.path.join((scope.selected.collection || 'posts'), window.path.basename(post.yml.permalink));
if (!/\.html?$/.test(scope.selected.path)) {
scope.selected.path = window.path.join(scope.selected.path, 'index.html');
}
} catch(e) { } catch(e) {
console.error(e); console.error(e);
console.error('ignoring update that created parse error'); console.error('ignoring update that created parse error');
@ -119,7 +130,6 @@ angular.module('myApp.post', ['ngRoute'])
} }
scope.upsert = function () { scope.upsert = function () {
console.log('upserted');
if (-1 === scope.extensions.indexOf(scope.selected.format)) { if (-1 === scope.extensions.indexOf(scope.selected.format)) {
window.alert('.' + scope.selected.format + ' is not a supported extension.\n\nPlease choose from: .' + scope.extensions.join(' .')); window.alert('.' + scope.selected.format + ' is not a supported extension.\n\nPlease choose from: .' + scope.extensions.join(' .'));
return; return;
@ -147,9 +157,9 @@ angular.module('myApp.post', ['ngRoute'])
+ scope.selected.post.body.trim() + scope.selected.post.body.trim()
}); });
console.log(files);
Desirae.putFiles(files).then(function (results) { Desirae.putFiles(files).then(function (results) {
console.log('TODO check for error'); console.log('TODO check for error');
console.log(files);
console.log(results); console.log(results);
$location.path('/build'); $location.path('/build');
}).catch(function (e) { }).catch(function (e) {