mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-18 00:00:12 +01:00
So now I've got rid of the svn:externals property on vendor which was supposed to be bringing in the tagged Rails release, and I'm using rake freeze_edge instead to freeze to the 1.1 release. Seems to be working OK for me now. Note that if you're using this, Ruby 1.8.4 is recommended, and you'll need to delete your old lighttpd.conf in config (if you have one) and let Rails generate a new one for you when you start lighttpd with script/server. git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@212 a4c988fc-2ded-0310-b66e-134b36920a42
53 lines
No EOL
1.3 KiB
Ruby
Executable file
53 lines
No EOL
1.3 KiB
Ruby
Executable file
#!/usr/local/bin/ruby
|
|
|
|
$:.unshift(File.dirname(__FILE__) + "/../lib")
|
|
|
|
require "action_controller"
|
|
|
|
Post = Struct.new("Post", :title, :body)
|
|
|
|
class BlogController < ActionController::Base
|
|
before_filter :initialize_session_storage
|
|
|
|
def index
|
|
@posts = @session["posts"]
|
|
|
|
render_template <<-"EOF"
|
|
<html><body>
|
|
<%= @flash["alert"] %>
|
|
<h1>Posts</h1>
|
|
<% @posts.each do |post| %>
|
|
<p><b><%= post.title %></b><br /><%= post.body %></p>
|
|
<% end %>
|
|
|
|
<h1>Create post</h1>
|
|
<form action="create">
|
|
Title: <input type="text" name="post[title]"><br>
|
|
Body: <textarea name="post[body]"></textarea><br>
|
|
<input type="submit" value="save">
|
|
</form>
|
|
|
|
</body></html>
|
|
EOF
|
|
end
|
|
|
|
def create
|
|
@session["posts"].unshift(Post.new(@params["post"]["title"], @params["post"]["body"]))
|
|
flash["alert"] = "New post added!"
|
|
redirect_to :action => "index"
|
|
end
|
|
|
|
private
|
|
def initialize_session_storage
|
|
@session["posts"] = [] if @session["posts"].nil?
|
|
end
|
|
end
|
|
|
|
ActionController::Base.template_root = File.dirname(__FILE__)
|
|
# ActionController::Base.logger = Logger.new("debug.log") # Remove first comment to turn on logging in current dir
|
|
|
|
begin
|
|
BlogController.process_cgi(CGI.new) if $0 == __FILE__
|
|
rescue => e
|
|
CGI.new.out { "#{e.class}: #{e.message}" }
|
|
end |