Skip to content
Browse files

first commit

  • Loading branch information...
0 parents commit 0e69ae1ba6b98a8e54a992e03919c3d03cf0f965 @videlalvaro committed
Showing with 153 additions and 0 deletions.
  1. +18 −0 README.md
  2. +53 −0 Rakefile
  3. +31 −0 app.js
  4. +3 −0 cloudfoundry.json
  5. +13 −0 manifest.yml
  6. +20 −0 npm-shrinkwrap.json
  7. +15 −0 vmcignore
18 README.md
@@ -0,0 +1,18 @@
+# cloudfoundry-octopress #
+
+This project eases the deployment of [octopress](http://octopress.org/) blogs to [Cloud Foundry](http://cloudfoundry.com/).
+
+## Requirements ##
+
+- A Cloud Foundry account. Get one [here](https://my.cloudfoundry.com/signup).
+- Octopress installed. Follow the setup steps from the octopress [website](http://octopress.org/docs/).
+- `vmc` installed: `gem install vmc`
+- Some ideas to blog about.
+
+## Instructions ##
+
+TODO
+
+# LICENSE #
+
+TODO
53 Rakefile
@@ -0,0 +1,53 @@
+require "rubygems"
+require "bundler/setup"
+require "stringex"
+
+current_dir = File.expand_path(File.dirname(__FILE__))
+
+# usage rake new_app[app_name]
+desc "Creates a new manifest file to deploy the blog to cloud foundry"
+task :new_app, :name do |t, args|
+ raise "### You need to provide an application name" unless !args.name.nil?
+ appname = args.name
+ filename = "manifest.yml"
+ if File.exist?(filename)
+ abort("rake aborted!") if ask("#{filename} already exists. Do you want to overwrite?", ['y', 'n']) == 'n'
+ end
+ puts "Writing manifest file: #{filename}"
+
+ manifest = IO.read("#{current_dir}/manifest.yml")
+ dest_manifest = "#{current_dir}/../manifest.yml"
+
+ File.open(dest_manifest, 'w') do |f|
+ f.write manifest.sub!("app_name", appname)
+ end
+
+ puts "Copying static node.js server"
+ FileUtils.cp("#{current_dir}/app.js", "#{current_dir}/../app.js")
+
+ puts "Copying .vmcignore file"
+ FileUtils.cp("#{current_dir}/vmcignore", "#{current_dir}/../.vmcignore")
+
+ puts "Copying npm-shrinkwrap file"
+ FileUtils.cp("#{current_dir}/npm-shrinkwrap.json", "#{current_dir}/../npm-shrinkwrap.json")
+
+ puts "Copying cloudfoundry.json"
+ FileUtils.cp("#{current_dir}/cloudfoundry.json", "#{current_dir}/../cloudfoundry.json")
+
+end
+
+## From octopress Rakefile
+## maybe we can include these somehow without the need for copy paste.
+def get_stdin(message)
+ print message
+ STDIN.gets.chomp
+end
+
+def ask(message, valid_options)
+ if valid_options
+ answer = get_stdin("#{message} #{valid_options.to_s.gsub(/"/, '').gsub(/, /,'/')} ") while !valid_options.include?(answer)
+ else
+ answer = get_stdin(message)
+ end
+ answer
+end
31 app.js
@@ -0,0 +1,31 @@
+var static = require('node-static'),
+http = require('http'),
+util = require('util');
+
+var webroot = './public',
+port = 4000;
+
+var file = new(static.Server)(webroot, {
+ cache: 600,
+ headers: { 'X-Powered-By': 'node-static' }
+});
+
+http.createServer(function(req, res) {
+ req.addListener('end', function() {
+ file.serve(req, res, function(err, result) {
+ if (err) {
+ console.error('Error serving %s - %s', req.url, err.message);
+ if (err.status === 404 || err.status === 500) {
+ file.serveFile(util.format('/%d.html', err.status), err.status, {}, req, res);
+ } else {
+ res.writeHead(err.status, err.headers);
+ res.end();
+ }
+ } else {
+ console.log('%s - %s', req.url, res.message);
+ }
+ });
+ });
+}).listen(port);
+
+console.log('node-static running at http://localhost:%d', port);
3 cloudfoundry.json
@@ -0,0 +1,3 @@
+{
+ "ignoreNodeModules": true
+}
13 manifest.yml
@@ -0,0 +1,13 @@
+---
+applications:
+ .:
+ name: app_name
+ framework:
+ name: node
+ info:
+ mem: 64M
+ description: Node.js Application
+ exec:
+ url: ${name}.${target-base}
+ mem: 64M
+ instances: 1
20 npm-shrinkwrap.json
@@ -0,0 +1,20 @@
+{
+ "dependencies": {
+ "node-static": {
+ "version": "0.6.2",
+ "dependencies": {
+ "optimist": {
+ "version": "0.3.4",
+ "dependencies": {
+ "wordwrap": {
+ "version": "0.0.2"
+ }
+ }
+ },
+ "colors": {
+ "version": "0.6.0-1"
+ }
+ }
+ }
+ }
+}
15 vmcignore
@@ -0,0 +1,15 @@
+CHANGELOG.markdown
+Gemfile
+Gemfile.lock
+README.markdown
+Rakefile
+_config.yml
+app.js
+cloudfoundry-octopress/
+config.rb
+config.ru
+manifest.yml
+node_modules/
+plugins/
+sass/
+source/

0 comments on commit 0e69ae1

Please sign in to comment.
Something went wrong with that request. Please try again.