Class: Precious::App

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/gollum/frontend/app.rb

Instance Method Summary collapse

Instance Method Details

#commit_messageObject



211
212
213
# File 'lib/gollum/frontend/app.rb', line 211

def commit_message
  { :message => params[:message] }
end

#show_page_or_file(name) ⇒ Object



185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/gollum/frontend/app.rb', line 185

def show_page_or_file(name)
  wiki = Gollum::Wiki.new(settings.gollum_path, settings.wiki_options)
  if page = wiki.page(name)
    @page = page
    @name = name
    @content = page.formatted_data
    @editable = true
    mustache :page
  elsif file = wiki.file(name)
    content_type file.mime_type
    file.raw_data
  else
    @name = name
    mustache :create
  end
end

#update_wiki_page(wiki, page, content, commit_message, name = nil, format = nil) ⇒ Object



202
203
204
205
206
207
208
209
# File 'lib/gollum/frontend/app.rb', line 202

def update_wiki_page(wiki, page, content, commit_message, name = nil, format = nil)
  return if !page ||  
    ((!content || page.raw_data == content) && page.format == format)
  name    ||= page.name
  format    = (format || page.format).to_sym
  content ||= page.raw_data
  wiki.update_page(page, name, format, content.to_s, commit_message)
end