Giter Site home page Giter Site logo

camping's Introduction

Build Status

Camping, a Microframework

Camping is a micro web framework which stays as small as possible. You can probably view the complete source code on a single page. But, you know, it's so small that, if you think about it, what can it really do? Apparently it can do a lot. It's pretty swell.

The idea here is to store a complete fledgling web application in a single file like many small CGIs. But to organize it as a Model-View-Controller application. And with time, you can move your Models, Views, and Controllers into other files as your app grows.

Camping supports multiple apps, capsuled code that runs together. Each app can have independent models, routes, and controllers.

Pack your gear when you go Camping! With a simple plugin system, Camping is easily extensible. Add all sorts of useful and silly things.

A Camping Skeleton

A skeletal Camping blog could look like this:

require 'camping'

Camping.goes :Blog

module Blog::Models
  class Post < Base; belongs_to :user; end
  class Comment < Base; belongs_to :user; end
  class User < Base; end
end

module Blog::Controllers
  class Index
    def get
      @posts = Post.find :all
      render :index
    end
  end
end

module Blog::Views
  def layout
    html do
      head { title "My Blog" }
      body do
        h1 "My Blog"
        self << yield
      end
    end
  end

  def index
    @posts.each do |post|
      h1 post.title
    end
  end
end

Installation

Interested yet? Luckily it's quite easy to install Camping. We'll be using a tool called RubyGems, and Bundler, so if you don't have that installed yet, go grab it! Once that's sorted out, open up a Terminal or Command Line and enter:

gem install camping

Also make certain to have Bundler installed:

gem install bundler

Even better, install the Camping Omnibus, a full package of recommended libs: Camping Omnibus will return for summer vacation.

Now make a new directory filled with your camp essentials using the camping new command:

camping new Donuts # You can replace Donuts with whatever but CamelCased.

Move to your new directory, then use bundler to install all of your camp's dependencies:

cd donuts; bundle install

You can now run camping using the camping command. We recommend running camping in development mode locally. Make certain to prefix the camping command with bundle exec to run your app with the gems you've installed just for your camp:

bundle exec camping -e development

Learning

First of all, you should read the first chapters of The Camping Book. It should hopefully get you started pretty quick. While you're doing that, you should be aware of the reference which contains documentation for all the different parts of Camping.

The wiki is the place for all tiny, useful tricks that we've collected over the years. Don't be afraid to share your own discoveries; the more, the better!

And if there's anything you're wondering about, don't be shy, but rather subscribe to the mailing list and ask there. We also have an IRC channel over at Freenode, so if you feel like chatting with us, you should join #camping @ irc.freenode.net.

Running Tests

Tests should be run using bundler and rake: bundle exec rake.

Minting Releases

We use Ruby Gems to distribute versions of Camping.

Authors

Camping was originally crafted by why the lucky stiff, but is now maintained by the community. This simply means that if we like your patch, it will be applied. Everything is managed through the mailing list, so just subscribe and you can instantly take part in shaping Camping.

camping's People

Contributors

aanand avatar amarshall avatar babalela avatar bryant1410 avatar busbey avatar daveeveritt avatar dragonstuff avatar fntz avatar gregkare avatar joshgoebel avatar jpalmieri avatar juanitofatas avatar judofyr avatar karloscarweber avatar kaylahrose avatar kevinlitchfield avatar lukateras avatar markjeee avatar markmfredrickson avatar matmarex avatar mountaincode avatar ncr avatar nickjenkins83 avatar olleolleolle avatar qwzybug avatar sadfuzzy avatar seanslerner avatar shime avatar techarch avatar technoweenie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

camping's Issues

typos in README and book chapter 02

README uses your when it means you're

chapter 02 misses a the 'to' in 'what to show' and says there's a 'mayor flaw'.

I thought the last one might be a pun, but without some illustrations of a major reworking of the examples I don't see how it could be.

Hello Clock example doesn't work

With code copied and pasted from the "Enjoying the view" section of the Hello Clock example it dies on the "render :sundial" line with the following error.

