This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
commit 243ef1a8b56f62cda6f6b26875e50142f5956719
tree 38f1d47f2abcad18dbf722f6a5b290cc50e6fb1d
parent 1dcec1197078720661ff932d4496b1a558372714
tree 38f1d47f2abcad18dbf722f6a5b290cc50e6fb1d
parent 1dcec1197078720661ff932d4496b1a558372714
camping /
| name | age | message | |
|---|---|---|---|
| |
CHANGELOG | Tue Oct 02 13:23:16 -0700 2007 | [zimbatm] |
| |
COPYING | Wed May 03 08:29:20 -0700 2006 | [why] |
| |
README | Mon Jul 07 16:15:09 -0700 2008 | [ncr] |
| |
Rakefile | Thu Jun 12 08:17:44 -0700 2008 | [judofyr] |
| |
bin/ | Tue May 20 22:52:52 -0700 2008 | [judofyr] |
| |
doc/ | Tue Oct 02 13:23:16 -0700 2007 | [zimbatm] |
| |
examples/ | Fri Oct 31 13:10:12 -0700 2008 | [judofyr] |
| |
extras/ | Fri Sep 01 00:48:45 -0700 2006 | [why] |
| |
lib/ | Thu Nov 13 13:27:54 -0800 2008 | [judofyr] |
| |
setup.rb | Tue Jan 17 21:39:29 -0800 2006 | [why] |
| |
test/ | Thu Nov 13 13:25:07 -0800 2008 | [judofyr] |
README
== Camping, a Microframework
Camping is a web framework which consistently stays at less than 4kb of code.
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?
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
like Rails does. You can then easily move it to Rails once you've got it going.
== 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 < R '/'
def get
@posts = Post.find :all
render :index
end
end
end
module Blog::Views
def layout
html do
body do
self << yield
end
end
end
def index
for post in @posts
h1 post.title
end
end
end
Some things you might have noticed:
* Camping::Models uses ActiveRecord to do its work. We love ActiveRecord!
* Camping::Controllers can be assigned URLs in the class definition. Neat?
* Camping::Views describes HTML using pure Ruby. Markup as Ruby, which we
call Markaby.
* You use Camping::goes to make a copy of the Camping framework under your
own module name (in this case: <tt>Blog</tt>.)
<b>NOTE:</b> Camping auto-prefixes table names. If your class is named
<tt>Blog::Models::Post</tt>, your table will be called <b>blog_posts</b>.
Since many Camping apps can be attached to a database at once, this helps
prevent name clash.
(If you want to see the full blog example, check out <tt>examples/blog/blog.rb</tt>
for the complete code.)
If you want to write larger applications with Camping, you are encouraged to
split the application into distinct parts which can be mounted at URLs on your
web server. You might have a blog at /blog and a wiki at /wiki. Each
self-contained. But you can certainly share layouts and models by storing them
in plain Ruby scripts.
Interested yet? Okay, okay, one step at a time.
== Installation
* <tt>gem install camping</tt>
Or for the bleeding edge:
* <tt>gem install camping --source code.whytheluckystiff.net</tt>
You are encourage to install Camping and SQLite3, since it is a small database
which fits perfectly with our compact bylaws, works well with the examples.
* See http://code.whytheluckystiff.net/camping/wiki/BeAlertWhenOnSqlite3 for instructions.
== Running Camping Apps
The blog example above and most Camping applications look a lot like CGI scripts.
If you run them from the commandline, you'll probably just see a pile of HTML.
Camping comes with an tool for launching apps from the commandline:
* Run: <tt>camping blog.rb</tt>
* Visit http://localhost:3301/ to use the app.
== How the Camping Tool Works
If your application isn't working with the <tt>camping</tt> tool, keep in mind
that the tool expects the following conventions to be used:
1. You must have SQLite3 and SQLite3-ruby installed. (Once again, please see
http://code.whytheluckystiff.net/camping/wiki/BeAlertWhenOnSqlite3 for instructions.)
2. If your script is called <tt>test.rb</tt>, Camping expects your application to
be stored in a module called <tt>Test</tt>. Case is not imporant, though. The
module can be called <tt>TeSt</tt> or any other permutation.
3. Your script's postamble (anything enclosed in <tt>if __FILE__ == $0</tt>) will be
ignored by the tool, since the tool will create an SQLite3 database at
<tt>~/.camping.db</tt>. Or, on Windows, <tt>$USER/Application Data/Camping.db</tt>.
4. If your application's module has a <tt>create</tt> method, it will be executed before
the web server starts up.
== The Rules of Thumb
Once you've started writing your own Camping app, I'd highly recommend that you become familiar
with the Camping Rules of Thumb which are listed on the wiki:
http://code.whytheluckystiff.net/camping/wiki/CampingRulesOfThumb





