updated to latest, fixed minor bugs

This commit is contained in:
AJ ONeal 2015-01-15 21:56:14 -07:00
parent f298003bc4
commit 61bd443e12
10 changed files with 85 additions and 30 deletions

1
.gitignore vendored
View File

@ -1,5 +1,4 @@
node_modules node_modules
bower_components
# Logs # Logs
logs logs

View File

@ -5,6 +5,7 @@ var PromiseA = require('bluebird')
, path = require('path') , path = require('path')
, cli = require('cli') , cli = require('cli')
, UUID = require('node-uuid') , UUID = require('node-uuid')
, Desi
; ;
cli.parse({ cli.parse({
@ -12,6 +13,13 @@ cli.parse({
//, output: ['o', 'name of output directory within ~/path/to/blog', 'string', './compiled'] //, output: ['o', 'name of output directory within ~/path/to/blog', 'string', './compiled']
}); });
function init() {
Desi = require('desirae').Desirae;
Desi.registerDataMapper('ruhoh', require('desirae-datamap-ruhoh').DesiraeDatamapRuhoh);
Desi.registerDataMapper('ruhoh@2.6', require('desirae-datamap-ruhoh').DesiraeDatamapRuhoh);
}
function serve(blogdir) { function serve(blogdir) {
var http = require('http') var http = require('http')
//, https = require('https') //, https = require('https')
@ -27,8 +35,7 @@ function serve(blogdir) {
} }
function build(blogdir) { function build(blogdir) {
var Desi = require('desirae').Desirae var desi = {}
, desi = {}
, env = {} , env = {}
; ;
@ -60,9 +67,7 @@ function createPost(originalDir, blogdir, title, extra) {
process.exit(1); process.exit(1);
} }
var Desi = require('desirae').Desirae var env = {}
//, desi = {}
, env = {}
, post = {} , post = {}
, slug , slug
, filepath , filepath
@ -149,7 +154,10 @@ function createPost(originalDir, blogdir, title, extra) {
}); });
} }
cli.main(function (args, options) { cli.main(function (args, options) {
init();
var command = args[0] var command = args[0]
, blogdir = options.blogdir , blogdir = options.blogdir
, originalDir = blogdir , originalDir = blogdir

View File

@ -38,6 +38,7 @@
"html5-boilerplate": "~4.3.0", "html5-boilerplate": "~4.3.0",
"bootstrap": "~3.3.1", "bootstrap": "~3.3.1",
"md5": "~0.1.3", "md5": "~0.1.3",
"desirae": "~0.9.0" "desirae": "~0.9.6",
"desirae-datamap-ruhoh": "~1.0.0"
} }
} }

View File