NameError: uninitialized constant Nuts::Base::Mab (eval):18:in `mab' (eval):15:in`render' /Users/masukomi/workspace/temp/nuts.rb:7:in `get' (eval):28:in`send' (eval):28:in `service' (eval):28:in`catch' (eval):28:in `service' (eval):39:in`call' /Library/Ruby/Gems/1.8/gems/camping-2.1/bin/../lib/camping/server.rb:176:in `call' /Library/Ruby/Gems/1.8/gems/rack-1.2.2/lib/rack/lint.rb:48:in`_call' /Library/Ruby/Gems/1.8/gems/rack-1.2.2/lib/rack/lint.rb:36:in `call' /Library/Ruby/Gems/1.8/gems/rack-1.2.2/lib/rack/showexceptions.rb:24:in`call' /Library/Ruby/Gems/1.8/gems/rack-1.2.2/lib/rack/commonlogger.rb:18:in `call' /Library/Ruby/Gems/1.8/gems/camping-2.1/bin/../lib/camping/server.rb:242:in`call' /Library/Ruby/Gems/1.8/gems/rack-1.2.2/lib/rack/content_length.rb:13:in `call' /Library/Ruby/Gems/1.8/gems/rack-1.2.2/lib/rack/chunked.rb:15:in`call' /Library/Ruby/Gems/1.8/gems/rack-1.2.2/lib/rack/handler/mongrel.rb:67:in `process' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in`process_client' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in`process_client' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in`initialize' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in`run' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `initialize' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in`new' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run' /Library/Ruby/Gems/1.8/gems/rack-1.2.2/lib/rack/handler/mongrel.rb:38:in`run' /Library/Ruby/Gems/1.8/gems/rack-1.2.2/lib/rack/server.rb:213:in `start' /Library/Ruby/Gems/1.8/gems/camping-2.1/bin/../lib/camping/server.rb:144:in`start' /Library/Ruby/Gems/1.8/gems/rack-1.2.2/lib/rack/server.rb:100:in `start' /Library/Ruby/Gems/1.8/gems/camping-2.1/bin/camping:9 /usr/bin/camping:19:in`load' /usr/bin/camping:19

Error compiling http11.c when installing camping-omnibus

OS X 10.7 (Lion)
Intel Mac
GCC: i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1
8GB RAM
3.06 GHz Intel Core 2 Duo

Building native extensions. This could take a while...
ERROR: Error installing camping-omnibus:
ERROR: Failed to build gem native extension.

    /Users/chuck/.rvm/rubies/ruby-1.9.3-p0/bin/ruby extconf.rb

checking for main() in -lc... yes
creating Makefile

make
compiling http11.c
http11.c: In function โ€˜http_fieldโ€™:
http11.c:70: warning: format not a string literal and no format arguments
http11.c:71: warning: format not a string literal and no format arguments
http11.c:77: error: โ€˜struct RStringโ€™ has no member named โ€˜ptrโ€™
http11.c:77: error: โ€˜struct RStringโ€™ has no member named โ€˜lenโ€™
http11.c:77: warning: left-hand operand of comma expression has no effect
http11.c: In function โ€˜request_uriโ€™:
http11.c:102: warning: format not a string literal and no format arguments
http11.c: In function โ€˜fragmentโ€™:
http11.c:113: warning: format not a string literal and no format arguments
http11.c: In function โ€˜request_pathโ€™:
http11.c:124: warning: format not a string literal and no format arguments
http11.c: In function โ€˜query_stringโ€™:
http11.c:135: warning: format not a string literal and no format arguments
http11.c: In function โ€˜header_doneโ€™:
http11.c:172: error: โ€˜struct RStringโ€™ has no member named โ€˜ptrโ€™
http11.c:174: error: โ€˜struct RStringโ€™ has no member named โ€˜ptrโ€™
http11.c:176: error: โ€˜struct RStringโ€™ has no member named โ€˜ptrโ€™
http11.c:177: error: โ€˜struct RStringโ€™ has no member named โ€˜lenโ€™
http11.c: In function โ€˜HttpParser_executeโ€™:
http11.c:298: error: โ€˜struct RStringโ€™ has no member named โ€˜ptrโ€™
http11.c:299: error: โ€˜struct RStringโ€™ has no member named โ€˜lenโ€™
http11.c:307: warning: format not a string literal and no format arguments
make: *** [http11.o] Error 1

