From ef8d7b57965cbc8ddcc004b914c9eae834d6d78d Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Tue, 13 Jan 2015 03:18:13 -0700 Subject: [PATCH] separating deardesi/desirae --- app.js | 17 ++ bower.json | 50 ++++ components/desirae/desirae.js | 63 +++++ components/version/interpolate-filter.js | 9 + components/version/interpolate-filter_test.js | 15 ++ components/version/version-directive.js | 9 + components/version/version-directive_test.js | 17 ++ components/version/version.js | 8 + components/version/version_test.js | 11 + views/about/about.html | 47 ++++ views/about/about.js | 14 ++ views/about/view2_test.js | 16 ++ views/authors/authors.html | 233 ++++++++++++++++++ views/authors/authors.js | 119 +++++++++ views/build/build.html | 119 +++++++++ views/build/build.js | 91 +++++++ views/configure/configure.html | 72 ++++++ views/configure/configure.js | 13 + views/create/create.html | 83 +++++++ views/post/post.html | 186 ++++++++++++++ views/post/post.js | 165 +++++++++++++ views/site/site.html | 200 +++++++++++++++ views/site/site.js | 49 ++++ views/site/view1_test.js | 16 ++ 24 files changed, 1622 insertions(+) create mode 100644 app.js create mode 100644 bower.json create mode 100644 components/desirae/desirae.js create mode 100644 components/version/interpolate-filter.js create mode 100644 components/version/interpolate-filter_test.js create mode 100644 components/version/version-directive.js create mode 100644 components/version/version-directive_test.js create mode 100644 components/version/version.js create mode 100644 components/version/version_test.js create mode 100644 views/about/about.html create mode 100644 views/about/about.js create mode 100644 views/about/view2_test.js create mode 100644 views/authors/authors.html create mode 100644 views/authors/authors.js create mode 100644 views/build/build.html create mode 100644 views/build/build.js create mode 100644 views/configure/configure.html create mode 100644 views/configure/configure.js create mode 100644 views/create/create.html create mode 100644 views/post/post.html create mode 100644 views/post/post.js create mode 100644 views/site/site.html create mode 100644 views/site/site.js create mode 100644 views/site/view1_test.js diff --git a/app.js b/app.js new file mode 100644 index 0000000..45969d8 --- /dev/null +++ b/app.js @@ -0,0 +1,17 @@ +'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'}); +}]); diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..d17de8f --- /dev/null +++ b/bower.json @@ -0,0 +1,50 @@ +{ + "name": "deardesi", + "version": "1.0.0", + "authors": [ + "AJ ONeal " + ], + "description": "A blogging platform in the browser. Wow!", + "main": "deardesi.js", + "moduleType": [ + "globals", + "node" + ], + "keywords": [ + "dear", + "desi", + "deardesi", + "blog", + "blogging", + "platform", + "browser" + ], + "license": "Apache2", + "homepage": "http://github.com/coolaj86/deardesi", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ], + "dependencies": { + "mustache": "~0.8.2", + "bluebird": "~2.6.2", + "rsvp": "~3.0.16", + "escape-string-regexp": "~1.0.2", + "js-yaml": "~3.2.5", + "path": "~3.46.1", + "forEachAsync": "~5.0.5", + "node-uuid": "~1.4.2", + "markdown-it": "~3.0.2", + "angular": "~1.3.8", + "angular-route": "~1.3.8", + "html5-boilerplate": "~4.3.0", + "bootstrap": "~3.3.1", + "md5": "~0.1.3" + }, + "resolutions": { + "bluebird": "~2.6.2" + } +} diff --git a/components/desirae/desirae.js b/components/desirae/desirae.js new file mode 100644 index 0000000..a71b9cc --- /dev/null +++ b/components/desirae/desirae.js @@ -0,0 +1,63 @@ +angular.module('myApp.services', []). + factory('Desirae', ['$q', function($q) { + var Desi = window.Desi || require('./deardesi').Desi + , desi = {} + , fsapi = window.fsapi + ; + + return { + reset: function () { + desi = {}; + } + , toDesiDate: Desi.toLocaleDate + , meta: function () { + var d = $q.defer() + ; + + if (desi.meta) { + d.resolve(desi); + return d.promise; + } + + Desi.init(desi).then(function () { + d.resolve(desi); + }); + + return d.promise; + } + , build: function (env) { + var d = $q.defer() + ; + + if (desi.built) { + d.resolve(desi); + return d.promise; + } + + Desi.buildAll(desi, env).then(function () { + d.resolve(desi); + }); + + return d.promise; + } + , write: function (env) { + var d = $q.defer() + ; + + if (desi.written) { + d.resolve(desi); + return d.promise; + } + + Desi.write(desi, env).then(function () { + d.resolve(desi); + }); + + return d.promise; + } + , putFiles: function (files) { + return $q.when(fsapi.putFiles(files)); + } + }; + }] +); diff --git a/components/version/interpolate-filter.js b/components/version/interpolate-filter.js new file mode 100644 index 0000000..03bb198 --- /dev/null +++ b/components/version/interpolate-filter.js @@ -0,0 +1,9 @@ +'use strict'; + +angular.module('myApp.version.interpolate-filter', []) + +.filter('interpolate', ['version', function(version) { + return function(text) { + return String(text).replace(/\%VERSION\%/mg, version); + }; +}]); diff --git a/components/version/interpolate-filter_test.js b/components/version/interpolate-filter_test.js new file mode 100644 index 0000000..ff56c52 --- /dev/null +++ b/components/version/interpolate-filter_test.js @@ -0,0 +1,15 @@ +'use strict'; + +describe('myApp.version module', function() { + beforeEach(module('myApp.version')); + + 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'); + })); + }); +}); diff --git a/components/version/version-directive.js b/components/version/version-directive.js new file mode 100644 index 0000000..74088f8 --- /dev/null +++ b/components/version/version-directive.js @@ -0,0 +1,9 @@ +'use strict'; + +angular.module('myApp.version.version-directive', []) + +.directive('appVersion', ['version', function(version) { + return function(scope, elm, attrs) { + elm.text(version); + }; +}]); diff --git a/components/version/version-directive_test.js b/components/version/version-directive_test.js new file mode 100644 index 0000000..4a59e11 --- /dev/null +++ b/components/version/version-directive_test.js @@ -0,0 +1,17 @@ +'use strict'; + +describe('myApp.version module', function() { + beforeEach(module('myApp.version')); + + describe('app-version directive', function() { + it('should print current version', function() { + module(function($provide) { + $provide.value('version', 'TEST_VER'); + }); + inject(function($compile, $rootScope) { + var element = $compile('')($rootScope); + expect(element.text()).toEqual('TEST_VER'); + }); + }); + }); +}); diff --git a/components/version/version.js b/components/version/version.js new file mode 100644 index 0000000..227b913 --- /dev/null +++ b/components/version/version.js @@ -0,0 +1,8 @@ +'use strict'; + +angular.module('myApp.version', [ + 'myApp.version.interpolate-filter', + 'myApp.version.version-directive' +]) + +.value('version', '0.8.0'); diff --git a/components/version/version_test.js b/components/version/version_test.js new file mode 100644 index 0000000..4ca6880 --- /dev/null +++ b/components/version/version_test.js @@ -0,0 +1,11 @@ +'use strict'; + +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'); + })); + }); +}); diff --git a/views/about/about.html b/views/about/about.html new file mode 100644 index 0000000..caf5ac4 --- /dev/null +++ b/views/about/about.html @@ -0,0 +1,47 @@ +
+
+
+ + + +
+
+
+