@ -4,6 +4,10 @@ angular.module('myApp.services', []).
, desi = {/*TODO api_base: '/api'*/} , desi = {/*TODO api_base: '/api'*/}
; ;
// TODO what version of ruhoh are ruhoh-twitter and ruhoh-boostrap-2
Desi.registerDataMapper('ruhoh', window.DesiraeDatamapRuhoh || require('desirae-datamap-ruhoh').DesiraeDatamapRuhoh);
Desi.registerDataMapper('ruhoh@2.6', window.DesiraeDatamapRuhoh || require('desirae-datamap-ruhoh').DesiraeDatamapRuhoh);
function getBlogdir () { function getBlogdir () {
return $http.get('/api/fs/rootdir').then(function (resp) { return $http.get('/api/fs/rootdir').then(function (resp) {
desi.blogdir = resp.data; desi.blogdir = resp.data;

View File

@ -100,6 +100,7 @@
<script src="./bower_components/desirae/lib/frontmatter.js"></script> <script src="./bower_components/desirae/lib/frontmatter.js"></script>
<script src="./bower_components/desirae/lib/browser-adapters.js"></script> <script src="./bower_components/desirae/lib/browser-adapters.js"></script>
<script src="./bower_components/desirae/lib/utils.js"></script> <script src="./bower_components/desirae/lib/utils.js"></script>
<script src="./bower_components/desirae-datamap-ruhoh/datamapper-ruhoh.js"></script>
<!-- UX Using Angular, but not getting fancy --> <!-- UX Using Angular, but not getting fancy -->
<script src="./bower_components/angular/angular.js"></script> <script src="./bower_components/angular/angular.js"></script>

View File

@ -1,6 +1,6 @@
{ {
"name": "desi", "name": "desi",
"version": "0.5.2", "version": "0.5.3",
"description": "A nice, friendly tool to help you get set up and start blogging, built on the Desirae blogging platform", "description": "A nice, friendly tool to help you get set up and start blogging, built on the Desirae blogging platform",
"main": "server.js", "main": "server.js",
"scripts": { "scripts": {
@ -44,7 +44,8 @@
"connect": "^3.3.4", "connect": "^3.3.4",
"connect-query": "^0.2.0", "connect-query": "^0.2.0",
"connect-send-json": "^1.0.0", "connect-send-json": "^1.0.0",
"desirae": "^0.9.3", "desirae": "^0.9.6",
"desirae-datamap-ruhoh": "^1.0.0",
"fs.extra": "^1.3.0", "fs.extra": "^1.3.0",
"node-uuid": "^1.4.2", "node-uuid": "^1.4.2",
"require-yaml": "0.0.1", "require-yaml": "0.0.1",

View File

@ -3,7 +3,7 @@
<div class="col-xs-12"> <div class="col-xs-12">
<div class="page-header"> <div class="page-header">
<h1>Welcome to Dear Desi! <small ng-bind="'(v%VERSION%)' | interpolate"></small></h1> <h1>Welcome to Desi! <small ng-bind="'(v%VERSION%)' | interpolate"></small></h1>
</div> </div>
<div class="jumbotron"> <div class="jumbotron">
@ -18,28 +18,42 @@
<div class="col-lg-7"> <div class="col-lg-7">
<br/> <br/>
<!--iframe width="560" height="315" src="//www.youtube.com/embed/YZzhIIJmlE0" frameborder="0" allowfullscreen></iframe--> <!--iframe width="560" height="315" src="//www.youtube.com/embed/YZzhIIJmlE0" frameborder="0" allowfullscreen></iframe-->
<img src="http://dropsha.re/files/fly6+.8/desi-parker-2.jpg"/> <pre>
<code>
npm install -g desi
git clone https://github.com/DearDesi/desirae-blog-template.git blog
pushd blog
git submodule add https://github.com/DearDesi/ruhoh-twitter.git \
themes/ruhoh-twitter
desi serve
</code>
</pre>
<br/> <br/>
</div> </div>
<div class="col-lg-5"> <div class="col-lg-5">
<h2>Dear Desi is...</h2> <h2>Why Desi?</h2>
<br/> <br/>
<ul> <ul>
<li>Builds in the Browser <li>Built in JavaScript
<ul> <ul>
<li>The in-browser static blog generator</li>
<li>Write content in Markdown, Jade, or HTML</li> <li>Write content in Markdown, Jade, or HTML</li>
<li>Mustache Templates</li> <li>Mustache Templates</li>
<li>Use <a href="http://ruhoh.com">ruhoh</a> themes (or roll your own)</li>
</ul> </ul>
</li> </li>
<li>Git, Dropbox, or regular Folders for management</li> <li>Build your blog right in your browser</li>
<li>Go headless with Node.js support</li> <li>Build headless with io.js (and node.js)</li>
<li>Use Git, Dropbox, or regular Folders for management</li>
<li>Dual Licensed Apache2 and MIT</li> <li>Dual Licensed Apache2 and MIT</li>
<li>No Ruby version Hell - it'll still work in 6 months! :-D</li> <li>No Ruby version Hell - it'll still work in 6 months! :-D</li>
</ul> </ul>
<h3>What are you waiting for?</h3> <h3>What are you waiting for?</h3>
<br/> <br/>
<a class="btn btn-primary btn-lg pull-right" href="/#authors">Get Started</a> <a class="btn btn-primary btn-lg pull-right" href="/#authors">Try it!</a>
</div> </div>
</div> </div>
</div> </div>

View File

@ -21,6 +21,11 @@ angular.module('myApp.build', ['ngRoute'])
scope.blogdir = desi.blogdir.path.replace(/^\/(Users|home)\/[^\/]+\//, '~/'); scope.blogdir = desi.blogdir.path.replace(/^\/(Users|home)\/[^\/]+\//, '~/');
scope.site = desi.site; scope.site = desi.site;
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;
}
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);
// 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)

View File

@ -122,7 +122,23 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="inputPostAbsPath" class="col-lg-2 control-label">Filepath</label> <label for="inputPostAbsPath" class="col-lg-2 control-label">Source Path</label>
<div class="col-lg-10">
<input
required="required"
disabled
ng-model="Post.selected.sourcepath"
ng-change="Post.onChange()"
type="text"
class="form-control"
id="inputPostAbsPath"
placeholder="i.e. ~/blog.me.co/posts/my-first-post.md"
>
</div>
</div>
<div class="form-group">
<label for="inputPostAbsPath" class="col-lg-2 control-label">Output Path</label>
<div class="col-lg-10"> <div class="col-lg-10">
<input <input
required="required" required="required"

View File

@ -9,7 +9,7 @@ angular.module('myApp.post', ['ngRoute'])
}]) }])
.controller('PostCtrl' .controller('PostCtrl'
, ['$scope', '$location', '$timeout', 'DesiraeService' , ['$scope', '$location', '$timeout', 'Desirae'
, function ($scope, $location, $timeout, DesiraeService) { , function ($scope, $location, $timeout, DesiraeService) {
var scope = this var scope = this
; ;
@ -19,6 +19,7 @@ angular.module('myApp.post', ['ngRoute'])
console.warn(desi); console.warn(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;
scope.env = desi.site;
newPost(); newPost();
updateDate(); updateDate();
@ -37,6 +38,7 @@ angular.module('myApp.post', ['ngRoute'])
, permalink: "/article/new.html" , permalink: "/article/new.html"
, uuid: window.uuid.v4() , uuid: window.uuid.v4()
, abspath: scope.blogdir , abspath: scope.blogdir
, sourcepath: ''
, post: { , post: {
yml: { yml: {
title: "" title: ""
@ -64,15 +66,17 @@ angular.module('myApp.post', ['ngRoute'])
post.yml.title = post.yml.title || ''; post.yml.title = post.yml.title || '';
post.yml.description = post.yml.description || ''; 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) { if (selected.permalink === post.yml.permalink) {
selected.permalink = '/articles/' + post.yml.title.toLowerCase() selected.permalink = '/articles/' + scope.slug + '/';
.replace(/["']/g, '') // + '.html' //+ selected.format
.replace(/\W/g, '-')
.replace(/^-+/g, '')
.replace(/-+$/g, '')
.replace(/--/g, '-')
+ '/' // + '.html' //+ selected.format
;
post.yml.permalink = selected.permalink; post.yml.permalink = selected.permalink;
} }
@ -85,13 +89,14 @@ angular.module('myApp.post', ['ngRoute'])
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((scope.env.compiled_path || 'compiled'), post.yml.permalink);
if (!/\.html?$/.test(selected.path)) { if (!/\.html?$/.test(selected.path)) {
selected.path = window.path.join(selected.path, 'index.html'); selected.path = window.path.join(selected.path, 'index.html');
} }
selected.url = window.path.join(scope.site.base_url + window.path.join(scope.site.base_path, post.yml.permalink)); selected.url = window.path.join(scope.site.base_url + window.path.join(scope.site.base_path, post.yml.permalink));
selected.abspath = window.path.join(scope.blogdir, selected.path); selected.abspath = window.path.join(scope.blogdir, selected.path);
selected.sourcepath = window.path.join((selected.collection || 'posts'), scope.slug + '.' + selected.format);
}; };
scope.onFrontmatterChange = function () { scope.onFrontmatterChange = function () {
var data var data
@ -111,12 +116,13 @@ angular.module('myApp.post', ['ngRoute'])
post = scope.selected.post; post = scope.selected.post;
scope.selected.path = window.path.join((scope.selected.collection || 'posts'), window.path.basename(post.yml.permalink)); scope.selected.path = window.path.join((scope.env.compiled_path || 'compiled'), post.yml.permalink);
if (!/\.html?$/.test(window.path.basename(post.yml.permalink))) { if (!/\.html?$/.test(window.path.basename(post.yml.permalink))) {
scope.selected.path = window.path.join(scope.selected.path.replace(/\.w+$/, ''), 'index.html'); scope.selected.path = window.path.join(scope.selected.path.replace(/\.w+$/, ''), 'index.html');
} }
scope.selected.url = window.path.join(scope.site.base_url + window.path.join(scope.site.base_path, post.yml.permalink)); scope.selected.url = window.path.join(scope.site.base_url + window.path.join(scope.site.base_path, post.yml.permalink));
scope.selected.abspath = window.path.join(scope.blogdir, scope.selected.path); scope.selected.abspath = window.path.join(scope.blogdir, scope.selected.path);
scope.selected.sourcepath = window.path.join((scope.selected.collection || 'posts'), scope.slug + '.' + scope.selected.format);
} 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');
@ -153,7 +159,7 @@ angular.module('myApp.post', ['ngRoute'])
; ;
files.push({ files.push({
path: scope.selected.path path: scope.selected.sourcepath
, contents: , contents:
'---\n' '---\n'
+ scope.selected.post.frontmatter.trim() + scope.selected.post.frontmatter.trim()