Tests

We don't need full unit tests, but at least a way to automatically running the apps under test/apps and making sure they work as expected.

Can't connect to Sqlite3

Sorry: I accidentally closed the thread.

Sure, here's the link:
http://pastie.org/1106699
It's just the example code from the book, with a controller class thrown in. I've tried a bunch of scripts that try to involve the DB and none of them will execute. I thought maybe Active Record wasn't being initialized but can't figure out why.

Thanks for your help.

Make Camping and Rack-Flash good buddies

We do some rack.session because we want a pretty @state.
This does not work with middleware like Rack-Flash.
Rack-Flash already kinda works for vanilla Rack apps (they monkey patch use() and run() which is bold but ...) and it works with Sinatra so let's try to make it work with us. Then we have one less reason to have rails-envy!

Offending code is in to_a()

  def to_a
    @env['rack.session'] = (Hash[@state])
    r = Rack::Response.new(@body, @status, @headers)
    @cookies._n.each do |k, v|
      r.set_cookie(k, v)
    end
    r.to_a

and

def initialize(env, m) #:nodoc: 
      r = @request = Rack::Request.new(@env = env)
      @root, @input, @cookies, @state,
      @headers, @status, @method =
      r.script_name.sub(/\/$/,''), n(r.params),
      Cookies[r.cookies], H[r.session.to_hash],
      {}, m =~ /r(\d+)/ ? $1.to_i : 200, m
      @cookies._p = self/"/"
    end

update rubyforge

preferably before 2.0. having to specify sources to get something like the current makes it really painful to use camping on hosted systems.

modify the x-sendfile logic to send appropriate cache headers

I know you should only use Camping in dev mode and then move on to Apache or Nginx + mod_rails for production but it would still be nice if in de mode that Camping was a bit smarter in this area.

See for example this page by the mod_xsendfile guys for Apache where they mention a couple of tricks:

  • Sets correct cache headers such as Etag and If-Modified-Since as if the file was statically served.
  • Processes cache headers such as If-None-Match or If-Modified-Since.

judofyr mentioned this code from Rack: https://github.com/rack/rack/blob/master/lib/rack/file.rb#L56-L64

Windows server reloading

After editing a file this happens:

!! Error loading C:/Users/Bertil/Camping/Blog/blog/blog.rb:
TypeError: wrong argument type Module (expected Class)
<main>:55:in `<module:Models>'
<main>:52:in `<module:Blog>'
<main>:1:in `<main>'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/camping-2.1.467/lib/camping.rb:44:in `eval'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/camping-2.1.467/lib/camping.rb:44:in `goes'
C:/Users/Bertil/Camping/Blog/blog/blog.rb:1:in `<top (required)>'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:234:in `load'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:234:in `block in load'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:223:in `block in load_dependency'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:640:in `new_constants_in'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:223:in `load_dependency'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:234:in `load'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/camping-2.1.467/lib/camping/reloader.rb:64:in `load_apps'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/camping-2.1.467/lib/camping/reloader.rb:109:in `reload!'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/camping-2.1.467/lib/camping/reloader.rb:184:in `block in reload!'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/camping-2.1.467/lib/camping/reloader.rb:183:in `each'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/camping-2.1.467/lib/camping/reloader.rb:183:in `reload!'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/camping-2.1.467/lib/camping/reloader.rb:162:in `update'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/camping-2.1.467/lib/camping/server.rb:157:in `find_scripts'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/camping-2.1.467/lib/camping/server.rb:161:in `reload!'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/camping-2.1.467/lib/camping/server.rb:169:in `call'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.3.3/lib/rack/lint.rb:48:in `_call'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.3.3/lib/rack/lint.rb:36:in `call'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.3.3/lib/rack/showexceptions.rb:24:in `call'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.3.3/lib/rack/commonlogger.rb:20:in `call'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.3.3/lib/rack/chunked.rb:41:in `call'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.3.3/lib/rack/content_length.rb:14:in `call'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/camping-2.1.467/lib/camping/server.rb:242:in `call'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.3.3/lib/rack/handler/webrick.rb:59:in `service'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
!! Error loading C:/Users/Bertil/Camping/Blog/blog/blog.rb, see backtrace above