Setup your new blog in just 5 minutes.

+
+
+
+
+
+
+
+ +
+
+
+

Dear Desi is...

+
+
    +
  • Builds in the Browser +
      +
    • The in-browser static blog generator
    • +
    • Write content in Markdown, Jade, or HTML
    • +
    • Mustache Templates
    • +
    +
  • +
  • Git, Dropbox, or regular Folders for management
  • +
  • Go headless with Node.js support
  • +
  • Dual Licensed Apache2 and MIT
  • +
  • No Ruby version Hell - it'll still work in 6 months! :-D
  • +
+

What are you waiting for?

+
+ Get Started +
+
+
+
+
+
diff --git a/views/about/about.js b/views/about/about.js new file mode 100644 index 0000000..ad83f44 --- /dev/null +++ b/views/about/about.js @@ -0,0 +1,14 @@ +'use strict'; + +angular.module('myApp.about', ['ngRoute']) + +.config(['$routeProvider', function($routeProvider) { + $routeProvider.when('/about', { + templateUrl: 'views/about/about.html', + controller: 'AboutCtrl' + }); +}]) + +.controller('AboutCtrl', [function() { + +}]); diff --git a/views/about/view2_test.js b/views/about/view2_test.js new file mode 100644 index 0000000..07b34d6 --- /dev/null +++ b/views/about/view2_test.js @@ -0,0 +1,16 @@ +'use strict'; + +describe('myApp.view2 module', function() { + + beforeEach(module('myApp.view2')); + + describe('view2 controller', function(){ + + it('should ....', inject(function($controller) { + //spec body + var view2Ctrl = $controller('View2Ctrl'); + expect(view2Ctrl).toBeDefined(); + })); + + }); +}); \ No newline at end of file diff --git a/views/authors/authors.html b/views/authors/authors.html new file mode 100644 index 0000000..99ea45d --- /dev/null +++ b/views/authors/authors.html @@ -0,0 +1,233 @@ +
+
+ +
+ +
+
+
+ /authors/.yml +
+
+ +
+
+
+
+
+
+
+
+
+ Profile Basics + +
+
+
+ +
+ +
+
+
+ +
+
+ +
+ +
+
+
+
+ +
+
+
+ +
+ +
+
+
+ +
+
+ +
+ +
+
+
+
+ +
+
+
+ +
+ +
+
+
+
+ +
+
+
+ +
+ +
+
+
+
+ + +
+
+
+ +
+
+
+ Social + +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+
+
+
+ +
+
+
+ Developers +
+ +
+ +
+
+
+ +
+ +
+
+ +
+
+
+ +
+
+
+ Feeds + +
+ +
+ +
+
+ +
+
+
+ + + +
+
+
+ + diff --git a/views/authors/authors.js b/views/authors/authors.js new file mode 100644 index 0000000..1390a38 --- /dev/null +++ b/views/authors/authors.js @@ -0,0 +1,119 @@ +'use strict'; + +angular.module('myApp.authors', ['ngRoute']) + +.config(['$routeProvider', function($routeProvider) { + $routeProvider.when('/authors', { + templateUrl: 'views/authors/authors.html', + controller: 'AuthorsCtrl as Authors' + }); +}]) + +.controller('AuthorsCtrl' + , ['$scope', '$timeout', '$location', 'Desirae' + , function($scope, $timeout, $location, Desirae) { + var scope = this + ; + + scope.newAuthor = function () { + console.log('new author'); + scope.new = { filename: 'new' }; + scope.selectAuthor(scope.new); + }; + + scope.selectAuthor = function (author) { + // TODO watch any change + scope.selectedAuthor = author || scope.selectedAuthor; + scope.updateHeadshotUrlNow(); + }; + + scope.upsert = function () { + var author = scope.selectedAuthor + , files = [] + , filename = author.filename + ; + + delete author.filename; + if ('new' !== filename && filename !== author.handle) { + files.push({ path: 'authors/' + filename + '.yml', contents: '', delete: true }); + } + files.push({ path: 'authors/' + author.handle + '.yml', contents: window.jsyaml.dump(author) }); + + console.log(files); + + Desirae.putFiles(files).then(function (results) { + console.log('updated author', results); + $location.path('/site'); + }).catch(function (e) { + author.filename = filename; + console.error(e); + window.alert("Error Nation! :/"); + throw e; + }); + }; + + scope.updateHeadshotUrlNow = function () { + var gravatar = 'http://www.gravatar.com/avatar/' + window.md5((scope.selectedAuthor.email||'foo').toLowerCase()) + '?d=identicon' + ; + + if (scope.selectedAuthor.headshot) { + scope.headshot = scope.selectedAuthor.headshot; + } + else if (scope.selectedAuthor.email) { + scope.headshot = gravatar; + } + else { + scope.headshot = 'http://www.gravatar.com/avatar/' + window.md5((scope.selectedAuthor.email||'foo').toLowerCase()) + '?d=mm'; + } + }; + + scope.updateHeadshotUrl = function () { + $timeout.cancel(scope.hslock); + scope.hslock = $timeout(function () { + scope.updateHeadshotUrlNow(); + }, 300); + }; + + function init() { + scope.newAuthor(); + + console.log('desi loading'); + Desirae.meta().then(function (desi) { + var filename + ; + + scope.blogdir = desi.blogdir.path.replace(/^\/(Users|home)\/[^\/]+\//, '~/'); + desi.authors = desi.authors || {}; + desi.authors.new = scope.new; + scope.authors = desi.authors; + + Object.keys(desi.authors).forEach(function (filename) { + if ('new' === filename) { + return; + } + desi.authors[filename].filename = filename; + desi.authors[filename].handle = desi.authors[filename].handle || filename; + }); + + filename = Object.keys(desi.authors)[0]; + scope.selectedAuthor = desi.authors[filename]; + + scope.updateHeadshotUrlNow(); + }).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; + }); + } + + init(); + /* + $scope.$watch(angular.bind(this, function () { return this.selectedAuthor; }), function (newValue, oldValue) { + //$scope.$watch('Authors.selecteAuthor', function (newValue, oldValue) + console.log(newValue, oldValue); + if(newValue !== oldValue) { + scope.dirty = true; + } + }, true); + */ +}]); diff --git a/views/build/build.html b/views/build/build.html new file mode 100644 index 0000000..ff53f6f --- /dev/null +++ b/views/build/build.html @@ -0,0 +1,119 @@ +
+
+
+ +
+ +
+
+

Are you ready?

+

+ Bonesaw is READY! +

+

+ +

+ Push the RED button... you know you want to! +
+
+ +
+
+
+
+ Production +

+ +
+ +
+ +
+
+
+ +
+ +
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+ Development +

+ +
+ +
+ +
+
+
+ +
+ +
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+ +
+
diff --git a/views/build/build.js b/views/build/build.js new file mode 100644 index 0000000..9533557 --- /dev/null +++ b/views/build/build.js @@ -0,0 +1,91 @@ +'use strict'; + +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() { + console.log('desi loading'); + DesiraeService.meta().then(function (desi) { + scope.blogdir = desi.blogdir.path.replace(/^\/(Users|home)\/[^\/]+\//, '~/'); + 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); + console.log(scope.production_url); + + // this is the responsibility of the build system (Dear Desi), not the library (Desirae) + scope.development_url = location.href.replace(/\/(#.*)?$/, '') + path.join('/', 'compiled_dev'); + console.log(scope.development_url); + + }).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']; + } + + 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(); + } + }; + + scope.buildOne = function (envstr) { + var 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.development_url.replace(/(https?:\/\/[^\/#?]+)/, '$1') + , 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'); + }); + }; + + init(); +}]); diff --git a/views/configure/configure.html b/views/configure/configure.html new file mode 100644 index 0000000..b950a9a --- /dev/null +++ b/views/configure/configure.html @@ -0,0 +1,72 @@ +
+
+ +
+ +
+
+
+
+
+ Advanced + +
+ +
+ +
+
+ +
+
+ +
+ +
+ +
+
+ +
+
+ +
+ +
+ +
+
+ +
+
+ +
+ +
+ +
+
+ +
+
+ +
+ +
+ +
+
+ +
+
+ +
+
+
+
+ +
+
diff --git a/views/configure/configure.js b/views/configure/configure.js new file mode 100644 index 0000000..d931c92 --- /dev/null +++ b/views/configure/configure.js @@ -0,0 +1,13 @@ +'use strict'; + +angular.module('myApp.configure', ['ngRoute']) + +.config(['$routeProvider', function($routeProvider) { + $routeProvider.when('/configure', { + templateUrl: 'views/configure/configure.html', + controller: 'ConfigureCtrl as Configure' + }); +}]) + +.controller('ConfigureCtrl', [function() { +}]); diff --git a/views/create/create.html b/views/create/create.html new file mode 100644 index 0000000..2b4a555 --- /dev/null +++ b/views/create/create.html @@ -0,0 +1,83 @@ +
+
+ +
+ +
+
+
+
+
+
+ +
+ +
+
+
+ +
+ +
+ +
+
+
+
+ +
+ + A longer block of help text that breaks onto a new line and may extend beyond one line. +
+
+
+ +
+
+ +
+
+ +
+
+
+
+ +
+ +
+ +
+
+
+
+ + +
+
+
+
+
+ diff --git a/views/post/post.html b/views/post/post.html new file mode 100644 index 0000000..cb11ccc --- /dev/null +++ b/views/post/post.html @@ -0,0 +1,186 @@ +
+ +
+ +
+ +
+
+
+
+
+ +
+ +
+
+ +
+ +
+ + Put your lovely post here, in github-flavored markdown! +
+
+ +
+ +
+ + +
+
+ +
+ +
+ + The description is often used by search engines as the snippit shown in search results. +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ + + + + + + + + +
+
+ + +
+
+
+ +
+
+ +
+ +
diff --git a/views/post/post.js b/views/post/post.js new file mode 100644 index 0000000..e3f40fe --- /dev/null +++ b/views/post/post.js @@ -0,0 +1,165 @@ +'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, 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; + newPost(); + + 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.md" + , uuid: window.uuid.v4() + , abspath: scope.blogdir + , post: { + yml: { + title: "" + , permalink: "/article/new.md" + , date: Desirae.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.onChange = function () { + var post = scope.selected.post + , selected = scope.selected + ; + + post.yml.title = post.yml.title || ''; + post.yml.description = post.yml.description || ''; + + if (selected.permalink === post.yml.permalink) { + selected.permalink = '/articles/' + post.yml.title.toLowerCase() + .replace(/["']/g, '') + .replace(/\W/g, '-') + .replace(/^-+/g, '') + .replace(/-+$/g, '') + .replace(/--/g, '-') + + '.' + selected.format + ; + + post.yml.permalink = selected.permalink; + } + if (window.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(); + + // 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.abspath = window.path.join(scope.blogdir, selected.path); + }; + scope.onFrontmatterChange = function () { + var data + ; + + 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; + } 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(); + } + }; + + 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 = Desirae.toDesiDate(new Date()); + } + scope.onChange(); + updateDate(); + }, 60 * 1000); + } + + scope.upsert = function () { + console.log('upserted'); + 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.path + , contents: + '---\n' + + scope.selected.post.frontmatter.trim() + + '\n' + + '---\n' + + '\n' + + scope.selected.post.body.trim() + }); + + console.log(files); + Desirae.putFiles(files).then(function (results) { + console.log('TODO check for error'); + 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(); +}]); diff --git a/views/site/site.html b/views/site/site.html new file mode 100644 index 0000000..10ee7ef --- /dev/null +++ b/views/site/site.html @@ -0,0 +1,200 @@ +
+
+ +
+ + +
+
+
+
+
+ General + +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+
+ +
+ +
+
+
+
+ + + + + + +
+ +
+ +
+
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+
+
+ + +
+
+
+
+ Development + +
+ +
+ +
+
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+
+
+ + +
+
+
+
+ Plugins + +
+ +
+ +
+ Found in the Admin section of Google Analytics +
+
+ +
+ +
+ +
+ Found under Admin > Settings in Disqus +
+
+ +
+
+
+
+ + +
+
diff --git a/views/site/site.js b/views/site/site.js new file mode 100644 index 0000000..e11e6a7 --- /dev/null +++ b/views/site/site.js @@ -0,0 +1,49 @@ +'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; + }).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.upsert = function () { + var files = [] + ; + + 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(); +}]); diff --git a/views/site/view1_test.js b/views/site/view1_test.js new file mode 100644 index 0000000..14ba79b --- /dev/null +++ b/views/site/view1_test.js @@ -0,0 +1,16 @@ +'use strict'; + +describe('myApp.view1 module', function() { + + beforeEach(module('myApp.view1')); + + describe('view1 controller', function(){ + + it('should ....', inject(function($controller) { + //spec body + var view1Ctrl = $controller('View1Ctrl'); + expect(view1Ctrl).toBeDefined(); + })); + + }); +}); \ No newline at end of file