Compare commits

..

No commits in common. "b1bb785739b20ce46f92c707de68921d59e81d98" and "416484db429b9984720ffc2e4dd28af129b7f1d8" have entirely different histories.

32 changed files with 1594 additions and 1958 deletions

View File

@ -1 +0,0 @@
{}

206
LICENSE
View File

@ -1,4 +1,202 @@
This Source Code Form is subject to the terms of the Mozilla
Public License, v. 2.0. If a copy of the MPL was not distributed
with this file, You can obtain one at
https://mozilla.org/MPL/2.0/.
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -5,20 +5,23 @@ Not a Web Developer?
You're in the wrong place. **Go to <http://dear.desi>** and follow the instructions there.
-->
# Did you mean to come here?
Did you mean to come here?
==========================
If you're a normal person interested in _Desi, the DIY blog platform for normal people_,
If you're a normal person interested in *Desi, the DIY blog platform for normal people*,
you might have meant to go to [DearDesi](http://dear.desi) instead.
Otherwise, if you're a cyborg, wizzard, or web developer: carry on.
# Dear Desi
Dear Desi
=========
These instructions cover the command line only.
If you want instructions for the web interface, head over to [DearDesi](http://dear.desi).
## Command Line Install (for developers)
Command Line Install (for developers)
--------------------
This assumes that you already have `git` and `node` installed,
otherwise see [node-installer.sh](https://git.coolaj86.com/coolaj86/node-installer.sh)
@ -33,20 +36,22 @@ npm install -g desi
That was easy
## Quick Usage
Quick Usage
-------
- desi init -d ~/Desktop/new-blog
- pushd ~/Desktop/new-blog
- desi post "my first post"
- desi build
- desi serve
* desi init -d ~/Desktop/new-blog
* pushd ~/Desktop/new-blog
* desi post "my first post"
* desi build
* desi serve
<http://local.dear.desi:65080>
**Note**: both through command line and web you need `site.yml` and `authors/xyz.yml` configured in order to create a post (as well as build).
The post commands output the location of post in various formats.
## Initialize your blog (step 1)
Initialize your blog (step 1)
--------
You can do this 3 ways:
@ -93,37 +98,34 @@ Obviously this is a little different for everyone, so here's what I'd recommend:
1. start by following the Automated procedure above
2. copy over your posts/articles folder(s)
3. edit `config.yml` to add a config with a permalink with your collections (posts, articles, essays, whatever you call them)
4. skip ahead to the _Setup your blog_ section and make sure your `site.yml` and `authors/xxx.yml` are correct.
4. skip ahead to the *Setup your blog* section and make sure your `site.yml` and `authors/xxx.yml` are correct.
5. run `desi build -d /path/to/blog` to test if there are any issues with your existing yaml
- if there are, you can take a look at the [normalize](https://github.com/DearDesi/desirae/blob/master/lib/transform-core.js#L72) function and perhaps hand-edit a few things (and when you're ready, you can [register your transform](https://github.com/DearDesi/deardesi/blob/master/bin/deardesi.js#L28) for collections.
* if there are, you can take a look at the [normalize](https://github.com/DearDesi/desirae/blob/master/lib/transform-core.js#L72) function and perhaps hand-edit a few things (and when you're ready, you can [register your transform](https://github.com/DearDesi/deardesi/blob/master/bin/deardesi.js#L28) for collections.
6. Now copy over your theme and set it to be the default in `site.yml`
7. build again. Your site probably won't look right:
- look for stuff like `urls.base_url`, `host`, `page.url` that might have an extra `/` at the beginning or end or be named slightly differently.
* look for stuff like `urls.base_url`, `host`, `page.url` that might have an extra `/` at the beginning or end or be named slightly differently.
See <https://github.com/DearDesi/desirae/blob/master/GLOSSARY.md> for disambiguation about the meaning of terms in Desi.
## Setup your blog (step 2)
Setup your blog (step 2)
------------
1. Create an authors file in `authors/YOUR_NAME.yml` and model it after [this example](https://github.com/DearDesi/deardesi/blob/master/example/authors/johndoe.yml)
- You don't need to use all of the fields (your template might not even support them all)
* You don't need to use all of the fields (your template might not even support them all)
2. Create a site file as `site.yml`, similar to [this example](https://github.com/DearDesi/deardesi/blob/master/example/site.yml)
**Important Things**
- `site.yml.base_url` - the point of ownership (usually blog.example.com or example.com)
- `site.yml.base_path` - where the blog is "mounted", relative to the `base_url` (usually `/` or `/blog`)
- `authors/me.yml.name` - most templates use this
- `authors/me.yml.email` - and this
- `authors/me.yml.twitter` - and this
* `site.yml.base_url` - the point of ownership (usually blog.example.com or example.com)
* `site.yml.base_path` - where the blog is "mounted", relative to the `base_url` (usually `/` or `/blog`)
* `authors/me.yml.name` - most templates use this
* `authors/me.yml.email` - and this
* `authors/me.yml.twitter` - and this
## Build your blog (step 2)
Build your blog (step 2)
------------
The build _will_ fail if you don't have `site.yml` and `authors/johndoe.yml` configured.
The build *will* fail if you don't have `site.yml` and `authors/johndoe.yml` configured.
```bash
desi build -d /path/to/blog
@ -132,10 +134,3 @@ desi serve -d /path/to/blog
```
Now open up your evergreen browser to <http://local.dear.desi:65080>
# License
This Source Code Form is subject to the terms of the Mozilla \
Public License, v. 2.0. If a copy of the MPL was not distributed \
with this file, You can obtain one at \
https://mozilla.org/MPL/2.0/.

34
app.js
View File

@ -1,21 +1,17 @@
"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'});
}]);

View File

@ -1,183 +1,157 @@
#!/usr/bin/env node
"use strict";
'use strict';
var PromiseA = require("bluebird"),
fs = PromiseA.promisifyAll(require("fs")),
fsx = PromiseA.promisifyAll(require("fs.extra")),
tar = require("tar"),
var PromiseA = require('bluebird')
, fs = PromiseA.promisifyAll(require('fs'))
, fsx = PromiseA.promisifyAll(require('fs.extra'))
, tar = require('tar')
//, requestAsync = PromiseA.promisify(require('request'))
request = PromiseA.promisifyAll(require("request")),
forEachAsync = require("foreachasync").forEachAsync,
, request = PromiseA.promisifyAll(require('request'))
, forEachAsync = require('foreachasync').forEachAsync
//, spawn = require('child_process').spawn
path = require("path"),
cli = require("cli"),
UUID = require("node-uuid"),
Desi,
zlib = require("zlib");
, path = require('path')
, cli = require('cli')
, UUID = require('node-uuid')
, Desi
, zlib = require('zlib')
;
cli.parse({
blogdir: ["d", "Where your blog is, i.e. ~/path/to/blog", "string", "./"],
//, output: ['o', 'name of output directory within ~/path/to/blog', 'string', './compiled']
blogdir: ['d', 'Where your blog is, i.e. ~/path/to/blog', 'string', './']
//, output: ['o', 'name of output directory within ~/path/to/blog', 'string', './compiled']
});
function init() {
Desi = require("desirae").Desirae;
Desi = require('desirae').Desirae;
//
// 1. Transform (yml, slug, etc)
//
Desi.registerTransform(
"lint",
require("desirae/lib/transform-core").DesiraeTransformCore.lint,
{ collections: true }
'lint'
, require('desirae/lib/transform-core').DesiraeTransformCore.lint
, { collections: true }
);
Desi.registerTransform(
"root",
require("desirae/lib/transform-core").DesiraeTransformCore.root,
{ root: true }
'root'
, require('desirae/lib/transform-core').DesiraeTransformCore.root
, { root: true }
);
Desi.registerTransform(
"normalize",
require("desirae/lib/transform-core").DesiraeTransformCore.normalize,
{ root: true, collections: true }
'normalize'
, require('desirae/lib/transform-core').DesiraeTransformCore.normalize
, { root: true, collections: true }
);
Desi.registerTransform(
"disqus",
require("desirae/lib/transform-core").DesiraeTransformCore.disqus,
{ collections: true }
'disqus'
, require('desirae/lib/transform-core').DesiraeTransformCore.disqus
, { collections: true }
);
//
// 2. Aggregate (rss, categories, tags, etc)
//
Desi.registerAggregator(
require("desirae/lib/aggregate-core").DesiraeAggregateCore.collate
);
Desi.registerAggregator(require('desirae/lib/aggregate-core').DesiraeAggregateCore.collate);
//
// 3. Datamap (ruhoh, desirae, jade, mustache, liquid)
//
Desi.registerDataMapper(
"desirae",
require("desirae/lib/datamap-core").DesiraeDatamapCore
);
Desi.registerDataMapper(
"desirae@1.0",
require("desirae/lib/datamap-core").DesiraeDatamapCore
);
Desi.registerDataMapper('desirae', require('desirae/lib/datamap-core').DesiraeDatamapCore);
Desi.registerDataMapper('desirae@1.0', require('desirae/lib/datamap-core').DesiraeDatamapCore);
// TODO ruhoh versions are ruhoh-twitter (1.0) and ruhoh-boostrap-2 (2.6)
Desi.registerDataMapper(
"ruhoh",
require("desirae-datamap-ruhoh").DesiraeDatamapRuhoh
);
Desi.registerDataMapper(
"ruhoh@1.0",
require("desirae-datamap-ruhoh").DesiraeDatamapRuhoh
);
Desi.registerDataMapper(
"ruhoh@2.6",
require("desirae-datamap-ruhoh").DesiraeDatamapRuhoh
);
Desi.registerDataMapper('ruhoh', require('desirae-datamap-ruhoh').DesiraeDatamapRuhoh);
Desi.registerDataMapper('ruhoh@1.0', require('desirae-datamap-ruhoh').DesiraeDatamapRuhoh);
Desi.registerDataMapper('ruhoh@2.6', require('desirae-datamap-ruhoh').DesiraeDatamapRuhoh);
//
// 4. Render (md -> html, less -> css, etc)
//
Desi.registerRenderer(
"js",
require("desirae/lib/render-core").DesiraeRenderJs,
{ themes: true, assets: true }
'js'
, require('desirae/lib/render-core').DesiraeRenderJs
, { themes: true, assets: true }
);
Desi.registerRenderer(
"css",
require("desirae/lib/render-core").DesiraeRenderCss,
{ themes: true, assets: true }
'css'
, require('desirae/lib/render-core').DesiraeRenderCss
, { themes: true, assets: true }
);
["html", "htm", "xhtm", "xhtml"].forEach(function (ext) {
['html', 'htm', 'xhtm', 'xhtml'].forEach(function (ext) {
Desi.registerRenderer(
ext,
require("desirae/lib/render-core").DesiraeRenderHtml,
{ root: true, collections: true, themes: true, assets: true }
ext
, require('desirae/lib/render-core').DesiraeRenderHtml
, { root: true, collections: true, themes: true, assets: true }
);
});
["md", "markdown", "mdown", "mkdn", "mkd", "mdwn", "mdtxt", "mdtext"].forEach(
function (ext) {
Desi.registerRenderer(
ext,
require("desirae/lib/render-core").DesiraeRenderMarkdown,
{ root: true, collections: true }
);
}
);
['md', 'markdown', 'mdown', 'mkdn', 'mkd', 'mdwn', 'mdtxt', 'mdtext'].forEach(function (ext) {
Desi.registerRenderer(
ext
, require('desirae/lib/render-core').DesiraeRenderMarkdown
, { root: true, collections: true }
);
});
Desi.registerRenderer(
"jade",
require("desirae/lib/render-core").DesiraeRenderJade,
// TODO how to support jade in place of Mustache for layouts?
{ root: true, collections: true, themes: true }
'jade'
, require('desirae/lib/render-core').DesiraeRenderJade
// TODO how to support jade in place of Mustache for layouts?
, { root: true, collections: true, themes: true }
);
}
function serve(displayDir, blogdir) {
var http = require("http"),
var http = require('http')
//, https = require('https')
app = require("../server").create({ blogdir: blogdir }),
server;
, app = require('../server').create({ blogdir: blogdir })
, server
;
server = http
.createServer(app)
.listen(65080, function () {
console.info("Listening from " + displayDir);
console.info(
"Listening on http://local.dear.desi:" + server.address().port
);
})
.on("error", function (err) {
if (/EADDRINUSE/.test(err.message)) {
console.error("");
console.error("You're already running desi in another tab.");
console.error("");
console.error(
"Go to the other tab and press <control> + c to stop her. Then you can come back here to try again."
);
console.error("");
console.error("");
return;
}
server = http.createServer(app).listen(65080, function () {
console.info("Listening from " + displayDir);
console.info("Listening on http://local.dear.desi:" + server.address().port);
}).on('error', function (err) {
if (/EADDRINUSE/.test(err.message)) {
console.error("");
console.error("You're already running desi in another tab.");
console.error("");
console.error("Go to the other tab and press <control> + c to stop her. Then you can come back here to try again.");
console.error("");
console.error("");
return;
}
throw err;
});
throw err;
});
//secureServer = https.createServer(app).listen(65043);
}
function build(blogdir) {
var desi = {},
env = {};
var desi = {}
, env = {}
;
env.working_path = env.blogdir = blogdir;
Desi.init(desi, env).then(function () {
env.url = desi.site.base_url + desi.site.base_path.replace(/^\/$/, "");
env.url = desi.site.base_url + desi.site.base_path.replace(/^\/$/, '');
env.base_url = desi.site.base_url;
env.base_path = desi.site.base_path;
env.compiled_path = "compiled";
env.compiled_path = 'compiled';
//env.since = 0;
Desi.buildAll(desi, env).then(function () {
Desi.write(desi, env).then(function (info) {
console.info(
"wrote",
info.numFiles,
"files",
"(" +
((info.size && (info.size / (1024 * 1024)).toFixed(2)) || "unkown"),
"MiB)",
"in",
((info.end - info.start) / 1000).toFixed(3) + "s"
'wrote', info.numFiles
, 'files'
, '(' + (info.size && (info.size / (1024 * 1024)).toFixed(2) || 'unkown'), 'MiB)'
, 'in'
, ((info.end - info.start) / 1000).toFixed(3) + 's'
);
console.info(
"Built and saved to " + path.join(env.working_path, env.compiled_path)
);
console.info('Built and saved to ' + path.join(env.working_path, env.compiled_path));
});
});
});
@ -185,33 +159,34 @@ function build(blogdir) {
function createPost(originalDir, blogdir, title, extra) {
if (!title) {
console.error('Usage desi post "My First Post"');
console.error("Usage desi post \"My First Post\"");
console.error("(you didn't specify a title)");
process.exit(1);
}
if (extra) {
console.error('Usage desi post "My First Post"');
console.error(
"(too many arguments - maybe you didn't put your title in quotes?)"
);
console.error("Usage desi post \"My First Post\"");
console.error("(too many arguments - maybe you didn't put your title in quotes?)");
process.exit(1);
}
var desi = {},
env = {},
post = {},
slug,
filepath,
displaypath;
var desi = {}
, env = {}
, post = {}
, slug
, filepath
, displaypath
;
env.working_path = env.blogdir = blogdir;
Desi.init(desi, env).then(function () {
// TODO move this 'create new post' logic to desirae proper
var collectionname = Object.keys(desi.config.collections)[0],
collection = desi.config.collections[collectionname],
entity = {};
/*
var collectionname = Object.keys(desi.config.collections)[0]
, collection = desi.config.collections[collectionname]
, entity = {}
;
/*
Desi.init(desi, env).then(function () {
env.url = desi.site.base_url + desi.site.base_path.replace(/^\/$/, '');
env.base_url = desi.site.base_url;
@ -226,92 +201,75 @@ function createPost(originalDir, blogdir, title, extra) {
// TODO use site.permalink or collection.permalink or something like that
slug = Desi.slugify(post.title);
// TODO as per config
post.uuid = UUID.v4();
// TODO as per config for default collection and default format (jade, md, etc)
filepath = path.join(blogdir, collectionname, slug + ".md");
displaypath = path
.join(originalDir, "posts", slug + ".md")
.replace(/^\/(Users|home)\/[^\/]+\//, "~/")
.replace(/ /g, "\\ ");
filepath = path.join(blogdir, collectionname, slug + '.md');
displaypath = path.join(originalDir, 'posts', slug + '.md').replace(/^\/(Users|home)\/[^\/]+\//, '~/').replace(/ /g, '\\ ');
["updated", "theme", "layout", "swatch"].forEach(function (key) {
['updated', 'theme', 'layout', 'swatch'].forEach(function (key) {
if (!post[key]) {
delete post[key];
}
});
Object.keys(post).forEach(function (key) {
entity[key] = post[key];
});
entity.slug = slug;
post.permalink = Desi.permalinkify(
desi,
collection.fallback_permalink || collection.permalink,
entity
);
return Desi.fsapi
.putFiles(
[
{
path: filepath,
contents:
"---\n" +
Desi.YAML.stringify(post).trim() +
"\n" +
"---\n" +
"\n" +
"\n",
},
],
{ overwrite: false }
)
.then(function (r) {
var err;
desi
, collection.fallback_permalink || collection.permalink
, entity);
return Desi.fsapi.putFiles([{
path: filepath
, contents:
'---\n'
+ Desi.YAML.stringify(post).trim()
+ '\n'
+ '---\n'
+ '\n'
+ '\n'
}], { overwrite: false }).then(function (r) {
var err
;
if (r.error || r.errors.length) {
err = r.error || r.errors[0];
if (/exists/i.test(err.message)) {
console.error("");
console.error(
"Looks like that post already exists. Try a different name?"
);
console.error("");
console.error("");
} else {
throw err;
}
if (r.error || r.errors.length) {
err = r.error || r.errors[0];
if (/exists/i.test(err.message)) {
console.error('');
console.error("Looks like that post already exists. Try a different name?");
console.error('');
console.error('');
} else {
throw err;
}
}
console.log("");
console.log(displaypath);
console.log("");
console.log(
"Markdown: [" +
post.title +
"](" +
desi.site.base_url +
path.join(desi.site.base_path, post.permalink) +
")"
);
console.log(
'HTML: <a href="' +
desi.site.base_url +
path.join(desi.site.base_path, post.permalink) +
'">' +
post.title +
"</a>"
);
console.log("");
console.log("");
console.log("vim " + displaypath);
console.log("(or emacs " + displaypath + ", if you swing that way)");
console.log("");
console.log("");
});
/*
console.log('');
console.log(displaypath);
console.log('');
console.log('Markdown: [' + post.title + ']('
+ desi.site.base_url
+ path.join(desi.site.base_path, post.permalink)
+ ')'
);
console.log('HTML: <a href="'
+ desi.site.base_url
+ path.join(desi.site.base_path, post.permalink)
+ '">' + post.title + '</a>'
);
console.log('');
console.log('');
console.log('vim ' + displaypath);
console.log('(or emacs ' + displaypath + ', if you swing that way)');
console.log('');
console.log('');
});
/*
});
*/
});
@ -320,132 +278,120 @@ function createPost(originalDir, blogdir, title, extra) {
function initialize(displayPath, blogdir) {
console.info("\nCreating new blog", displayPath);
return fs
.readdirAsync(blogdir)
.then(function (nodes) {
// ignore dotfiles (.DS_Store, etc)
nodes = nodes.filter(function (node) {
return !/^\./.test(node);
});
return fs.readdirAsync(blogdir).then(function (nodes) {
// ignore dotfiles (.DS_Store, etc)
nodes = nodes.filter(function (node) {
return !/^\./.test(node);
});
if (nodes.length) {
console.error(
"\n\tOops! It looks like that directory is already being used"
);
console.error(
"\nIf you want you can DELETE it and start from scratch:"
);
console.error("\n\trm -r '" + blogdir.replace("'", "'\"'\"'") + "'");
console.error("\nOr you can specify a different directory.");
console.error("\n");
process.exit(1);
if (nodes.length) {
console.error("\n\tOops! It looks like that directory is already being used");
console.error("\nIf you want you can DELETE it and start from scratch:");
console.error("\n\trm -r '" + blogdir.replace("'", "'\"'\"'") + "'");
console.error("\nOr you can specify a different directory.");
console.error("\n");
process.exit(1);
}
}).catch(function (/*err*/) {
// doesn't exist? No problamo (all the better, actually)
return;
}).then(function () {
return fsx.mkdirp(blogdir);
}).then(function () {
return new PromiseA(function (resolve, reject) {
var t = tar.Extract({ path: blogdir, strip: 1 })
, gunzip = zlib.createGunzip()
;
console.info("Downloading blog template...", displayPath);
request.get("https://github.com/DearDesi/desirae-blog-template/archive/v1.1.0.tar.gz")
.pipe(gunzip)
.pipe(t)
.on('end', resolve)
.on('error', reject)
;
});
}).then(function () {
var themes
;
themes = [
{ name: 'ruhoh-twitter'
, url: "https://github.com/DearDesi/ruhoh-twitter/archive/v1.0.0.tar.gz"
}
})
.catch(function (/*err*/) {
// doesn't exist? No problamo (all the better, actually)
return;
})
.then(function () {
return fsx.mkdirp(blogdir);
})
.then(function () {
, { name: 'ruhoh-bootstrap-2'
, url: "https://github.com/DearDesi/ruhoh-bootstrap-2/archive/v1.0.1.tar.gz"
}
];
return forEachAsync(themes, function (theme) {
return new PromiseA(function (resolve, reject) {
var t = tar.Extract({ path: blogdir, strip: 1 }),
gunzip = zlib.createGunzip();
console.info("Downloading blog template...", displayPath);
request
.get(
"https://github.com/DearDesi/desirae-blog-template/archive/v1.1.0.tar.gz"
)
var t = tar.Extract({ path: path.join(blogdir, 'themes', theme.name), strip: 1 })
, gunzip = zlib.createGunzip()
;
console.info("Downloading theme '" + theme.name + "'");
request.get(theme.url)
.pipe(gunzip)
.pipe(t)
.on("end", resolve)
.on("error", reject);
.on('end', resolve)
.on('error', reject)
;
});
})
.then(function () {
var themes;
themes = [
{
name: "ruhoh-twitter",
url:
"https://github.com/DearDesi/ruhoh-twitter/archive/v1.0.0.tar.gz",
},
{
name: "ruhoh-bootstrap-2",
url:
"https://github.com/DearDesi/ruhoh-bootstrap-2/archive/v1.0.1.tar.gz",
},
];
return forEachAsync(themes, function (theme) {
return new PromiseA(function (resolve, reject) {
var t = tar.Extract({
path: path.join(blogdir, "themes", theme.name),
strip: 1,
}),
gunzip = zlib.createGunzip();
console.info("Downloading theme '" + theme.name + "'");
request
.get(theme.url)
.pipe(gunzip)
.pipe(t)
.on("end", resolve)
.on("error", reject);
});
});
})
.then(function () {
console.info("Done.");
console.info("\nTo start the web editor run this:");
console.info(
"\n\tdesi serve -d '" + blogdir.replace("'", "'\"'\"'") + "'"
);
});
}).then(function () {
console.info("Done.");
console.info("\nTo start the web editor run this:");
console.info("\n\tdesi serve -d '" + blogdir.replace("'", "'\"'\"'") + "'");
})
;
}
cli.main(function (args, options) {
init();
var command = args[0],
blogdir = options.blogdir,
originalDir = blogdir,
displayPath;
var command = args[0]
, blogdir = options.blogdir
, originalDir = blogdir
, displayPath
;
if (!blogdir) {
blogdir = path.resolve("./");
originalDir = "./";
blogdir = path.resolve('./');
originalDir = './';
}
displayPath = path
.resolve(originalDir)
.replace(/^\/(Users|home)\/[^\/]+\//, "~/")
.replace(/ /g, "\\ ");
displayPath = path.resolve(originalDir)
.replace(/^\/(Users|home)\/[^\/]+\//, '~/')
.replace(/ /g, '\\ ')
;
if ("init" === command) {
if ('init' === command) {
initialize(displayPath, blogdir);
return;
}
if (!fs.existsSync(path.join(blogdir, "site.yml"))) {
if (!fs.existsSync(path.join(blogdir, 'site.yml'))) {
console.error("Usage: desi [serve|init|post] -d ~/path/to/blog");
console.error(
"(if ~/path/to/blog doesn't yet exist or doesn't have config.yml, site.yml, etc, " +
"try `deardesi init -d ~/path/to/blog'"
);
console.error("(if ~/path/to/blog doesn't yet exist or doesn't have config.yml, site.yml, etc, "
+ "try `deardesi init -d ~/path/to/blog'");
process.exit(1);
return;
} else if ("build" === command) {
}
else if ('build' === command) {
build(blogdir);
return;
} else if ("post" === command) {
}
else if ('post' === command) {
createPost(originalDir, blogdir, args[1], args[2]);
return;
} else if ("serve" === command) {
}
else if ('serve' === command) {
serve(displayPath, blogdir);
return;
} else {
}
else {
console.error("Usage: desi [serve|init|post] -d ~/path/to/blog");
return;
}

View File

@ -1,10 +1,15 @@
{
"name": "deardesi",
"version": "0.8.5",
"authors": ["AJ ONeal <awesome@coolaj86.com>"],
"authors": [
"AJ ONeal <awesome@coolaj86.com>"
],
"description": "A blogging platform in the browser. Wow!",
"main": "deardesi.js",
"moduleType": ["globals", "node"],
"moduleType": [
"globals",
"node"
],
"keywords": [
"dear",
"desi",
@ -16,7 +21,13 @@
],
"license": "Apache2",
"homepage": "http://github.com/DearDesi/deardesi",
"ignore": ["**/.*", "node_modules", "bower_components", "test", "tests"],
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"escape-string-regexp": "~1.0.2",
"path": "~3.46.1",

View File

@ -1,27 +1,32 @@
angular.module("myApp.services", []).factory("Desirae", [
"$q",
"$http",
function ($q, $http) {
var Desi = window.Desirae || require("./deardesi").Desirae,
desi = {
/*TODO api_base: '/api'*/
};
angular.module('myApp.services', []).
factory('Desirae', ['$q', '$http', function ($q, $http) {
var Desi = window.Desirae || require('./deardesi').Desirae
, desi = {/*TODO api_base: '/api'*/}
;
//
// 1. Transform (yml, slug, etc)
//
Desi.registerTransform("lint", window.DesiraeTransformCore.lint, {
collections: true,
});
Desi.registerTransform("root", window.DesiraeTransformCore.root, {
root: true,
});
Desi.registerTransform("normalize", window.DesiraeTransformCore.normalize, {
root: true,
collections: true,
});
Desi.registerTransform("disqus", window.DesiraeTransformCore.disqus, {
collections: true,
});
Desi.registerTransform(
'lint'
, window.DesiraeTransformCore.lint
, { collections: true }
);
Desi.registerTransform(
'root'
, window.DesiraeTransformCore.root
, { root: true }
);
Desi.registerTransform(
'normalize'
, window.DesiraeTransformCore.normalize
, { root: true, collections: true }
);
Desi.registerTransform(
'disqus'
, window.DesiraeTransformCore.disqus
, { collections: true }
);
//
// 2. Aggregate (rss, categories, tags, etc)
@ -31,66 +36,60 @@ angular.module("myApp.services", []).factory("Desirae", [
//
// 3. Datamap (ruhoh, desirae, jade, mustache, liquid)
//
Desi.registerDataMapper("desirae", window.DesiraeDatamapCore);
Desi.registerDataMapper("desirae@1.0", window.DesiraeDatamapCore);
Desi.registerDataMapper("ruhoh", window.DesiraeDatamapRuhoh);
Desi.registerDataMapper("ruhoh@1.0", window.DesiraeDatamapRuhoh);
Desi.registerDataMapper("ruhoh@2.6", window.DesiraeDatamapRuhoh);
Desi.registerDataMapper('desirae', window.DesiraeDatamapCore);
Desi.registerDataMapper('desirae@1.0', window.DesiraeDatamapCore);
Desi.registerDataMapper('ruhoh', window.DesiraeDatamapRuhoh);
Desi.registerDataMapper('ruhoh@1.0', window.DesiraeDatamapRuhoh);
Desi.registerDataMapper('ruhoh@2.6', window.DesiraeDatamapRuhoh);
//
// 4. Render (md -> html, less -> css, etc)
//
Desi.registerRenderer("js", window.DesiraeRenderCss, {
themes: true,
assets: true,
});
Desi.registerRenderer("css", window.DesiraeRenderCss, {
themes: true,
assets: true,
Desi.registerRenderer(
'js'
, window.DesiraeRenderCss
, { themes: true, assets: true }
);
Desi.registerRenderer(
'css'
, window.DesiraeRenderCss
, { themes: true, assets: true }
);
['html', 'htm', 'xhtm', 'xhtml'].forEach(function (ext) {
Desi.registerRenderer(
ext
, window.DesiraeRenderHtml
, { root: true, collections: true, themes: true, assets: true }
);
});
["html", "htm", "xhtm", "xhtml"].forEach(function (ext) {
Desi.registerRenderer(ext, window.DesiraeRenderHtml, {
root: true,
collections: true,
themes: true,
assets: true,
});
['md', 'markdown', 'mdown', 'mkdn', 'mkd', 'mdwn', 'mdtxt', 'mdtext'].forEach(function (ext) {
Desi.registerRenderer(
ext
, window.DesiraeRenderMarkdown
, { root: true, collections: true }
);
});
[
"md",
"markdown",
"mdown",
"mkdn",
"mkd",
"mdwn",
"mdtxt",
"mdtext",
].forEach(function (ext) {
Desi.registerRenderer(ext, window.DesiraeRenderMarkdown, {
root: true,
collections: true,
});
});
Desi.registerRenderer("jade", window.DesiraeRenderJade, {
root: true,
collections: true,
themes: true,
});
Desi.registerRenderer(
'jade'
, window.DesiraeRenderJade
, { root: true, collections: true, themes: true }
);
function gdrive2host(str) {
// https://drive.google.com/folderview?id=0ByLnfhJOd1-baUh1Wms0US16QkE&usp=sharing
// https://googledrive.com/host/0ByLnfhJOd1-baUh1Wms0US16QkE
var m;
var m
;
str = str || "";
str = str || '';
m = str.match(/(?=drive.*google|google.*drive).*folderview.*id=([^&]+)/i);
console.log(m);
if (m && m[1]) {
return "https://googledrive.com/host/" + m[1];
return 'https://googledrive.com/host/' + m[1];
}
}
@ -104,42 +103,42 @@ angular.module("myApp.services", []).factory("Desirae", [
// https://www.dropbox.com/s/3n20djtrs2p0j9k/index.html?dl=0
// https://dl.dropboxusercontent.com/s/3n20djtrs2p0j9k/index.html
str = str || "";
str = str || '';
if (!str.match(/dropboxusercontent\.com\/u\/([^\/]+)\/index.html/)) {
window.alert(
"Sorry, Desi can't use that type of dropbox link." +
"\n\n1. Open the Dropbox folder on your computer" +
"\n (The DropBox app must be installed)" +
"\n\n2. Open the Public folder" +
"\n (if you don't have a Public folder, your account doesn't support hosting websites and you're simply out of luck)" +
"\n\n2. Create a new file called index.html" +
"\n\n3. Right-click on index.html" +
"\n\n4. Select 'Copy Public Link'" +
"\n\n5. Paste that link as the URL for Desi"
);
window.alert("Sorry, Desi can't use that type of dropbox link."
+ "\n\n1. Open the Dropbox folder on your computer"
+ "\n (The DropBox app must be installed)"
+ "\n\n2. Open the Public folder"
+ "\n (if you don't have a Public folder, your account doesn't support hosting websites and you're simply out of luck)"
+ "\n\n2. Create a new file called index.html"
+ "\n\n3. Right-click on index.html"
+ "\n\n4. Select 'Copy Public Link'"
+ "\n\n5. Paste that link as the URL for Desi"
);
return;
}
return str.replace(/\/index\.html$/, "");
return str.replace(/\/index\.html$/, '');
}
function splitUrl(str) {
var m;
var m
;
str = str || "";
str = str || '';
m = str.match(/(https?:\/\/)?([^\.\/?#]+\.[^\/?#]+)(\/[^#?]+)?/i);
console.log(m);
if (!m || !m[2]) {
return;
}
return {
baseUrl: (m[1] || "http://") + m[2],
basePath: (m[3] && m[3].replace(/\/$/, "")) || "/",
baseUrl: (m[1] || 'http://') + m[2]
, basePath: (m[3] && m[3].replace(/\/$/, '')) || '/'
};
}
function getBlogdir() {
return $http.get("/api/fs/rootdir").then(function (resp) {
function getBlogdir () {
return $http.get('/api/fs/rootdir').then(function (resp) {
desi.blogdir = resp.data;
return resp.data;
});
@ -147,16 +146,18 @@ angular.module("myApp.services", []).factory("Desirae", [
getBlogdir();
return {
splitUrl: splitUrl,
gdrive2host: gdrive2host,
dropbox2host: dropbox2host,
reset: function () {
splitUrl: splitUrl
, gdrive2host: gdrive2host
, dropbox2host: dropbox2host
, reset: function () {
desi = {};
return getBlogdir();
},
toDesiDate: Desi.toLocaleDate,
meta: function () {
var d = $q.defer();
}
, toDesiDate: Desi.toLocaleDate
, meta: function () {
var d = $q.defer()
;
if (desi.meta) {
d.resolve(desi);
return d.promise;
@ -167,9 +168,11 @@ angular.module("myApp.services", []).factory("Desirae", [
});
return d.promise;
},
build: function (env) {
var d = $q.defer();
}
, build: function (env) {
var d = $q.defer()
;
if (desi.built) {
d.resolve(desi);
return d.promise;
@ -180,9 +183,11 @@ angular.module("myApp.services", []).factory("Desirae", [
});
return d.promise;
},
write: function (env) {
var d = $q.defer();
}
, write: function (env) {
var d = $q.defer()
;
if (desi.written) {
d.resolve(desi);
return d.promise;
@ -193,10 +198,10 @@ angular.module("myApp.services", []).factory("Desirae", [
});
return d.promise;
},
putFiles: function (files) {
}
, putFiles: function (files) {
return $q.when(Desi.fsapi.putFiles(files));
},
}
};
},
]);
}]
);

View File

@ -1,13 +1,9 @@
"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\%/gm, version);
};
},
]);
.filter('interpolate', ['version', function(version) {
return function(text) {
return String(text).replace(/\%VERSION\%/mg, version);
};
}]);

View File

@ -1,19 +1,15 @@
"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');
}));
});
});

View File

@ -1,13 +1,9 @@
"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);
};
}]);

View File

@ -1,16 +1,16 @@
"use strict";
'use strict';
describe("myApp.version module", function () {
beforeEach(module("myApp.version"));
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");
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("<span app-version></span>")($rootScope);
expect(element.text()).toEqual("TEST_VER");
inject(function($compile, $rootScope) {
var element = $compile('<span app-version></span>')($rootScope);
expect(element.text()).toEqual('TEST_VER');
});
});
});

View File

@ -1,9 +1,8 @@
"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');

View File

@ -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');
}));
});
});

View File

@ -1,8 +1,12 @@
"use strict";
'use strict';
var fsapi = require('desirae/lib/node-adapters').fsapi
;
var fsapi = require("desirae/lib/node-adapters").fsapi;
module.exports.create = function (options) {
var restful = {};
var restful = {}
;
//
// Required for desirae
//
@ -12,24 +16,18 @@ module.exports.create = function (options) {
return;
}
var opts = {},
dirnames =
(req.query.dir && [req.query.dir]) ||
(req.query.dirs && req.query.dirs.split(/,/g)) ||
req.body.dirs;
var opts = {}
, dirnames = req.query.dir && [req.query.dir] || (req.query.dirs && req.query.dirs.split(/,/g)) || req.body.dirs
;
if (!dirnames || !dirnames.length) {
res.send({
error:
"please specify GET w/ req.query.dir or POST w/ _method=GET&dirs=path/to/thing,...",
});
res.send({ error: "please specify GET w/ req.query.dir or POST w/ _method=GET&dirs=path/to/thing,..." });
return;
}
if (
!dirnames.every(function (dirname) {
return "string" === typeof dirname;
})
) {
if (!dirnames.every(function (dirname) {
return 'string' === typeof dirname;
})) {
res.send({ error: "malformed request: " + JSON.stringify(dirnames) });
return;
}
@ -44,13 +42,13 @@ module.exports.create = function (options) {
opts.extensions = req.query.extensions.split(/,/g);
}
if ("true" === req.query.dotfiles) {
if ('true' === req.query.dotfiles) {
opts.dotfiles = true;
}
if ("false" === req.query.sha1sum) {
if ('false' === req.query.sha1sum) {
opts.sha1sum = false;
}
if ("true" === req.query.contents) {
if ('true' === req.query.contents) {
opts.contents = true;
}
@ -70,15 +68,11 @@ module.exports.create = function (options) {
return;
}
var filepaths =
(req.query.path && [req.query.path]) ||
(req.query.paths && req.query.paths.split(/,/g)) ||
req.body.paths;
var filepaths = req.query.path && [req.query.path] || (req.query.paths && req.query.paths.split(/,/g)) || req.body.paths
;
if (!filepaths || !filepaths.length) {
res.send({
error:
"please specify GET w/ req.query.path or POST _method=GET&paths=path/to/thing,...",
});
res.send({ error: "please specify GET w/ req.query.path or POST _method=GET&paths=path/to/thing,..." });
return;
}
@ -92,15 +86,15 @@ module.exports.create = function (options) {
};
restful.putFiles = function (req, res, next) {
if (
!(/^POST|PUT$/i.test(req.method) || /^POST|PUT$/i.test(req.query._method))
) {
if (!(/^POST|PUT$/i.test(req.method) || /^POST|PUT$/i.test(req.query._method))) {
next();
return;
}
var opts = {},
files = req.body.files;
var opts = {}
, files = req.body.files
;
if (!files || !files.length) {
res.send({ error: "please specify POST w/ req.body.files" });
return;
@ -113,16 +107,16 @@ module.exports.create = function (options) {
};
restful.copy = function (req, res, next) {
if (
!(/^POST|PUT$/i.test(req.method) || /^POST|PUT$/i.test(req.query._method))
) {
if (!(/^POST|PUT$/i.test(req.method) || /^POST|PUT$/i.test(req.query._method))) {
next();
return;
}
var opts = {},
files = req.body.files;
if ("object" !== typeof files || !Object.keys(files).length) {
var opts = {}
, files = req.body.files
;
if ('object' !== typeof files || !Object.keys(files).length) {
res.send({ error: "please specify POST w/ req.body.files" });
return;
}

View File

@ -2,191 +2,129 @@
<!--[if lt IE 7]> <html lang="en" ng-app="myApp" class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html lang="en" ng-app="myApp" class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html lang="en" ng-app="myApp" class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html lang="en" ng-app="myApp" class="no-js">
<!--<![endif]-->
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<!--[if gt IE 8]><!--> <html lang="en" ng-app="myApp" class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Desi, the DIY Blog Platform</title>
<meta
name="description"
content="Desi is the DIY blog platform for normal people. You can build your blog with Desi in your browser and then host it on Google Drive, DropBox, Github, or a good ol' fashion web host via ftp."
/>
<title>Desi, the DIY Blog Platform</title>
<meta name="description" content="Desi is the DIY blog platform for normal people. You can build your blog with Desi in your browser and then host it on Google Drive, DropBox, Github, or a good ol' fashion web host via ftp.">
<!-- Style -->
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link
rel="stylesheet"
href="bower_components/html5-boilerplate/css/normalize.css"
/>
<link
rel="stylesheet"
href="bower_components/html5-boilerplate/css/main.css"
/>
<link
rel="stylesheet"
href="bower_components/bootstrap/dist/css/bootstrap.min.css"
/>
<!-- just as a fallback -->
<link
rel="stylesheet"
href="//maxcdn.bootstrapcdn.com/bootswatch/3.3.1/spacelab/bootstrap.min.css"
/>
<!-- Style -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="bower_components/html5-boilerplate/css/normalize.css">
<link rel="stylesheet" href="bower_components/html5-boilerplate/css/main.css">
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css"><!-- just as a fallback -->
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootswatch/3.3.1/spacelab/bootstrap.min.css">
<script src="bower_components/html5-boilerplate/js/vendor/modernizr-2.6.2.min.js"></script>
</head>
<body>
<!--[if lt IE 7]>
<p class="browsehappy">
You are using an <strong>outdated</strong> browser. Please
<a href="http://browsehappy.com/">upgrade your browser</a> to improve
your experience.
</p>
<![endif]-->
<script src="bower_components/html5-boilerplate/js/vendor/modernizr-2.6.2.min.js"></script>
</head>
<body>
<!--.navbar.navbar-default.navbar-fixed-top-->
<div
style="margin-bottom: 0; border-top-width: 0"
class="navbar navbar-default"
>
<div class="container">
<div class="navbar-header">
<div
style="padding-top: 9px; padding-left: 9px; padding-bottom: 9px"
class="pull-left"
>
<img
ng-src="http://dropsha.re/files/VY15+v8/desirae-parker-crop.jpg"
style="border: 1px solid grey; height: 54px; width: 54px"
class="navbar-logo"
/>
</div>
<a
href="#/"
style="padding-top: 23px; padding-left: 25px"
class="navbar-brand"
>Desi</a
>
<div style="padding-top: 9px">
<button
type="button"
ng-init="navCollapsed = true"
ng-click="navCollapsed = !navCollapsed"
class="navbar-toggle"
>
<span class="icon-bar"></span><span class="icon-bar"></span
><span class="icon-bar"></span>
</button>
</div>
</div>
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<!--.navbar.navbar-default.navbar-fixed-top-->
<div style="margin-bottom: 0; border-top-width: 0;" class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<div
id="navbar-main"
ng-class="!navCollapsed &amp;&amp; 'in'"
class="navbar-collapse collapse"
>
<ul style="padding-top: 9px" class="nav navbar-nav">
<li><a href="#/authors">Authors</a></li>
<li><a href="#/site">Site</a></li>
<li><a href="#/post">Post</a></li>
<li><a href="#/build">Build</a></li>
</ul>
style="padding-top: 9px; padding-left: 9px; padding-bottom: 9px;"
class="pull-left"><img
ng-src="http://dropsha.re/files/VY15+v8/desirae-parker-crop.jpg"
style="border: 1px solid grey; height: 54px; width: 54px;"
class="navbar-logo"/></div>
<a href="#/"
style="padding-top: 23px; padding-left: 25px;"
class="navbar-brand">Desi</a>
<div style="padding-top: 9px;">
<button type="button" ng-init="navCollapsed = true" ng-click="navCollapsed = !navCollapsed" class="navbar-toggle"><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button>
</div>
</div>
<div id="navbar-main" ng-class="!navCollapsed &amp;&amp; 'in'" class="navbar-collapse collapse">
<ul style="padding-top: 9px;" class="nav navbar-nav">
<li><a href="#/authors">Authors</a></li>
<li><a href="#/site">Site</a></li>
<li><a href="#/post">Post</a></li>
<li><a href="#/build">Build</a></li>
</ul>
</div>
</div>
</div>
<div ng-view></div>
<div ng-view></div>
<footer>
<center>
<p>
<!-- http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html -->
<!-- also needs updating at http://plus.google.com/me/about/edit/co -->
<a href="mailto:develop@dear.desi" rel="me">develop@dear.desi</a>
|
<a href="https://twitter.com/dearbesiblog?rel=author" rel="me"
>Twitter</a
>
<!--a href="https://www.facebook.com/coolaj86?rel=author" rel="me">Facebook</a-->
|
<a href="https://github.com/DearDesi/desirae?rel=author" rel="me"
>Github</a
>
(v<span app-version></span>)
<!--a href="https://plus.google.com/111222501744950155474?rel=author" data-user="AJ ONeal" rel="me">Google+</a -->
|
<a href="https://www.youtube.com/watch?v=pFAKAWP_sec" rel="me"
>YouTube</a
>
|
<a href="http://www.apache.org/licenses/LICENSE-2.0"
>Apache 2 License</a
>
|
<a href="http://opensource.org/licenses/MIT">MIT License</a>
</p>
<p>
© AJ ONeal Tech LLC 2015 with help from
<a
href="http://angularjs.org"
target="_blank"
title="Superheroic JavaScript MVW Framework"
>AngularJS</a
>,
<a
href="http://iojs.org"
target="_blank"
title="Open source, cross-platform server-side JavaScript runtime environment"
>io.js</a
>, and
<a href="http://twitter.github.com/bootstrap/" target="_blank"
>Twitter Bootstrap</a
>
</p>
</center>
</footer>
<footer>
<center>
<p>
<!-- http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html -->
<!-- also needs updating at http://plus.google.com/me/about/edit/co -->
<a href="mailto:develop@dear.desi" rel="me">develop@dear.desi</a>
|
<a href="https://twitter.com/dearbesiblog?rel=author" rel="me">Twitter</a>
<!--a href="https://www.facebook.com/coolaj86?rel=author" rel="me">Facebook</a-->
|
<a href="https://github.com/DearDesi/desirae?rel=author" rel="me">Github</a> (v<span app-version></span>)
<!--a href="https://plus.google.com/111222501744950155474?rel=author" data-user="AJ ONeal" rel="me">Google+</a -->
|
<a href="https://www.youtube.com/watch?v=pFAKAWP_sec" rel="me">YouTube</a>
|
<a href="http://www.apache.org/licenses/LICENSE-2.0">Apache 2 License</a>
|
<a href="http://opensource.org/licenses/MIT">MIT License</a>
</p>
<p>© AJ ONeal Tech LLC 2015
with help from
<a href="http://angularjs.org" target="_blank" title="Superheroic JavaScript MVW Framework">AngularJS</a>,
<a href="http://iojs.org" target="_blank"
title="Open source, cross-platform server-side JavaScript runtime environment">io.js</a>,
and <a href="http://twitter.github.com/bootstrap/" target="_blank">Twitter Bootstrap</a>
</p>
</center>
</footer>
<!-- Deps -->
<script src="./bower_components/bluebird/js/browser/bluebird.js"></script>
<script src="./bower_components/mustache/mustache.js"></script>
<script src="./bower_components/markdown-it/dist/markdown-it.js"></script>
<script src="./bower_components/jade/jade.js"></script>
<script src="./bower_components/js-yaml/dist/js-yaml.js"></script>
<script src="./bower_components/path/path.js"></script>
<script src="./bower_components/node-uuid/uuid.js"></script>
<script src="./bower_components/forEachAsync/forEachAsync.js"></script>
<!-- Deps -->
<script src="./bower_components/bluebird/js/browser/bluebird.js"></script>
<script src="./bower_components/mustache/mustache.js"></script>
<script src="./bower_components/markdown-it/dist/markdown-it.js"></script>
<script src="./bower_components/jade/jade.js"></script>
<script src="./bower_components/js-yaml/dist/js-yaml.js"></script>
<script src="./bower_components/path/path.js"></script>
<script src="./bower_components/node-uuid/uuid.js"></script>
<script src="./bower_components/forEachAsync/forEachAsync.js"></script>
<!-- Libs -->
<script src="./bower_components/desirae/lib/verify-config.js"></script>
<!-- Libs -->
<script src="./bower_components/desirae/lib/verify-config.js"></script>
<!-- Desi -->
<script src="./bower_components/desirae/desirae.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/utils.js"></script>
<script src="./bower_components/desirae/lib/transform-core.js"></script>
<script src="./bower_components/desirae/lib/aggregate-core.js"></script>
<script src="./bower_components/desirae/lib/datamap-core.js"></script>
<script src="./bower_components/desirae/lib/render-core.js"></script>
<script src="./bower_components/desirae-datamap-ruhoh/datamapper-ruhoh.js"></script>
<!-- Desi -->
<script src="./bower_components/desirae/desirae.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/utils.js"></script>
<script src="./bower_components/desirae/lib/transform-core.js"></script>
<script src="./bower_components/desirae/lib/aggregate-core.js"></script>
<script src="./bower_components/desirae/lib/datamap-core.js"></script>
<script src="./bower_components/desirae/lib/render-core.js"></script>
<script src="./bower_components/desirae-datamap-ruhoh/datamapper-ruhoh.js"></script>
<!-- UX Using Angular, but not getting fancy -->
<script src="./bower_components/angular/angular.js"></script>
<script src="./bower_components/angular-route/angular-route.js"></script>
<script src="./bower_components/md5/build/md5.min.js"></script>
<script src="./app.js"></script>
<script src="./views/about/about.js"></script>
<script src="./views/authors/authors.js"></script>
<script src="./views/site/site.js"></script>
<script src="./views/configure/configure.js"></script>
<script src="./views/build/build.js"></script>
<script src="./views/post/post.js"></script>
<script src="components/desirae/desirae.js"></script>
<script src="components/version/version.js"></script>
<script src="components/version/version-directive.js"></script>
<script src="components/version/interpolate-filter.js"></script>
</body>
<!-- UX Using Angular, but not getting fancy -->
<script src="./bower_components/angular/angular.js"></script>
<script src="./bower_components/angular-route/angular-route.js"></script>
<script src="./bower_components/md5/build/md5.min.js"></script>
<script src="./app.js"></script>
<script src="./views/about/about.js"></script>
<script src="./views/authors/authors.js"></script>
<script src="./views/site/site.js"></script>
<script src="./views/configure/configure.js"></script>
<script src="./views/build/build.js"></script>
<script src="./views/post/post.js"></script>
<script src="components/desirae/desirae.js"></script>
<script src="components/version/version.js"></script>
<script src="components/version/version-directive.js"></script>
<script src="components/version/interpolate-filter.js"></script>
</body>
</html>

View File

@ -4,7 +4,6 @@
"description": "A nice, friendly tool to help you get set up and start blogging, built on the Desirae blogging platform",
"main": "server.js",
"scripts": {
"prettier": "prettier --write './**/*.{js,css,json,md,html}'",
"test": "echo \"Error: no test specified\" && exit 1"
},
"bin": {
@ -32,7 +31,7 @@
"octopress"
],
"author": "AJ ONeal <coolaj86@gmail.com> (https://coolaj86.com/)",
"license": "MPL-2.0",
"license": "(MIT OR ISC OR Apache-2.0)",
"bugs": {
"url": "https://git.coolaj86.com/coolaj86/deardesi.js/issues"
},

View File

@ -1,31 +1,36 @@
"use strict";
'use strict';
var path = require("path");
var path = require('path');
function create(options) {
var connect = require("connect"),
query = require("connect-query"),
bodyParser = require("body-parser"),
serveStatic = require("serve-static"),
send = require("connect-send-json"),
app = connect(),
restful = require("./desirae-http-api").create(options);
var connect = require('connect')
, query = require('connect-query')
, bodyParser = require('body-parser')
, serveStatic = require('serve-static')
, send = require('connect-send-json')
, app = connect()
, restful = require('./desirae-http-api').create(options)
;
app
.use(send.json())
.use(query())
.use(bodyParser.json({ limit: 10 * 1024 * 1024 })) // 10mb
.use(require("compression")());
.use(require('compression')())
;
//
// Keeping the API *required* by desirae super minimal
// so that it can be implemented easily in any language
//
app
.use("/api/fs/static", serveStatic(options.blogdir))
.use("/api/fs/walk", restful.walk)
.use("/api/fs/files", restful.getFiles)
.use("/api/fs/files", restful.putFiles)
.use("/api/fs/copy", restful.copy);
.use('/api/fs/static', serveStatic(options.blogdir))
.use('/api/fs/walk', restful.walk)
.use('/api/fs/files', restful.getFiles)
.use('/api/fs/files', restful.putFiles)
.use('/api/fs/copy', restful.copy)
;
// end Desirae API
if (options.tmpdir) {
@ -33,30 +38,32 @@ function create(options) {
}
// this is used by DearDesi, but not required for desirae
app.use("/api/fs/rootdir", function (req, res) {
var pathname = path.resolve(options.blogdir);
res.send({
path: pathname,
name: path.basename(pathname),
relativePath: path.dirname(pathname),
});
return;
});
app
.use('/api/fs/rootdir', function (req, res) {
var pathname = path.resolve(options.blogdir)
;
res.send({
path: pathname
, name: path.basename(pathname)
, relativePath: path.dirname(pathname)
});
return;
})
;
app
// the AngularJS App
.use(serveStatic(__dirname))
// TODO change file requests to '/blog'
//.use(serveStatic(options.blogdir))
.use("/blog", serveStatic(options.blogdir))
.use(
"/compiled_dev",
serveStatic(path.join(options.blogdir, "/compiled_dev"))
)
.use("/compiled", serveStatic(path.join(options.blogdir, "/compiled")));
.use('/blog', serveStatic(options.blogdir))
.use('/compiled_dev', serveStatic(path.join(options.blogdir, '/compiled_dev')))
.use('/compiled', serveStatic(path.join(options.blogdir, '/compiled')))
;
return app;
}
module.exports = create({ blogdir: path.join(__dirname, "blog") });
module.exports = create({ blogdir: path.join(__dirname, 'blog') });
module.exports.create = create;

View File

@ -1,11 +1,9 @@
<div class="container">
<div class="row">
<div class="col-xs-12">
<div class="page-header">
<h1>
Welcome to Desi!
<small ng-bind="'(v%VERSION%)' | interpolate"></small>
</h1>
<h1>Welcome to Desi! <small ng-bind="'(v%VERSION%)' | interpolate"></small></h1>
</div>
<div class="jumbotron">
@ -13,12 +11,13 @@
<div class="col-lg-7">
<p>Setup your new blog in just 5 minutes.</p>
</div>
<div class="col-lg-5"></div>
<div class="col-lg-5">
</div>
</div>
<div class="row">
<div class="col-lg-7">
<!-- iframe width="560" height="315" src="//www.youtube.com/embed/pFAKAWP_sec" frameborder="0" allowfullscreen></iframe -->
<br />
<br/>
<p>Run these commands in Terminal:</p>
<pre>
<code>curl -fsSL bit.ly/install-deardesi | bash
@ -29,28 +28,18 @@ open ~/Desktop/my-blog
desi serve -d ~/Desktop/my-blog</code>
</pre>
<br />
<p>
Then open
<a href="http://local.dear.desi:65080"
>http://local.dear.desi:65080</a
>
in your browser.
</p>
<br/>
<p>Then open <a href="http://local.dear.desi:65080">http://local.dear.desi:65080</a> in your browser.</p>
</div>
<div class="col-lg-5">
<h2>Why Desi?</h2>
<br />
<br/>
<ul>
<li>
Built in JavaScript
<li>Built in JavaScript
<ul>
<li>Write content in Markdown, Jade, or HTML</li>
<li>Mustache Templates</li>
<li>
Use <a href="http://ruhoh.com">ruhoh</a> themes (or roll
your own)
</li>
<li>Use <a href="http://ruhoh.com">ruhoh</a> themes (or roll your own)</li>
</ul>
</li>
<li>Build your blog right in your browser</li>
@ -60,10 +49,8 @@ desi serve -d ~/Desktop/my-blog</code>
<li>No Ruby version Hell - it'll still work in 6 months! :-D</li>
</ul>
<h3>What are you waiting for?</h3>
<br />
<a class="btn btn-primary btn-lg pull-right" href="/#authors"
>Get Started!</a
>
<br/>
<a class="btn btn-primary btn-lg pull-right" href="/#authors">Get Started!</a>
</div>
</div>
</div>

View File

@ -1,16 +1,14 @@
"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() {
}]);

View File

@ -1,13 +1,16 @@
"use strict";
'use strict';
describe("myApp.view2 module", function () {
beforeEach(module("myApp.view2"));
describe('myApp.view2 module', function() {
describe("view2 controller", function () {
it("should ....", inject(function ($controller) {
beforeEach(module('myApp.view2'));
describe('view2 controller', function(){
it('should ....', inject(function($controller) {
//spec body
var view2Ctrl = $controller("View2Ctrl");
var view2Ctrl = $controller('View2Ctrl');
expect(view2Ctrl).toBeDefined();
}));
});
});
});

View File

@ -7,50 +7,39 @@
<div class="row" ng-if="Authors.authors">
<div class="col-md-offset-1 col-md-8">
<div class="form-group">
<select
<select
ng-options="author as author.filename for (handle, author) in Authors.authors"
class="form-control"
ng-model="Authors.selectedAuthor"
ng-change="Authors.selectAuthor()"
></select>
></select>
</div>
</div>
<br />
<br/>
</div>
</div>
<div class="col-md-5 col-sm-6 col-xs-4">
<br />
<img style="height: 75px" ng-src="{{Authors.headshot}}" />
<br/>
<img style="height:75px;" ng-src="{{Authors.headshot}}" />
</div>
</div>
</div>
<form
class="form-horizontal"
name="newAuthors"
ng-submit="Authors.upsert(Authors.selectedAuthor)"
>
<form class="form-horizontal" name="newAuthors" ng-submit="Authors.upsert(Authors.selectedAuthor)">
<div class="row">
<div class="col-sm-8">
<small
><span ng-bind="Authors.blogdir"></span>/authors/<span
ng-bind="Authors.selectedAuthor.handle"
></span
><span ng-if="Authors.selectedAuthor.handle">.yml</span></small
>
<small><span ng-bind="Authors.blogdir"
></span>/authors/<span ng-bind="Authors.selectedAuthor.handle"
></span><span ng-if="Authors.selectedAuthor.handle"
>.yml</span></small>
</div>
<div class="col-sm-4">
<button
class="btn btn-success pull-right"
type="submit"
ng-disabled="Authors.dirty || !Authors.selectedAuthor.handle"
>
Save &amp; Continue
</button>
<button class="btn btn-success pull-right" type="submit" ng-disabled="Authors.dirty || !Authors.selectedAuthor.handle">Save &amp; Continue</button>
</div>
</div>
<div class="row">
<br />
<br/>
</div>
<div class="row">
<div class="col-lg-12">
@ -58,138 +47,97 @@
<fieldset>
<legend>Profile Basics</legend>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="inputAuthorName" class="col-lg-4 control-label"
>Name*</label
>
<div class="col-lg-8">
<input
ng-model="Authors.selectedAuthor.name"
required="required"
type="text"
class="form-control"
id="inputAuthorName"
name="inputAuthorName"
placeholder="i.e. John Doe"
/>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label
for="inputAuthorNickname"
class="col-lg-4 control-label"
>Handle*</label
>
<div class="col-lg-8">
<input
ng-model="Authors.selectedAuthor.handle"
required="required"
type="text"
class="form-control"
id="inputAuthorNickname"
name="inputAuthorNickname"
placeholder="i.e. johndoe"
/>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="inputAuthorName" class="col-lg-4 control-label">Name*</label>
<div class="col-lg-8">
<input ng-model="Authors.selectedAuthor.name"
required="required"
type="text"
class="form-control"
id="inputAuthorName"
name="inputAuthorName"
placeholder="i.e. John Doe">
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="inputAuthorEmail" class="col-lg-4 control-label"
>Email*</label
>
<div class="col-lg-8">
<input
ng-model="Authors.selectedAuthor.email"
ng-change="Authors.updateHeadshotUrl()"
required="required"
type="email"
class="form-control"
id="inputAuthorEmail"
name="inputAuthorEmail"
placeholder="i.e. john.doe@gmail.com"
/>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="inputAuthorWebsite" class="col-lg-4 control-label"
>Website</label
>
<div class="col-lg-8">
<input
ng-model="Authors.selectedAuthor.website"
type="url"
class="form-control"
id="inputAuthorWebsite"
name="inputAuthorWebsite"
placeholder="i.e. http://johndoe.name"
/>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="inputAuthorNickname" class="col-lg-4 control-label">Handle*</label>
<div class="col-lg-8">
<input ng-model="Authors.selectedAuthor.handle"
required="required"
type="text"
class="form-control"
id="inputAuthorNickname"
name="inputAuthorNickname"
placeholder="i.e. johndoe">
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="form-group">
<label for="inputAuthorBio" class="col-lg-2 control-label"
>Bio
<small
>(<span
ng-bind="Authors.selectedAuthor.bio.length || 0"
></span
>/140)</small
></label
>
<div class="col-lg-10">
<textarea
ng-model="Authors.selectedAuthor.bio"
class="form-control"
id="inputAuthorBio"
placeholder="i.e. Brogrammatic Ninja-throwing Rockstar Badassian Wizard JavaScript Superstar. 3+ years experience as a jalapeno poppers brony. YOLO."
></textarea>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="inputAuthorEmail" class="col-lg-4 control-label">Email*</label>
<div class="col-lg-8">
<input ng-model="Authors.selectedAuthor.email" ng-change="Authors.updateHeadshotUrl()"
required="required"
type="email"
class="form-control"
id="inputAuthorEmail"
name="inputAuthorEmail"
placeholder="i.e. john.doe@gmail.com">
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="form-group">
<label
for="inputAuthorHeadshot"
class="col-lg-2 control-label"
>Headshot</label
<div class="col-md-6">
<div class="form-group">
<label for="inputAuthorWebsite" class="col-lg-4 control-label">Website</label>
<div class="col-lg-8">
<input ng-model="Authors.selectedAuthor.website"
type="url"
class="form-control"
id="inputAuthorWebsite"
name="inputAuthorWebsite"
placeholder="i.e. http://johndoe.name"
>
<div class="col-lg-10">
<input
ng-model="Authors.selectedAuthor.headshot"
ng-change="Authors.updateHeadshotUrl()"
type="text"
class="form-control"
id="inputAuthorHeadshot"
placeholder="i.e. https://i.imgur.com/qqpxDmJ.jpg"
/>
<span class="help-block"
>Hint: Link your photo to your email on
<a href="https://gravatar.com">Gravatar</a> or upload to
<a href="https://imgur.com">imgur</a>.</span
>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="form-group">
<label for="inputAuthorBio" class="col-lg-2 control-label">Bio
<small>(<span ng-bind="Authors.selectedAuthor.bio.length || 0"></span>/140)</small></label>
<div class="col-lg-10">
<textarea ng-model="Authors.selectedAuthor.bio"
class="form-control" id="inputAuthorBio" placeholder="i.e. Brogrammatic Ninja-throwing Rockstar Badassian Wizard JavaScript Superstar. 3+ years experience as a jalapeno poppers brony. YOLO."></textarea>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="form-group">
<label for="inputAuthorHeadshot" class="col-lg-2 control-label">Headshot</label>
<div class="col-lg-10">
<input ng-model="Authors.selectedAuthor.headshot" ng-change="Authors.updateHeadshotUrl()"
type="text" class="form-control" id="inputAuthorHeadshot" placeholder="i.e. https://i.imgur.com/qqpxDmJ.jpg">
<span class="help-block">Hint: Link your photo to your email on <a href="https://gravatar.com">Gravatar</a> or upload to <a href="https://imgur.com">imgur</a>.</span>
</div>
</div>
</div>
</div>
</fieldset>
</div>
</div>
@ -200,47 +148,26 @@
<legend>Social</legend>
<div class="form-group">
<label for="inputAuthorTwitter" class="col-lg-2 control-label"
>Twitter</label
>
<label for="inputAuthorTwitter" class="col-lg-2 control-label">Twitter</label>
<div class="col-lg-10">
<input
ng-model="Authors.selectedAuthor.twitter"
type="text"
class="form-control"
id="inputAuthorTwitter"
placeholder="i.e. @johndoe"
/>
<input ng-model="Authors.selectedAuthor.twitter"
type="text" class="form-control" id="inputAuthorTwitter" placeholder="i.e. @johndoe">
</div>
</div>
<div class="form-group">
<label for="inputAuthorFacebook" class="col-lg-2 control-label"
>Facebook URL</label
>
<label for="inputAuthorFacebook" class="col-lg-2 control-label">Facebook URL</label>
<div class="col-lg-10">
<input
ng-model="Authors.selectedAuthor.facebook"
type="text"
class="form-control"
id="inputAuthorFacebook"
placeholder="i.e. facebook.com/johndoe"
/>
<input ng-model="Authors.selectedAuthor.facebook"
type="text" class="form-control" id="inputAuthorFacebook" placeholder="i.e. facebook.com/johndoe">
</div>
</div>
<div class="form-group">
<label for="inputAuthorGooglePlus" class="col-lg-2 control-label"
>Google+ URL</label
>
<label for="inputAuthorGooglePlus" class="col-lg-2 control-label">Google+ URL</label>
<div class="col-lg-10">
<input
ng-model="Authors.selectedAuthor.googleplus"
type="text"
class="form-control"
id="inputAuthorGooglePlus"
placeholder="i.e. plus.google.com/+johndoe"
/>
<input ng-model="Authors.selectedAuthor.googleplus"
type="text" class="form-control" id="inputAuthorGooglePlus" placeholder="i.e. plus.google.com/+johndoe">
</div>
</div>
</fieldset>
@ -252,36 +179,21 @@
<fieldset>
<legend>Developers</legend>
<div class="form-group">
<label for="inputAuthorGithub" class="col-lg-2 control-label"
>Github</label
>
<label for="inputAuthorGithub" class="col-lg-2 control-label">Github</label>
<div class="col-lg-10">
<input
ng-model="Authors.selectedAuthor.github"
type="text"
class="form-control"
id="inputAuthorGithub"
placeholder="i.e. johndoe"
/>
<input ng-model="Authors.selectedAuthor.github"
type="text" class="form-control" id="inputAuthorGithub" placeholder="i.e. johndoe">
</div>
</div>
<div class="form-group">
<label
for="inputAuthorStackOverflow"
class="col-lg-2 control-label"
>StackOverflow</label
>
<label for="inputAuthorStackOverflow" class="col-lg-2 control-label">StackOverflow</label>
<div class="col-lg-10">
<input
ng-model="Authors.selectedAuthor.stackoverflow"
type="text"
class="form-control"
id="inputAuthorStackOverflow"
placeholder="i.e. http://stackoverflow.com/users/151312/johndoe"
/>
<input ng-model="Authors.selectedAuthor.stackoverflow"
type="text" class="form-control" id="inputAuthorStackOverflow" placeholder="i.e. http://stackoverflow.com/users/151312/johndoe">
</div>
</div>
</fieldset>
</fieldset>
</div>
</div>
@ -291,26 +203,19 @@
<legend>Feeds</legend>
<div class="form-group">
<label for="inputAuthorFeedburner" class="col-lg-2 control-label"
>Feedburner</label
>
<label for="inputAuthorFeedburner" class="col-lg-2 control-label">Feedburner</label>
<div class="col-lg-10">
<input
ng-model="Authors.selectedAuthor.feedburner"
type="text"
class="form-control"
id="inputAuthorFeedburner"
placeholder="i.e. johndoe"
/>
<input ng-model="Authors.selectedAuthor.feedburner"
type="text" class="form-control" id="inputAuthorFeedburner" placeholder="i.e. johndoe">
</div>
</div>
</fieldset>
</div>
</div>
<button class="btn btn-primary pull-right" type="submit">
Save &amp; Continue
</button>
<button class="btn btn-primary pull-right" type="submit">Save &amp; Continue</button>
</div>
</form>
</div>

View File

@ -1,134 +1,113 @@
"use strict";
'use strict';
angular
.module("myApp.authors", ["ngRoute"])
angular.module('myApp.authors', ['ngRoute'])
.config([
"$routeProvider",
function ($routeProvider) {
$routeProvider.when("/authors", {
templateUrl: "views/authors/authors.html",
controller: "AuthorsCtrl as Authors",
.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;
});
},
])
.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);
};
filename = Object.keys(desi.authors)[0];
scope.selectedAuthor = desi.authors[filename];
scope.selectAuthor = function (author) {
// TODO watch any change
scope.selectedAuthor = author || scope.selectedAuthor;
scope.updateHeadshotUrlNow();
};
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;
});
}
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();
/*
init();
/*
$scope.$watch(angular.bind(this, function () { return this.selectedAuthor; }), function (newValue, oldValue) {
//$scope.$watch('Authors.selecteAuthor', function (newValue, oldValue)
console.log(newValue, oldValue);
@ -137,5 +116,4 @@ angular
}
}, true);
*/
},
]);
}]);

View File

@ -3,7 +3,7 @@
<div class="row">
<div class="page-header">
<h1>Build Static Site</h1>
<h3><span ng-bind="Build.blogdir"></span></h3>
<h3><span ng-bind="Build.blogdir"></span></h3>
</div>
</div>
@ -11,27 +11,16 @@
<div class="col-lg-12">
<h2>Are you ready?</h2>
<p>
<small
><a
href="https://www.youtube.com/watch?v=-E0oiKjLzTc"
target="_blank"
>Bonesaw</a
>
is READY!</small
>
<small><a href="https://www.youtube.com/watch?v=-E0oiKjLzTc" target="_blank">Bonesaw</a> is READY!</small>
</p>
<p>
<button
ng-click="Build.build(['production', 'development'])"
class="btn btn-danger"
type="button"
>
Build Sites
</button>
<button
ng-click="Build.build(['production', 'development'])"
class="btn btn-danger"
type="button"
>Build Sites</button>
</p>
<span class="help-block"
>Push the RED button... you know you want to!</span
>
<span class="help-block">Push the RED button... you know you want to!</span>
</div>
</div>
@ -40,42 +29,28 @@
<div class="well bs-component">
<fieldset>
<legend>Production</legend>
<p>
<a ng-href="{{Build.display_url}}" target="_blank"
><span ng-bind="Build.display_url"></span
></a>
</p>
<p><a ng-href="{{Build.display_url}}" target="_blank"><span ng-bind="Build.display_url"></span></a></p>
<div class="form-group">
<label for="inputProdCanonicalUrl" class="col-lg-2 control-label"
>Canonical URL</label
>
<label for="inputProdCanonicalUrl" class="col-lg-2 control-label">Canonical URL</label>
<div class="col-lg-10">
<input
ng-model="Build.production_url"
<input ng-model="Build.production_url"
required="required"
placeholder="i.e. https://example.com/myblog"
type="url"
class="form-control"
id="inputProdCanonicalUrl"
/>
<br />
id="inputProdCanonicalUrl">
<br/>
</div>
</div>
<div class="form-group">
<label for="inputProdOutput" class="col-lg-2 control-label"
>Output Path</label
>
<label for="inputProdOutput" class="col-lg-2 control-label">Output Path</label>
<div class="col-lg-10">
<input
<input
disabled
ng-value="Build.blogdir + '/compiled'"
type="text"
class="form-control"
id="inputProdOutput"
disabled
/>
type="text" class="form-control" id="inputProdOutput" disabled>
</div>
</div>
@ -88,9 +63,7 @@
ng-click="Build.build(['production'])"
class="btn btn-primary pull-right"
type="button"
>
Build Production Site
</button>
>Build Production Site</button>
</div>
</div>
</fieldset>
@ -98,16 +71,10 @@
<div class="well bs-component">
<fieldset>
<legend>Development</legend>
<p>
<a ng-href="{{Build.development_url}}" target="_blank"
><span ng-bind="Build.development_url"></span
></a>
</p>
<p><a ng-href="{{Build.development_url}}" target="_blank"><span ng-bind="Build.development_url"></span></a></p>
<div class="form-group">
<label for="inputDevCanonicalUrl" class="col-lg-2 control-label"
>Canonical URL</label
>
<label for="inputDevCanonicalUrl" class="col-lg-2 control-label">Canonical URL</label>
<div class="col-lg-10">
<input
ng-model="Build.development_url"
@ -116,25 +83,18 @@
placeholder="i.e. https://example.com/myblog"
type="url"
class="form-control"
id="inputDevCanonicalUrl"
/>
<br />
id="inputDevCanonicalUrl">
<br/>
</div>
</div>
<div class="form-group">
<label for="inputDevOutput" class="col-lg-2 control-label"
>Output Path</label
>
<label for="inputDevOutput" class="col-lg-2 control-label">Output Path</label>
<div class="col-lg-10">
<input
<input
disabled
ng-value="Build.blogdir + '/compiled_dev'"
type="text"
class="form-control"
id="inputDevOutput"
disabled
/>
type="text" class="form-control" id="inputDevOutput" disabled>
</div>
</div>
@ -147,14 +107,13 @@
ng-click="Build.build(['development'])"
class="btn btn-primary pull-right"
type="button"
>
Build Development Site
</button>
>Build Development Site</button>
</div>
</div>
</fieldset>
</div>
</div>
</div>
</form>
</div>

View File

@ -1,135 +1,100 @@
"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",
});
},
])
.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"];
.controller('BuildCtrl'
, ['$scope', '$location', '$timeout', 'Desirae'
, function ($scope, $location, $timeout, DesiraeService) {
var scope = this
, path = window.path
;
return DesiraeService.meta()
.then(function (desi) {
scope.blogdir = desi.blogdir.path.replace(
/^\/(Users|home)\/[^\/]+\//,
"~/"
);
scope.site = desi.site;
function init() {
scope.extensions = ['md', 'html'];
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 DesiraeService.meta().then(function (desi) {
scope.blogdir = desi.blogdir.path.replace(/^\/(Users|home)\/[^\/]+\//, '~/');
scope.site = desi.site;
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";
}
// this is the responsibility of the build system (Dear Desi), not the library (Desirae)
scope.development_url =
location.href.replace(/\/(#.*)?$/, "") +
path.join("/", "compiled_dev");
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;
});
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.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();
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';
}
// this is the responsibility of the build system (Dear Desi), not the library (Desirae)
scope.development_url = location.href.replace(/\/(#.*)?$/, '') + path.join('/', 'compiled_dev');
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.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) {
return DesiraeService.reset().then(function () {
return init().then(function () {
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.production_url.replace(/(https?:\/\/[^\/#?]+).*/, '$1')
, base_path: scope.production_url.replace(/https?:\/\/[^\/#?]+/, '')
, compiled_path: 'compiled'
, since: 0
, onError: scope.onError
};
} else {
return window.Promise.reject();
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
};
}
};
scope.buildOne = function (envstr) {
return DesiraeService.reset().then(function () {
return init().then(function () {
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.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);
});
});
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();
}]);

View File

@ -14,16 +14,9 @@
<legend>Advanced</legend>
<div class="form-group">
<label for="inputRootConf" class="col-lg-2 control-label"
>Root Pages</label
>
<label for="inputRootConf" class="col-lg-2 control-label">Root Pages</label>
<div class="col-lg-8">
<input
type="text"
class="form-control"
id="inputRootConf"
placeholder="i.e. images"
/>
<input type="text" class="form-control" id="inputRootConf" placeholder="i.e. images">
</div>
<div class="col-lg-2">
<button class="btn" type="button">Add</button>
@ -31,16 +24,9 @@
</div>
<div class="form-group">
<label for="inputThemesConf" class="col-lg-2 control-label"
>Themes</label
>
<label for="inputThemesConf" class="col-lg-2 control-label">Themes</label>
<div class="col-lg-8">
<input
type="text"
class="form-control"
id="inputThemesConf"
placeholder="i.e. images"
/>
<input type="text" class="form-control" id="inputThemesConf" placeholder="i.e. images">
</div>
<div class="col-lg-2">
<button class="btn" type="button">Add</button>
@ -48,16 +34,9 @@
</div>
<div class="form-group">
<label for="inputCollectionsConf" class="col-lg-2 control-label"
>Collections</label
>
<label for="inputCollectionsConf" class="col-lg-2 control-label">Collections</label>
<div class="col-lg-8">
<input
type="text"
class="form-control"
id="inputCollectionsConf"
placeholder="i.e. images"
/>
<input type="text" class="form-control" id="inputCollectionsConf" placeholder="i.e. images">
</div>
<div class="col-lg-2">
<button class="btn" type="button">Add</button>
@ -65,16 +44,9 @@
</div>
<div class="form-group">
<label for="inputAssetsConf" class="col-lg-2 control-label"
>Assets</label
>
<label for="inputAssetsConf" class="col-lg-2 control-label">Assets</label>
<div class="col-lg-8">
<input
type="text"
class="form-control"
id="inputAssetsConf"
placeholder="i.e. images"
/>
<input type="text" class="form-control" id="inputAssetsConf" placeholder="i.e. images">
</div>
<div class="col-lg-2">
<button class="btn" type="button">Add</button>
@ -82,24 +54,19 @@
</div>
<div class="form-group">
<label for="inputWidgetsConf" class="col-lg-2 control-label"
>Widgets</label
>
<label for="inputWidgetsConf" class="col-lg-2 control-label">Widgets</label>
<div class="col-lg-8">
<input
type="text"
class="form-control"
id="inputWidgetsConf"
placeholder="i.e. images"
/>
<input type="text" class="form-control" id="inputWidgetsConf" placeholder="i.e. images">
</div>
<div class="col-lg-2">
<button class="btn" type="button">Add</button>
</div>
</div>
</fieldset>
</fieldset>
</div>
</div>
</div>
</form>
</div>

View File

@ -1,16 +1,13 @@
"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() {
}]);

View File

@ -11,48 +11,27 @@
<div class="well bs-component">
<fieldset>
<div class="form-group">
<label for="inputEmail" class="col-lg-2 control-label"
>Email</label
>
<label for="inputEmail" class="col-lg-2 control-label">Email</label>
<div class="col-lg-10">
<input
type="text"
class="form-control"
id="inputEmail"
placeholder="Email"
/>
<input type="text" class="form-control" id="inputEmail" placeholder="Email">
</div>
</div>
<div class="form-group">
<label for="inputPassword" class="col-lg-2 control-label"
>Password</label
>
<label for="inputPassword" class="col-lg-2 control-label">Password</label>
<div class="col-lg-10">
<input
type="password"
class="form-control"
id="inputPassword"
placeholder="Password"
/>
<input type="password" class="form-control" id="inputPassword" placeholder="Password">
<div class="checkbox">
<label> <input type="checkbox" /> Checkbox </label>
<label>
<input type="checkbox"> Checkbox
</label>
</div>
</div>
</div>
<div class="form-group">
<label for="textArea" class="col-lg-2 control-label"
>Textarea</label
>
<label for="textArea" class="col-lg-2 control-label">Textarea</label>
<div class="col-lg-10">
<textarea
class="form-control"
rows="3"
id="textArea"
></textarea>
<span class="help-block"
>A longer block of help text that breaks onto a new line and
may extend beyond one line.</span
>
<textarea class="form-control" rows="3" id="textArea"></textarea>
<span class="help-block">A longer block of help text that breaks onto a new line and may extend beyond one line.</span>
</div>
</div>
<div class="form-group">
@ -60,24 +39,13 @@
<div class="col-lg-10">
<div class="radio">
<label>
<input
type="radio"
name="optionsRadios"
id="optionsRadios1"
value="option1"
checked=""
/>
<input type="radio" name="optionsRadios" id="optionsRadios1" value="option1" checked="">
Option one is this
</label>
</div>
<div class="radio">
<label>
<input
type="radio"
name="optionsRadios"
id="optionsRadios2"
value="option2"
/>
<input type="radio" name="optionsRadios" id="optionsRadios2" value="option2">
Option two can be something else
</label>
</div>
@ -93,7 +61,7 @@
<option>4</option>
<option>5</option>
</select>
<br />
<br>
<select multiple="" class="form-control">
<option>1</option>
<option>2</option>
@ -110,15 +78,6 @@
</div>
</div>
</fieldset>
<div
id="source-button"
class="btn btn-primary btn-xs"
style="display: none"
>
&lt; &gt;
</div>
</div>
<div id="source-button" class="btn btn-primary btn-xs" style="display: none;">&lt; &gt;</div></div>
</div>
</div>
</form>
</div>

View File

@ -3,7 +3,7 @@
<div class="row">
<div class="page-header">
<h1>Write a Post</h1>
<h3><span ng-bind="Post.selected.post.yml.permalink"></span></h3>
<h3><span ng-bind="Post.selected.post.yml.permalink" ></span></h3>
</div>
</div>
@ -12,9 +12,7 @@
<div class="well bs-component">
<fieldset>
<div class="form-group">
<label for="inputPostTitle" class="col-lg-2 control-label"
>Title*</label
>
<label for="inputPostTitle" class="col-lg-2 control-label">Title*</label>
<div class="col-lg-10">
<input
required="required"
@ -24,7 +22,7 @@
class="form-control"
id="inputPostTitle"
placeholder="i.e. My First Post"
/>
>
</div>
</div>
<!--
@ -42,9 +40,7 @@
</div>
-->
<div class="form-group">
<label for="textAreaPost" class="col-lg-2 control-label"
>Post*</label
>
<label for="textAreaPost" class="col-lg-2 control-label">Post*</label>
<div class="col-lg-10">
<textarea
required="required"
@ -54,10 +50,8 @@
rows="20"
id="textAreaPost"
placeholder="i.e. I Don't Know Anything About the Gold Standard... But I Do Love Little Kittens!"
></textarea>
<span class="help-block"
>Put your lovely post here, in github-flavored markdown!</span
>
></textarea>
<span class="help-block">Put your lovely post here, in github-flavored markdown!</span>
</div>
</div>
@ -69,13 +63,10 @@
ng-model="Post.selected.format"
ng-change="Post.onChange()"
class="form-control"
id="select"
>
id="select">
<option value="html">HTML</option>
<option selected="selected" value="md">Markdown</option>
<option disabled="disabled" value="jade">
Jade (Not Implemented)
</option>
<option disabled="disabled" value="jade">Jade (Not Implemented)</option>
</select>
<!--div class="checkbox">
<label>
@ -86,51 +77,35 @@
</div>
<div class="form-group">
<label for="textAreaDesc" class="col-lg-2 control-label"
>Description
<small
>(<span
ng-bind="Post.selected.post.yml.description.length || 0"
></span
>/140)</small
></label
>
<label for="textAreaDesc" class="col-lg-2 control-label">Description
<small>(<span ng-bind="Post.selected.post.yml.description.length || 0"></span>/140)</small></label>
<div class="col-lg-10">
<textarea
ng-change="Post.onChange()"
ng-model="Post.selected.post.yml.description"
placeholder="i.e. An alternate recipe for Peeta Mellarks's famous apple goat cheese tarts using only ingredients available in district 10"
class="form-control"
rows="2"
id="textAreaDesc"
></textarea>
<span class="help-block"
>The description is often used by search engines as the
snippit shown in search results.</span
>
rows="2"
id="textAreaDesc"></textarea>
<span class="help-block">The description is often used by search engines as the snippit shown in search results.</span>
</div>
</div>
<div class="form-group">
<label for="textAreaYaml" class="col-lg-2 control-label"
>Frontmatter</label
>
<label for="textAreaYaml" class="col-lg-2 control-label">Frontmatter</label>
<div class="col-lg-10">
<textarea
required="required"
ng-change="Post.onFrontmatterChange()"
ng-model="Post.selected.post.frontmatter"
class="form-control"
rows="5"
id="textAreaYaml"
></textarea>
rows="5"
id="textAreaYaml"></textarea>
</div>
</div>
<div class="form-group">
<label for="inputPostAbsPath" class="col-lg-2 control-label"
>Source Path</label
>
<label for="inputPostAbsPath" class="col-lg-2 control-label">Source Path</label>
<div class="col-lg-10">
<input
required="required"
@ -141,14 +116,12 @@
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
>
<label for="inputPostAbsPath" class="col-lg-2 control-label">Output Path</label>
<div class="col-lg-10">
<input
required="required"
@ -159,21 +132,18 @@
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"
>Links</label
>
<label for="inputPostAbsPath" class="col-lg-2 control-label">Links</label>
<div class="col-lg-10">
<p class="help-block">
<a ng-href="{{Post.selected.url}}"
><span ng-bind="Post.selected.url"></span
></a>
<p class="help-block"
><a ng-href="{{Post.selected.url}}"><span
ng-bind="Post.selected.url"></span></a>
</p>
<input
<input
required="required"
ng-model="Post.selected.markdown"
ng-change="Post.onChange()"
@ -181,8 +151,8 @@
class="form-control"
id="inputPostMarkdown"
placeholder="i.e. [My First Post](/articles/my-first-post.html)"
/>
<input
>
<input
required="required"
ng-model="Post.selected.ahref"
ng-change="Post.onChange()"
@ -190,10 +160,10 @@
class="form-control"
id="inputPostAhref"
placeholder="i.e. <a href='/articles/my-first-post.html'>My First Post</a>"
/>
>
</div>
</div>
<!--div class="form-group">
<label for="inputPostAbsPath" class="col-lg-2 control-label">URL</label>
<div class="col-lg-10">
@ -209,7 +179,7 @@
>
</div>
</div-->
<!--
<div class="form-group">
<label for="select" class="col-lg-2 control-label">Selects</label>
@ -259,21 +229,17 @@
<div class="form-group">
<div class="col-lg-10 col-lg-offset-2">
<!--button class="btn btn-default">Save Draft</button-->
<button type="submit" class="btn btn-primary pull-right">
Publish
</button>
<button
type="submit"
class="btn btn-primary pull-right"
>Publish</button>
</div>
</div>
</fieldset>
<div
id="source-button"
class="btn btn-primary btn-xs"
style="display: none"
>
&lt; &gt;
</div>
<div id="source-button" class="btn btn-primary btn-xs" style="display: none;">&lt; &gt;</div>
</div>
</div>
</div>
</form>
</div>

View File

@ -1,269 +1,210 @@
"use strict";
angular
.module("myApp.post", ["ngRoute"])
'use strict';
angular.module('myApp.post', ['ngRoute'])
.config([
"$routeProvider",
function ($routeProvider) {
$routeProvider.when("/post", {
templateUrl: "views/post/post.html",
controller: "PostCtrl as Post",
});
},
])
.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) {
/*
.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;
});
scope.extensions = ["md", "html"];
if (/dropbox/.test(scope.site.base_url)) {
scope.env.explicitIndexes = true;
}
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();
}
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.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.extensions = ['md', 'html'];
}
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;
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.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;
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;
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;
post = scope.selected.post;
post = scope.selected.post;
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"
);
}
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();
}
};
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.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');
}
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];
}
});
scope.onChange();
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);
}
var files = [];
files.push({
path: scope.selected.filepath,
contents:
"---\n" +
scope.selected.post.frontmatter.trim() +
"\n" +
"---\n" +
"\n" +
scope.selected.post.body.trim(),
});
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;
}
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;
});
};
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();
init();
},
]);
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();
}]);

View File

@ -2,19 +2,11 @@
<div class="row">
<div class="page-header">
<h1>Site Configuration</h1>
<h3>
<span ng-bind="Site.blogdir"></span
><button
class="btn btn-primary pull-right"
type="submit"
form="formSiteConf"
>
Save &amp; Continue
</button>
</h3>
<h3><span ng-bind="Site.blogdir"></span><button class="btn btn-primary pull-right" type="submit" form="formSiteConf">Save &amp; Continue</button></h3>
</div>
</div>
<form id="formSiteConf" class="form-horizontal" ng-submit="Site.upsert()">
<div class="row">
<div class="col-lg-12">
@ -23,59 +15,42 @@
<legend>General</legend>
<div class="form-group">
<label for="inputBlogTitle" class="col-lg-3 control-label"
>Title</label
>
<label for="inputBlogTitle" class="col-lg-3 control-label">Title</label>
<div class="col-lg-9">
<input
<input
ng-model="Site.site.title"
required="required"
type="text"
class="form-control"
id="inputBlogTitle"
placeholder="My Awesome Blog"
/>
type="text" class="form-control" id="inputBlogTitle" placeholder="My Awesome Blog">
</div>
</div>
<div class="form-group">
<label for="inputBlogTagline" class="col-lg-3 control-label"
>Tagline</label
>
<label for="inputBlogTagline" class="col-lg-3 control-label">Tagline</label>
<div class="col-lg-9">
<input
<input
ng-model="Site.site.tagline"
type="text"
class="form-control"
id="inputBlogTagline"
placeholder="i.e. I have not failed, I've just found 10,000 ways that do not work."
/>
type="text" class="form-control" id="inputBlogTagline"
placeholder="i.e. I have not failed, I've just found 10,000 ways that do not work.">
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="form-group">
<label for="inputSiteDesc" class="col-lg-3 control-label"
>Description
<small
>(<span ng-bind="Site.site.description.length || 0"></span
>/140)</small
></label
>
<label for="inputSiteDesc" class="col-lg-3 control-label">Description
<small>(<span ng-bind="Site.site.description.length || 0"></span>/140)</small></label>
<div class="col-lg-9">
<textarea
ng-model="Site.site.description"
required="required"
class="form-control"
id="inputSiteDesc"
placeholder="i.e. For tips and tricks for try-hard ethical master cleanses, 3 wolf moons on Tumblr, disruptive lo-fi, preserving narwhals and eating kale chips, etc. YOLO."
></textarea>
class="form-control" id="inputSiteDesc" placeholder="i.e. For tips and tricks for try-hard ethical master cleanses, 3 wolf moons on Tumblr, disruptive lo-fi, preserving narwhals and eating kale chips, etc. YOLO."></textarea>
</div>
</div>
</div>
</div>
<!-- TODO -->
<!--
<div class="form-group">
@ -94,9 +69,7 @@
-->
<div class="form-group">
<label for="inputProdUrl" class="col-lg-3 control-label"
>URL</label
>
<label for="inputProdUrl" class="col-lg-3 control-label">URL</label>
<div class="col-lg-9">
<input
ng-model="Site.url"
@ -105,38 +78,32 @@
placeholder="i.e. https://example.com/myblog"
type="text"
class="form-control"
id="inputProdHost"
/>
<br />
id="inputProdHost">
<br/>
<span class="help-block"
><span class="text-muted" ng-bind="Site.base_url"></span
><strong
><span ng-bind="Site.base_path"></span
><span ng-bind="Site.dropboxIndex"></span
></strong>
</span>
</div>
</div>
<div class="form-group">
<label for="inputProdOutput" class="col-lg-3 control-label"
>Output Path</label
>
<label for="inputProdOutput" class="col-lg-3 control-label">Output Path</label>
<div class="col-lg-9">
<input
<input
ng-value="Site.blogdir + '/compiled'"
type="text"
class="form-control"
id="inputProdOutput"
disabled
/>
type="text" class="form-control" id="inputProdOutput" disabled>
</div>
</div>
</fieldset>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="well bs-component">
@ -144,56 +111,47 @@
<legend>Development</legend>
<div class="form-group">
<label for="inputDevHost" class="col-lg-3 control-label"
>Base URL</label
>
<label for="inputDevHost" class="col-lg-3 control-label">Base URL</label>
<div class="col-lg-9">
<input
value="https://local.dear.desi:65080"
type="url"
class="form-control"
id="inputDevHost"
disabled
/>
<br />
disabled>
<br/>
</div>
</div>
<div class="form-group">
<label for="inputDevBase" class="col-lg-3 control-label"
>Base Path</label
>
<label for="inputDevBase" class="col-lg-3 control-label">Base Path</label>
<div class="col-lg-9">
<input
value="/compiled_dev"
placeholder="i.e. /blog in https://example.com/blog"
type="text"
class="form-control"
id="inputDevBase"
disabled
/>
type="text" class="form-control" id="inputDevBase"
disabled>
</div>
</div>
<div class="form-group">
<label for="inputDevOutput" class="col-lg-3 control-label"
>Output Path</label
>
<label for="inputDevOutput" class="col-lg-3 control-label">Output Path</label>
<div class="col-lg-9">
<input
ng-value="Site.blogdir + '/compiled_dev'"
type="text"
class="form-control"
id="inputDevOutput"
disabled
/>
disabled>
</div>
</div>
</fieldset>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="well bs-component">
@ -201,9 +159,7 @@
<legend>Plugins</legend>
<div class="form-group">
<label for="inputGoogleAnalyticsId" class="col-lg-3 control-label"
>Google Analytics ID</label
>
<label for="inputGoogleAnalyticsId" class="col-lg-3 control-label">Google Analytics ID</label>
<div class="col-lg-9">
<input
ng-model="Site.site.google_analytics_tracking_id"
@ -211,35 +167,30 @@
type="text"
class="form-control"
id="inputGoogleAnalyticsId"
/>
<br />
>
<br/>
<small>Found in the Admin section of Google Analytics</small>
</div>
</div>
<div class="form-group">
<label for="inputDisqusShortname" class="col-lg-3 control-label"
>Disqus Shortname</label
>
<label for="inputDisqusShortname" class="col-lg-3 control-label">Disqus Shortname</label>
<div class="col-lg-9">
<input
ng-model="Site.site.disqus_shortname"
placeholder="i.e. johndoe-blog"
type="text"
class="form-control"
id="inputDisqusShortname"
/>
<br />
type="text" class="form-control" id="inputDisqusShortname"
>
<br/>
<small>Found under Admin &gt; Settings in Disqus</small>
</div>
</div>
</fieldset>
</div>
</div>
</div>
<button class="btn btn-primary pull-right" type="submit">
Save &amp; Continue
</button>
<button class="btn btn-primary pull-right" type="submit">Save &amp; Continue</button>
</form>
</div>

View File

@ -1,124 +1,106 @@
"use strict";
'use strict';
angular
.module("myApp.site", ["ngRoute"])
angular.module('myApp.site', ['ngRoute'])
.config([
"$routeProvider",
function ($routeProvider) {
$routeProvider.when("/site", {
templateUrl: "views/site/site.html",
controller: "SiteCtrl as Site",
});
},
])
.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;
.controller('SiteCtrl', ['$scope', '$location', 'Desirae', function ($scope, $location, Desirae) {
var scope = this
;
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;
}
function init() {
console.log('desi loading');
Desirae.meta().then(function (desi) {
scope.blogdir = desi.blogdir.path.replace(/^\/(Users|home)\/[^\/]+\//, '~/');
scope.site = desi.site;
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;
});
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 = function () {
console.log("new url [0]", scope.url);
var parts = Desirae.splitUrl(scope.url),
url;
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;
});
}
if (!parts) {
scope.base_url = "";
scope.base_path = "";
return;
}
scope.onChange = function () {
console.log('new url [0]', scope.url);
var parts = Desirae.splitUrl(scope.url)
, url
;
scope.base_url = parts.baseUrl;
scope.base_path = parts.basePath;
if (!parts) {
scope.base_url = '';
scope.base_path = '';
return;
}
scope.dropboxIndex = "";
scope.base_url = parts.baseUrl;
scope.base_path = parts.basePath;
url = Desirae.gdrive2host(scope.url);
scope.dropboxIndex = '';
if (!url && Desirae.dropbox2host(scope.url)) {
url = Desirae.dropbox2host(scope.url);
scope.dropboxIndex = "/index.html";
}
url = Desirae.gdrive2host(scope.url)
;
console.log("new url [1]", url);
if (!url && Desirae.dropbox2host(scope.url)) {
if (url) {
parts = Desirae.splitUrl(url);
scope.base_url = parts.baseUrl;
scope.base_path = parts.basePath;
}
url = Desirae.dropbox2host(scope.url);
scope.dropboxIndex = '/index.html';
}
//scope.url = scope.base_url + scope.base_path;
};
console.log('new url [1]', url);
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 });
if (url) {
parts = Desirae.splitUrl(url);
scope.base_url = parts.baseUrl;
scope.base_path = parts.basePath;
}
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;
});
};
//scope.url = scope.base_url + scope.base_path;
};
init();
},
]);
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();
}]);

View File

@ -1,13 +1,16 @@
"use strict";
'use strict';
describe("myApp.view1 module", function () {
beforeEach(module("myApp.view1"));
describe('myApp.view1 module', function() {
describe("view1 controller", function () {
it("should ....", inject(function ($controller) {
beforeEach(module('myApp.view1'));
describe('view1 controller', function(){
it('should ....', inject(function($controller) {
//spec body
var view1Ctrl = $controller("View1Ctrl");
var view1Ctrl = $controller('View1Ctrl');
expect(view1Ctrl).toBeDefined();
}));
});
});
});