As far as I know, the only solution is to restart the server. Which is not productive you know!
I don't know if I'm the only one having this problem though.

Kids, this why you don't develop in windows!

ActiveRecord Multipul Inserts

I'm new to ruby so excuse me if this is an error on my part.

If I try to create 2 different objects with 2 different models it seems like only the first item is validating.

Heres is the code from my controller:

unless @company = Company.create(
  :name => @input.name,
  :sub_domain => @input.sub_domain)

  unless @user.User.create(
    :company_id => @company.id,
    :first_name => @input.first_name,
    :last_name => @input.last_name,
    :email => @input.email,
    :password => @input.password)
    return redirect Login
  end
end

@errors = @company.errors.full_messages | @user.errors.full_messages
render :register

Here is my model:

class Company < Base
  validates_presence_of :name
  validates_presence_of :sub_domain
  validates_uniqueness_of :sub_domain
end

class User < Base
  validates_presence_of :first_name
  validates_presence_of :last_name
  validates_presence_of :email
  validates_presence_of :password
  validates_uniqueness_of :email
end

The validation only seems to work on the company model. once the validation passes for the company it redirects and doesn't validate or save the user. Is this an issue with camping or am I doing something wrong?

Edit by judofyr: I cleaned up the indentation of the code a bit. Tips: If you indent text with four spaces at this issue tracker, it will also turn it into a code block.

Markaby doesn't work in 1.9

We can fix this by adding attr_reader :builder in Camping::Mab, but this should actually be reported to the Markaby guys (whoevery they are?)

The real problem is:

elsif instance_variables.include?("@#{sym}")
  instance_variable_get("@#{sym}")

instance_variables returns Array of Symbols in 1.9.

Thanks to David Ray for reporting the bug!

remove ActiveRecord as a dependency

When trying to run the hompage example from the wiki I get the following error. It appears that camping wants ActiveRecord installed.

/Users/ironman/.rvm/gems/ree-1.8.7-2009.10/gems/camping-2.0/bin/../lib/camping/ar.rb:6: ActiveRecord could not be loaded (is it installed?): no such file to load -- active_record (MissingLibrary)
from /Users/ironman/.rvm/gems/ree-1.8.7-2009.10/gems/camping-2.0/bin/../lib/camping/server.rb:38:in `connect'
from /Users/ironman/.rvm/gems/ree-1.8.7-2009.10/gems/camping-2.0/bin/../lib/camping/server.rb:33:in `initialize'
from /Users/ironman/.rvm/gems/ree-1.8.7-2009.10/gems/camping-2.0/bin/camping:96:in `new'
from /Users/ironman/.rvm/gems/ree-1.8.7-2009.10/gems/camping-2.0/bin/camping:96
from /Users/ironman/.rvm/gems/ree-1.8.7-2009.10/bin/camping:19:in `load'
from /Users/ironman/.rvm/gems/ree-1.8.7-2009.10/bin/camping:19

Is there a way out to use HAML with camping

Hi,
I like camping and I'm just starting to use it. But the code to generate the view is a pain.
So, can I use HAML for the view part?
And, is there a way out not to restart the server each time even if I modified a single character?

Camping Ruby 1.9.1

Is camping compatible with ruby 1.9.1? I just upgraded my server to 1.9.1 and now I am getting this:

