Sha256: 21f50ebaedb3f26e27d9e4407ff87727b13786df84d3acc62f846ae7a514a431
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
require 'innate' require 'yaml/store' STORE = YAML::Store.new('games.yaml') def STORE.[](key) transaction{|s| s[key] } end def STORE.[]=(key, value) transaction{|s| s[key] = value } end def STORE.each YAML.load_file('games.yaml').sort_by{|k,v| -v }.each{|(k,v)| yield(k, v) } end class Games include Innate::Node map '/' provide :html => :haml def index TEMPLATE end def create if request.post? name = request.params['name'] STORE[name] ||= 0 end redirect_referrer end def vote(name) STORE[url_decode name] += 1 redirect_referrer end TEMPLATE = <<-'T'.strip !!! XML !!! %html %head %title Top Retro Games %body %h1 Vote on your favorite Retro Game %form{:action => r(:create), :method => 'POST'} %input{:type => 'text', :name => 'name'} %input{:type => 'submit', :value => 'Add'} %ol - STORE.each do |name, votes| %li = Games.a("Vote", "/vote/#{u name}") = h("%5d => %s" % [votes, name]) T end Innate.start
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
manveru-innate-2009.02.06 | example/app/retro_games.rb |