Fixed links to Wiki pages with slashes and other interesting characters in the name

This commit is contained in:
Alexey Verkhovsky 2005-02-05 16:36:27 +00:00
parent 5cb21ff619
commit 21f7693c06
11 changed files with 27 additions and 24 deletions

View file

@ -85,6 +85,9 @@ class Page
@web.make_link(author, nil, options) @web.make_link(author, nil, options)
end end
def url
CGI.escape(self.name)
end
private private

View file

@ -8,7 +8,7 @@
<%= render("#{@web.markup}_help") if @web %> <%= render("#{@web.markup}_help") if @web %>
<form id="editForm" action="../save/<%= @page.name %>" method="post" onSubmit="cleanAuthorName();"> <form id="editForm" action="../save/<%= @page.url %>" method="post" onSubmit="cleanAuthorName();">
<p> <p>
<textarea name="content" style="width: 450px; height: 500px"><%= @page.content %></textarea> <textarea name="content" style="width: 450px; height: 500px"><%= @page.content %></textarea>
</p> </p>
@ -16,7 +16,7 @@
<input type="submit" value="Submit" accesskey="s"/> as <input type="submit" value="Submit" accesskey="s"/> as
<input type="text" name="author" id="authorName" value="<%= @author %>" <input type="text" name="author" id="authorName" value="<%= @author %>"
onClick="this.value == 'AnonymousCoward' ? this.value = '' : true" /> onClick="this.value == 'AnonymousCoward' ? this.value = '' : true" />
| <a href="../cancel_edit/<%= @page.name %>" accesskey="c">Cancel</a> <small>(unlocks page)</small> | <a href="../cancel_edit/<%= @page.url %>" accesskey="c">Cancel</a> <small>(unlocks page)</small>
</p> </p>
</form> </form>

View file

@ -17,7 +17,7 @@
<% end %> <% end %>
<ul><% for page in @pages_by_name %> <ul><% for page in @pages_by_name %>
<li><a href="../show/<%= page.name %>"><%= truncate(page.plain_name, 35) %></a></li> <li><a href="../show/<%= page.url %>"><%= truncate(page.plain_name, 35) %></a></li>
<% end %></ul> <% end %></ul>
<% if @web.count_pages %> <% if @web.count_pages %>
@ -51,7 +51,7 @@
</h2> </h2>
<ul style="margin-bottom: 35px"> <ul style="margin-bottom: 35px">
<% for page in @pages_that_are_orphaned %><li><a href="../show/<%= page.name %>"><%= truncate(page.plain_name, 35) %></a></li><% end %> <% for page in @pages_that_are_orphaned %><li><a href="../show/<%= page.url %>"><%= truncate(page.plain_name, 35) %></a></li><% end %>
</ul> </ul>
<% end %> <% end %>
</div> </div>

View file

@ -8,12 +8,12 @@
<p> <p>
<%= link_to 'Edit the page anyway', <%= link_to 'Edit the page anyway',
{:web => @web_name, :action => 'edit', :id => @page.name, :params => {'break_lock' => '1'} }, {:web => @web_name, :action => 'edit', :id => @page.url, :params => {'break_lock' => '1'} },
{:accesskey => 'E'} {:accesskey => 'E'}
%> %>
<%= link_to 'Cancel', <%= link_to 'Cancel',
{:web => @web_name, :action => 'show', :id => @page.name}, {:web => @web_name, :action => 'show', :id => @page.url},
{:accesskey => 'C'} {:accesskey => 'C'}
%> %>

View file