NoMethodError at /register
undefined method `scan' for :Register:Symbol
Ruby (eval): in block (2 levels) in M, line 30

If I reload the camping app I then get a standard camping 404

Camping Problem!
/ not found

Is this an issue with ruby 1.9.1 or did I do something wrong when I compiled ruby?

Route-generating for escaped URLs fails

Camping.goes :App

module App::Controllers
  class Styles < R '/style\.css'
  end

  class Index
    def get
      R(Styles)
    end
  end
end

This raises "bad route" on the latest version. Solution seems to add .gsub(/\\(.)/){$1} to Helpers#R. More information/patch coming later when I'm at my dev machine.

Getting started

We should have at least a complete "Getting started"-chapter.

Error running Camping 1.5.180 on ruby 1.9

Hello,

I am trying the tutorial in the Camping Book and get an error running "camping nuts.rb"
http://gist.github.com/305343

I have tested camping (1.5.180) and camping (1.9.354) on ruby 1.9.1p376 (2009-12-07 revision 26041) [powerpc-darwin9] and neither version of camping works.

It works fine with Ruby 1.8.6. Could support for Ruby 1.9 be added?

Thanks.

Migrations are not good enough

Migrations suck. I mean, really. If you wanted to start an aviary of your own, you would just say there are birds. birds fly with the weather, not when you tell them every little detail of the routes to take. you shouldn't have to know when the wind is good to put out a bird feeder.

The common case for camping apps is saying "I want to make sure there's a database like this." I don't want to muck around with phpmyadmin or mysql or sqlite. I want magic. I want danger. I want to still use migrations if things get suck.

ex: http://github.com/busbey/camping/blob/master/examples/blog.rb

I have this implemented in a way that lives along side the current migrations stuff, but I'm testing out one more fix for the case where someone wants to use ActiveRecords subclasses in one table thing.

Less useful, but this is the patch that makes the blog example look the way I want and moves the migration example to the side. apply and look at them. tell me that migration thing looks like camping would approve. busbey/camping@92820d6

Tilt integration

You don't always want to use Markaby (or want to place templates in files instead), so Tilt integration would be nice.

The websites are in a sorry state.

camping.rubyforge.org / whywentcamping.com

  • is unreadable because of a missing background.
    • scrolling is dog slow
    • the site is uglier than whywentcamping.judofyr.net. The theme of the homepage clashes with the rest of the site (book, API).

whywentcamping.judofyr.net gives 404 for /reference and /news.

http://ruby-camping.com/ adds little and dilutes the web presence. Furthermore, the white rectangle behind the menu is too short, the 'Documentation' link sticks out.

All graphic problems are experienced in Chrome on OS X 10.6.

migrations can happen in wrong order and minor versions may be lost

If a user defines their migrations in a different order than the numbers they assign to them, Camping will do them in the order of definitions rather than version order.

Also, the current approach to avoiding initializing @Final makes it so that if the last two migrations are only different by minor number and are out of order, the last migration won't happen.

Mind you, I don't expect this is common. But the only warning given to users is that migrations must happen after model definitions.

cherry pick for test:

busbey/camping@8eca5ee

to reproduce:

  1. start the app: camping migrations.rb
  2. send 9000 ninjas after the president by browsing to http://localhost:3301/migrations/9000
  • Expected:
    1. a console for launch shows all migrations happen in version order
    2. Samantha steps in to win a burger
  • Actual:
    1. console shows NoIMeanWeNeedBadderDudes happening before WaitWeShouldDoThisEarlier
    2. console shows NoIMeanWeNeedBadderDudes doesn't happen
    3. There isn't a strong enough dude to stop the ninjas and we're all doomed.

cherry pick solutions

If you want some formatting changes, let me know. my vimrc is wonky on this machine.

restart Camping from the error screen

i want a button to restart the camping server from the error screen web page without alt-tabbing back to the terminal and wrestling with the right meta-key combo to find the screen the camping server is on and them ctrl-c and up arrow and enter and yada yada yada. can i have a button?

Extending Camping Controllers

Basically what I want to do is extend my controllers with a base controller that does some authentication and sets some session variables every time a controller is called. Here is my code so far:

module App::Controllers
    class App_Controller
        if company = Company.find(:first,
            :conditions => {:subdomain => ENV['SERVER_NAME']})
            @state.company_id = company.id
            #Check to see if user is logged in
                #If Not, Redirect to login
        else
            redirect :register
        end     
    end
    class Appointments < App_Controller
        def get
            @appointments = Appointment.find(:all, 
                :conditions => {:company_id => @state.company_id})
        end
    end
end

Actual Result:

This fails for 2 reasons:

  1. /home/#####/.gem/ruby/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:105:in `const_missing': uninitialized constant App::Controllers::App_Controller::Company (NameError)

Im not able to access the model unless I access via App::Models::Company

