Sha256: 48323e1208268e7c8d39fb4f797bc9c9433932fc46995fae528193f68cb59cee

Contents?: true

Size: 1.66 KB

Versions: 3

Compression:

Stored size: 1.66 KB

Contents

#Encoding: UTF-8
module Caramelize
  autoload :DatabaseConnector, 'caramelize/database_connector'
  autoload :WikkaConverter, 'caramelize/wiki/wikka_converter'
  
  class WikkaWiki < Wiki
    include DatabaseConnector
    include WikkaConverter
    
    def initialize options={}
      super(options)
      options[:markup] = :wikka
    end

    # after calling this action, I expect the @titles and @revisions to be filled
    def read_pages
      sql = "SELECT id, tag, body, time, latest, user, note FROM wikka_pages ORDER BY time;"
      @revisions = []
      @titles = []
      results = database.query(sql)
      results.each do |row|
        @titles << row["tag"]
        author = @authors[row["user"]]
        page = Page.new({:id => row["id"],
                            :title =>   row["tag"],
                            :body =>    row["body"],
                            :markup =>  :wikka,
                            :latest =>  row["latest"] == "Y",
                            :time =>    row["time"],
                            :message => row["note"],
                            :author =>  author,
                            :author_name => row["user"]})
        @revisions << page
      end
      @titles.uniq!
      #@revisions.sort! { |a,b| a.time <=> b.time }
      
      @revisions
    end
    
    def read_authors
      sql = "SELECT name, email FROM wikka_users;"
      @authors = {}
      results = database.query(sql)
      results.each do |row|
        author = Author.new
        #author.id    = row["id"]
        author.name  = row["name"]
        author.email = row["email"]
        @authors[author.name] = author
      end
      @authors
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
caramelize-0.1.2 lib/caramelize/wiki/wikkawiki.rb
caramelize-0.1.1 lib/caramelize/wiki/wikkawiki.rb
caramelize-0.1.0 lib/caramelize/wiki/wikkawiki.rb