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



225
226
227
228
229
230
231
232
# File 'lib/gollum/frontend/app.rb', line 225

def commit_message
  if self.respond_to?('user_authed?') && user_authed?
    user = get_user
    return { :message => params[:message], :name => user.name, :email => user.email}
  else
    return { :message => params[:message]}
  end
end

#show_page_or_file(name) ⇒ Object



200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/gollum/frontend/app.rb', line 200

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
    redirect "/create/#{CGI.escape(name)}"
  end
end

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



216
217
218
219
220
221
222
223
# File 'lib/gollum/frontend/app.rb', line 216

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