Skip to content

Commit d1406bb

Browse files
committed
Add UI for commit message, redirect w/ 303
1 parent b9090e9 commit d1406bb

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

git-wiki.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,12 @@ def to_html
6969
Page.wikify(RDiscount.new(content).to_html)
7070
end
7171

72-
def save!(data)
72+
def save!(data, msg)
73+
msg = "web commit: #{self}" if msg.empty?
7374
Dir.chdir(GitWiki.repository.working_dir) do
7475
File.open(@blob.name, 'w') {|f| f.puts(data.gsub("\r\n", "\n")) }
7576
GitWiki.repository.add(@blob.name)
76-
GitWiki.repository.commit_index("web commit: #{self}")
77+
GitWiki.repository.commit_index(msg)
7778
end
7879
end
7980
end
@@ -102,8 +103,8 @@ def save!(data)
102103

103104
post '/pages/:page/edit' do
104105
@page = Page.find_or_create(params[:page])
105-
@page.save!(params[:body])
106-
redirect @page.url
106+
@page.save!(params[:content], params[:msg])
107+
redirect @page.url, 303
107108
end
108109

109110
configure do

views/edit.haml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
%form{:method => 'POST', :action => @page.edit_url}
22
%p
3-
%textarea{:name => 'body', :rows => 25, :cols => 80}~ @page.content
3+
%textarea{:name => 'content', :rows => 25, :cols => 80}~ @page.content
44
%p
5-
%input{:type => :submit, :value => "Save Changes"}
5+
%input{:type => :text, :name => 'msg', :size => 65}
6+
%input{:type => :submit, :value => "Commit"}

0 commit comments

Comments
 (0)