Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added rudimentary version reverting

  • Loading branch information...
commit bbaf36c95aef290babe74ef0a303f71d974153b4 1 parent 2275f06
Jeffrey Chupp authored
Showing with 42 additions and 1 deletion.
  1. +4 −1 views/history.haml
  2. +29 −0 views/revert.haml
  3. +9 −0 wiki.rb
View
5 views/history.haml
@@ -5,4 +5,7 @@
%div{:class => "history#{( i % 2 == 0 ? '_alt' : '')}"}
.history_title= article.title
.history_body= PARSER.parse(article.body)
- .history_date= friendly_time(article.updated_at)
+ .history_date= friendly_time(article.updated_at)
+ %form{:action => "/#{@article.slug}/edit", :method=>'post'}
+ %input{:type => 'hidden', :name => 'body', :value => article.body}
+ %input{:type => 'submit', :value => 'Restore'}
View
29 views/revert.haml
@@ -0,0 +1,29 @@
+%form{:action => "/", :method=>"post"}
+ %h1
+ = "#{@action.first} #{@article.title}"
+ %p
+ %label{:for => :title} Title
+ %br
+ %input{:type => :text, :name => :title, :id => :title, :value => @article.title}
+
+ %p
+ %label{:for => :slug} Slug
+ %br
+ %input{:type => :text, :name => :slug, :id => :slug, :value => @article.slug}
+
+ %p
+ %label{:for => :current_body} Current Body
+ %br
+ = find_and_preserve do
+ %textarea{:cols => 70, :rows => 10, :name => :body, :id => :current_body}
+ =@current_body
+
+ %p
+ %label{:for => :body} Desired Body
+ %br
+ = find_and_preserve do
+ %textarea{:cols => 70, :rows => 15, :name => :body, :id => :body}
+ =@article.body
+
+ %p
+ %input{:type => :submit, :value => @action.last}
View
9 wiki.rb
@@ -4,6 +4,7 @@
helpers do
# break up a CamelCased word into something more readable
+ # this is used when you create a new page by visiting /NewItem
def de_wikify(phrase)
phrase.gsub(/(\w)([A-Z])/, "\\1 \\2")
end
@@ -56,4 +57,12 @@ def friendly_time(time)
@article = Article.first(:slug => params[:slug])
@action = ["Editing", "Edit"]
haml :edit
+end
+
+post '/:slug/edit' do
+ @article = Article.first(:slug => params[:slug])
+ @current_body = @article.body
+ @article.body = params[:body] if params[:body]
+ @action = ["Reverting", "Save"]
+ haml :revert
end
Please sign in to comment.
Something went wrong with that request. Please try again.