@ -27,14 +27,14 @@
<div class="navigation"> <div class="navigation">
<% if @page.name == "HomePage" %> <% if @page.name == "HomePage" %>
<a href="../edit/<%= @page.name %>" class="navlink" accesskey="E">Edit Page</a> <a href="../edit/<%= @page.url %>" class="navlink" accesskey="E">Edit Page</a>
| <a href="../edit_web" class="navlink">Edit Web</a> | <a href="../edit_web" class="navlink">Edit Web</a>
<% else %> <% else %>
<a href="../edit/<%= @page.name %>" class="navlink" accesskey="E">Edit</a> <a href="../edit/<%= @page.url %>" class="navlink" accesskey="E">Edit</a>
<% end %> <% end %>
<% if @page.revisions.length > 1 %> <% if @page.revisions.length > 1 %>
| <a href="../revision/<%= @page.name %>?rev=<%= @page.revisions.length - 2 %>" class="navlink" accesskey="R">Back in time</a> | <a href="../revision/<%= @page.url %>?rev=<%= @page.revisions.length - 2 %>" class="navlink" accesskey="R">Back in time</a>
<small>(<%= @page.revisions.length - 1 %> revisions)</small> <small>(<%= @page.revisions.length - 1 %> revisions)</small>
<% end %> <% end %>
@ -48,9 +48,9 @@
<% end %> <% end %>
<small> <small>
| Views: <a href="../print/<%= @page.name %>" accesskey="p">Print</a> | Views: <a href="../print/<%= @page.url %>" accesskey="p">Print</a>
<% if defined? RedClothForTex and RedClothForTex.available? and @web.markup == :textile %> <% if defined? RedClothForTex and RedClothForTex.available? and @web.markup == :textile %>
| <a href="../tex/<%= @page.name %>">TeX</a> | <a href="../pdf/<%= @page.name %>">PDF</a> | <a href="../tex/<%= @page.url %>">TeX</a> | <a href="../pdf/<%= @page.url %>">PDF</a>
<% end %> <% end %>
</small> </small>

View file

@ -20,7 +20,7 @@
<ul> <ul>
<% end %> <% end %>
<li> <li>
<a href="../show/<%= page.name %>"><%= page.plain_name %></a> <a href="../show/<%= page.url %>"><%= page.plain_name %></a>
<div class="byline" style="margin-bottom: 0px"> <div class="byline" style="margin-bottom: 0px">
by <%= page.author_link %> by <%= page.author_link %>
at <%= page.created_at.strftime "%H:%M" %> at <%= page.created_at.strftime "%H:%M" %>

View file

@ -25,9 +25,9 @@
<% if @revision.next_revision %> <% if @revision.next_revision %>
<% if @revision.next_revision.number < (@page.revisions.length - 1) %> <% if @revision.next_revision.number < (@page.revisions.length - 1) %>
<a href="../revision/<%= @page.name %>?rev=<%= @revision.next_revision.number %>" class="navlink"> <a href="../revision/<%= @page.url %>?rev=<%= @revision.next_revision.number %>" class="navlink">
<% else %> <% else %>
<a href="../show/<%= @page.name %>" class="navlink"> <a href="../show/<%= @page.url %>" class="navlink">
<% end %> <% end %>
Forward in time</a> Forward in time</a>
(<%= @revision.page.revisions.length - @revision.next_revision.number %> more) (<%= @revision.page.revisions.length - @revision.next_revision.number %> more)
@ -38,11 +38,11 @@
<% end %> <% end %>
<% if @revision.previous_revision %> <% if @revision.previous_revision %>
<a href="../revision/<%= @page.name %>?rev=<%= @revision.previous_revision.number %>" class="navlink">Back in time</a> <a href="../revision/<%= @page.url %>?rev=<%= @revision.previous_revision.number %>" class="navlink">Back in time</a>
(<%= @revision.previous_revision.number + 1 %> more) (<%= @revision.previous_revision.number + 1 %> more)
<% end %> <% end %>
| <a href="../show/<%= @page.name %>" class="navlink">See current</a> | <a href="../show/<%= @page.url %>" class="navlink">See current</a>
<% if @revision.previous_revision %> <% if @revision.previous_revision %>
<span id="show_changes"> <span id="show_changes">
@ -53,7 +53,7 @@
</span> </span>
<% end %> <% end %>
| <a href="../rollback/<%= @page.name %>?rev=<%= @revision.number %>" class="navlink">Rollback</a> | <a href="../rollback/<%= @page.url %>?rev=<%= @revision.number %>" class="navlink">Rollback</a>
<% if @page.references.length > 0 %> <% if @page.references.length > 0 %>
<small> <small>

View file

