Permalink
Browse files

Made booboo in page model that sets next version incorrectly, fixed r…

…egex to not be so damn greedy
  • Loading branch information...
1 parent b5c64c9 commit f72d2eb11a6c69b88b5d3c48a509cd35fc284e4d @codafoo committed Apr 14, 2008
Showing with 4 additions and 12 deletions.
  1. +1 −1 app/controllers/pages_controller.rb
  2. +1 −1 app/helpers/pages_helper.rb
  3. +2 −10 app/models/page.rb
@@ -20,9 +20,9 @@ def index
# GET /pages/1.xml
def show
@page = site.pages.find_by_permalink(params[:id] || "home")
- @version = @page.versions.find_by_version(@page.version)
if @page
+ @version = @page.versions.find_by_version(@page.version)
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @page }
@@ -2,7 +2,7 @@ module PagesHelper
def wikified_body(body)
r = RedCloth.new(body)
- r.gsub!(/\[\[(.*)(\|(.*))?\]\]/) {wiki_link(*$1.split("|")[0..1])}
+ r.gsub!(/\[\[([^\]]*)(\|(.*))?\]\]/) {wiki_link(*$1.split("|")[0..1])}
r.to_html
end
View
@@ -58,19 +58,11 @@ def set_permalink
self.permalink = Page.count == 0 ? "home" : "#{title.downcase.strip.gsub(/ |\.|@/, '-')}"
end
end
-
- def next_version
- self.versions.size > self.version ? self.version + 1 : false
- end
-
- def previous_version
- self.version > 1 ? self.version - 1 : false
- end
-
+
def set_links
Link.transaction do
# outbound_links.delete_all
- body.scan(/\[\[(.*?)\]\]/).each do |link|
+ body.scan(/\[\[([^\]]*)\]\]/).each do |link|
link = link[0].downcase.gsub(' ', '-')
if page = site.pages.find_by_permalink(link)
Link.create! :from_page_id => id, :to_page_id => page.id

0 comments on commit f72d2eb

Please sign in to comment.