Permalink
Browse files

Added theming interface and refactored out base theme

  • Loading branch information...
1 parent 4c30607 commit 1d03b10906c6e3392946b9fb71a5c78db690577c @colinwren colinwren committed May 25, 2013
View
File renamed without changes.
@@ -1,3 +0,0 @@
-title: Post 1
-date: 2013-05-12
-----
@@ -1,12 +0,0 @@
-title: Post 2
-date: 2013-05-12
-----
-
-#Post 2
-
-```javascript
-for (var i = 0; i < i++) {
- alert(i);
-}
-
-```
@@ -1,14 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
- <title>My Blog</title>
- <meta charset="utf8">
- <meta name="viewport" content="width=device-width">
- <link href="/monokai.css" rel="stylesheet">
-</head>
-<body>
- <ul>
- <li><a href="/blog">Blog</a></li><li><a href="/">Home</a></li>
- </ul>
-</body>
-</html>
@@ -1,20 +0,0 @@
-doctype 5
-html
- head
- title= "My Blog"
- meta(charset="utf8")
- meta(name="viewport", content="width=device-width")
- link(href="/styles/main.css", rel="stylesheet")
- link(href="/styles/tomorrow-night-bright.css", rel="stylesheet")
- block title
- body
- block header
- ul
- li
- a(href="/blog") Blog
- li
- a(href="/") Home
- block content
- block footer
- //- this needs to be conditionally included based on envirnoment
- script(src="http://localhost:35729/livereload.js")
@@ -1 +0,0 @@
-<% include base %>
@@ -1,3 +0,0 @@
-extends base
-block content
- div!= content
@@ -1 +0,0 @@
-<% include ../layouts/base %>
@@ -1,8 +0,0 @@
-extends ../../layouts/base
-block content
- ul
- each post in posts
- li
- span Posted on #{post.date}
- br
- a(href="/#{post.url}") #{post.title}
@@ -1 +0,0 @@
-<% include ../layouts/base %>
@@ -1 +0,0 @@
-extends ../layouts/base
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
@@ -1,51 +0,0 @@
-/* Tomorrow Night Bright Theme */
-/* Original theme - https://github.com/chriskempson/tomorrow-theme */
-/* http://jmblog.github.com/color-themes-for-google-code-highlightjs */
-.tomorrow-comment, pre .comment, pre .title {
- color: #969896;
-}
-
-.tomorrow-red, pre .variable, pre .attribute, pre .tag, pre .regexp, pre .ruby .constant, pre .xml .tag .title, pre .xml .pi, pre .xml .doctype, pre .html .doctype, pre .css .id, pre .css .class, pre .css .pseudo {
- color: #d54e53;
-}
-
-.tomorrow-orange, pre .number, pre .preprocessor, pre .built_in, pre .literal, pre .params, pre .constant {
- color: #e78c45;
-}
-
-.tomorrow-yellow, pre .ruby .class .title, pre .css .rules .attribute {
- color: #e7c547;
-}
-
-.tomorrow-green, pre .string, pre .value, pre .inheritance, pre .header, pre .ruby .symbol, pre .xml .cdata {
- color: #b9ca4a;
-}
-
-.tomorrow-aqua, pre .css .hexcolor {
- color: #70c0b1;
-}
-
-.tomorrow-blue, pre .function, pre .python .decorator, pre .python .title, pre .ruby .function .title, pre .ruby .title .keyword, pre .perl .sub, pre .javascript .title, pre .coffeescript .title {
- color: #7aa6da;
-}
-
-.tomorrow-purple, pre .keyword, pre .javascript .function {
- color: #c397d8;
-}
-
-pre code {
- display: block;
- background: black;
- color: #eaeaea;
- padding: 0.5em;
-}
-
-pre .coffeescript .javascript,
-pre .javascript .xml,
-pre .tex .formula,
-pre .xml .javascript,
-pre .xml .vbscript,
-pre .xml .css,
-pre .xml .cdata {
- opacity: 0.5;
-}
View
@@ -1,4 +1,4 @@
- var utils = require('./utils.js');
+var utils = require('./utils.js');
module.exports = function(argv) {
var now = new Date();
var post = {
View
@@ -2,7 +2,7 @@ var utils = require('./utils.js');
var spawn = require('child_process').spawn;
var async = require('async');
-module.exports = function(options) {
+module.exports = function(options, callback) {
utils.safeWriteDir(process.cwd() + '/' + options.siteName);
process.chdir(options.siteName);
@@ -14,12 +14,15 @@ module.exports = function(options) {
utils.renderTemplate('_package.json', 'package.json', options, callback);
},
function(callback) {
- utils.copyBoilerplates(options, callback);
+ utils.downloadTheme(options, callback);
}
], function(err) {
if (err) throw err;
process.stdin.destroy();
// Install node modules
- spawn('npm', ['install'], { stdio: 'inherit' });
+ var npmInstall = spawn('npm', ['install'], { stdio: 'inherit' });
+ npmInstall.on('close', function() {
+ callback();
+ });
});
};
View
@@ -1,18 +1,19 @@
var fs = require('fs');
var program = require('commander');
-var wrench = require('wrench');
var async = require('async');
var _ = require('lodash');
var colors = require('colors');
var path = require('path');
+var request = require('request');
+var AdmZip = require('adm-zip');
module.exports = {
renderTemplate: renderTemplate,
createPrompt: createPrompt,
getExtension: getExtension,
safePrompt: safePrompt,
safeWriteDir: safeWriteDir,
- copyBoilerplates: copyBoilerplates
+ downloadTheme: downloadTheme
};
function renderTemplate (template, destination, data, callback) {
@@ -56,7 +57,7 @@ function getExtension (path) {
return _.last(path.split('.'));
}
-function copyBoilerplates (options, callback) {
+function downloadTheme (options, callback) {
var extensions = [
'md',
'css',
@@ -77,19 +78,47 @@ function copyBoilerplates (options, callback) {
extensions.push('js');
}
- // Recursively read directories contents.
- var files = wrench.readdirSyncRecursive(path.resolve(__dirname, '../') + '/boilerplates');
- async.eachSeries(files, function(filePath, callback) {
+ var repo = options.repo || 'colinwren/testTheme';
- if (filePath.indexOf('.') === -1) { // If its a directory
- safeWriteDir(process.cwd() + '/' + filePath);
- callback();
+ // Get theme zip
+ var req = request({
+ uri: 'https://github.com/' + repo + '/archive/master.zip',
+ headers: {
+ 'Accept-Encoding': 'gzip,deflate,sdch'
+ }
+ });
+
+ // Improve this
+ req.on('error', function(err) {
+ console.log(err);
+ process.exit(1);
+ });
+
+ var zipPath = '.tmpZip.zip';
+ var out = fs.createWriteStream(zipPath);
+ req.pipe(out);
+
+ req.on('end', function() {
+ var zip = new AdmZip(zipPath);
- } else if (extensions.indexOf(getExtension(filePath)) !== -1) {
- var source = fs.readFileSync(path.resolve(__dirname, '../') + '/boilerplates/' + filePath , 'utf8');
- safeWriteFile(filePath, source, callback);
- } else callback();
- }, callback);
+ async.eachSeries(zip.getEntries(), function(zipEntry, callback) {
+ var filePath = zipEntry.entryName.split('/').slice(1).join('/');
+
+ if (filePath.indexOf('.') === -1) { // If its a directory
+ safeWriteDir(process.cwd() + '/' + filePath);
+ callback();
+
+ } else if (extensions.indexOf(getExtension(filePath)) !== -1) {
+ var source = zipEntry.getData() + '';
+ safeWriteFile(filePath, source, callback);
+
+ } else callback();
+
+ }, function() {
+ fs.unlinkSync(zipPath);
+ callback();
+ });
+ });
}
function safeWriteFile(filePath, data, callback) {
@@ -111,7 +140,7 @@ function safeWriteDir(dirPath) {
var overwrite = false;
function resolveWriteConflict(filePath, data, callback) {
if (overwrite) {
- overwriteFile(filePath, data, choice, callback);
+ overwriteFile(filePath, data, callback);
} else {
safePrompt('There is already a file at ' + filePath.red + '!\n How do you want to handle it?', [
@@ -143,7 +172,7 @@ function overwriteAll(filePath, data, callback) {
callback();
}
-function abortGeneration(filePath, data, callback) {
+function abortGeneration() {
console.log('Generation Aborted!');
process.exit(1);
}
View
@@ -1,9 +1,9 @@
{
- "name": "jsblog",
+ "name": "cabin",
"version": "0.0.0",
- "description": "globaljsblog",
+ "description": "",
"main": "index.js",
- "bin": "./bin/jsblog",
+ "bin": "./bin/cabin",
"repository": {
"type": "git",
"url": "https://github.com/ChrisWren/globaljsblog.git"
@@ -25,6 +25,7 @@
"devDependencies": {
"mocha": "*",
"should": "~1.2.2",
- "github-download": "~0.2.0"
+ "adm-zip": "~0.4.3",
+ "request": "~2.21.0"
}
}
View
@@ -3,7 +3,7 @@
"version": "0.0.0",
"devDependencies": {
"grunt": "~0.4.1",
- "grunt-blog": "git+https://colinwren@github.com/ChrisWren/jsblog.git",
+ "grunt-blog": "git+https://colinwren@github.com/ChrisWren/grunt-blog.git",
"grunt-contrib-copy": "~0.4.1",<% if (coffee) { %>
"grunt-contrib-coffee": "~0.6.5",<% } %><% if (preprocesser = 'compass') { %>
"grunt-contrib-compass": "~0.2.0",

0 comments on commit 1d03b10

Please sign in to comment.