From 414ed31a58779299579332aabd1baf2f72578300 Mon Sep 17 00:00:00 2001
From: Alexey Verkhovsky
Date: Fri, 18 Feb 2005 23:19:42 +0000
Subject: [PATCH] Converting hyperlinks to link_to calls (now that we have
Routes, they work)
---
app/helpers/application_helper.rb | 12 ++++++++-
app/models/page.rb | 4 ---
app/views/wiki/edit.rhtml | 13 ++++++---
app/views/wiki/list.rhtml | 27 ++++++++++++++-----
app/views/wiki/locked.rhtml | 4 +--
app/views/wiki/new.rhtml | 7 +++--
app/views/wiki/page.rhtml | 39 ++++++++++++++++++++++-----
app/views/wiki/recently_revised.rhtml | 2 +-
app/views/wiki/revision.rhtml | 38 +++++++++++++++++++++-----
app/views/wiki/rss_feed.rhtml | 4 +--
app/views/wiki/search.rhtml | 8 ++++--
app/views/wiki/web_list.rhtml | 2 +-
test/functional/routes_test.rb | 12 ++++-----
13 files changed, 127 insertions(+), 45 deletions(-)
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index c8d597ac..1d3df38f 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -33,9 +33,19 @@ module ApplicationHelper
html_options.join("\n")
end
+ # Creates a hyperlink to a Wiki page, without checking if the page exists or not
+ def link_to_existing_page(page, text = nil, html_options = {})
+ link_to(
+ text || page.name,
+ {:web => @web.address, :action => 'show', :id => page.name, :only_path => true},
+ html_options)
+ end
+
+
+ # Creates a hyperlink to a Wiki page, or to a "new page" form if the page doesn't exist yet
def link_to_page(page_name, web = @web, text = nil, options = {})
raise 'Web not defined' if web.nil?
- home_page_url = url_for :web => web.address, :action => 'show', :id => 'HomePage', :only_path => true
+ home_page_url = url_for :web => web.address, :action => 'show', :id => page_name, :only_path => true
base_url = home_page_url.sub(%r-/show/HomePage/?$-, '')
web.make_link(page_name, text, options.merge(:base_url => base_url))
end
diff --git a/app/models/page.rb b/app/models/page.rb
index 1f714101..ddb286f7 100644
--- a/app/models/page.rb
+++ b/app/models/page.rb
@@ -85,10 +85,6 @@ class Page
@web.make_link(author, nil, options)
end
- def url
- CGI.escape(self.name)
- end
-
private
def continous_revision?(created_at, author)
diff --git a/app/views/wiki/edit.rhtml b/app/views/wiki/edit.rhtml
index 386676f0..9a05e05c 100644
--- a/app/views/wiki/edit.rhtml
+++ b/app/views/wiki/edit.rhtml
@@ -8,7 +8,10 @@
<%= render("#{@web.markup}_help") if @web %>
-
-
+<%= end_form_tag %>