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



221
222
223
# File 'lib/gollum/frontend/app.rb', line 221

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

#show_page_or_file(name) ⇒ Object



195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/gollum/frontend/app.rb', line 195

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 = false
    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



212
213
214
215
216
217
218
219
# File 'lib/gollum/frontend/app.rb', line 212

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