Skip to content
This repository has been archived by the owner on Jan 17, 2022. It is now read-only.

Commit

Permalink
Merge branch 'release/v0.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
ffffranklin committed Nov 8, 2014
2 parents c9a245e + 8f414bd commit 6f3054d
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea/
.vagrant/
node_modules/
temp/
22 changes: 22 additions & 0 deletions .vagrant-provision.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

NPM_DIR="/usr/local/share/npm"

echo "Provisioning: started..."
echo "Current user is '$USER'"

echo "Provisioning: Installing sass"
gem install sass

echo "Provisioning: Installing node"
apt-get update
apt-get install -y nodejs nodejs-legacy npm git

echo "Provisioning: Installing yeoman and tumblr theme generator"
npm config -g set prefix $NPM_DIR
npm install --no-color -g yo grunt-cli generator-tumblr-theme
chmod -R 775 $NPM_DIR && chown -R vagrant $NPM_DIR

echo "export PATH=\"\$PATH:$NPM_DIR/bin\"" >> /home/vagrant/.bashrc

echo "Provisioning: Complete."
8 changes: 8 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty32"
config.vm.network "public_network"
config.vm.provision :shell, path: ".vagrant-provision.sh"
end
47 changes: 34 additions & 13 deletions app/templates/Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
var os = require('os');
var SpottrServer = require('spottr');

module.exports = function(grunt) {

var appPort = 9000;

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
watch: {
options:{
livereload: true
},
scripts: {
files: [
'app/theme/scripts/*.js',
'app/theme.tumblr',
],
options:{
livereload: true
}
'app/theme/scripts/**/*/.js',
'app/theme.tumblr'
]
},
styles: {
files: ['app/theme/styles/*.scss'],
tasks: ['sass'],
options:{
livereload: true
}
files: ['app/theme/styles/**/*.scss'],
tasks: ['sass']
}
},
sass: {
Expand All @@ -33,7 +36,7 @@ module.exports = function(grunt) {
connect: {
main: {
options: {
port: 9000,
port: appPort,
base: 'app'
}
}
Expand All @@ -50,5 +53,23 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-open');
grunt.registerTask('default', ['serve']);
grunt.registerTask('server', ['sass', 'connect', 'open', 'watch']);
grunt.registerTask('serve',['sass', 'connect', 'spottr', 'open', 'watch']);
grunt.registerTask('serve-remote',['sass', 'connect', 'spottr', 'print-remote', 'watch']);
grunt.registerTask('spottr', function (err) {
var server = new SpottrServer();
server.start();
});
grunt.registerTask('print-remote', function (err) {
var ifaces = os.networkInterfaces();
console.log('Your remote server is browser-accessible via these URLs:')
for (var dev in ifaces) {
var alias=0;
ifaces[dev].forEach(function(details){
if (details.family=='IPv4') {
console.log('http://'+details.address+':'+appPort, '('+dev+(alias?':'+alias:'')+')');
++alias;
}
});
}
});
};
4 changes: 3 additions & 1 deletion app/templates/_package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"name": "package",
"version": "0.0.0",
"dependencies": {},
"dependencies": {
"spottr": "git://github.com/ffffranklin/spottr"
},
"devDependencies": {
"grunt-contrib-sass": "^0.8.1",
"grunt-contrib-watch": "~0.6.1",
Expand Down
58 changes: 58 additions & 0 deletions app/templates/spottr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* Spottr
*
* A tumblr blog proxy that converts XML tumblr logs to JSON
* @author ffffranklin
*/

var PORT = 8080;
var http = require('http');

http.createServer(function (req, res) {

var url;


// check if url path starts with content and has a character after it
if (req.url.match(/^\/content\/\S+/)) {

// returns [1] as undefined if no greater than 0 in length
url = req.url.match('^/content\/(.*){0,}')[1];

if (url) {

console.log('Spottr: Requesting source of "%s"', url);

http.get('http://' + url, function (response) {

res.writeHeader(200, {"Content-Type": "text/plain"});

console.log('Spottr: Response received with status code %s', response.statusCode);

if (response.statusCode === 200) {
response.setEncoding('utf8');
response.on('data', function (chunk) {
res.write(chunk);
});
response.on('end', function () {
// TODO make sure to end response if this 'end' event never happens
res.end();
})
} else {
res.write('Didn\'t work');
res.end();
}
}).on('error', function (e) {
console.log('Got error: ' + e.message);
});

}
} else {
res.write('404');
res.end();
}

}).listen(PORT);

console.log('Spottr: Created Server "http://localhost:%s"', PORT);

3 changes: 2 additions & 1 deletion app/templates/tumblr-themr-1.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,8 @@ $.noConflict();
if (typeof TumblrThemr.cache[c] !== "undefined" && TumblrThemr.cache[c] !== null) {
TumblrThemr.render(d, TumblrThemr.cache[c])
} else {
$.ajax({url: "http://tumblrxmltojson.icelab.com.au/content/" + c + "?callback=?",dataType: "json",success: function(e) {
// $.ajax({url: "http://tumblrxmltojson.icelab.com.au/content/" + c + "?callback=?",dataType: "json",success: function(e) {
$.ajax({url: "http://" + window.location.hostname + ":8080/content/" + c + "?callback=?",dataType: "json",success: function(e) {
TumblrThemr.cache[c] = e;
TumblrThemr.render(d, e)
},error: function(e, f) {
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "generator-tumblr-theme",
"version": "0.2.3",
"version": "0.3.0",
"description": "A tumblr theme generator for Yeoman",
"homepage": "https://github.com/ffffranklin/generator-tumblr-theme",
"bugs": "https://github.com/ffffranklin/generator-tumblr-theme/issues",
Expand All @@ -24,9 +24,9 @@
"yeoman-generator"
],
"dependencies": {
"yeoman-generator": "^0.17.0",
"chalk": "^0.5.0",
"yosay": "^0.3.0"
"yeoman-generator": "^0.17.7",
"chalk": "^0.5.1",
"yosay": "^1.0.0"
},
"devDependencies": {
"mocha": "*"
Expand Down

0 comments on commit 6f3054d

Please sign in to comment.