2)./controllers.rb:7: undefined method `redirect' for App::Controllers::App_Controller:Class (NoMethodError)

Im not able to access the redirect method. I tried App::Controllers.redirect but that didn't seem to work.

Expected Result:

Because the App_Controller class exists in the App::Controllers module I would assume that the base class would have the Models and helper methods available too them with out having to App::Models::

Im ok with having to use App::Models:: but either way I wasnt able to access the redirect method. How can I access the redirect method from my base class?

Bundler module

A Bundler module where you specify the gems needed for your app. Me and Judofyr discussed it's implementation and use.

Basically just implement the Bundler from rails so you can go something like:

App::Bundle
gem Campclub
gem haml
end

Didn't seem to be too hard to add!

Can't connect to Sqlite3

Hi,
I'm using Ruby 1.9 and Camping 2.1. I can run a camping app fine until I attempt to connect to the DB. For example, when I try to load the sample nuts.rb migration file I get this message:

"ArgumentError: Anonymous modules have no name to be referenced by"

All relevant dependencies are installed, and I can interact with sqlite3 in Rails without a problem. I've tried everything I can think of over the last couple days, including trying earlier releases of Camping.
Anyone have any ideas? Google searches have led me nowhere.
Thanks,
MK

Try Camping!

Ruby interpreter running in a JRuby applet. Text editor using Bespin. WEBrick powered server running your app. Test cases which must pass in order to follow the tutorial. Tons of tutorials.

Goal: It should teach you all about web development in Ruby, starting with Camping and then explaining HTTP, Rack, and maybe even HTML and CSS.

make Camping smarter about partials

At the moment (unless I am mistaken) you have to

<%= render(:my_partial, {:layout => false}) %>

but in Sinatra and possibly others they are smart enough not to invoke the magic function layout from partial templates. I'm sure this would be an easy tweak but I haven't a clue how to hack on Camping as the source is obfuscated. Pointers on how to hack on this would be welcome so I can submit a patch.

class Something < R:SomethingElse

I love how the new route maker allows us to do stuff like class Index, class Users and class UsersAll, but I'm not a very fan of class UserN or any of the more complex cases.

The way of generating the route is genius, but tying it to the class name feels a little dirty. What should you do when you allow more than numbers in the route? Change the class to UserX? Change it to class UserN < '/user/([^/]+)'?

How about this:

class User < R:UserN    # uses "UserN" to generate route, not "User"
end

# After change:
class User < R:UserX; end

# After more complex change:
class User < R '/user/([a-z]+)'; end

restful camping

i like having restful interfaces on my camping apps. I liked reststop when it worked pre 2.0

i appreciate everything that people have done to start making it work with 2.0, but the gymnastics it needs right now reminds me of the things i don't like about it. like how it makes me type

module Garden::Controllers
  class Shovels < REST "shovels"
  end
end

or how it makes me define JSON and XML views that essentially just encode the thing I got out of my model.

because REST is all about your models. it gives default conventions for hte controller part (as HTTP GET, PUT, POST, DELETE) and for the view parts (with accept type saying 'serialize to xml' or json or whatever).

so I'm thinking about adding another autoload for models to do that. see that the model is supposed to be done with rest (with the option to say it's read only?) and then automagic like make some default controllers and views. let the user override them if they want to control something.

Maybe an alternative to Base?

module Garden::Models
  class Shovel < Rest
  end
end

Maybe as a decoration in your model declaration?

module Garden::Models
  class Shovel < Base
    available_via_rest
  end
end

I dunno. what do people think?

Is this common enough to be worth having in Camping proper, or should i take this party over to Reststop and try to dance there?

Replace Markaby?

Hi,

Would it be possible to replace Markaby with Parkaby once Camping V2 is released?
It would be a good way to get more attention and feedback for Parkaby...

BTW, I wouldn't mind if you renamed Parkaby "Markaby 2.0". Since the API is identical, everyone would benefit from the speed improvements, and you would benefit from the name recognition of Markaby. The API similarity is engough to claim the filiation, IMO, even though the underpants are quite different.

Cheers,
--Pygy

Figure out a better implementation of Camping.goes

I mean, gsub-bing on and eval-ing Camping's own source code? There just has to be a less braindead way.

What we have leads to ugly stack traces and forces every extension to Camping to do even worse things - not only evaling its own code in Camping module and all apps that might have been already created, but also modifying the "source-string" that is kept around.

Isn't it possible to maybe dup the module and all of its "submodules"? Maybe Camping.goes could create a new, empty module and include Camping into it? Maybe we could make Camping a class and have everything inherit from it? Just food for though, I haven't tried any one of these, really.

(We could also just drop the idea of multiple apps, but I feel that'd be too much - they're a pretty nice thing.)

(The motivation for this issue is that I recently suggested someone Camping as a Ruby web framework, and somebody else complained about, I'll cite, "meta-recursive bootstrapping process that practically breaks your brain", and I had to think hard about some reasoning as to why we do that. Here: http://www.reddit.com/r/programming/comments/ngy7r/php_cracks_in_the_foundation/c39d2et?context=3)

(Related to #10)

Sinatra is slower than Camping

Now this is embarrassing:

git clone git://github.com/judofyr/web-frameworks-benchmark.git
gem install sinatra camping thin --no-rdoc --no-ri
./benchmark.rb start
# Write down the numbers
./benchmark.rb stop

On my machine (old macbook):

Rack => 2694.66 rps
Camping => 2060.95 rps
Sinatra => 1331.15 rps

On a last gen MBP 2.8ghz/4gb RAM:

Rack => 4314.81 rps
Camping => 2420.32 rps
Sinatra => 1720.71 rps

The benchmark is created by the Padrino guys, but I'm seriously thinking something is wrong somewhere (probably some of my code). Remember that Camping is three years old and just recently got updated its core to Rack, with no specific focus on performance (as for as I can remember). I was sooooo looking forward tuning Camping 2.1 for performance, but it looks like it's pretty fast already :(

All the cool guys are using Sinatra, so it should definitely be the fastest micro framework out there.

Mab: Adding stuff before yielding causes a weird escaping problem

If I do this:

def layout
  # head stuff etc goes here
  body do
    script src: R(script, 'main.js') do; end
    self << yield
  end
end

It worked with Markaby, but in Mab I get this oddly escaped output after the script (I've added line breaks):

<html>
<head>
<script src="/static/script%2Fjquery-1.7.1.min.js"></script>
</head>
<body>
<script src="/static/script%2Fmain.js ></script>
&lt;h1&gt;Food&lt;/h1&gt;&lt;p&gt;Experimenting.&lt;/p&gt;&lt;h2&gt;blah&lt;/h2&gt;&lt;h4&gt;Raw JSON&lt;/h4&gt;&lt;p id=&quot;blahblah&quot;&gt;&lt;/p&gt;&lt;h4&gt;Rendered&lt;/h4&gt;&lt;p id=&quot;hi&quot;&gt;&lt;/p&gt;&lt;h2&gt;wut&lt;/h2&gt;&lt;div id=&quot;hello&quot;&gt;&lt;/div&gt;
</body></html>

bugfix: lib/camping/reloader.rb

line 107 in function reload!

consider changing return if @mtime >= mtime to return if @mtime >= mtime rescue nil

this fixes a weird exception i get due to Eclipse uploading files with a strange initial mtime. Camping initially chokes on the nil value from #mtime but this suppresses that choking with no apparent ill side effects.

Rackification

I have a few ideas of how we can integrate Camping even more with Rack, but let's talk about this after 2.0.

Buzzzzzzz!

This project needs a serious marketing push.

Camping 2.0, a major milestone, the first release in several years didn't even get a blog post describing the new features.

Camping is a technical gem, and it's a pleasure to use. It shouldn't be lingering in the dark corners of the interwebz like it's doing now. This github repository is nowhere to be seen in Google queries for "camping ruby".

Magnus' post to ruby-talk[1] was great, but few people ever saw it. It gathered royally 3 upvotes on Hacker news, and didn't appear in proggit (although it got an honorable mention in the ruby subreddit).

The post has one big flaw: The first time I found it (while actually searching for something Camping-related), I bounced back because I thought it was just the source code. A single sentence before that could make it more engaging, but I'm not sure it would be enough to ensure that the readers would get further. I'd put it at the end of the post.

Perhaps you could create a "reintroducing Camping 2.0" blog post on judofyr.net, with the same content as the ML post with a short preamble explaining why you re-announce it?

[1]http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/360767

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.