Permalink
Browse files

first commit

  • Loading branch information...
0 parents commit 7da55263ec635ac847157a19d819965dbdd5fb62 @jackdempsey committed Nov 14, 2009
@@ -0,0 +1,22 @@
+.DS_Store
+log/*
+tmp/*
+TAGS
+*~
+.#*
+schema/schema.rb
+schema/*_structure.sql
+schema/*.sqlite3
+schema/*.sqlite
+schema/*.db
+*.sqlite
+*.sqlite3
+*.db
+src/*
+.hgignore
+.hg/*
+.svn/*
+gems/gems/*/
+gems/specifications/*
+!gems/gems/thor*/
+!gems/specifications/thor*
@@ -0,0 +1,20 @@
+Copyright (c) 2009 <YOUR NAME HERE>
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,7 @@
+= blog
+
+Description goes here.
+
+== Copyright
+
+Copyright (c) 2009 <YOUR NAME HERE>. See LICENSE for details.
@@ -0,0 +1,56 @@
+require 'rubygems'
+require 'rake'
+require 'pancake'
+
+begin
+ require 'jeweler'
+ Jeweler::Tasks.new do |gem|
+ gem.name = "blog"
+ gem.summary = %Q{TODO}
+ gem.email = "TODO"
+ gem.homepage = "TODO"
+ gem.authors = ["TODO"]
+ gem.add_dependency "pancake", ">=0.1.8"
+ gem.files = FileList["[A-Z]*", "pancake.init", "{lib,spec,rails}/**/*"]
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
+ end
+
+rescue LoadError
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
+end
+
+require File.join(File.dirname(__FILE__), "lib", "blog")
+Pancake.root = Pancake.get_root(__FILE__, "lib", "blog")
+THIS_STACK = Blog
+Blog.load_rake_tasks!
+
+require 'spec/rake/spectask'
+Spec::Rake::SpecTask.new(:spec) do |spec|
+ spec.libs << 'lib' << 'spec'
+ spec.spec_files = FileList['spec/**/*_spec.rb']
+end
+
+Spec::Rake::SpecTask.new(:rcov) do |spec|
+ spec.libs << 'lib' << 'spec'
+ spec.pattern = 'spec/**/*_spec.rb'
+ spec.rcov = true
+end
+
+
+task :default => :spec
+
+require 'rake/rdoctask'
+Rake::RDocTask.new do |rdoc|
+ if File.exist?('VERSION.yml')
+ config = YAML.load(File.read('VERSION.yml'))
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
+ else
+ version = ""
+ end
+
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = "foo #{version}"
+ rdoc.rdoc_files.include('README*')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
+
@@ -0,0 +1 @@
+0.0.0
@@ -0,0 +1,19 @@
+require 'active_record'
+
+class Blog < Pancake::Stacks::Short
+ add_root(__FILE__, "blog")
+
+ # Hook to use before we mount any applications
+ # before_mount_applications do
+ # end
+
+ initialize_stack
+
+ ActiveRecord::Base.establish_connection(
+ YAML.load_file(
+ ::File.join(Pancake.get_root(__FILE__, 'blog', 'config'), 'database.yml')
+ )[Pancake.env]
+ )
+end
+
+require ::File.join(Pancake.get_root(__FILE__, 'blog'), 'blog')
@@ -0,0 +1,13 @@
+class Blog
+ get "/", :_name => :home do
+ v.blog_entries = BlogEntry.all
+ render :root
+ end
+
+ post "/" do
+ blog_entry = BlogEntry.new(params.blog_entry)
+ blog_entry.save
+ redirect url(:home)
+ end
+end
+
@@ -0,0 +1,10 @@
+require 'pancake'
+require ::File.join(::File.expand_path(::File.dirname(__FILE__)), "..", "blog")
+
+# get the application to run. The applicadtion in the Pancake.start block
+# is the master application. It will have all requests directed to it through the
+# pancake middleware
+# This should be a very minimal file, but should be used when any stand alone code needs to be included
+app = Pancake.start(:root => Pancake.get_root(__FILE__)){ Blog.stackup(:master => true) }
+
+run app
@@ -0,0 +1,23 @@
+# Enter any global configuration for the stack in this file.
+
+class Blog
+ # include middleware for the development stack
+ # Labels can be set in the config/environments/<env>.rb file to limit
+ # middleware loading.
+ # stack(:middleware_name, :labels => [:development, :production]).use(MiddlewareClass)
+
+ class self::Configuration
+ # Add defaults to your stack configuration.
+ # This is scoped to this stack, and is inhertied into child stacks
+ #
+ # Fixed value defaults:
+ # default :var_name, :value, "A description of the variable"
+ #
+ # Lazy Defaults:
+ # default :var_name, lambda{ configuration_method }, "Some Description"
+
+ # Declare methods on your configuraiton
+ # def configuration_method; #stuff; end
+ end
+end
+
@@ -0,0 +1,13 @@
+development: &defaults
+ adapter: mysql
+ host: localhost
+ username: root
+ password:
+ database: pancake_blog_development
+ encoding: utf8
+
+test:
+ <<: *defaults
+
+production:
+ <<: *defaults
@@ -0,0 +1,18 @@
+Pancake.logger.info "Loading Development Environment"
+
+# Set the middleware lables to load
+Pancake.stack_labels = [:development]
+
+# Pancake.handle_errors!(true) # uncomment to have the stack handle any errors that occur
+
+class Blog
+ # include middleware for the development stack
+ # stack(:middleware_name).use(MiddlewareClass)
+end
+
+# Add code to hooks. Default available hooks:
+# :before_build_stack, :before_mount_applications, :after_initialize_application, :after_build_stack
+
+# Blog.before_build_stack do
+# # stuff to do
+# end
@@ -0,0 +1,19 @@
+Pancake.logger.info "Loading Production Environment"
+
+# Set the middleware lables to load
+Pancake.stack_labels = [:production]
+
+Pancake.handle_errors!(true) # uncomment to have the stack handle any errors that occur
+
+class Blog
+ # include middleware for the development stack
+ # stack(:middleware_name).use(MiddlewareClass)
+end
+
+# Add code to hooks. Default available hooks:
+# :before_build_stack, :before_mount_applications, :after_initialize_application, :after_build_stack
+
+# Blog.before_build_stack do
+# # stuff to do
+# end
+
@@ -0,0 +1,20 @@
+Pancake.logger.info "Loading Staging Environment"
+
+# Set the middleware lables to load
+Pancake.stack_labels = [:staging]
+
+Pancake.handle_errors!(true) # uncomment to have the stack handle any errors that occur
+
+class Blog
+ # include middleware for the development stack
+ # stack(:middleware_name).use(MiddlewareClass)
+end
+
+# Add code to hooks. Default available hooks:
+# :before_build_stack, :before_mount_applications, :after_initialize_application, :after_build_stack
+
+# Blog.before_build_stack do
+# # stuff to do
+# end
+
+
@@ -0,0 +1,5 @@
+class BlogEntry < ActiveRecord::Base
+ def to_s
+ title
+ end
+end
@@ -0,0 +1,17 @@
+# Sets the default handler for FastCGI scripts
+AddHandler fastcgi-script .fcgi
+
+# If Apache2 is used together with mod_fcgid,
+# uncomment the line below and comment in the line
+# above to set the correct script handler
+#AddHandler fcgid-script .fcgi
+
+RewriteEngine On
+
+RewriteRule ^$ index.html [QSA]
+RewriteRule ^([^.]+)$ $1.html [QSA]
+RewriteCond %{REQUEST_FILENAME} !-f
+RewriteRule ^(.*)$ merb.fcgi [QSA,L]
+
+
+ErrorDocument 500 "<h2>Application Error</h2>Merb could not be reached"
@@ -0,0 +1,15 @@
+#!/usr/bin/env ruby
+ENV['RACK_ENV'] ||= ARGV[0] || "development"
+
+ARGV.clear # Don't pass args to irb
+
+require 'rubygems'
+require 'pancake'
+
+Pancake.root = Pancake.get_root(__FILE__, "..")
+
+# Load the Blog stack
+require File.join(Pancake.root, "..", "blog")
+Pancake::Console.new(Blog)
+
+
@@ -0,0 +1,16 @@
+namespace :blog do
+ namespace :db do
+ desc "A simple way to get the blog_entries table created"
+ task :bootstrap do
+ ActiveRecord::Base.connection.instance_eval do
+ create_table :blog_entries, :force => true do |t|
+ t.column :title, :string
+ t.column :body, :text
+ end
+ end
+ BlogEntry.create(:title => "The World's First Pancake Blog Entry!", :body => "This really is cool stuff. Major props to hassox")
+ BlogEntry.create(:title => "Are you Brendan Smith?", :body => "If so, you have inherited the sum of 10 million pounds!")
+ end
+ end
+end
+
@@ -0,0 +1,27 @@
+- inherits_from :base
+
+- content_block :content do
+
+ %h1 Welcome to the Pancake Blog
+
+ %div
+ This is a simple blog that will serve as a battleground for developing and testing this delicious framework.
+
+ - v.blog_entries.each do |entry|
+ %h2= entry
+ %div= entry.body
+ %hr{:width => '75%'}
+
+ %form{:action => '/', :method => 'post'}
+ %div
+ %label{:for => 'blog_entry_title'} Title
+ %div
+ %input{:id => 'blog_entry_title', :type => 'text', :name => 'blog_entry[title]', :size => 30}
+
+ %div
+ %label{:for => 'blog_entry_body'} Body
+ %div
+ %textarea{:id => 'blog_entry_body', :name => 'blog_entry[body]', :rows => 8, :cols => 60}
+
+ %input{:type => 'submit', :value => "Create"}
+
@@ -0,0 +1 @@
+require ::File.join(::File.expand_path(::File.dirname(__FILE__)), "lib", "blog")
@@ -0,0 +1,11 @@
+require ::File.expand_path(::File.dirname(__FILE__) + '/spec_helper')
+
+describe "blog" do
+ def app
+ blog.stackup
+ end
+
+ it "fails" do
+ fail "hey buddy, you should probably rename this file and start specing for real"
+ end
+end
@@ -0,0 +1,13 @@
+require 'spec'
+require 'rack/test'
+require 'pancake'
+
+
+$LOAD_PATH.unshift(File.dirname(__FILE__))
+$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
+require 'blog'
+
+Spec::Runner.configure do |config|
+ config.include(Rack::Test::Methods)
+ config.include(Pancake::Test::Matchers)
+end

0 comments on commit 7da5526

Please sign in to comment.