Sha256: 0f23452ff722bab99daa71fcbc733a67cedc5e7706bc3b81939a3cefd3f52c82

Contents?: true

Size: 805 Bytes

Versions: 4

Compression:

Stored size: 805 Bytes

Contents

# The minimal _why wiki in Innate with ERB

%w[rubygems innate erb maruku yaml/store].each{|l| require(l) }

DB = YAML::Store.new('wiki.yaml') unless defined?(DB)

class Wiki
  Innate.node '/'
  layout 'wiki'
  provide :html, :engine => :ERB

  def index(page = 'Home')
    @page = page
    @text = 'foo'
    sync{
      @text = DB[page].to_s.dup
      @text.gsub!(/\[\[(.*?)\]\]/) do
        %(<a href="#{r($1)}" class="#{DB[$1] ? 'exists' : 'missing'}">#{h($1)}</a>)
      end
    }
  end

  def edit(page)
    @page = page
    @text = sync{ DB[page].to_s }
  end

  def save
    page, text = request[:page, :text]
    sync{ DB[page] = text } if request.post? and page and text

    redirect(r(page))
  end

  private

  def sync
    Innate::STATE.sync{ DB.transaction{ yield }}
  end
end

Innate.start

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
manveru-innate-2009.04.18 example/app/whywiki_erb/start.rb
manveru-innate-2009.04 example/app/whywiki_erb/start.rb
innate-2009.04 example/app/whywiki_erb/start.rb
innate-2009.04.12 example/app/whywiki_erb/start.rb