AJ ONeal
4 years ago
31 changed files with 1970 additions and 1415 deletions
@ -0,0 +1 @@ |
|||
{} |
@ -1,17 +1,21 @@ |
|||
'use strict'; |
|||
"use strict"; |
|||
|
|||
// Declare app level module which depends on views, and components
|
|||
angular.module('myApp', [ |
|||
'ngRoute', |
|||
'myApp.about', |
|||
'myApp.authors', |
|||
'myApp.site', |
|||
'myApp.build', |
|||
'myApp.configure', |
|||
'myApp.post', |
|||
'myApp.version', |
|||
'myApp.services' |
|||
]). |
|||
config(['$routeProvider', function ($routeProvider) { |
|||
$routeProvider.otherwise({redirectTo: '/about'}); |
|||
}]); |
|||
angular |
|||
.module("myApp", [ |
|||
"ngRoute", |
|||
"myApp.about", |
|||
"myApp.authors", |
|||
"myApp.site", |
|||
"myApp.build", |
|||
"myApp.configure", |
|||
"myApp.post", |
|||
"myApp.version", |
|||
"myApp.services", |
|||
]) |
|||
.config([ |
|||
"$routeProvider", |
|||
function ($routeProvider) { |
|||
$routeProvider.otherwise({ redirectTo: "/about" }); |
|||
}, |
|||
]); |
|||
|
@ -1,9 +1,13 @@ |
|||
'use strict'; |
|||
"use strict"; |
|||
|
|||
angular.module('myApp.version.interpolate-filter', []) |
|||
angular |
|||
.module("myApp.version.interpolate-filter", []) |
|||
|
|||
.filter('interpolate', ['version', function(version) { |
|||
return function(text) { |
|||
return String(text).replace(/\%VERSION\%/mg, version); |
|||
}; |
|||
}]); |
|||
.filter("interpolate", [ |
|||
"version", |
|||
function (version) { |
|||
return function (text) { |
|||
return String(text).replace(/\%VERSION\%/gm, version); |
|||
}; |
|||
}, |
|||
]); |
|||
|
@ -1,15 +1,19 @@ |
|||
'use strict'; |
|||
"use strict"; |
|||
|
|||
describe('myApp.version module', function() { |
|||
beforeEach(module('myApp.version')); |
|||
describe("myApp.version module", function () { |
|||
beforeEach(module("myApp.version")); |
|||
|
|||
describe('interpolate filter', function() { |
|||
beforeEach(module(function($provide) { |
|||
$provide.value('version', 'TEST_VER'); |
|||
})); |
|||
describe("interpolate filter", function () { |
|||
beforeEach( |
|||
module(function ($provide) { |
|||
$provide.value("version", "TEST_VER"); |
|||
}) |
|||
); |
|||
|
|||
it('should replace VERSION', inject(function(interpolateFilter) { |
|||
expect(interpolateFilter('before %VERSION% after')).toEqual('before TEST_VER after'); |
|||
it("should replace VERSION", inject(function (interpolateFilter) { |
|||
expect(interpolateFilter("before %VERSION% after")).toEqual( |
|||
"before TEST_VER after" |
|||
); |
|||
})); |
|||
}); |
|||
}); |
|||
|
@ -1,9 +1,13 @@ |
|||
'use strict'; |
|||
"use strict"; |
|||
|
|||
angular.module('myApp.version.version-directive', []) |
|||
angular |
|||
.module("myApp.version.version-directive", []) |
|||
|
|||
.directive('appVersion', ['version', function(version) { |
|||
return function(scope, elm, attrs) { |
|||
elm.text(version); |
|||
}; |
|||
}]); |
|||
.directive("appVersion", [ |
|||
"version", |
|||
function (version) { |
|||
return function (scope, elm, attrs) { |
|||
elm.text(version); |
|||
}; |
|||
}, |
|||
]); |
|||
|
@ -1,8 +1,9 @@ |
|||
'use strict'; |
|||
"use strict"; |
|||
|
|||
angular.module('myApp.version', [ |
|||
'myApp.version.interpolate-filter', |
|||
'myApp.version.version-directive' |
|||
]) |
|||
angular |
|||
.module("myApp.version", [ |
|||
"myApp.version.interpolate-filter", |
|||
"myApp.version.version-directive", |
|||
]) |
|||
|
|||
.value('version', '0.8.0'); |
|||
.value("version", "0.8.0"); |
|||
|
@ -1,11 +1,11 @@ |
|||
'use strict'; |
|||
"use strict"; |
|||
|
|||
describe('myApp.version module', function() { |
|||
beforeEach(module('myApp.version')); |
|||
describe("myApp.version module", function () { |
|||
beforeEach(module("myApp.version")); |
|||
|
|||
describe('version service', function() { |
|||
it('should return current version', inject(function(version) { |
|||
expect(version).toEqual('0.1'); |
|||
describe("version service", function () { |
|||
it("should return current version", inject(function (version) { |
|||
expect(version).toEqual("0.1"); |
|||
})); |
|||
}); |
|||
}); |
|||
|
@ -1,14 +1,16 @@ |
|||
'use strict'; |
|||
"use strict"; |
|||
|
|||
angular.module('myApp.about', ['ngRoute']) |
|||
angular |
|||
.module("myApp.about", ["ngRoute"]) |
|||
|
|||
.config(['$routeProvider', function($routeProvider) { |
|||
$routeProvider.when('/about', { |
|||
templateUrl: 'views/about/about.html', |
|||
controller: 'AboutCtrl' |
|||
}); |
|||
}]) |
|||
.config([ |
|||
"$routeProvider", |
|||
function ($routeProvider) { |
|||
$routeProvider.when("/about", { |
|||
templateUrl: "views/about/about.html", |
|||
controller: "AboutCtrl", |
|||
}); |
|||
}, |
|||
]) |
|||
|
|||
.controller('AboutCtrl', [function() { |
|||
|
|||
}]); |
|||
.controller("AboutCtrl", [function () {}]); |
|||
|
@ -1,16 +1,13 @@ |
|||
'use strict'; |
|||
"use strict"; |
|||
|
|||
describe('myApp.view2 module', function() { |
|||
describe("myApp.view2 module", function () { |
|||
beforeEach(module("myApp.view2")); |
|||
|
|||
beforeEach(module('myApp.view2')); |
|||
|
|||
describe('view2 controller', function(){ |
|||
|
|||
it('should ....', inject(function($controller) { |
|||
describe("view2 controller", function () { |
|||
it("should ....", inject(function ($controller) { |
|||
//spec body
|
|||
var view2Ctrl = $controller('View2Ctrl'); |
|||
var view2Ctrl = $controller("View2Ctrl"); |
|||
expect(view2Ctrl).toBeDefined(); |
|||
})); |
|||
|
|||
}); |
|||
}); |
|||
}); |
|||
|
@ -1,100 +1,135 @@ |
|||
'use strict'; |
|||
"use strict"; |
|||
|
|||
angular.module('myApp.build', ['ngRoute']) |
|||
angular |
|||
.module("myApp.build", ["ngRoute"]) |
|||
|
|||
.config(['$routeProvider', function($routeProvider) { |
|||
$routeProvider.when('/build', { |
|||
templateUrl: 'views/build/build.html', |
|||
controller: 'BuildCtrl as Build' |
|||
}); |
|||
}]) |
|||
|
|||
.controller('BuildCtrl' |
|||
, ['$scope', '$location', '$timeout', 'Desirae' |
|||
, function ($scope, $location, $timeout, DesiraeService) { |
|||
var scope = this |
|||
, path = window.path |
|||
; |
|||
|
|||
function init() { |
|||
scope.extensions = ['md', 'html']; |
|||
|
|||
return DesiraeService.meta().then(function (desi) { |
|||
scope.blogdir = desi.blogdir.path.replace(/^\/(Users|home)\/[^\/]+\//, '~/'); |
|||
scope.site = desi.site; |
|||
.config([ |
|||
"$routeProvider", |
|||
function ($routeProvider) { |
|||
$routeProvider.when("/build", { |
|||
templateUrl: "views/build/build.html", |
|||
controller: "BuildCtrl as Build", |
|||
}); |
|||
}, |
|||
]) |
|||
|
|||
if (!desi.site.base_url || !desi.site.base_path) { |
|||
window.alert("Please go back to the site config and enter any mandatory missing fields (base_url, base_path)."); |
|||
return; |
|||
} |
|||
.controller("BuildCtrl", [ |
|||
"$scope", |
|||
"$location", |
|||
"$timeout", |
|||
"Desirae", |
|||
function ($scope, $location, $timeout, DesiraeService) { |
|||
var scope = this, |
|||
path = window.path; |
|||
function init() { |
|||
scope.extensions = ["md", "html"]; |
|||
|
|||
scope.display_url = scope.production_url = desi.site.base_url + path.join('/', desi.site.base_path); |
|||
if (/dropbox/.test(scope.display_url)) { |
|||
scope.display_url += '/index.html'; |
|||
} |
|||
return DesiraeService.meta() |
|||
.then(function (desi) { |
|||
scope.blogdir = desi.blogdir.path.replace( |
|||
/^\/(Users|home)\/[^\/]+\//, |
|||
"~/" |
|||
); |
|||
scope.site = desi.site; |
|||
|
|||
// this is the responsibility of the build system (Dear Desi), not the library (Desirae)
|
|||
scope.development_url = location.href.replace(/\/(#.*)?$/, '') + path.join('/', 'compiled_dev'); |
|||
if (!desi.site.base_url || !desi.site.base_path) { |
|||
window.alert( |
|||
"Please go back to the site config and enter any mandatory missing fields (base_url, base_path)." |
|||
); |
|||
return; |
|||
} |
|||
|
|||
return desi; |
|||
}).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."); |
|||
console.error(e); |
|||
throw e; |
|||
}); |
|||
} |
|||
scope.display_url = scope.production_url = |
|||
desi.site.base_url + path.join("/", desi.site.base_path); |
|||
if (/dropbox/.test(scope.display_url)) { |
|||
scope.display_url += "/index.html"; |
|||
} |
|||
|
|||
scope.onError = function (e) { |
|||
console.error(e); |
|||
if (window.confirm("Encountered an error. Please inspect the console.\n\nWould you like to ignore the error and continue?")) { |
|||
return window.Promise.resolve(); |
|||
} else { |
|||
return window.Promise.reject(); |
|||
} |
|||
}; |
|||
// 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.buildOne = function (envstr) { |
|||
return DesiraeService.reset().then(function () { |
|||
return init().then(function () { |
|||
var env |
|||
; |
|||
return desi; |
|||
}) |
|||
.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." |
|||
); |
|||
console.error(e); |
|||
throw e; |
|||
}); |
|||
} |
|||
|
|||
// TODO is there a legitimate case where in addition to base_path (root of the blog)
|
|||
// a user would need owner_base? i.e. school.edu/~/rogers/blog school.edu/~/rogers/assets
|
|||
if ('production' === envstr) { |
|||
env = { |
|||
url: scope.production_url |
|||
, base_url: scope.production_url.replace(/(https?:\/\/[^\/#?]+).*/, '$1') |
|||
, base_path: scope.production_url.replace(/https?:\/\/[^\/#?]+/, '') |
|||
, compiled_path: 'compiled' |
|||
, since: 0 |
|||
, onError: scope.onError |
|||
}; |
|||
scope.onError = function (e) { |
|||
console.error(e); |
|||
if ( |
|||
window.confirm( |
|||
"Encountered an error. Please inspect the console.\n\nWould you like to ignore the error and continue?" |
|||
) |
|||
) { |
|||
return window.Promise.resolve(); |
|||
} else { |
|||
env = { |
|||
url: scope.development_url |
|||
, base_url: scope.development_url.replace(/(https?:\/\/[^\/#?]+).*/, '$1') |
|||
, base_path: scope.development_url.replace(/https?:\/\/[^\/#?]+/, '') |
|||
, compiled_path: 'compiled_dev' |
|||
, since: 0 |
|||
, onError: scope.onError |
|||
}; |
|||
return window.Promise.reject(); |
|||
} |
|||
}; |
|||
|
|||
scope.buildOne = function (envstr) { |
|||
return DesiraeService.reset().then(function () { |
|||
return init().then(function () { |
|||
var env; |
|||
|
|||
return DesiraeService.build(env).then(function () { |
|||
DesiraeService.write(env); |
|||
// TODO is there a legitimate case where in addition to base_path (root of the blog)
|
|||
// a user would need owner_base? i.e. school.edu/~/rogers/blog school.edu/~/rogers/assets
|
|||
if ("production" === envstr) { |
|||
env = { |
|||
url: scope.production_url, |
|||
base_url: scope.production_url.replace( |
|||
/(https?:\/\/[^\/#?]+).*/, |
|||
"$1" |
|||
), |
|||
base_path: scope.production_url.replace( |
|||
/https?:\/\/[^\/#?]+/, |
|||
"" |
|||
), |
|||
compiled_path: "compiled", |
|||
since: 0, |
|||
onError: scope.onError, |
|||
}; |
|||
} else { |
|||
env = { |
|||
url: scope.development_url, |
|||
base_url: scope.development_url.replace( |
|||
/(https?:\/\/[^\/#?]+).*/, |
|||
"$1" |
|||
), |
|||
base_path: scope.development_url.replace( |
|||
/https?:\/\/[^\/#?]+/, |
|||
"" |
|||
), |
|||
compiled_path: "compiled_dev", |
|||
since: 0, |
|||
onError: scope.onError, |
|||
}; |
|||
} |
|||
|
|||
return DesiraeService.build(env).then(function () { |
|||
DesiraeService.write(env); |
|||
}); |
|||
}); |
|||
}); |
|||
}); |
|||
}); |
|||
}; |
|||
}; |
|||
|
|||
scope.build = function (envs) { |
|||
window.forEachAsync(envs, function (env) { |
|||
return scope.buildOne(env); |
|||
}).then(function () { |
|||
window.alert('Build(s) Complete'); |
|||
}); |
|||
}; |
|||
scope.build = function (envs) { |
|||
window |
|||
.forEachAsync(envs, function (env) { |
|||
return scope.buildOne(env); |
|||
}) |
|||
.then(function () { |
|||
window.alert("Build(s) Complete"); |
|||
}); |
|||
}; |
|||
|
|||
init(); |
|||
}]); |
|||
init(); |
|||
}, |
|||
]); |
|||
|
@ -1,13 +1,16 @@ |
|||
'use strict'; |
|||
"use strict"; |
|||
|
|||
angular.module('myApp.configure', ['ngRoute']) |
|||
angular |
|||
.module("myApp.configure", ["ngRoute"]) |
|||
|
|||
.config(['$routeProvider', function($routeProvider) { |
|||
$routeProvider.when('/configure', { |
|||
templateUrl: 'views/configure/configure.html', |
|||
controller: 'ConfigureCtrl as Configure' |
|||
}); |
|||
}]) |
|||
.config([ |
|||
"$routeProvider", |
|||
function ($routeProvider) { |
|||
$routeProvider.when("/configure", { |
|||
templateUrl: "views/configure/configure.html", |
|||
controller: "ConfigureCtrl as Configure", |
|||
}); |
|||
}, |
|||
]) |
|||
|
|||
.controller('ConfigureCtrl', [function() { |
|||
}]); |
|||
.controller("ConfigureCtrl", [function () {}]); |
|||
|
@ -1,210 +1,269 @@ |
|||
'use strict'; |
|||
angular.module('myApp.post', ['ngRoute']) |
|||
|
|||
.config(['$routeProvider', function($routeProvider) { |
|||
$routeProvider.when('/post', { |
|||
templateUrl: 'views/post/post.html', |
|||
controller: 'PostCtrl as Post' |
|||
}); |
|||
}]) |
|||
|
|||
.controller('PostCtrl' |
|||
, ['$scope', '$location', '$timeout', 'Desirae' |
|||
, function ($scope, $location, $timeout, DesiraeService) { |
|||
var scope = this |
|||
, path = window.path |
|||
; |
|||
|
|||
function init() { |
|||
DesiraeService.meta().then(function (desi) { |
|||
/* |
|||
"use strict"; |
|||
angular |
|||
.module("myApp.post", ["ngRoute"]) |
|||
|
|||
.config([ |
|||
"$routeProvider", |
|||
function ($routeProvider) { |
|||
$routeProvider.when("/post", { |
|||
templateUrl: "views/post/post.html", |
|||
controller: "PostCtrl as Post", |
|||
}); |
|||
}, |
|||
]) |
|||
|
|||
.controller("PostCtrl", [ |
|||
"$scope", |
|||
"$location", |
|||
"$timeout", |
|||
"Desirae", |
|||
function ($scope, $location, $timeout, DesiraeService) { |
|||
var scope = this, |
|||
path = window.path; |
|||
function init() { |
|||
DesiraeService.meta() |
|||
.then(function (desi) { |
|||
/* |
|||
if (!scope.site.base_url) { |
|||
window.alert("Please go to the site tab and add a url first"); |
|||
return; |
|||
} |
|||
*/ |
|||
scope.blogdir = desi.blogdir.path.replace(/^\/(Users|home)\/[^\/]+\//, '~/'); |
|||
scope.site = desi.site; |
|||
scope.env = desi.site; |
|||
newPost(); |
|||
scope.blogdir = desi.blogdir.path.replace( |
|||
/^\/(Users|home)\/[^\/]+\//, |
|||
"~/" |
|||
); |
|||
scope.site = desi.site; |
|||
scope.env = desi.site; |
|||
newPost(); |
|||
|
|||
if (/dropbox/.test(scope.site.base_url)) { |
|||
scope.env.explicitIndexes = true; |
|||
} |
|||
|
|||
updateDate(); |
|||
}) |
|||
.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." |
|||
); |
|||
console.error(e); |
|||
throw e; |
|||
}); |
|||
|
|||
if (/dropbox/.test(scope.site.base_url)) { |
|||
scope.env.explicitIndexes = true; |
|||
scope.extensions = ["md", "html"]; |
|||
} |
|||
|
|||
updateDate(); |
|||
}).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."); |
|||
console.error(e); |
|||
throw e; |
|||
}); |
|||
|
|||
scope.extensions = ['md', 'html']; |
|||
} |
|||
|
|||
function newPost() { |
|||
scope.selected = { |
|||
format: 'md' |
|||
, permalink: "/article/new.html" |
|||
, uuid: window.uuid.v4() |
|||
, abspath: scope.blogdir |
|||
, sourcepath: '' |
|||
, fileepath: '' |
|||
, post: { |
|||
yml: { |
|||
title: "" |
|||
, permalink: "/article/new.html" |
|||
, date: DesiraeService.toDesiDate(new Date())// "YYYY-MM-DD HH:MM pm" // TODO desirae
|
|||
, updated: null |
|||
, description: "" |
|||
, categories: [] |
|||
, tags: [] |
|||
, theme: null |
|||
, layout: null |
|||
, swatch: null |
|||
} |
|||
function newPost() { |
|||
scope.selected = { |
|||
format: "md", |
|||
permalink: "/article/new.html", |
|||
uuid: window.uuid.v4(), |
|||
abspath: scope.blogdir, |
|||
sourcepath: "", |
|||
fileepath: "", |
|||
post: { |
|||
yml: { |
|||
title: "", |
|||
permalink: "/article/new.html", |
|||
date: DesiraeService.toDesiDate(new Date()), // "YYYY-MM-DD HH:MM pm" // TODO desirae
|
|||
updated: null, |
|||
description: "", |
|||
categories: [], |
|||
tags: [], |
|||
theme: null, |
|||
layout: null, |
|||
swatch: null, |
|||
}, |
|||
}, |
|||
}; |
|||
scope.selected.date = scope.selected.post.yml.date; |
|||
scope.selected.post.frontmatter = window.jsyaml |
|||
.dump(scope.selected.post.yml) |
|||
.trim(); |
|||
} |
|||
}; |
|||
scope.selected.date = scope.selected.post.yml.date; |
|||
scope.selected.post.frontmatter = window.jsyaml.dump(scope.selected.post.yml).trim(); |
|||
} |
|||
|
|||
scope.onChange = function () { |
|||
var post = scope.selected.post |
|||
, selected = scope.selected |
|||
; |
|||
|
|||
post.yml.title = post.yml.title || ''; |
|||
selected.title = post.yml.title; |
|||
post.yml.description = post.yml.description || ''; |
|||
|
|||
scope.slug = post.yml.title.toLowerCase() |
|||
.replace(/["']/g, '') |
|||
.replace(/\W/g, '-') |
|||
.replace(/^-+/g, '') |
|||
.replace(/-+$/g, '') |
|||
.replace(/--/g, '-') |
|||
; |
|||
|
|||
if (selected.permalink === post.yml.permalink) { |
|||
selected.permalink = '/articles/' + scope.slug + '/'; |
|||
// + '.html' //+ selected.format
|
|||
|
|||
post.yml.permalink = selected.permalink; |
|||
} |
|||
/* |
|||
|
|||
scope.onChange = function () { |
|||
var post = scope.selected.post, |
|||
selected = scope.selected; |
|||
post.yml.title = post.yml.title || ""; |
|||
selected.title = post.yml.title; |
|||
post.yml.description = post.yml.description || ""; |
|||
|
|||
scope.slug = post.yml.title |
|||
.toLowerCase() |
|||
.replace(/["']/g, "") |
|||
.replace(/\W/g, "-") |
|||
.replace(/^-+/g, "") |
|||
.replace(/-+$/g, "") |
|||
.replace(/--/g, "-"); |
|||
|
|||
if (selected.permalink === post.yml.permalink) { |
|||
selected.permalink = "/articles/" + scope.slug + "/"; |
|||
// + '.html' //+ selected.format
|
|||
|
|||
post.yml.permalink = selected.permalink; |
|||
} |
|||
/* |
|||
if (path.extname(post.yml.permalink) !== '.' + 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
|
|||
selected.path = path.join((scope.env.compiled_path || 'compiled'), post.yml.permalink); |
|||
if (!/\.html?$/.test(selected.path)) { |
|||
selected.path = path.join(selected.path, 'index.html'); |
|||
} |
|||
// TODO use some sort of filepath pattern in config.yml
|
|||
selected.path = path.join( |
|||
scope.env.compiled_path || "compiled", |
|||
post.yml.permalink |
|||
); |
|||
if (!/\.html?$/.test(selected.path)) { |
|||
selected.path = path.join(selected.path, "index.html"); |
|||
} |
|||
|
|||
selected.url = path.join(scope.site.base_url + path.join(scope.site.base_path, post.yml.permalink)); |
|||
if (scope.env.explicitIndexes && /\/$/.test(selected.url)) { |
|||
selected.url += 'index.html'; |
|||
} |
|||
selected.markdown = '[' + selected.title + '](' + selected.url + ')'; |
|||
selected.ahref = '<a href="' + selected.url + '">' + selected.title + '</a>'; |
|||
selected.abspath = path.join(scope.blogdir, selected.path); |
|||
selected.filepath = path.join((selected.collection || 'posts'), scope.slug + '.' + selected.format); |
|||
selected.sourcepath = path.join(scope.blogdir, (selected.collection || 'posts'), scope.slug + '.' + selected.format); |
|||
}; |
|||
scope.onFrontmatterChange = function () { |
|||
var data |
|||
, post |
|||
; |
|||
|
|||
try { |
|||
if (!scope.selected.post.frontmatter || !scope.selected.post.frontmatter.trim()) { |
|||
throw new Error('deleted frontmatter'); |
|||
} |
|||
data = window.jsyaml.load(scope.selected.post.frontmatter); |
|||
//scope.selected.format = data.permalink.replace(/.*\.(\w+$)/, '$1');
|
|||
if (!data.permalink) { |
|||
data = scope.selected.permalink; |
|||
} |
|||
scope.selected.post.yml = data; |
|||
selected.url = path.join( |
|||
scope.site.base_url + |
|||
path.join(scope.site.base_path, post.yml.permalink) |
|||
); |
|||
if (scope.env.explicitIndexes && /\/$/.test(selected.url)) { |
|||
selected.url += "index.html"; |
|||
} |
|||
selected.markdown = "[" + selected.title + "](" + selected.url + ")"; |
|||
selected.ahref = |
|||
'<a href="' + selected.url + '">' + selected.title + "</a>"; |
|||
selected.abspath = path.join(scope.blogdir, selected.path); |
|||
selected.filepath = path.join( |
|||
selected.collection || "posts", |
|||
scope.slug + "." + selected.format |
|||
); |
|||
selected.sourcepath = path.join( |
|||
scope.blogdir, |
|||
selected.collection || "posts", |
|||
scope.slug + "." + selected.format |
|||
); |
|||
}; |
|||
scope.onFrontmatterChange = function () { |
|||
var data, post; |
|||
|
|||
post = scope.selected.post; |
|||
try { |
|||
if ( |
|||
!scope.selected.post.frontmatter || |
|||
!scope.selected.post.frontmatter.trim() |
|||
) { |
|||
throw new Error("deleted frontmatter"); |
|||
} |
|||
data = window.jsyaml.load(scope.selected.post.frontmatter); |
|||
//scope.selected.format = data.permalink.replace(/.*\.(\w+$)/, '$1');
|
|||
if (!data.permalink) { |
|||
data = scope.selected.permalink; |
|||
} |
|||
scope.selected.post.yml = data; |
|||
|
|||
scope.selected.path = path.join((scope.env.compiled_path || 'compiled'), post.yml.permalink); |
|||
if (!/\.html?$/.test(path.basename(post.yml.permalink))) { |
|||
scope.selected.path = path.join(scope.selected.path.replace(/\.w+$/, ''), 'index.html'); |
|||
} |
|||
post = scope.selected.post; |
|||
|
|||
scope.selected.url = path.join(scope.site.base_url + path.join(scope.site.base_path, post.yml.permalink)); |
|||
if (scope.env.explicitIndexes && /\/$/.test(scope.selected.url)) { |
|||
scope.selected.url += 'index.html'; |
|||
} |
|||
scope.selected.abspath = path.join(scope.blogdir, scope.selected.path); |
|||
scope.selected.sourcepath = path.join(scope.blogdir, (scope.selected.collection || 'posts'), scope.slug + '.' + scope.selected.format); |
|||
scope.selected.filepath = path.join((scope.selected.collection || 'posts'), scope.slug + '.' + scope.selected.format); |
|||
} catch(e) { |
|||
console.error(e); |
|||
console.error('ignoring update that created parse error'); |
|||
scope.selected.post.frontmatter = window.jsyaml.dump(scope.selected.post.yml).trim(); |
|||
} |
|||
}; |
|||
scope.selected.path = path.join( |
|||
scope.env.compiled_path || "compiled", |
|||
post.yml.permalink |
|||
); |
|||
if (!/\.html?$/.test(path.basename(post.yml.permalink))) { |
|||
scope.selected.path = path.join( |
|||
scope.selected.path.replace(/\.w+$/, ""), |
|||
"index.html" |
|||
); |
|||
} |
|||
|
|||
function updateDate() { |
|||
$timeout.cancel(scope.dtlock); |
|||
scope.dtlock = $timeout(function () { |
|||
if (scope.selected && scope.selected.date === scope.selected.post.yml.date) { |
|||
scope.selected.date = scope.selected.post.yml.date = DesiraeService.toDesiDate(new Date()); |
|||
} |
|||
scope.onChange(); |
|||
updateDate(); |
|||
}, 60 * 1000); |
|||
} |
|||
|
|||
scope.upsert = function () { |
|||
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(' .')); |
|||
return; |
|||
} |
|||
scope.selected.url = path.join( |
|||
scope.site.base_url + |
|||
path.join(scope.site.base_path, post.yml.permalink) |
|||
); |
|||
if (scope.env.explicitIndexes && /\/$/.test(scope.selected.url)) { |
|||
scope.selected.url += "index.html"; |
|||
} |
|||
scope.selected.abspath = path.join( |
|||
scope.blogdir, |
|||
scope.selected.path |
|||
); |
|||
scope.selected.sourcepath = path.join( |
|||
scope.blogdir, |
|||
scope.selected.collection || "posts", |
|||
scope.slug + "." + scope.selected.format |
|||
); |
|||
scope.selected.filepath = path.join( |
|||
scope.selected.collection || "posts", |
|||
scope.slug + "." + scope.selected.format |
|||
); |
|||
} catch (e) { |
|||
console.error(e); |
|||
console.error("ignoring update that created parse error"); |
|||
scope.selected.post.frontmatter = window.jsyaml |
|||
.dump(scope.selected.post.yml) |
|||
.trim(); |
|||
} |
|||
}; |
|||
|
|||
scope.selected.post.yml.uuid = scope.selected.uuid; |
|||
['updated', 'theme', 'layout', 'swatch'].forEach(function (key) { |
|||
if (!scope.selected.post.yml[key]) { |
|||
delete scope.selected.post.yml[key]; |
|||
function updateDate() { |
|||
$timeout.cancel(scope.dtlock); |
|||
scope.dtlock = $timeout(function () { |
|||
if ( |
|||
scope.selected && |
|||
scope.selected.date === scope.selected.post.yml.date |
|||
) { |
|||
scope.selected.date = scope.selected.post.yml.date = DesiraeService.toDesiDate( |
|||
new Date() |
|||
); |
|||
} |
|||
scope.onChange(); |
|||
updateDate(); |
|||
}, 60 * 1000); |
|||
} |
|||
}); |
|||
scope.onChange(); |
|||
|
|||
var files = [] |
|||
; |
|||
|
|||
files.push({ |
|||
path: scope.selected.filepath |
|||
, contents: |
|||
'---\n' |
|||
+ scope.selected.post.frontmatter.trim() |
|||
+ '\n' |
|||
+ '---\n' |
|||
+ '\n' |
|||
+ scope.selected.post.body.trim() |
|||
}); |
|||
|
|||
DesiraeService.putFiles(files).then(function (results) { |
|||
console.log('TODO check for error'); |
|||
console.log(files); |
|||
console.log(results); |
|||
$location.path('/build'); |
|||
}).catch(function (e) { |
|||
$timeout.cancel(scope.dtlock); |
|||
console.error(scope.site); |
|||
console.error(e); |
|||
window.alert("Error Nation! :/"); |
|||
throw e; |
|||
}); |
|||
}; |
|||
|
|||
init(); |
|||
}]); |
|||
|
|||
scope.upsert = function () { |
|||
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(" .") |
|||
); |
|||
return; |
|||
} |
|||
|
|||
scope.selected.post.yml.uuid = scope.selected.uuid; |
|||
["updated", "theme", "layout", "swatch"].forEach(function (key) { |
|||
if (!scope.selected.post.yml[key]) { |
|||
delete scope.selected.post.yml[key]; |
|||
} |
|||
}); |
|||
scope.onChange(); |
|||
|
|||
var files = []; |
|||
files.push({ |
|||
path: scope.selected.filepath, |
|||
contents: |
|||
"---\n" + |
|||
scope.selected.post.frontmatter.trim() + |
|||
"\n" + |
|||
"---\n" + |
|||
"\n" + |
|||
scope.selected.post.body.trim(), |
|||
}); |
|||
|
|||
DesiraeService.putFiles(files) |
|||
.then(function (results) { |
|||
console.log("TODO check for error"); |
|||
console.log(files); |
|||
console.log(results); |
|||
$location.path("/build"); |
|||
}) |
|||
.catch(function (e) { |
|||
$timeout.cancel(scope.dtlock); |
|||
console.error(scope.site); |
|||
console.error(e); |
|||
window.alert("Error Nation! :/"); |
|||
throw e; |
|||
}); |
|||
}; |
|||
|
|||
init(); |
|||
}, |
|||
]); |
|||
|
@ -1,106 +1,124 @@ |
|||
'use strict'; |
|||
|
|||
angular.module('myApp.site', ['ngRoute']) |
|||
|
|||
.config(['$routeProvider', function($routeProvider) { |
|||
$routeProvider.when('/site', { |
|||
templateUrl: 'views/site/site.html', |
|||
controller: 'SiteCtrl as Site' |
|||
}); |
|||
}]) |
|||
|
|||
.controller('SiteCtrl', ['$scope', '$location', 'Desirae', function ($scope, $location, Desirae) { |
|||
var scope = this |
|||
; |
|||
|
|||
function init() { |
|||
console.log('desi loading'); |
|||
Desirae.meta().then(function (desi) { |
|||
scope.blogdir = desi.blogdir.path.replace(/^\/(Users|home)\/[^\/]+\//, '~/'); |
|||
scope.site = desi.site; |
|||
|
|||
var parts = Desirae.splitUrl(scope.site.base_url + (scope.site.base_path || '/')) |
|||
; |
|||
|
|||
if (parts) { |
|||
scope.base_url = scope.site.base_url; |
|||
scope.base_path = scope.site.base_path; |
|||
scope.url = scope.base_url + scope.site.base_path; |
|||
"use strict"; |
|||
|
|||
angular |
|||
.module("myApp.site", ["ngRoute"]) |
|||
|
|||
.config([ |
|||
"$routeProvider", |
|||
function ($routeProvider) { |
|||
$routeProvider.when("/site", { |
|||
templateUrl: "views/site/site.html", |
|||
controller: "SiteCtrl as Site", |
|||
}); |
|||
}, |
|||
]) |
|||
|
|||
.controller("SiteCtrl", [ |
|||
"$scope", |
|||
"$location", |
|||
"Desirae", |
|||
function ($scope, $location, Desirae) { |
|||
var scope = this; |
|||
function init() { |
|||
console.log("desi loading"); |
|||
Desirae.meta() |
|||
.then(function (desi) { |
|||
scope.blogdir = desi.blogdir.path.replace( |
|||
/^\/(Users|home)\/[^\/]+\//, |
|||
"~/" |
|||
); |
|||
scope.site = desi.site; |
|||
|
|||
var parts = Desirae.splitUrl( |
|||
scope.site.base_url + (scope.site.base_path || "/") |
|||
); |
|||
if (parts) { |
|||
scope.base_url = scope.site.base_url; |
|||
scope.base_path = scope.site.base_path; |
|||
scope.url = scope.base_url + scope.site.base_path; |
|||
} |
|||
|
|||
scope.onChange(); |
|||
}) |
|||
.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." |
|||
); |
|||
console.error(e); |
|||
throw e; |
|||
}); |
|||
} |
|||
|
|||
scope.onChange(); |
|||
}).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."); |
|||
console.error(e); |
|||
throw e; |
|||
}); |
|||
} |
|||
|
|||
scope.onChange = function () { |
|||
console.log('new url [0]', scope.url); |
|||
var parts = Desirae.splitUrl(scope.url) |
|||
, url |
|||
; |
|||
|
|||
if (!parts) { |
|||
scope.base_url = ''; |
|||
scope.base_path = ''; |
|||
return; |
|||
} |
|||
|
|||
scope.base_url = parts.baseUrl; |
|||
scope.base_path = parts.basePath; |
|||
|
|||
scope.dropboxIndex = ''; |
|||
|
|||
url = Desirae.gdrive2host(scope.url) |
|||
; |
|||
|
|||
if (!url && Desirae.dropbox2host(scope.url)) { |
|||
|
|||
url = Desirae.dropbox2host(scope.url); |
|||
scope.dropboxIndex = '/index.html'; |
|||
} |
|||
|
|||
console.log('new url [1]', url); |
|||
|
|||
if (url) { |
|||
parts = Desirae.splitUrl(url); |
|||
scope.base_url = parts.baseUrl; |
|||
scope.base_path = parts.basePath; |
|||
} |
|||
|
|||
//scope.url = scope.base_url + scope.base_path;
|
|||
}; |
|||
|
|||
scope.upsert = function () { |
|||
var files = [] |
|||
; |
|||
|
|||
if (!scope.base_url || !scope.base_path) { |
|||
window.alert("URL: " + (scope.url) + "\nSomething about your URL doesn't look right."); |
|||
return; |
|||
} |
|||
// Just in case of http://blog.com/me/ + /blog vs http://blog.com + /me/blog
|
|||
// don't change it unless it's truly different.
|
|||
if ((scope.base_url + scope.base_path) !== (scope.site.base_url + scope.site.base_path)) { |
|||
scope.site.base_url = scope.base_url; |
|||
scope.site.base_path = scope.base_path; |
|||
} |
|||
files.push({ path: 'site.yml', contents: scope.site }); |
|||
|
|||
console.log(files); |
|||
Desirae.putFiles(files).then(function (results) { |
|||
console.log('TODO check for error'); |
|||
console.log(results); |
|||
$location.path('/post'); |
|||
}).catch(function (e) { |
|||
console.error(scope.site); |
|||
console.error(e); |
|||
window.alert("Error Nation! :/"); |
|||
throw e; |
|||
}); |
|||
}; |
|||
|
|||
init(); |
|||
}]); |
|||
scope.onChange = function () { |
|||
console.log("new url [0]", scope.url); |
|||
var parts = Desirae.splitUrl(scope.url), |
|||
url; |
|||
|
|||
if (!parts) { |
|||
scope.base_url = ""; |
|||
scope.base_path = ""; |
|||
return; |
|||
} |
|||
|
|||
scope.base_url = parts.baseUrl; |
|||
scope.base_path = parts.basePath; |
|||
|
|||
scope.dropboxIndex = ""; |
|||
|
|||
url = Desirae.gdrive2host(scope.url); |
|||
|
|||
if (!url && Desirae.dropbox2host(scope.url)) { |
|||
url = Desirae.dropbox2host(scope.url); |
|||
scope.dropboxIndex = "/index.html"; |
|||
} |
|||
|
|||
console.log("new url [1]", url); |
|||
|
|||
if (url) { |
|||
parts = Desirae.splitUrl(url); |
|||
scope.base_url = parts.baseUrl; |
|||
scope.base_path = parts.basePath; |
|||
} |
|||
|
|||
//scope.url = scope.base_url + scope.base_path;
|
|||
}; |
|||
|
|||
scope.upsert = function () { |
|||
var files = []; |
|||
if (!scope.base_url || !scope.base_path) { |
|||
window.alert( |
|||
"URL: " + |
|||
scope.url + |
|||
"\nSomething about your URL doesn't look right." |
|||
); |
|||
return; |
|||
} |
|||
// Just in case of http://blog.com/me/ + /blog vs http://blog.com + /me/blog
|
|||
// don't change it unless it's truly different.
|
|||
if ( |
|||
scope.base_url + scope.base_path !== |
|||
scope.site.base_url + scope.site.base_path |
|||
) { |
|||
scope.site.base_url = scope.base_url; |
|||
scope.site.base_path = scope.base_path; |
|||
} |
|||
files.push({ path: "site.yml", contents: scope.site }); |
|||
|
|||
console.log(files); |
|||
Desirae.putFiles(files) |
|||
.then(function (results) { |
|||
console.log("TODO check for error"); |
|||
console.log(results); |
|||
$location.path("/post"); |
|||
}) |
|||
.catch(function (e) { |
|||
console.error(scope.site); |
|||
console.error(e); |
|||
window.alert("Error Nation! :/"); |
|||
throw e; |
|||
}); |
|||
}; |
|||
|
|||
init(); |
|||
}, |
|||
]); |
|||
|
@ -1,16 +1,13 @@ |
|||
'use strict'; |
|||
"use strict"; |
|||
|
|||
describe('myApp.view1 module', function() { |
|||
describe("myApp.view1 module", function () { |
|||
beforeEach(module("myApp.view1")); |
|||
|
|||
beforeEach(module('myApp.view1')); |
|||
|
|||
describe('view1 controller', function(){ |
|||
|
|||
it('should ....', inject(function($controller) { |
|||
describe("view1 controller", function () { |
|||
it("should ....", inject(function ($controller) { |
|||
//spec body
|
|||
var view1Ctrl = $controller('View1Ctrl'); |
|||
var view1Ctrl = $controller("View1Ctrl"); |
|||
expect(view1Ctrl).toBeDefined(); |
|||
})); |
|||
|
|||
}); |
|||
}); |
|||
}); |
|||
|
Loading…
Reference in new issue