Permalink
Browse files

README, removing after filter

  • Loading branch information...
1 parent a35478b commit 02922634a355e9dbab78d94720b62b1d9b9d9029 @winton committed May 30, 2011
Showing with 110 additions and 236 deletions.
  1. +107 −188 README.md
  2. +3 −10 lib/stasis.rb
  3. +0 −38 lib/stasis/plugins/after.rb
View
295 README.md
@@ -1,270 +1,189 @@
Stasis
======
-An extensible static site generator.
+Static sites made powerful.
-Philosophy
-----------
+Stasis is not your typical static site generator. Access your database. Pull data from an API. Render to any number of dynamic paths. Get crazy.
-Stasis is a perfect complement to modern dynamic frameworks:
-
-1. Use Stasis to generate your HTML and other assets.
-2. Serve that data in the most performant way possible (usually Nginx).
-3. Use your dynamic framework to serve data to the client (usually JSON).
-4. Use your dynamic framework (or `cron`) to regenerate Stasis pages as needed.
-
-Stasis is not your typical "one to one" markup renderer. Render to any number of dynamic paths. Access your database. Pull data from an API. Get crazy.
-
-Requirements
-------------
-
- gem install stasis
-
-Supported Template Engines
---------------------------
-
-Stasis uses [Tilt](https://github.com/rtomayko/tilt) to support the following template engines:
-
- ENGINE FILE EXTENSIONS REQUIRED LIBRARIES
- -------------------------- ----------------- ----------------------------
- ERB .erb none (included ruby stdlib)
- Interpolated String .str none (included ruby core)
- Haml .haml haml
- Sass .sass haml
- Less CSS .less less
- Builder .builder builder
- Liquid .liquid liquid
- RDiscount .markdown rdiscount
- RedCloth .textile redcloth
- RDoc .rdoc rdoc
- Radius .radius radius
- Markaby .mab markaby
- Nokogiri .nokogiri nokogiri
- CoffeeScript .coffee coffee-script (+node coffee)
- Slim .slim slim (>= 0.7)
-
-Example
+Install
-------
-The [spec project](https://github.com/winton/stasis/tree/master/spec/fixtures/project) implements all of the features in this README.
-
-Get Started
------------
-
-Create a directory for your project, and within that directory, a markup file:
+ gem install stasis
-### view.html.erb
+One-to-One Example
+------------------
- Welcome <%= '!' * 3 %>
+Example project:
-Generate Static Files
----------------------
+ project/
+ index.html.haml
+ subdirectory/
+ index.html.haml
+ other.txt
-Open your terminal, `cd` into your project directory, and run the `stasis` command:
+Open terminal and run `stasis` on the project:
+ cd project
stasis
-You now have a `public` directory with rendered markup:
+This generates a `public` directory:
- public/
- view.html
- view.html.erb
+ project/
+ public/
+ index.html
+ subdirectory/
+ index.html
+ other.txt
-If the file extension is a supported markup file, it renders into `public`.
+Templates (`index.html.haml`) are rendered and the template extension is removed.
-If the file extension is unsupported, it copies into `public`.
+Since `.txt` is not a supported template extension, Stasis copies `other.txt` and does nothing further to it.
Controllers
-----------
-The only reserved filename in a Stasis project is `controller.rb`.
+Let's add controllers to the project:
-You can have a `controller.rb` at any directory level:
+ project/
+ controller.rb
+ index.html.haml
+ subdirectory/
+ controller.rb
+ index.html.haml
+ other.txt
- controller.rb
- index.html.erb
- pages/
- controller.rb
- page.html.erb
+Each controller executes once before rendering templates at the same directory level or below.
-Controllers at the same directory level or above execute for a particular markup file.
+Before Filters
+--------------
-For example, `page.html.erb` uses both controllers, but `index.html.erb` only uses the top-level controller.
+In your controller:
-Callbacks
----------
+ before 'index.html.haml' do
+ # any class variables set here will be available to your template
+ @something = true
+ end
-Define `before` and `after` render callbacks within your controller:
+The `before` method can take any number of paths and/or regular expressions.
-### controller.rb
+Layouts
+-------
- # Call before any file renders
-
- before do
- @what_is_rendering = "any file"
- end
+Create a `layout.html.haml` file:
- # Call before any ERB file renders
-
- before /.*erb/ do
- @what_is_rendering = "ERB file"
- end
-
- # Call only before view.html.erb renders
-
- before 'view.html.erb' do
- @what_is_rendering = "the view"
- end
+ %html
+ %body= yield
+
+Set the default layout:
+
+ layout 'layout.html.haml'
-### view.html.erb
+Set the layout for a particular file:
- <%= @what_is_rendering %>
+ layout 'index.html.haml' => 'layout.html.haml'
-Change the Destination
-----------------------
+Or use a regular expression:
-Let's say we want `view.html.erb` to be our front page:
+ layout /.*.html.haml/ => 'layout.html.haml'
-### controller.rb
+Set the layout from a before filter if you like:
- destination 'view.html.erb' => '/index.html'
-
- # or
-
- before 'view.html.erb' do
- @destination = '/index.html'
+ before 'index.html.haml' do
+ layout 'layout.html.haml'
end
Ignore
------
-Sometimes you will want to ignore certain files entirely (no render, no copy).
+Use the `ignore` method in your controller to ignore certain files.
-For example, you'll often want to ignore filenames with an underscore at the beginning (partials):
-
-### controller.rb
+For example, to ignore files with an underscore at the beginning (partials):
ignore /_.*/
- # or
+Rendering
+---------
+
+Render within a template:
+
+ %html
+ %body= render '_partial.html.haml'
- before /_.*/ do
- @ignore = true
+Render within a `before` block:
+
+ before 'index.html.haml' do
+ @partial = render '_partial.html.haml'
end
-Layouts
--------
+Render text:
-Create the layout markup:
+ render :text => 'Hello'
-### layout.html.erb
+Render with local variables:
- <html>
- <body><%= yield %></body>
- </html>
+ render 'index.html.haml', :locals => { :x => true }
-### controller.rb
+Render with a block for the template to `yield` to:
- # set default layout for all views
+ render 'index.html.haml' { 'Hello' }
- layout 'layout.html.erb'
+Instead
+-------
- # or set layout for specific view
+The `instead` method changes the output of the file being rendered:
- layout 'view.html.erb' => 'layout.html.erb'
-
- # or
-
- before 'view.html.erb' do
- @layout = 'layout.html.erb'
+ before 'index.html.haml' do
+ instead render('subdirectory/index.html.haml')
end
-Layout files are automatically ignored (don't want to render a `layout.html` file).
-
Helpers
-------
-Define helper methods within your controllers.
-
-### controller.rb
+The `helpers` method allows you to make methods available to `before` callbacks and templates:
helpers do
- def active?(path)
- @source == path
+ def say_hello
+ 'Hello'
end
end
-### layout.html.erb
-
- <% if active?('view.html.erb') %>
- Rendering view.html.erb
- <% end -%>
-
Priority
--------
-You may want some files to render or copy before others:
+Change the order in which files are rendered or copied:
-### controller.rb
+ priority 'index.html.erb' => 1, /.*\.txt/ => 2
- priority 'view.html.erb' => 1, /.*css/ => 2, /.*js/ => 2
+In this example, text files are copied to `public` before `index.html.erb` renders.
The default priority is `0`.
-Rendering
----------
-
-Render other files within a callback, helper, or view:
-
-### view.html.erb
-
- <%= render '_partial.html.erb', :locals => { :x => 'y' } %>
-
-Summary
--------
-
-Use the following methods in your controllers:
-
-* `after`
-* `before`
-* `destination`
-* `ignore`
-* `layout`
-* `priority`
-
-Use the following methods within a callback, helper, or view:
-
-* `render`
-
-Use the following class variables in your callbacks, helpers, or views:
+Supported Template Engines
+--------------------------
-* `@destination`
-* `@layout`
-* `@source`
+Stasis uses [Tilt](https://github.com/rtomayko/tilt) to support the following template engines:
-Only alter these class variables from a `before` callback.
+ ENGINE FILE EXTENSIONS REQUIRED LIBRARIES
+ -------------------------- ----------------- ----------------------------
+ ERB .erb none (included ruby stdlib)
+ Interpolated String .str none (included ruby core)
+ Haml .haml haml
+ Sass .sass haml
+ Less CSS .less less
+ Builder .builder builder
+ Liquid .liquid liquid
+ RDiscount .markdown rdiscount
+ RedCloth .textile redcloth
+ RDoc .rdoc rdoc
+ Radius .radius radius
+ Markaby .mab markaby
+ Nokogiri .nokogiri nokogiri
+ CoffeeScript .coffee coffee-script (+node coffee)
+ Slim .slim slim (>= 0.7)
Continuous Rendering
--------------------
To continuously render files as you change them, run:
- stasis -c
-
-Web Server
-----------
-
-To start Stasis in web server mode, run:
-
- stasis -p 3000
-
-In your browser, visit [http://localhost:3000](http://localhost:3000).
-
-In web server mode, Stasis continuously renders (`-c`).
-
-Other Topics:
--------------
-
-* [Asset Packaging](https://github.com/winton/stasis/wiki/Asset-Packaging)
-* [Callback Execution Order](https://github.com/winton/stasis/wiki/Callback-Execution-Order).
-* [Run Stasis Programmatically](https://github.com/winton/stasis/wiki/Run-Stasis-Programmatically)
+ stasis -c
View
@@ -1,14 +1,7 @@
-# **Stasis** is an extensible static site generator.
+# **Stasis** makes static sites powerful.
#
-# Stasis is a perfect complement to modern dynamic frameworks:
-#
-# 1. Use Stasis to generate your HTML and other assets.
-# 2. Serve that data in the most performant way possible (usually Nginx).
-# 3. Use your dynamic framework to serve data to the client (usually JSON).
-# 4. Use your dynamic framework (or `cron`) to regenerate Stasis pages as needed.
-#
-# Stasis is not your typical "one to one" markup renderer. Render to any number of
-# dynamic paths. Access your database. Pull data from an API. Get crazy.
+# Stasis is not your typical static site generator. Access your database. Pull data from
+# an API. Render to any number of dynamic paths. Get crazy.
### Prerequisites
Oops, something went wrong.

0 comments on commit 0292263

Please sign in to comment.