@ -6,7 +6,7 @@
<%= "<p style='color:red'>Please correct the error that caused this error in rendering:<br/><small>#{@params["msg"]}</small></p>" if @params["msg"] %> <%= "<p style='color:red'>Please correct the error that caused this error in rendering:<br/><small>#{@params["msg"]}</small></p>" if @params["msg"] %>
<form id="editForm" action="../save/<%= @page.name %>" method="post" onSubmit="cleanAuthorName();"> <form id="editForm" action="../save/<%= @page.url %>" method="post" onSubmit="cleanAuthorName();">
<p> <p>
<textarea name="content" style="font-size: 12px; width: 450px; height: 500px"><%= @revision.content %></textarea> <textarea name="content" style="font-size: 12px; width: 450px; height: 500px"><%= @revision.content %></textarea>
</p> </p>
@ -14,7 +14,7 @@
<input type="submit" value="Update"> as <input type="submit" value="Update"> as
<input type="text" name="author" id="authorName" value="<%= @author %>" <input type="text" name="author" id="authorName" value="<%= @author %>"
onClick="this.value == 'AnonymousCoward' ? this.value = '' : true"> onClick="this.value == 'AnonymousCoward' ? this.value = '' : true">
| <a href="../cancel_edit/<%= @page.name %>">Cancel</a> <small>(unlocks page)</small> | <a href="../cancel_edit/<%= @page.url %>">Cancel</a> <small>(unlocks page)</small>
</p> </p>
</form> </form>

View file

@ -13,8 +13,8 @@
<description><%= CGI.escapeHTML(page.display_content) %></description> <description><%= CGI.escapeHTML(page.display_content) %></description>
<% end %> <% end %>
<pubDate><%= page.created_at.strftime "%a, %e %b %Y %H:%M:%S %Z" %></pubDate> <pubDate><%= page.created_at.strftime "%a, %e %b %Y %H:%M:%S %Z" %></pubDate>
<guid><%= url_for :only_path => false, :web => @web_name, :action => 'show', :id => page.name %></guid> <guid><%= url_for :only_path => false, :web => @web_name, :action => 'show', :id => page.url %></guid>
<link><%= url_for :only_path => false, :web => @web_name, :action => 'show', :id => page.name %></link> <link><%= url_for :only_path => false, :web => @web_name, :action => 'show', :id => page.url %></link>
<dc:creator><%= WikiWords.separate(page.author) %></dc:creator> <dc:creator><%= WikiWords.separate(page.author) %></dc:creator>
</item> </item>
<% end %> <% end %>

View file

@ -4,7 +4,7 @@
<h2><%= @title_results.length %> page(s) containing search string in the page name:</h2> <h2><%= @title_results.length %> page(s) containing search string in the page name:</h2>
<ul> <ul>
<% for page in @title_results %> <% for page in @title_results %>
<li><a href="../show/<%= page.name %>"><%= page.plain_name %></a></li> <li><a href="../show/<%= page.url %>"><%= page.plain_name %></a></li>
<% end %> <% end %>
</ul> </ul>
<% end %> <% end %>
@ -14,7 +14,7 @@
<h2> <%= @results.length %> page(s) containing search string in the page text:</h2> <h2> <%= @results.length %> page(s) containing search string in the page text:</h2>
<ul> <ul>
<% for page in @results %> <% for page in @results %>
<li><a href="../show/<%= page.name %>"><%= page.plain_name %></a></li> <li><a href="../show/<%= page.url %>"><%= page.plain_name %></a></li>
<% end %> <% end %>
</ul> </ul>
<% end %> <% end %>

View file

@ -409,7 +409,7 @@ class WikiControllerTest < Test::Unit::TestCase
['http://localhost:8080/wiki1/show/HomePage', ['http://localhost:8080/wiki1/show/HomePage',
'http://localhost:8080/wiki1/show/Oak', 'http://localhost:8080/wiki1/show/Oak',
'http://localhost:8080/wiki1/show/Elephant', 'http://localhost:8080/wiki1/show/Elephant',
'http://localhost:8080/wiki1/show/Title With Spaces'] 'http://localhost:8080/wiki1/show/Title+With+Spaces']
assert_template_xpath_match '/rss/channel/link', assert_template_xpath_match '/rss/channel/link',
'http://localhost:8080/wiki1/show/HomePage' 'http://localhost:8080/wiki1/show/HomePage'