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 Apache License
Public License, v. 2.0. If a copy of the MPL was not distributed Version 2.0, January 2004
with this file, You can obtain one at http://www.apache.org/licenses/
https://mozilla.org/MPL/2.0/.
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. 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. you might have meant to go to [DearDesi](http://dear.desi) instead.
Otherwise, if you're a cyborg, wizzard, or web developer: carry on. Otherwise, if you're a cyborg, wizzard, or web developer: carry on.
# Dear Desi Dear Desi
=========
These instructions cover the command line only. These instructions cover the command line only.
If you want instructions for the web interface, head over to [DearDesi](http://dear.desi). 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, This assumes that you already have `git` and `node` installed,
otherwise see [node-installer.sh](https://git.coolaj86.com/coolaj86/node-installer.sh) otherwise see [node-installer.sh](https://git.coolaj86.com/coolaj86/node-installer.sh)
@ -33,20 +36,22 @@ npm install -g desi
That was easy That was easy
## Quick Usage Quick Usage
-------
- desi init -d ~/Desktop/new-blog * desi init -d ~/Desktop/new-blog
- pushd ~/Desktop/new-blog * pushd ~/Desktop/new-blog
- desi post "my first post" * desi post "my first post"
- desi build * desi build
- desi serve * desi serve
<http://local.dear.desi:65080> <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). **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. 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: 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 1. start by following the Automated procedure above
2. copy over your posts/articles folder(s) 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) 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 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` 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: 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. 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) 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) 2. Create a site file as `site.yml`, similar to [this example](https://github.com/DearDesi/deardesi/blob/master/example/site.yml)
**Important Things** **Important Things**
- `site.yml.base_url` - the point of ownership (usually blog.example.com or example.com) * `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`) * `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.name` - most templates use this
- `authors/me.yml.email` - and this * `authors/me.yml.email` - and this
- `authors/me.yml.twitter` - 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 ```bash
desi build -d /path/to/blog 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> 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 // Declare app level module which depends on views, and components
angular angular.module('myApp', [
.module("myApp", [ 'ngRoute',
"ngRoute", 'myApp.about',
"myApp.about", 'myApp.authors',
"myApp.authors", 'myApp.site',
"myApp.site", 'myApp.build',
"myApp.build", 'myApp.configure',
"myApp.configure", 'myApp.post',
"myApp.post", 'myApp.version',
"myApp.version", 'myApp.services'
"myApp.services", ]).
]) config(['$routeProvider', function ($routeProvider) {
.config([ $routeProvider.otherwise({redirectTo: '/about'});
"$routeProvider", }]);
function ($routeProvider) {
$routeProvider.otherwise({ redirectTo: "/about" });
},
]);

View File

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

View File

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

View File

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

View File

@ -1,13 +1,9 @@
"use strict"; 'use strict';
angular angular.module('myApp.version.interpolate-filter', [])
.module("myApp.version.interpolate-filter", [])
.filter("interpolate", [ .filter('interpolate', ['version', function(version) {
"version", return function(text) {
function (version) { return String(text).replace(/\%VERSION\%/mg, version);
return function (text) {
return String(text).replace(/\%VERSION\%/gm, version);
}; };
}, }]);
]);

View File

@ -1,19 +1,15 @@
"use strict"; 'use strict';
describe("myApp.version module", function () { describe('myApp.version module', function() {
beforeEach(module("myApp.version")); beforeEach(module('myApp.version'));
describe("interpolate filter", function () { describe('interpolate filter', function() {
beforeEach( beforeEach(module(function($provide) {
module(function ($provide) { $provide.value('version', 'TEST_VER');
$provide.value("version", "TEST_VER"); }));
})
);
it("should replace VERSION", inject(function (interpolateFilter) { it('should replace VERSION', inject(function(interpolateFilter) {
expect(interpolateFilter("before %VERSION% after")).toEqual( expect(interpolateFilter('before %VERSION% after')).toEqual('before TEST_VER after');
"before TEST_VER after"
);
})); }));
}); });
}); });

View File

@ -1,13 +1,9 @@
"use strict"; 'use strict';
angular angular.module('myApp.version.version-directive', [])
.module("myApp.version.version-directive", [])
.directive("appVersion", [ .directive('appVersion', ['version', function(version) {
"version", return function(scope, elm, attrs) {
function (version) {
return function (scope, elm, attrs) {
elm.text(version); elm.text(version);
}; };
}, }]);
]);

View File

@ -1,16 +1,16 @@
"use strict"; 'use strict';
describe("myApp.version module", function () { describe('myApp.version module', function() {
beforeEach(module("myApp.version")); beforeEach(module('myApp.version'));
describe("app-version directive", function () { describe('app-version directive', function() {
it("should print current version", function () { it('should print current version', function() {
module(function ($provide) { module(function($provide) {
$provide.value("version", "TEST_VER"); $provide.value('version', 'TEST_VER');
}); });
inject(function ($compile, $rootScope) { inject(function($compile, $rootScope) {
var element = $compile("<span app-version></span>")($rootScope); var element = $compile('<span app-version></span>')($rootScope);
expect(element.text()).toEqual("TEST_VER"); expect(element.text()).toEqual('TEST_VER');
}); });
}); });
}); });

View File

@ -1,9 +1,8 @@
"use strict"; 'use strict';
angular angular.module('myApp.version', [
.module("myApp.version", [ 'myApp.version.interpolate-filter',
"myApp.version.interpolate-filter", 'myApp.version.version-directive'
"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 () { describe('myApp.version module', function() {
beforeEach(module("myApp.version")); beforeEach(module('myApp.version'));
describe("version service", function () { describe('version service', function() {
it("should return current version", inject(function (version) { it('should return current version', inject(function(version) {
expect(version).toEqual("0.1"); 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) { module.exports.create = function (options) {
var restful = {}; var restful = {}
;
// //
// Required for desirae // Required for desirae
// //
@ -12,24 +16,18 @@ module.exports.create = function (options) {
return; return;
} }
var opts = {}, var opts = {}
dirnames = , dirnames = req.query.dir && [req.query.dir] || (req.query.dirs && req.query.dirs.split(/,/g)) || req.body.dirs
(req.query.dir && [req.query.dir]) || ;
(req.query.dirs && req.query.dirs.split(/,/g)) ||
req.body.dirs;
if (!dirnames || !dirnames.length) { if (!dirnames || !dirnames.length) {
res.send({ res.send({ error: "please specify GET w/ req.query.dir or POST w/ _method=GET&dirs=path/to/thing,..." });
error:
"please specify GET w/ req.query.dir or POST w/ _method=GET&dirs=path/to/thing,...",
});
return; return;
} }
if ( if (!dirnames.every(function (dirname) {
!dirnames.every(function (dirname) { return 'string' === typeof dirname;
return "string" === typeof dirname; })) {
})
) {
res.send({ error: "malformed request: " + JSON.stringify(dirnames) }); res.send({ error: "malformed request: " + JSON.stringify(dirnames) });
return; return;
} }
@ -44,13 +42,13 @@ module.exports.create = function (options) {
opts.extensions = req.query.extensions.split(/,/g); opts.extensions = req.query.extensions.split(/,/g);
} }
if ("true" === req.query.dotfiles) { if ('true' === req.query.dotfiles) {
opts.dotfiles = true; opts.dotfiles = true;
} }
if ("false" === req.query.sha1sum) { if ('false' === req.query.sha1sum) {
opts.sha1sum = false; opts.sha1sum = false;
} }
if ("true" === req.query.contents) { if ('true' === req.query.contents) {
opts.contents = true; opts.contents = true;
} }
@ -70,15 +68,11 @@ module.exports.create = function (options) {
return; return;
} }
var filepaths = var filepaths = req.query.path && [req.query.path] || (req.query.paths && req.query.paths.split(/,/g)) || req.body.paths
(req.query.path && [req.query.path]) || ;
(req.query.paths && req.query.paths.split(/,/g)) ||
req.body.paths;
if (!filepaths || !filepaths.length) { if (!filepaths || !filepaths.length) {
res.send({ res.send({ error: "please specify GET w/ req.query.path or POST _method=GET&paths=path/to/thing,..." });
error:
"please specify GET w/ req.query.path or POST _method=GET&paths=path/to/thing,...",
});
return; return;
} }
@ -92,15 +86,15 @@ module.exports.create = function (options) {
}; };
restful.putFiles = function (req, res, next) { restful.putFiles = function (req, res, next) {
if ( if (!(/^POST|PUT$/i.test(req.method) || /^POST|PUT$/i.test(req.query._method))) {
!(/^POST|PUT$/i.test(req.method) || /^POST|PUT$/i.test(req.query._method))
) {
next(); next();
return; return;
} }
var opts = {}, var opts = {}
files = req.body.files; , files = req.body.files
;
if (!files || !files.length) { if (!files || !files.length) {
res.send({ error: "please specify POST w/ req.body.files" }); res.send({ error: "please specify POST w/ req.body.files" });
return; return;
@ -113,16 +107,16 @@ module.exports.create = function (options) {
}; };
restful.copy = function (req, res, next) { restful.copy = function (req, res, next) {
if ( if (!(/^POST|PUT$/i.test(req.method) || /^POST|PUT$/i.test(req.query._method))) {
!(/^POST|PUT$/i.test(req.method) || /^POST|PUT$/i.test(req.query._method))
) {
next(); next();
return; return;
} }
var opts = {}, var opts = {}
files = req.body.files; , files = req.body.files
if ("object" !== typeof files || !Object.keys(files).length) { ;
if ('object' !== typeof files || !Object.keys(files).length) {
res.send({ error: "please specify POST w/ req.body.files" }); res.send({ error: "please specify POST w/ req.body.files" });
return; return;
} }

View File

@ -2,93 +2,50 @@
<!--[if lt IE 7]> <html lang="en" ng-app="myApp" class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]--> <!--[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 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 IE 8]> <html lang="en" ng-app="myApp" class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <!--[if gt IE 8]><!--> <html lang="en" ng-app="myApp" class="no-js"> <!--<![endif]-->
<html lang="en" ng-app="myApp" class="no-js"> <head>
<!--<![endif]--> <meta charset="utf-8">
<head> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>Desi, the DIY Blog Platform</title> <title>Desi, the DIY Blog Platform</title>
<meta <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.">
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 --> <!-- Style -->
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1">
<link <link rel="stylesheet" href="bower_components/html5-boilerplate/css/normalize.css">
rel="stylesheet" <link rel="stylesheet" href="bower_components/html5-boilerplate/css/main.css">
href="bower_components/html5-boilerplate/css/normalize.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">
<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> <script src="bower_components/html5-boilerplate/js/vendor/modernizr-2.6.2.min.js"></script>
</head> </head>
<body> <body>
<!--[if lt IE 7]> <!--[if lt IE 7]>
<p class="browsehappy"> <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>
You are using an <strong>outdated</strong> browser. Please
<a href="http://browsehappy.com/">upgrade your browser</a> to improve
your experience.
</p>
<![endif]--> <![endif]-->
<!--.navbar.navbar-default.navbar-fixed-top--> <!--.navbar.navbar-default.navbar-fixed-top-->
<div <div style="margin-bottom: 0; border-top-width: 0;" class="navbar navbar-default">
style="margin-bottom: 0; border-top-width: 0"
class="navbar navbar-default"
>
<div class="container"> <div class="container">
<div class="navbar-header"> <div class="navbar-header">
<div <div
style="padding-top: 9px; padding-left: 9px; padding-bottom: 9px" style="padding-top: 9px; padding-left: 9px; padding-bottom: 9px;"
class="pull-left" class="pull-left"><img
>
<img
ng-src="http://dropsha.re/files/VY15+v8/desirae-parker-crop.jpg" ng-src="http://dropsha.re/files/VY15+v8/desirae-parker-crop.jpg"
style="border: 1px solid grey; height: 54px; width: 54px" style="border: 1px solid grey; height: 54px; width: 54px;"
class="navbar-logo" class="navbar-logo"/></div>
/> <a href="#/"
</div> style="padding-top: 23px; padding-left: 25px;"
<a class="navbar-brand">Desi</a>
href="#/"
style="padding-top: 23px; padding-left: 25px"
class="navbar-brand"
>Desi</a
>
<div style="padding-top: 9px"> <div style="padding-top: 9px;">
<button <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>
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> </div>
<div <div id="navbar-main" ng-class="!navCollapsed &amp;&amp; 'in'" class="navbar-collapse collapse">
id="navbar-main" <ul style="padding-top: 9px;" class="nav navbar-nav">
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="#/authors">Authors</a></li>
<li><a href="#/site">Site</a></li> <li><a href="#/site">Site</a></li>
<li><a href="#/post">Post</a></li> <li><a href="#/post">Post</a></li>
@ -107,44 +64,24 @@
<!-- also needs updating at http://plus.google.com/me/about/edit/co --> <!-- 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="mailto:develop@dear.desi" rel="me">develop@dear.desi</a>
| |
<a href="https://twitter.com/dearbesiblog?rel=author" rel="me" <a href="https://twitter.com/dearbesiblog?rel=author" rel="me">Twitter</a>
>Twitter</a
>
<!--a href="https://www.facebook.com/coolaj86?rel=author" rel="me">Facebook</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" <a href="https://github.com/DearDesi/desirae?rel=author" rel="me">Github</a> (v<span app-version></span>)
>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://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" <a href="https://www.youtube.com/watch?v=pFAKAWP_sec" rel="me">YouTube</a>
>YouTube</a
>
| |
<a href="http://www.apache.org/licenses/LICENSE-2.0" <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache 2 License</a>
>Apache 2 License</a
>
| |
<a href="http://opensource.org/licenses/MIT">MIT License</a> <a href="http://opensource.org/licenses/MIT">MIT License</a>
</p> </p>
<p> <p>© AJ ONeal Tech LLC 2015
© AJ ONeal Tech LLC 2015 with help from with help from
<a <a href="http://angularjs.org" target="_blank" title="Superheroic JavaScript MVW Framework">AngularJS</a>,
href="http://angularjs.org" <a href="http://iojs.org" target="_blank"
target="_blank" title="Open source, cross-platform server-side JavaScript runtime environment">io.js</a>,
title="Superheroic JavaScript MVW Framework" and <a href="http://twitter.github.com/bootstrap/" target="_blank">Twitter Bootstrap</a>
>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> </p>
</center> </center>
</footer> </footer>
@ -188,5 +125,6 @@
<script src="components/version/version.js"></script> <script src="components/version/version.js"></script>
<script src="components/version/version-directive.js"></script> <script src="components/version/version-directive.js"></script>
<script src="components/version/interpolate-filter.js"></script> <script src="components/version/interpolate-filter.js"></script>
</body>
</body>
</html> </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", "description": "A nice, friendly tool to help you get set up and start blogging, built on the Desirae blogging platform",
"main": "server.js", "main": "server.js",
"scripts": { "scripts": {
"prettier": "prettier --write './**/*.{js,css,json,md,html}'",
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"bin": { "bin": {
@ -32,7 +31,7 @@
"octopress" "octopress"
], ],
"author": "AJ ONeal <coolaj86@gmail.com> (https://coolaj86.com/)", "author": "AJ ONeal <coolaj86@gmail.com> (https://coolaj86.com/)",
"license": "MPL-2.0", "license": "(MIT OR ISC OR Apache-2.0)",
"bugs": { "bugs": {
"url": "https://git.coolaj86.com/coolaj86/deardesi.js/issues" "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) { function create(options) {
var connect = require("connect"), var connect = require('connect')
query = require("connect-query"), , query = require('connect-query')
bodyParser = require("body-parser"), , bodyParser = require('body-parser')
serveStatic = require("serve-static"), , serveStatic = require('serve-static')
send = require("connect-send-json"), , send = require('connect-send-json')
app = connect(),
restful = require("./desirae-http-api").create(options); , app = connect()
, restful = require('./desirae-http-api').create(options)
;
app app
.use(send.json()) .use(send.json())
.use(query()) .use(query())
.use(bodyParser.json({ limit: 10 * 1024 * 1024 })) // 10mb .use(bodyParser.json({ limit: 10 * 1024 * 1024 })) // 10mb
.use(require("compression")()); .use(require('compression')())
;
// //
// Keeping the API *required* by desirae super minimal // Keeping the API *required* by desirae super minimal
// so that it can be implemented easily in any language // so that it can be implemented easily in any language
// //
app app
.use("/api/fs/static", serveStatic(options.blogdir)) .use('/api/fs/static', serveStatic(options.blogdir))
.use("/api/fs/walk", restful.walk) .use('/api/fs/walk', restful.walk)
.use("/api/fs/files", restful.getFiles) .use('/api/fs/files', restful.getFiles)
.use("/api/fs/files", restful.putFiles) .use('/api/fs/files', restful.putFiles)
.use("/api/fs/copy", restful.copy); .use('/api/fs/copy', restful.copy)
;
// end Desirae API // end Desirae API
if (options.tmpdir) { if (options.tmpdir) {
@ -33,30 +38,32 @@ function create(options) {
} }
// this is used by DearDesi, but not required for desirae // this is used by DearDesi, but not required for desirae
app.use("/api/fs/rootdir", function (req, res) { app
var pathname = path.resolve(options.blogdir); .use('/api/fs/rootdir', function (req, res) {
var pathname = path.resolve(options.blogdir)
;
res.send({ res.send({
path: pathname, path: pathname
name: path.basename(pathname), , name: path.basename(pathname)
relativePath: path.dirname(pathname), , relativePath: path.dirname(pathname)
}); });
return; return;
}); })
;
app app
// the AngularJS App // the AngularJS App
.use(serveStatic(__dirname)) .use(serveStatic(__dirname))
// TODO change file requests to '/blog' // TODO change file requests to '/blog'
//.use(serveStatic(options.blogdir)) //.use(serveStatic(options.blogdir))
.use("/blog", serveStatic(options.blogdir)) .use('/blog', serveStatic(options.blogdir))
.use( .use('/compiled_dev', serveStatic(path.join(options.blogdir, '/compiled_dev')))
"/compiled_dev", .use('/compiled', serveStatic(path.join(options.blogdir, '/compiled')))
serveStatic(path.join(options.blogdir, "/compiled_dev")) ;
)
.use("/compiled", serveStatic(path.join(options.blogdir, "/compiled")));
return app; return app;
} }
module.exports = create({ blogdir: path.join(__dirname, "blog") }); module.exports = create({ blogdir: path.join(__dirname, 'blog') });
module.exports.create = create; module.exports.create = create;

View File

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

View File

@ -1,16 +1,14 @@
"use strict"; 'use strict';
angular angular.module('myApp.about', ['ngRoute'])
.module("myApp.about", ["ngRoute"])
.config([ .config(['$routeProvider', function($routeProvider) {
"$routeProvider", $routeProvider.when('/about', {
function ($routeProvider) { templateUrl: 'views/about/about.html',
$routeProvider.when("/about", { controller: 'AboutCtrl'
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 () { describe('myApp.view2 module', function() {
beforeEach(module("myApp.view2"));
describe("view2 controller", function () { beforeEach(module('myApp.view2'));
it("should ....", inject(function ($controller) {
describe('view2 controller', function(){
it('should ....', inject(function($controller) {
//spec body //spec body
var view2Ctrl = $controller("View2Ctrl"); var view2Ctrl = $controller('View2Ctrl');
expect(view2Ctrl).toBeDefined(); expect(view2Ctrl).toBeDefined();
})); }));
}); });
}); });

View File

@ -15,42 +15,31 @@
></select> ></select>
</div> </div>
</div> </div>
<br /> <br/>
</div> </div>
</div> </div>
<div class="col-md-5 col-sm-6 col-xs-4"> <div class="col-md-5 col-sm-6 col-xs-4">
<br /> <br/>
<img style="height: 75px" ng-src="{{Authors.headshot}}" /> <img style="height:75px;" ng-src="{{Authors.headshot}}" />
</div> </div>
</div> </div>
</div> </div>
<form <form class="form-horizontal" name="newAuthors" ng-submit="Authors.upsert(Authors.selectedAuthor)">
class="form-horizontal"
name="newAuthors"
ng-submit="Authors.upsert(Authors.selectedAuthor)"
>
<div class="row"> <div class="row">
<div class="col-sm-8"> <div class="col-sm-8">
<small <small><span ng-bind="Authors.blogdir"
><span ng-bind="Authors.blogdir"></span>/authors/<span ></span>/authors/<span ng-bind="Authors.selectedAuthor.handle"
ng-bind="Authors.selectedAuthor.handle" ></span><span ng-if="Authors.selectedAuthor.handle"
></span >.yml</span></small>
><span ng-if="Authors.selectedAuthor.handle">.yml</span></small
>
</div> </div>
<div class="col-sm-4"> <div class="col-sm-4">
<button <button class="btn btn-success pull-right" type="submit" ng-disabled="Authors.dirty || !Authors.selectedAuthor.handle">Save &amp; Continue</button>
class="btn btn-success pull-right"
type="submit"
ng-disabled="Authors.dirty || !Authors.selectedAuthor.handle"
>
Save &amp; Continue
</button>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<br /> <br/>
</div> </div>
<div class="row"> <div class="row">
<div class="col-lg-12"> <div class="col-lg-12">
@ -61,40 +50,30 @@
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
<div class="form-group"> <div class="form-group">
<label for="inputAuthorName" class="col-lg-4 control-label" <label for="inputAuthorName" class="col-lg-4 control-label">Name*</label>
>Name*</label
>
<div class="col-lg-8"> <div class="col-lg-8">
<input <input ng-model="Authors.selectedAuthor.name"
ng-model="Authors.selectedAuthor.name"
required="required" required="required"
type="text" type="text"
class="form-control" class="form-control"
id="inputAuthorName" id="inputAuthorName"
name="inputAuthorName" name="inputAuthorName"
placeholder="i.e. John Doe" placeholder="i.e. John Doe">
/>
</div> </div>
</div> </div>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<div class="form-group"> <div class="form-group">
<label <label for="inputAuthorNickname" class="col-lg-4 control-label">Handle*</label>
for="inputAuthorNickname"
class="col-lg-4 control-label"
>Handle*</label
>
<div class="col-lg-8"> <div class="col-lg-8">
<input <input ng-model="Authors.selectedAuthor.handle"
ng-model="Authors.selectedAuthor.handle"
required="required" required="required"
type="text" type="text"
class="form-control" class="form-control"
id="inputAuthorNickname" id="inputAuthorNickname"
name="inputAuthorNickname" name="inputAuthorNickname"
placeholder="i.e. johndoe" placeholder="i.e. johndoe">
/>
</div> </div>
</div> </div>
</div> </div>
@ -103,38 +82,30 @@
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
<div class="form-group"> <div class="form-group">
<label for="inputAuthorEmail" class="col-lg-4 control-label" <label for="inputAuthorEmail" class="col-lg-4 control-label">Email*</label>
>Email*</label
>
<div class="col-lg-8"> <div class="col-lg-8">
<input <input ng-model="Authors.selectedAuthor.email" ng-change="Authors.updateHeadshotUrl()"
ng-model="Authors.selectedAuthor.email"
ng-change="Authors.updateHeadshotUrl()"
required="required" required="required"
type="email" type="email"
class="form-control" class="form-control"
id="inputAuthorEmail" id="inputAuthorEmail"
name="inputAuthorEmail" name="inputAuthorEmail"
placeholder="i.e. john.doe@gmail.com" placeholder="i.e. john.doe@gmail.com">
/>
</div> </div>
</div> </div>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<div class="form-group"> <div class="form-group">
<label for="inputAuthorWebsite" class="col-lg-4 control-label" <label for="inputAuthorWebsite" class="col-lg-4 control-label">Website</label>
>Website</label
>
<div class="col-lg-8"> <div class="col-lg-8">
<input <input ng-model="Authors.selectedAuthor.website"
ng-model="Authors.selectedAuthor.website"
type="url" type="url"
class="form-control" class="form-control"
id="inputAuthorWebsite" id="inputAuthorWebsite"
name="inputAuthorWebsite" name="inputAuthorWebsite"
placeholder="i.e. http://johndoe.name" placeholder="i.e. http://johndoe.name"
/> >
</div> </div>
</div> </div>
</div> </div>
@ -143,22 +114,11 @@
<div class="row"> <div class="row">
<div class="col-lg-12"> <div class="col-lg-12">
<div class="form-group"> <div class="form-group">
<label for="inputAuthorBio" class="col-lg-2 control-label" <label for="inputAuthorBio" class="col-lg-2 control-label">Bio
>Bio <small>(<span ng-bind="Authors.selectedAuthor.bio.length || 0"></span>/140)</small></label>
<small
>(<span
ng-bind="Authors.selectedAuthor.bio.length || 0"
></span
>/140)</small
></label
>
<div class="col-lg-10"> <div class="col-lg-10">
<textarea <textarea ng-model="Authors.selectedAuthor.bio"
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>
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> </div>
@ -167,29 +127,17 @@
<div class="row"> <div class="row">
<div class="col-lg-12"> <div class="col-lg-12">
<div class="form-group"> <div class="form-group">
<label <label for="inputAuthorHeadshot" class="col-lg-2 control-label">Headshot</label>
for="inputAuthorHeadshot"
class="col-lg-2 control-label"
>Headshot</label
>
<div class="col-lg-10"> <div class="col-lg-10">
<input <input ng-model="Authors.selectedAuthor.headshot" ng-change="Authors.updateHeadshotUrl()"
ng-model="Authors.selectedAuthor.headshot" type="text" class="form-control" id="inputAuthorHeadshot" placeholder="i.e. https://i.imgur.com/qqpxDmJ.jpg">
ng-change="Authors.updateHeadshotUrl()" <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>
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> </div>
</fieldset> </fieldset>
</div> </div>
</div> </div>
@ -200,47 +148,26 @@
<legend>Social</legend> <legend>Social</legend>
<div class="form-group"> <div class="form-group">
<label for="inputAuthorTwitter" class="col-lg-2 control-label" <label for="inputAuthorTwitter" class="col-lg-2 control-label">Twitter</label>
>Twitter</label
>
<div class="col-lg-10"> <div class="col-lg-10">
<input <input ng-model="Authors.selectedAuthor.twitter"
ng-model="Authors.selectedAuthor.twitter" type="text" class="form-control" id="inputAuthorTwitter" placeholder="i.e. @johndoe">
type="text"
class="form-control"
id="inputAuthorTwitter"
placeholder="i.e. @johndoe"
/>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="inputAuthorFacebook" class="col-lg-2 control-label" <label for="inputAuthorFacebook" class="col-lg-2 control-label">Facebook URL</label>
>Facebook URL</label
>
<div class="col-lg-10"> <div class="col-lg-10">
<input <input ng-model="Authors.selectedAuthor.facebook"
ng-model="Authors.selectedAuthor.facebook" type="text" class="form-control" id="inputAuthorFacebook" placeholder="i.e. facebook.com/johndoe">
type="text"
class="form-control"
id="inputAuthorFacebook"
placeholder="i.e. facebook.com/johndoe"
/>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="inputAuthorGooglePlus" class="col-lg-2 control-label" <label for="inputAuthorGooglePlus" class="col-lg-2 control-label">Google+ URL</label>
>Google+ URL</label
>
<div class="col-lg-10"> <div class="col-lg-10">
<input <input ng-model="Authors.selectedAuthor.googleplus"
ng-model="Authors.selectedAuthor.googleplus" type="text" class="form-control" id="inputAuthorGooglePlus" placeholder="i.e. plus.google.com/+johndoe">
type="text"
class="form-control"
id="inputAuthorGooglePlus"
placeholder="i.e. plus.google.com/+johndoe"
/>
</div> </div>
</div> </div>
</fieldset> </fieldset>
@ -252,35 +179,20 @@
<fieldset> <fieldset>
<legend>Developers</legend> <legend>Developers</legend>
<div class="form-group"> <div class="form-group">
<label for="inputAuthorGithub" class="col-lg-2 control-label" <label for="inputAuthorGithub" class="col-lg-2 control-label">Github</label>
>Github</label
>
<div class="col-lg-10"> <div class="col-lg-10">
<input <input ng-model="Authors.selectedAuthor.github"
ng-model="Authors.selectedAuthor.github" type="text" class="form-control" id="inputAuthorGithub" placeholder="i.e. johndoe">
type="text"
class="form-control"
id="inputAuthorGithub"
placeholder="i.e. johndoe"
/>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label <label for="inputAuthorStackOverflow" class="col-lg-2 control-label">StackOverflow</label>
for="inputAuthorStackOverflow"
class="col-lg-2 control-label"
>StackOverflow</label
>
<div class="col-lg-10"> <div class="col-lg-10">
<input <input ng-model="Authors.selectedAuthor.stackoverflow"
ng-model="Authors.selectedAuthor.stackoverflow" type="text" class="form-control" id="inputAuthorStackOverflow" placeholder="i.e. http://stackoverflow.com/users/151312/johndoe">
type="text"
class="form-control"
id="inputAuthorStackOverflow"
placeholder="i.e. http://stackoverflow.com/users/151312/johndoe"
/>
</div> </div>
</div> </div>
</fieldset> </fieldset>
</div> </div>
</div> </div>
@ -291,26 +203,19 @@
<legend>Feeds</legend> <legend>Feeds</legend>
<div class="form-group"> <div class="form-group">
<label for="inputAuthorFeedburner" class="col-lg-2 control-label" <label for="inputAuthorFeedburner" class="col-lg-2 control-label">Feedburner</label>
>Feedburner</label
>
<div class="col-lg-10"> <div class="col-lg-10">
<input <input ng-model="Authors.selectedAuthor.feedburner"
ng-model="Authors.selectedAuthor.feedburner" type="text" class="form-control" id="inputAuthorFeedburner" placeholder="i.e. johndoe">
type="text"
class="form-control"
id="inputAuthorFeedburner"
placeholder="i.e. johndoe"
/>
</div> </div>
</div> </div>
</fieldset> </fieldset>
</div> </div>
</div> </div>
<button class="btn btn-primary pull-right" type="submit"> <button class="btn btn-primary pull-right" type="submit">Save &amp; Continue</button>
Save &amp; Continue
</button>
</div> </div>
</form> </form>
</div> </div>

View File

@ -1,28 +1,23 @@
"use strict"; 'use strict';
angular angular.module('myApp.authors', ['ngRoute'])
.module("myApp.authors", ["ngRoute"])
.config([ .config(['$routeProvider', function($routeProvider) {
"$routeProvider", $routeProvider.when('/authors', {
function ($routeProvider) { templateUrl: 'views/authors/authors.html',
$routeProvider.when("/authors", { controller: 'AuthorsCtrl as Authors'
templateUrl: "views/authors/authors.html",
controller: "AuthorsCtrl as Authors",
}); });
}, }])
])
.controller('AuthorsCtrl'
, ['$scope', '$timeout', '$location', 'Desirae'
, function($scope, $timeout, $location, Desirae) {
var scope = this
;
.controller("AuthorsCtrl", [
"$scope",
"$timeout",
"$location",
"Desirae",
function ($scope, $timeout, $location, Desirae) {
var scope = this;
scope.newAuthor = function () { scope.newAuthor = function () {
console.log("new author"); console.log('new author');
scope.new = { filename: "new" }; scope.new = { filename: 'new' };
scope.selectAuthor(scope.new); scope.selectAuthor(scope.new);
}; };
@ -33,30 +28,23 @@ angular
}; };
scope.upsert = function () { scope.upsert = function () {
var author = scope.selectedAuthor, var author = scope.selectedAuthor
files = [], , files = []
filename = author.filename; , filename = author.filename
;
delete author.filename; delete author.filename;
if ("new" !== filename && filename !== author.handle) { if ('new' !== filename && filename !== author.handle) {
files.push({ files.push({ path: 'authors/' + filename + '.yml', contents: '', delete: true });
path: "authors/" + filename + ".yml",
contents: "",
delete: true,
});
} }
files.push({ files.push({ path: 'authors/' + author.handle + '.yml', contents: window.jsyaml.dump(author) });
path: "authors/" + author.handle + ".yml",
contents: window.jsyaml.dump(author),
});
console.log(files); console.log(files);
Desirae.putFiles(files) Desirae.putFiles(files).then(function (results) {
.then(function (results) { console.log('updated author', results);
console.log("updated author", results); $location.path('/site');
$location.path("/site"); }).catch(function (e) {
})
.catch(function (e) {
author.filename = filename; author.filename = filename;
console.error(e); console.error(e);
window.alert("Error Nation! :/"); window.alert("Error Nation! :/");
@ -65,19 +53,17 @@ angular
}; };
scope.updateHeadshotUrlNow = function () { scope.updateHeadshotUrlNow = function () {
var gravatar = var gravatar = 'http://www.gravatar.com/avatar/' + window.md5((scope.selectedAuthor.email||'foo').toLowerCase()) + '?d=identicon'
"http://www.gravatar.com/avatar/" + ;
window.md5((scope.selectedAuthor.email || "foo").toLowerCase()) +
"?d=identicon";
if (scope.selectedAuthor.headshot) { if (scope.selectedAuthor.headshot) {
scope.headshot = scope.selectedAuthor.headshot; scope.headshot = scope.selectedAuthor.headshot;
} else if (scope.selectedAuthor.email) { }
else if (scope.selectedAuthor.email) {
scope.headshot = gravatar; scope.headshot = gravatar;
} else { }
scope.headshot = else {
"http://www.gravatar.com/avatar/" + scope.headshot = 'http://www.gravatar.com/avatar/' + window.md5((scope.selectedAuthor.email||'foo').toLowerCase()) + '?d=mm';
window.md5((scope.selectedAuthor.email || "foo").toLowerCase()) +
"?d=mm";
} }
}; };
@ -91,37 +77,30 @@ angular
function init() { function init() {
scope.newAuthor(); scope.newAuthor();
console.log("desi loading"); console.log('desi loading');
Desirae.meta() Desirae.meta().then(function (desi) {
.then(function (desi) { var filename
var filename; ;
scope.blogdir = desi.blogdir.path.replace( scope.blogdir = desi.blogdir.path.replace(/^\/(Users|home)\/[^\/]+\//, '~/');
/^\/(Users|home)\/[^\/]+\//,
"~/"
);
desi.authors = desi.authors || {}; desi.authors = desi.authors || {};
desi.authors.new = scope.new; desi.authors.new = scope.new;
scope.authors = desi.authors; scope.authors = desi.authors;
Object.keys(desi.authors).forEach(function (filename) { Object.keys(desi.authors).forEach(function (filename) {
if ("new" === filename) { if ('new' === filename) {
return; return;
} }
desi.authors[filename].filename = filename; desi.authors[filename].filename = filename;
desi.authors[filename].handle = desi.authors[filename].handle = desi.authors[filename].handle || filename;
desi.authors[filename].handle || filename;
}); });
filename = Object.keys(desi.authors)[0]; filename = Object.keys(desi.authors)[0];
scope.selectedAuthor = desi.authors[filename]; scope.selectedAuthor = desi.authors[filename];
scope.updateHeadshotUrlNow(); scope.updateHeadshotUrlNow();
}) }).catch(function (e) {
.catch(function (e) { window.alert("An Error Occured. Most errors that occur in the init phase are parse errors in the config files or permissions errors on files or directories, but check the error console for details.");
window.alert(
"An Error Occured. Most errors that occur in the init phase are parse errors in the config files or permissions errors on files or directories, but check the error console for details."
);
console.error(e); console.error(e);
throw e; throw e;
}); });
@ -137,5 +116,4 @@ angular
} }
}, true); }, true);
*/ */
}, }]);
]);

View File

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

View File

@ -1,61 +1,44 @@
"use strict"; 'use strict';
angular angular.module('myApp.build', ['ngRoute'])
.module("myApp.build", ["ngRoute"])
.config([ .config(['$routeProvider', function($routeProvider) {
"$routeProvider", $routeProvider.when('/build', {
function ($routeProvider) { templateUrl: 'views/build/build.html',
$routeProvider.when("/build", { controller: 'BuildCtrl as 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
;
.controller("BuildCtrl", [
"$scope",
"$location",
"$timeout",
"Desirae",
function ($scope, $location, $timeout, DesiraeService) {
var scope = this,
path = window.path;
function init() { function init() {
scope.extensions = ["md", "html"]; scope.extensions = ['md', 'html'];
return DesiraeService.meta() return DesiraeService.meta().then(function (desi) {
.then(function (desi) { scope.blogdir = desi.blogdir.path.replace(/^\/(Users|home)\/[^\/]+\//, '~/');
scope.blogdir = desi.blogdir.path.replace(
/^\/(Users|home)\/[^\/]+\//,
"~/"
);
scope.site = desi.site; scope.site = desi.site;
if (!desi.site.base_url || !desi.site.base_path) { if (!desi.site.base_url || !desi.site.base_path) {
window.alert( window.alert("Please go back to the site config and enter any mandatory missing fields (base_url, base_path).");
"Please go back to the site config and enter any mandatory missing fields (base_url, base_path)."
);
return; return;
} }
scope.display_url = scope.production_url = scope.display_url = scope.production_url = desi.site.base_url + path.join('/', desi.site.base_path);
desi.site.base_url + path.join("/", desi.site.base_path);
if (/dropbox/.test(scope.display_url)) { if (/dropbox/.test(scope.display_url)) {
scope.display_url += "/index.html"; scope.display_url += '/index.html';
} }
// this is the responsibility of the build system (Dear Desi), not the library (Desirae) // this is the responsibility of the build system (Dear Desi), not the library (Desirae)
scope.development_url = scope.development_url = location.href.replace(/\/(#.*)?$/, '') + path.join('/', 'compiled_dev');
location.href.replace(/\/(#.*)?$/, "") +
path.join("/", "compiled_dev");
return desi; return desi;
}) }).catch(function (e) {
.catch(function (e) { window.alert("An Error Occured. Most errors that occur in the init phase are parse errors in the config files or permissions errors on files or directories, but check the error console for details.");
window.alert(
"An Error Occured. Most errors that occur in the init phase are parse errors in the config files or permissions errors on files or directories, but check the error console for details."
);
console.error(e); console.error(e);
throw e; throw e;
}); });
@ -63,11 +46,7 @@ angular
scope.onError = function (e) { scope.onError = function (e) {
console.error(e); console.error(e);
if ( if (window.confirm("Encountered an error. Please inspect the console.\n\nWould you like to ignore the error and continue?")) {
window.confirm(
"Encountered an error. Please inspect the console.\n\nWould you like to ignore the error and continue?"
)
) {
return window.Promise.resolve(); return window.Promise.resolve();
} else { } else {
return window.Promise.reject(); return window.Promise.reject();
@ -77,39 +56,28 @@ angular
scope.buildOne = function (envstr) { scope.buildOne = function (envstr) {
return DesiraeService.reset().then(function () { return DesiraeService.reset().then(function () {
return init().then(function () { return init().then(function () {
var env; var env
;
// TODO is there a legitimate case where in addition to base_path (root of the blog) // 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 // a user would need owner_base? i.e. school.edu/~/rogers/blog school.edu/~/rogers/assets
if ("production" === envstr) { if ('production' === envstr) {
env = { env = {
url: scope.production_url, url: scope.production_url
base_url: scope.production_url.replace( , base_url: scope.production_url.replace(/(https?:\/\/[^\/#?]+).*/, '$1')
/(https?:\/\/[^\/#?]+).*/, , base_path: scope.production_url.replace(/https?:\/\/[^\/#?]+/, '')
"$1" , compiled_path: 'compiled'
), , since: 0
base_path: scope.production_url.replace( , onError: scope.onError
/https?:\/\/[^\/#?]+/,
""
),
compiled_path: "compiled",
since: 0,
onError: scope.onError,
}; };
} else { } else {
env = { env = {
url: scope.development_url, url: scope.development_url
base_url: scope.development_url.replace( , base_url: scope.development_url.replace(/(https?:\/\/[^\/#?]+).*/, '$1')
/(https?:\/\/[^\/#?]+).*/, , base_path: scope.development_url.replace(/https?:\/\/[^\/#?]+/, '')
"$1" , compiled_path: 'compiled_dev'
), , since: 0
base_path: scope.development_url.replace( , onError: scope.onError
/https?:\/\/[^\/#?]+/,
""
),
compiled_path: "compiled_dev",
since: 0,
onError: scope.onError,
}; };
} }
@ -121,15 +89,12 @@ angular
}; };
scope.build = function (envs) { scope.build = function (envs) {
window window.forEachAsync(envs, function (env) {
.forEachAsync(envs, function (env) {
return scope.buildOne(env); return scope.buildOne(env);
}) }).then(function () {
.then(function () { window.alert('Build(s) Complete');
window.alert("Build(s) Complete");
}); });
}; };
init(); init();
}, }]);
]);

View File

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

View File

@ -1,16 +1,13 @@
"use strict"; 'use strict';
angular angular.module('myApp.configure', ['ngRoute'])
.module("myApp.configure", ["ngRoute"])
.config([ .config(['$routeProvider', function($routeProvider) {
"$routeProvider", $routeProvider.when('/configure', {
function ($routeProvider) { templateUrl: 'views/configure/configure.html',
$routeProvider.when("/configure", { controller: 'ConfigureCtrl as 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"> <div class="well bs-component">
<fieldset> <fieldset>
<div class="form-group"> <div class="form-group">
<label for="inputEmail" class="col-lg-2 control-label" <label for="inputEmail" class="col-lg-2 control-label">Email</label>
>Email</label
>
<div class="col-lg-10"> <div class="col-lg-10">
<input <input type="text" class="form-control" id="inputEmail" placeholder="Email">
type="text"
class="form-control"
id="inputEmail"
placeholder="Email"
/>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="inputPassword" class="col-lg-2 control-label" <label for="inputPassword" class="col-lg-2 control-label">Password</label>
>Password</label
>
<div class="col-lg-10"> <div class="col-lg-10">
<input <input type="password" class="form-control" id="inputPassword" placeholder="Password">
type="password"
class="form-control"
id="inputPassword"
placeholder="Password"
/>
<div class="checkbox"> <div class="checkbox">
<label> <input type="checkbox" /> Checkbox </label> <label>
<input type="checkbox"> Checkbox
</label>
</div> </div>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="textArea" class="col-lg-2 control-label" <label for="textArea" class="col-lg-2 control-label">Textarea</label>
>Textarea</label
>
<div class="col-lg-10"> <div class="col-lg-10">
<textarea <textarea class="form-control" rows="3" id="textArea"></textarea>
class="form-control" <span class="help-block">A longer block of help text that breaks onto a new line and may extend beyond one line.</span>
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> </div>
<div class="form-group"> <div class="form-group">
@ -60,24 +39,13 @@
<div class="col-lg-10"> <div class="col-lg-10">
<div class="radio"> <div class="radio">
<label> <label>
<input <input type="radio" name="optionsRadios" id="optionsRadios1" value="option1" checked="">
type="radio"
name="optionsRadios"
id="optionsRadios1"
value="option1"
checked=""
/>
Option one is this Option one is this
</label> </label>
</div> </div>
<div class="radio"> <div class="radio">
<label> <label>
<input <input type="radio" name="optionsRadios" id="optionsRadios2" value="option2">
type="radio"
name="optionsRadios"
id="optionsRadios2"
value="option2"
/>
Option two can be something else Option two can be something else
</label> </label>
</div> </div>
@ -93,7 +61,7 @@
<option>4</option> <option>4</option>
<option>5</option> <option>5</option>
</select> </select>
<br /> <br>
<select multiple="" class="form-control"> <select multiple="" class="form-control">
<option>1</option> <option>1</option>
<option>2</option> <option>2</option>
@ -110,15 +78,6 @@
</div> </div>
</div> </div>
</fieldset> </fieldset>
<div <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>
</div>
</form>
</div>

View File

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

View File

@ -1,38 +1,29 @@
"use strict"; 'use strict';
angular angular.module('myApp.post', ['ngRoute'])
.module("myApp.post", ["ngRoute"])
.config([ .config(['$routeProvider', function($routeProvider) {
"$routeProvider", $routeProvider.when('/post', {
function ($routeProvider) { templateUrl: 'views/post/post.html',
$routeProvider.when("/post", { controller: 'PostCtrl as 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
;
.controller("PostCtrl", [
"$scope",
"$location",
"$timeout",
"Desirae",
function ($scope, $location, $timeout, DesiraeService) {
var scope = this,
path = window.path;
function init() { function init() {
DesiraeService.meta() DesiraeService.meta().then(function (desi) {
.then(function (desi) {
/* /*
if (!scope.site.base_url) { if (!scope.site.base_url) {
window.alert("Please go to the site tab and add a url first"); window.alert("Please go to the site tab and add a url first");
return; return;
} }
*/ */
scope.blogdir = desi.blogdir.path.replace( scope.blogdir = desi.blogdir.path.replace(/^\/(Users|home)\/[^\/]+\//, '~/');
/^\/(Users|home)\/[^\/]+\//,
"~/"
);
scope.site = desi.site; scope.site = desi.site;
scope.env = desi.site; scope.env = desi.site;
newPost(); newPost();
@ -42,64 +33,61 @@ angular
} }
updateDate(); updateDate();
}) }).catch(function (e) {
.catch(function (e) { window.alert("An Error Occured. Most errors that occur in the init phase are parse errors in the config files or permissions errors on files or directories, but check the error console for details.");
window.alert(
"An Error Occured. Most errors that occur in the init phase are parse errors in the config files or permissions errors on files or directories, but check the error console for details."
);
console.error(e); console.error(e);
throw e; throw e;
}); });
scope.extensions = ["md", "html"]; scope.extensions = ['md', 'html'];
} }
function newPost() { function newPost() {
scope.selected = { scope.selected = {
format: "md", format: 'md'
permalink: "/article/new.html", , permalink: "/article/new.html"
uuid: window.uuid.v4(), , uuid: window.uuid.v4()
abspath: scope.blogdir, , abspath: scope.blogdir
sourcepath: "", , sourcepath: ''
fileepath: "", , fileepath: ''
post: { , post: {
yml: { yml: {
title: "", title: ""
permalink: "/article/new.html", , permalink: "/article/new.html"
date: DesiraeService.toDesiDate(new Date()), // "YYYY-MM-DD HH:MM pm" // TODO desirae , date: DesiraeService.toDesiDate(new Date())// "YYYY-MM-DD HH:MM pm" // TODO desirae
updated: null, , updated: null
description: "", , description: ""
categories: [], , categories: []
tags: [], , tags: []
theme: null, , theme: null
layout: null, , layout: null
swatch: null, , swatch: null
}, }
}, }
}; };
scope.selected.date = scope.selected.post.yml.date; scope.selected.date = scope.selected.post.yml.date;
scope.selected.post.frontmatter = window.jsyaml scope.selected.post.frontmatter = window.jsyaml.dump(scope.selected.post.yml).trim();
.dump(scope.selected.post.yml)
.trim();
} }
scope.onChange = function () { scope.onChange = function () {
var post = scope.selected.post, var post = scope.selected.post
selected = scope.selected; , 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 post.yml.title = post.yml.title || '';
.toLowerCase() selected.title = post.yml.title;
.replace(/["']/g, "") post.yml.description = post.yml.description || '';
.replace(/\W/g, "-")
.replace(/^-+/g, "") scope.slug = post.yml.title.toLowerCase()
.replace(/-+$/g, "") .replace(/["']/g, '')
.replace(/--/g, "-"); .replace(/\W/g, '-')
.replace(/^-+/g, '')
.replace(/-+$/g, '')
.replace(/--/g, '-')
;
if (selected.permalink === post.yml.permalink) { if (selected.permalink === post.yml.permalink) {
selected.permalink = "/articles/" + scope.slug + "/"; selected.permalink = '/articles/' + scope.slug + '/';
// + '.html' //+ selected.format // + '.html' //+ selected.format
post.yml.permalink = selected.permalink; post.yml.permalink = selected.permalink;
@ -113,44 +101,29 @@ angular
post.frontmatter = window.jsyaml.dump(post.yml).trim(); post.frontmatter = window.jsyaml.dump(post.yml).trim();
// TODO use some sort of filepath pattern in config.yml // TODO use some sort of filepath pattern in config.yml
selected.path = path.join( selected.path = path.join((scope.env.compiled_path || 'compiled'), post.yml.permalink);
scope.env.compiled_path || "compiled",
post.yml.permalink
);
if (!/\.html?$/.test(selected.path)) { if (!/\.html?$/.test(selected.path)) {
selected.path = path.join(selected.path, "index.html"); selected.path = path.join(selected.path, 'index.html');
} }
selected.url = path.join( selected.url = path.join(scope.site.base_url + path.join(scope.site.base_path, post.yml.permalink));
scope.site.base_url +
path.join(scope.site.base_path, post.yml.permalink)
);
if (scope.env.explicitIndexes && /\/$/.test(selected.url)) { if (scope.env.explicitIndexes && /\/$/.test(selected.url)) {
selected.url += "index.html"; selected.url += 'index.html';
} }
selected.markdown = "[" + selected.title + "](" + selected.url + ")"; selected.markdown = '[' + selected.title + '](' + selected.url + ')';
selected.ahref = selected.ahref = '<a href="' + selected.url + '">' + selected.title + '</a>';
'<a href="' + selected.url + '">' + selected.title + "</a>";
selected.abspath = path.join(scope.blogdir, selected.path); selected.abspath = path.join(scope.blogdir, selected.path);
selected.filepath = path.join( selected.filepath = path.join((selected.collection || 'posts'), scope.slug + '.' + selected.format);
selected.collection || "posts", selected.sourcepath = path.join(scope.blogdir, (selected.collection || 'posts'), scope.slug + '.' + selected.format);
scope.slug + "." + selected.format
);
selected.sourcepath = path.join(
scope.blogdir,
selected.collection || "posts",
scope.slug + "." + selected.format
);
}; };
scope.onFrontmatterChange = function () { scope.onFrontmatterChange = function () {
var data, post; var data
, post
;
try { try {
if ( if (!scope.selected.post.frontmatter || !scope.selected.post.frontmatter.trim()) {
!scope.selected.post.frontmatter || throw new Error('deleted frontmatter');
!scope.selected.post.frontmatter.trim()
) {
throw new Error("deleted frontmatter");
} }
data = window.jsyaml.load(scope.selected.post.frontmatter); data = window.jsyaml.load(scope.selected.post.frontmatter);
//scope.selected.format = data.permalink.replace(/.*\.(\w+$)/, '$1'); //scope.selected.format = data.permalink.replace(/.*\.(\w+$)/, '$1');
@ -161,56 +134,30 @@ angular
post = scope.selected.post; post = scope.selected.post;
scope.selected.path = path.join( scope.selected.path = path.join((scope.env.compiled_path || 'compiled'), post.yml.permalink);
scope.env.compiled_path || "compiled",
post.yml.permalink
);
if (!/\.html?$/.test(path.basename(post.yml.permalink))) { if (!/\.html?$/.test(path.basename(post.yml.permalink))) {
scope.selected.path = path.join( scope.selected.path = path.join(scope.selected.path.replace(/\.w+$/, ''), 'index.html');
scope.selected.path.replace(/\.w+$/, ""),
"index.html"
);
} }
scope.selected.url = path.join( scope.selected.url = path.join(scope.site.base_url + path.join(scope.site.base_path, post.yml.permalink));
scope.site.base_url +
path.join(scope.site.base_path, post.yml.permalink)
);
if (scope.env.explicitIndexes && /\/$/.test(scope.selected.url)) { if (scope.env.explicitIndexes && /\/$/.test(scope.selected.url)) {
scope.selected.url += "index.html"; scope.selected.url += 'index.html';
} }
scope.selected.abspath = path.join( scope.selected.abspath = path.join(scope.blogdir, scope.selected.path);
scope.blogdir, scope.selected.sourcepath = path.join(scope.blogdir, (scope.selected.collection || 'posts'), scope.slug + '.' + scope.selected.format);
scope.selected.path scope.selected.filepath = path.join((scope.selected.collection || 'posts'), scope.slug + '.' + scope.selected.format);
); } catch(e) {
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(e);
console.error("ignoring update that created parse error"); console.error('ignoring update that created parse error');
scope.selected.post.frontmatter = window.jsyaml scope.selected.post.frontmatter = window.jsyaml.dump(scope.selected.post.yml).trim();
.dump(scope.selected.post.yml)
.trim();
} }
}; };
function updateDate() { function updateDate() {
$timeout.cancel(scope.dtlock); $timeout.cancel(scope.dtlock);
scope.dtlock = $timeout(function () { scope.dtlock = $timeout(function () {
if ( if (scope.selected && scope.selected.date === scope.selected.post.yml.date) {
scope.selected && scope.selected.date = scope.selected.post.yml.date = DesiraeService.toDesiDate(new Date());
scope.selected.date === scope.selected.post.yml.date
) {
scope.selected.date = scope.selected.post.yml.date = DesiraeService.toDesiDate(
new Date()
);
} }
scope.onChange(); scope.onChange();
updateDate(); updateDate();
@ -219,43 +166,38 @@ angular
scope.upsert = function () { scope.upsert = function () {
if (-1 === scope.extensions.indexOf(scope.selected.format)) { if (-1 === scope.extensions.indexOf(scope.selected.format)) {
window.alert( window.alert('.' + scope.selected.format + ' is not a supported extension.\n\nPlease choose from: .' + scope.extensions.join(' .'));
"." +
scope.selected.format +
" is not a supported extension.\n\nPlease choose from: ." +
scope.extensions.join(" .")
);
return; return;
} }
scope.selected.post.yml.uuid = scope.selected.uuid; scope.selected.post.yml.uuid = scope.selected.uuid;
["updated", "theme", "layout", "swatch"].forEach(function (key) { ['updated', 'theme', 'layout', 'swatch'].forEach(function (key) {
if (!scope.selected.post.yml[key]) { if (!scope.selected.post.yml[key]) {
delete scope.selected.post.yml[key]; delete scope.selected.post.yml[key];
} }
}); });
scope.onChange(); scope.onChange();
var files = []; var files = []
;
files.push({ files.push({
path: scope.selected.filepath, path: scope.selected.filepath
contents: , contents:
"---\n" + '---\n'
scope.selected.post.frontmatter.trim() + + scope.selected.post.frontmatter.trim()
"\n" + + '\n'
"---\n" + + '---\n'
"\n" + + '\n'
scope.selected.post.body.trim(), + scope.selected.post.body.trim()
}); });
DesiraeService.putFiles(files) DesiraeService.putFiles(files).then(function (results) {
.then(function (results) { console.log('TODO check for error');
console.log("TODO check for error");
console.log(files); console.log(files);
console.log(results); console.log(results);
$location.path("/build"); $location.path('/build');
}) }).catch(function (e) {
.catch(function (e) {
$timeout.cancel(scope.dtlock); $timeout.cancel(scope.dtlock);
console.error(scope.site); console.error(scope.site);
console.error(e); console.error(e);
@ -265,5 +207,4 @@ angular
}; };
init(); init();
}, }]);
]);

View File

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

View File

@ -1,37 +1,27 @@
"use strict"; 'use strict';
angular angular.module('myApp.site', ['ngRoute'])
.module("myApp.site", ["ngRoute"])
.config([ .config(['$routeProvider', function($routeProvider) {
"$routeProvider", $routeProvider.when('/site', {
function ($routeProvider) { templateUrl: 'views/site/site.html',
$routeProvider.when("/site", { controller: 'SiteCtrl as Site'
templateUrl: "views/site/site.html",
controller: "SiteCtrl as Site",
}); });
}, }])
])
.controller('SiteCtrl', ['$scope', '$location', 'Desirae', function ($scope, $location, Desirae) {
var scope = this
;
.controller("SiteCtrl", [
"$scope",
"$location",
"Desirae",
function ($scope, $location, Desirae) {
var scope = this;
function init() { function init() {
console.log("desi loading"); console.log('desi loading');
Desirae.meta() Desirae.meta().then(function (desi) {
.then(function (desi) { scope.blogdir = desi.blogdir.path.replace(/^\/(Users|home)\/[^\/]+\//, '~/');
scope.blogdir = desi.blogdir.path.replace(
/^\/(Users|home)\/[^\/]+\//,
"~/"
);
scope.site = desi.site; scope.site = desi.site;
var parts = Desirae.splitUrl( var parts = Desirae.splitUrl(scope.site.base_url + (scope.site.base_path || '/'))
scope.site.base_url + (scope.site.base_path || "/") ;
);
if (parts) { if (parts) {
scope.base_url = scope.site.base_url; scope.base_url = scope.site.base_url;
scope.base_path = scope.site.base_path; scope.base_path = scope.site.base_path;
@ -39,40 +29,40 @@ angular
} }
scope.onChange(); scope.onChange();
}) }).catch(function (e) {
.catch(function (e) { window.alert("An Error Occured. Most errors that occur in the init phase are parse errors in the config files or permissions errors on files or directories, but check the error console for details.");
window.alert(
"An Error Occured. Most errors that occur in the init phase are parse errors in the config files or permissions errors on files or directories, but check the error console for details."
);
console.error(e); console.error(e);
throw e; throw e;
}); });
} }
scope.onChange = function () { scope.onChange = function () {
console.log("new url [0]", scope.url); console.log('new url [0]', scope.url);
var parts = Desirae.splitUrl(scope.url), var parts = Desirae.splitUrl(scope.url)
url; , url
;
if (!parts) { if (!parts) {
scope.base_url = ""; scope.base_url = '';
scope.base_path = ""; scope.base_path = '';
return; return;
} }
scope.base_url = parts.baseUrl; scope.base_url = parts.baseUrl;
scope.base_path = parts.basePath; scope.base_path = parts.basePath;
scope.dropboxIndex = ""; scope.dropboxIndex = '';
url = Desirae.gdrive2host(scope.url); url = Desirae.gdrive2host(scope.url)
;
if (!url && Desirae.dropbox2host(scope.url)) { if (!url && Desirae.dropbox2host(scope.url)) {
url = Desirae.dropbox2host(scope.url); url = Desirae.dropbox2host(scope.url);
scope.dropboxIndex = "/index.html"; scope.dropboxIndex = '/index.html';
} }
console.log("new url [1]", url); console.log('new url [1]', url);
if (url) { if (url) {
parts = Desirae.splitUrl(url); parts = Desirae.splitUrl(url);
@ -84,34 +74,27 @@ angular
}; };
scope.upsert = function () { scope.upsert = function () {
var files = []; var files = []
;
if (!scope.base_url || !scope.base_path) { if (!scope.base_url || !scope.base_path) {
window.alert( window.alert("URL: " + (scope.url) + "\nSomething about your URL doesn't look right.");
"URL: " +
scope.url +
"\nSomething about your URL doesn't look right."
);
return; return;
} }
// Just in case of http://blog.com/me/ + /blog vs http://blog.com + /me/blog // Just in case of http://blog.com/me/ + /blog vs http://blog.com + /me/blog
// don't change it unless it's truly different. // don't change it unless it's truly different.
if ( if ((scope.base_url + scope.base_path) !== (scope.site.base_url + scope.site.base_path)) {
scope.base_url + scope.base_path !==
scope.site.base_url + scope.site.base_path
) {
scope.site.base_url = scope.base_url; scope.site.base_url = scope.base_url;
scope.site.base_path = scope.base_path; scope.site.base_path = scope.base_path;
} }
files.push({ path: "site.yml", contents: scope.site }); files.push({ path: 'site.yml', contents: scope.site });
console.log(files); console.log(files);
Desirae.putFiles(files) Desirae.putFiles(files).then(function (results) {
.then(function (results) { console.log('TODO check for error');
console.log("TODO check for error");
console.log(results); console.log(results);
$location.path("/post"); $location.path('/post');
}) }).catch(function (e) {
.catch(function (e) {
console.error(scope.site); console.error(scope.site);
console.error(e); console.error(e);
window.alert("Error Nation! :/"); window.alert("Error Nation! :/");
@ -120,5 +103,4 @@ angular
}; };
init(); init();
}, }]);
]);

View File

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