Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Switch to (crappy) routes

git-svn-id: http://rubygems.rubyforge.org/svn/docs.rubygems.org@2302 3d4018f9-ac1a-0410-99e9-8a154d859a19
  • Loading branch information...
commit 0af35b7efb1bb59429d4944ebbf6d69ac3e5d441 1 parent 5869be7
@drbrain drbrain authored
Showing with 266 additions and 254 deletions.
  1. +4 −4 app/controllers/account_controller.rb
  2. +3 −7 app/controllers/application_controller.rb
  3. +1 −1  app/controllers/book_controller.rb
  4. +4 −2 app/controllers/chapter_controller.rb
  5. +2 −2 app/controllers/error_controller.rb
  6. +1 −1  app/controllers/page_controller.rb
  7. +3 −21 app/helpers/application_helper.rb
  8. +3 −9 app/helpers/syndicate_helper.rb
  9. +1 −1  app/views/account/welcome.html.erb
  10. +1 −1  app/views/book/edit.html.erb
  11. +1 −1  app/views/book/new.html.erb
  12. +1 −1  app/views/chapter/edit.html.erb
  13. +1 −1  app/views/chapter/new.html.erb
  14. +5 −6 app/views/export/book.html.erb
  15. +3 −3 app/views/layouts/application.html.erb
  16. +1 −1  app/views/page/edit.html.erb
  17. +2 −4 app/views/page/history.html.erb
  18. +1 −1  app/views/page/new.html.erb
  19. +4 −4 app/views/read/chapter.html.erb
  20. +2 −3 app/views/shared/_book_options.html.erb
  21. +9 −7 app/views/shared/_chapter_options.html.erb
  22. +7 −9 app/views/shared/_page_options.html.erb
  23. +4 −7 app/views/shared/_side_navigation.html.erb
  24. +6 −6 app/views/shared/_side_options.html.erb
  25. +2 −3 app/views/shared/_top_navigation.html.erb
  26. +6 −3 app/views/shelf/index.html.erb
  27. +12 −7 app/views/shelf/recent.html.erb
  28. +9 −7 app/views/syndicate/atom.rxml
  29. +6 −6 app/views/syndicate/rss.rxml
  30. +2 −2 app/views/user/approve.html.erb
  31. +51 −1 config/routes.rb
  32. +2 −2 lib/login_system.rb
  33. +105 −119 public/javascripts/markup.js
  34. +1 −1  vendor/plugins/acts_as_list/lib/active_record/acts/list.rb
View
8 app/controllers/account_controller.rb
@@ -13,7 +13,7 @@ def approve
end
end
- redirect_back_or_default :controller => 'shelf', :action => 'index'
+ redirect_back_or_default shelf_path
end
def delete
@@ -22,7 +22,7 @@ def delete
@author.destroy if @author
end
- redirect_back_or_default :controller => 'shelf', :action => 'index'
+ redirect_back_or_default shelf_path
end
def login
@@ -33,7 +33,7 @@ def login
session[:author] = author
flash['notice'] = 'Login successful'
- redirect_back_or_default :controller => 'shelf', :action => 'index'
+ redirect_back_or_default shelf_path
return
else
@@ -58,7 +58,7 @@ def signup
Author.authenticate @author.login, params[:author][:password]
if session[:author] then
- redirect_back_or_default :controller => 'shelf', :action => 'index'
+ redirect_back_or_default shelf_path
else
redirect_to :action => 'welcome'
end
View
10 app/controllers/application_controller.rb
@@ -30,17 +30,13 @@ def redirect_back(default = { :controller => "shelf" })
end
def redirect_to_book(book)
- return redirect_to_shelf if book.nil?
- redirect_to :controller => 'read', :action => 'book', :id => book.id
+ return redirect_to shelf_path if book.nil?
+ redirect_to book_path(book)
end
def redirect_to_chapter(chapter)
return redirect_to_book(@book) if chapter.nil?
- redirect_to :controller => 'read', :action => 'chapter', :id => chapter.id
- end
-
- def redirect_to_shelf
- redirect_to :controller => 'shelf', :action => 'index'
+ redirect_to chapter_path(chapter)
end
end
View
2  app/controllers/book_controller.rb
@@ -18,7 +18,7 @@ def delete
[matches].flatten.compact.uniq.each { |book| book.destroy }
end
- redirect_to_shelf
+ redirect_to shelf_path
end
def edit
View
6 app/controllers/chapter_controller.rb
@@ -3,9 +3,11 @@ class ChapterController < ApplicationController
before_filter :login_required
def new
- @book = Book.find params[:id]
+ @book = Book.find params[:book_id]
@chapter = @book.chapters.build params[:chapter]
- @chapter.parent_id ||= params[:parent] || 0
+
+ @chapter.parent = @book.chapters.find params[:chapter_id] if
+ params.key? :chapter_id
if request.post? and @chapter.save then
flash['notice'] = 'Chapter was successfully created.'
View
4 app/controllers/error_controller.rb
@@ -4,13 +4,13 @@ def access_denied
@title = "Access Denied"
@message = "You must be logged in to see this page."
@return_string = "Login"
- @return_url = url_for :controller => 'account', :action => 'login'
+ @return_url = login_path
render_action 'generic'
end
def email_approval_error
@return_string = 'Back to Approvals'
- @return_url = url_for :controller => 'user', :action => 'approve'
+ @return_url = approve_path
if !session[:author] then
# since this error page shows the approved author's email address, we
View
2  app/controllers/page_controller.rb
@@ -79,7 +79,7 @@ def show
@page.send list_method
redirect_to_chapter @chapter
else
- redirect_to_shelf
+ redirect_to shelf_path
end
end
end
View
24 app/helpers/application_helper.rb
@@ -10,11 +10,7 @@ def author_welcomeline
def book_title_or_tagline(string)
return string unless @book
- link_to_book @book.title, @book
- end
-
- def confirmed_link_to(title, options = {})
- link_to title, options, :confirm => 'Are you sure?'
+ link_to @book.title, book_path(@book)
end
def find_next_item(current)
@@ -37,26 +33,12 @@ def list_link(direction, obj)
:action => direction, :id => obj.id)
end
- def link_to_book(text, book)
- link_to(text, :controller => 'read', :action => 'book', :id => book.id)
- end
-
- def link_to_chapter(text, chapter)
- link_to(text, :controller => 'read', :action => 'chapter',
- :id => chapter.id)
- end
-
def link_to_image(image, options)
link_to image_tag(image), options
end
def link_to_page(text, page)
- link_to(text, :controller => 'read', :action => 'chapter',
- :id => page.chapter.id, :anchor=> "page#{page.id}")
- end
-
- def link_to_shelf(text)
- link_to(text)
+ link_to text, chapter_path(page.chapter, :anchor => "page#{page.id}")
end
def render_errors(obj)
@@ -100,7 +82,7 @@ def render_navigation(parent, options = {})
for item in parent.children
if configuration[:chapters] then
- nav << "<li>#{link_to_chapter(item.title, item)}</li>\n"
+ nav << "<li>#{link_to item.title, chapter_path(item)}</li>\n"
end
# if this is the currently active category add links to pages
View
12 app/helpers/syndicate_helper.rb
@@ -1,11 +1,5 @@
module SyndicateHelper
- def server_url_for(options = {})
- options = options.megre :only_path => false
-
- url_for options
- end
-
def pub_date(time)
time.strftime "%a, %e %b %Y %H:%M:%S %Z"
end
@@ -15,9 +9,9 @@ def post_title(post)
end
def post_link(post)
- server_url_for(:controller => 'read', :action => 'chapter',
- :id => post.page.chapter.id,
- :anchor => "page#{post.page.id}")
+ url_for(:controller => 'read', :action => 'chapter',
+ :id => post.page.chapter.id, :anchor => "page#{post.page.id}",
+ :only_path => false)
end
end
View
2  app/views/account/welcome.html.erb
@@ -8,5 +8,5 @@
approved by a current author of the system.
</p>
- <%= link_to "&larr; shelf", :controller=>"shelf", :action => "index"%>
+ <%= link_to '&larr; shelf', shelf_path %>
</div>
View
2  app/views/book/edit.html.erb
@@ -2,7 +2,7 @@
initPreview("book_body", "livepreview", "...")
</script>
-<%= form_tag :action => 'edit', :id => @book.id %>
+<%= form_tag edit_book_path(@book) %>
<h1>Editing Book</h1>
<%= render :partial => 'form' %>
View
2  app/views/book/new.html.erb
@@ -2,7 +2,7 @@
initPreview("book_body", "livepreview", "...")
</script>
-<%= form_tag :action => 'new' %>
+<%= form_tag new_book_path %>
<h1>Create a new book</h1>
<%= render :partial => 'form' %>
View
2  app/views/chapter/edit.html.erb
@@ -1,4 +1,4 @@
-<%= form_tag :action => 'edit', :id => @chapter.id %>
+<%= form_tag edit_chapter_path(@chapter) %>
<h1>Editing Chapter</h1>
<%= render :partial => 'form' %>
View
2  app/views/chapter/new.html.erb
@@ -1,4 +1,4 @@
-<%= form_tag :action => 'new' %>
+<%= form_tag new_chapter_path %>
<h1>Create chapter</h1>
<%= hidden_field 'chapter', 'book_id' %>
View
11 app/views/export/book.html.erb
@@ -4,10 +4,9 @@
<p>You can export the current book in following formats:</p>
<ul>
- <li><%= link_to "html", :action=> "html", :id => @book.id %></li>
- <li><%= link_to "yaml", :action=> "yaml", :id => @book.id %></li>
- <li><%= link_to "textile", :action=> "textile", :id => @book.id %></li>
- <li><%= link_to "text", :action=> "text", :id => @book.id %></li>
+ <li><%= link_to 'html', html_export_path(@book) %></li>
+ <li><%= link_to 'yaml', yaml_export_path(@book) %></li>
+ <li><%= link_to 'textile', textile_export_path(@book) %></li>
+ <li><%= link_to 'text', text_export_path(@book) %></li>
</ul>
-
-</div>
+</div>
View
6 app/views/layouts/application.html.erb
@@ -8,8 +8,8 @@
<link rel="stylesheet" href="/stylesheets/forms.css" type="text/css" />
<link rel="stylesheet" href="/stylesheets/more.css" type="text/css" />
- <link rel="alternate" type="application/rss+xml" title="Recent changes (RSS 2.0)" href="<%= url_for :controller => "syndicate", :action => "rss" %>" />
- <link rel="alternate" type="application/atom+xml" title="Recent changes (Atom 0.3)" href="<%= url_for :controller => "syndicate", :action => "atom" %>" />
+ <link rel="alternate" type="application/rss+xml" title="Recent changes (RSS 2.0)" href="<%= rss_feed_path %>" />
+ <link rel="alternate" type="application/atom+xml" title="Recent changes (Atom 0.3)" href="<%= atom_feed_path %>" />
<% if author? then -%>
<script type="text/javascript" src="/javascripts/markup.js"></script>
@@ -19,7 +19,7 @@
<div id="container">
<img src="/images/rubygems-125x125t.png" align="left">
<div id="header">
- <h1><%= link_to "RubyGems Manuals", :controller => "shelf", :action =>"index" %></h1>
+ <h1><%= link_to 'RubyGems Manuals', shelf_path %></h1>
<p class="tagline"><%= book_title_or_tagline "Your guide to packaging bliss" %></p>
<ul id="navMain">
<%= render :partial => 'shared/top_navigation', :locals => { :book => @book } %>
View
2  app/views/page/edit.html.erb
@@ -1,4 +1,4 @@
-<%= form_tag :action => 'edit', :id => @page.id %>
+<%= form_tag edit_page_path(@page) %>
<h1>Editing Page</h1>
<%= render :partial => 'form' %>
<input type="submit" id="form_submit" value="Update" />
View
6 app/views/page/history.html.erb
@@ -1,12 +1,10 @@
-<h2>Revision log for <em>"<%= @page.title %>"</em></h2>
-
-<p>work in progress..</p>
+<h2>Revision log for <em><%= @page.title %></em></h2>
<table>
<tr>
<th>Date</th><th>Revision</th><th>Title</th>
</tr>
- <% for rev in @page.revisions.find_all -%>
+ <% for rev in @page.revisions.find :all -%>
<tr>
<td>
<%= rev.updated_at %>
View
2  app/views/page/new.html.erb
@@ -1,4 +1,4 @@
-<%= form_tag :action => 'new', :id => @chapter.id %>
+<%= form_tag new_page_path(@chapter) %>
<h1>New Page</h1>
<%= render :partial => 'form' %>
View
8 app/views/read/chapter.html.erb
@@ -7,15 +7,15 @@
<%= render :partial => 'page', :collection => @chapter.pages %>
<div>
-<% if p = find_prev_item(@chapter) then -%>
+<% if prv = find_prev_item(@chapter) then -%>
<div class="left-floaty">
- <%= link_to_chapter "&larr; previous chapter", p %>
+ <%= link_to '&larr; previous chapter', chapter_path(prv) %>
</div>
<% end -%>
-<% if n = find_next_item(@chapter) then -%>
+<% if nxt = find_next_item(@chapter) then -%>
<div class="right-floaty">
- <%= link_to_chapter "next chapter &rarr;", n %>
+ <%= link_to 'next chapter &rarr;', nxt %>
</div>
<% end -%>
</div>
View
5 app/views/shared/_book_options.html.erb
@@ -2,7 +2,6 @@
<span id="admin_book_<%= book.id %>" class="admin">
&nbsp;&nbsp;&nbsp;&nbsp;
-<%= link_to 'edit', :controller => 'book', :action => 'edit', :id => book.id %> |
-<%= confirmed_link_to 'delete', :controller => 'book', :action=> 'delete',
- :id => book.id %>
+<%= link_to 'edit', edit_book_path(book) %> |
+<%= link_to 'delete', delete_book_path(book), :confirm => 'Are you sure?' %>
</span>
View
16 app/views/shared/_chapter_options.html.erb
@@ -1,9 +1,11 @@
-<a href="#" onclick="document.getElementById('chapter_admin_<%= chapter.id %>').style.display='block'; return false;">Chapter options &rarr;</a>
+<a href="#" onclick="document.getElementById('admin_chapter_<%= chapter.id %>').style.display='block'; return false;">Chapter options &rarr;</a>
-<ul id="chapter_admin_<%= chapter.id %>" class="admin">
- <li><%= link_to "New page", :controller => "page", :action => "new", :id => chapter.id %> </li>
- <li><%= link_to "Edit chapter title", :controller=> "chapter", :action=>"edit", :id => chapter.id %> </li>
- <li><%= link_to "Create sub chapter", :controller=> "chapter", :action=>"new", :id => chapter.book.id, :params => { "parent" => chapter.id } %> </li>
- <li><%= confirmed_link_to "Delete this chapter", :controller=> "chapter", :action=>"delete", :id => chapter.id %> </li>
- <li>Move <%= list_link "up", chapter %> <%= list_link "down", chapter %> <%= list_link "top", chapter %> <%= list_link "bottom", chapter %></li>
+<ul id="admin_chapter_<%= chapter.id %>" class="admin">
+ <li><%= link_to 'New page', new_page_path(chapter) %></li>
+ <li><%= link_to 'Edit chapter title', edit_chapter_path(chapter) %></li>
+ <li><%= link_to 'Create sub chapter', new_sub_chapter_path(chapter.book, chapter) %></li>
+ <li><%= link_to 'Delete this chapter', delete_chapter_path(chapter), :confirm => 'Are you sure?' %></li>
+
+ <li>Move <%= list_link 'up', chapter %> <%= list_link 'down', chapter %>
+ <%= list_link 'top', chapter %> <%= list_link 'bottom', chapter %></li>
</ul>
View
16 app/views/shared/_page_options.html.erb
@@ -1,12 +1,10 @@
-<a href="#" onclick="document.getElementById('admin_<%= page.id %>').style.display='inline'; return false;">options &rarr;</a>
+<a href="#" onclick="document.getElementById('admin_page_<%= page.id %>').style.display='inline'; return false;">options &rarr;</a>
-<span id="admin_<%= page.id %>" class="admin">
+<span id="admin_page_<%= page.id %>" class="admin">
&nbsp;&nbsp;&nbsp;&nbsp;
-<%= link_to 'edit', :controller => 'page', :action => 'edit', :id => page.id %> |
-<%= confirmed_link_to 'delete', :controller => 'page', :action => 'delete',
- :id => page.id %> |
-move <%= list_link 'up', page %> <%= list_link 'down', page %>
-<%= list_link 'top', page %>/<%= list_link 'bottom', page %>
-<%= link_to 'log', :controller => 'page', :action => 'history',
- :id => page.id %>
+<%= link_to 'log', history_page_path(page) %> |
+<%= link_to 'edit', edit_page_path(page) %> |
+<%= link_to 'delete', delete_page_path(page), :confirm => 'Are you sure?' %> |
+Move <%= list_link 'up', page %> <%= list_link 'down', page %>
+ <%= list_link 'top', page %> <%= list_link 'bottom', page %>
</span>
View
11 app/views/shared/_side_navigation.html.erb
@@ -7,17 +7,14 @@
<br />
<h2>Options</h2>
- <%= link_to 'exports', :controller => 'export', :action => 'book', :id => book.id %><br />
+ <%= link_to 'exports', export_book_path(book) %><br />
<% else -%>
<h2>Welcome</h2>
- <p>Choose a book...</p>
- <br />
- <br />
<% end -%>
-<%= link_to 'recent changes', :controller => 'shelf', :action => 'recent' %><br />
-<%= link_to 'rss 2.0', :controller=>'syndicate', :action => 'rss' %> |
-<%= link_to 'atom', :controller=>'syndicate', :action => 'atom' %>
+<%= link_to 'recent changes', recent_path %><br />
+<%= link_to 'rss 2.0', rss_feed_path %> |
+<%= link_to 'atom', atom_feed_path %>
<br />
<br />
View
12 app/views/shared/_side_options.html.erb
@@ -1,13 +1,13 @@
<% if author? then -%>
-<%= link_to 'Approve users', :controller => 'user', :action => 'approve' %><br/>
-<%= link_to 'Create book', :controller => 'book', :action => 'new' %><br/>
+<%= link_to 'Approve users', approve_path %><br/>
+<%= link_to 'Create book', new_book_path %><br/>
<% if book then -%>
-<%= link_to 'Append chapter', :controller => 'chapter', :action => 'new', :id => book.id %><br/>
+<%= link_to 'Append chapter', new_chapter_path(book) %><br/>
<% end -%>
<% if chapter then -%>
-<%= link_to 'Append page', :controller => 'page', :action => 'new', :id => chapter.id %><br/>
+<%= link_to 'Append page', new_page_path(chapter) %><br/>
<% end -%>
<% else -%>
-<%= link_to 'Login', :controller => 'account', :action => 'login' %>
-<%= link_to 'Signup', :controller => 'account', :action => 'signup' %>
+<%= link_to 'Login', login_path %>
+<%= link_to 'Signup', signup_path %>
<% end -%>
View
5 app/views/shared/_top_navigation.html.erb
@@ -1,7 +1,6 @@
-<li class="first-child current"><%= link_to "bookshelf", :controller => "shelf", :action => "index" %></li>
+<li class="first-child current"><%= link_to 'Manuals', shelf_path %></li>
<% if book then -%>
-<li><%= link_to 'current book', :controller => 'read', :action => 'book', :id=> @book.id %></li>
+<li><%= link_to 'Current Book', book_path(@book), :title => @book.title %></li>
<% end -%>
<li><a href="http://rubyforge.org/frs/?group_id=126">Downloads</a></li>
-<li><a href="http://docs.rubygems.org/">Manuals</a></li>
<li><a href="http://rubygems.rubyforge.org/rubygems-update/">API Documentation</a></li>
View
9 app/views/shelf/index.html.erb
@@ -2,11 +2,14 @@
<% unless Book.published.empty? then -%>
-<p>Select a book from the list below<% if author? then %> or <%= link_to 'create your own', :controller => 'book', :action => 'new' %> book<% end %>.</p>
+<p>Select a book from the list below<% if author? then %> or
+ <%= link_to 'create your own', new_book_path %> book<% end %>.</p>
-<% Book.published.each do |book| -%>
+<% Book.find(:all).each do |book|
+ next unless author? or !book.published? -%>
<div class="bookinfo">
-<h3><%= link_to book.title, :controller => 'read', :action => 'book', :id => book.id %></h3>
+<h3><%= link_to book.title, book_path(book) %></h3>
+<%= "(unpublished)" if author? and not book.published? %>
<%= render :partial => 'shared/book_options', :locals => { :book => book } if author? %>
<div class="body">
<%= book.intro_html %>
View
19 app/views/shelf/recent.html.erb
@@ -1,18 +1,23 @@
<h2>Recent changes</h2>
-<%= link_to_image 'xml.png', :controller => 'syndicate', :action => 'atom' %> Atom<br/>
-<%= link_to_image 'xml.png', :controller => 'syndicate', :action => 'rss' %> RSS 2.0<br/>
-
+<%= link_to_image 'xml.png', atom_path %> Atom<br />
+<%= link_to_image 'xml.png', rss_path %> RSS 2.0<br />
+
+<ul>
<% for date, revisions in @timeline -%>
- <li><ul><b><%= date.strftime '%B %d,%Y' %></b>
+<li>
+ <ul>
+ <b><%= date.strftime '%B %d,%Y' %></b>
<% for revision in revisions -%>
<li>
- <%= link_to_book revision.page.chapter.book.title, revision.page.chapter.book %>: <%= link_to_page revision.title, revision.page %>
+ <%= link_to revision.page.chapter.book.title, book_path(revision.page.chapter.book) %>:
+ <%= link_to_page revision.title, revision.page %>
<div class="byline" style="margin-bottom: 0px">
by <%= revision.author.name -%>
at <%= revision.created_at.strftime '%I:%M%p' -%>
</div>
- </li>
+ </li>
<% end -%>
- </li></ul>
+</ul>
+</li>
<% end -%>
</ul>
View
16 app/views/syndicate/atom.rxml
@@ -1,9 +1,10 @@
-xml.feed "version" => "0.3", "xml:lang" => "en-US", "xmlns" => "http://purl.org/atom/ns#" do
- xml.title "Hieraki recent changes"
- xml.tagline "mode" => "escaped", "type" => "text/html"
+xml.feed('version' => '0.3', 'xml:lang' => 'en-US',
+ 'xmlns' => 'http://purl.org/atom/ns#') do
+ xml.title 'Hieraki recent changes'
+ xml.tagline 'mode' => 'escaped', 'type' => 'text/html'
xml.id "tag:#{request.host},2004:Hieraki"
- xml.generator "Hieraki", "url" => "http://www.hieraki.org"
- xml.link "rel" => "alternate", "type" => "text/html", "href" => server_url_for(:controller => "shelf")
+ xml.generator 'Hieraki', 'url' => 'http://www.hieraki.org'
+ xml.link 'rel' => 'alternate', 'type' => 'text/html', 'href' => shelf_url
xml.modified @posts.first.updated_at.xmlschema unless @posts.empty?
@@ -16,9 +17,10 @@ xml.feed "version" => "0.3", "xml:lang" => "en-US", "xmlns" => "http://purl.org/
xml.modified entry.updated_at.xmlschema
xml.title post_title(entry)
- xml.link "rel" => "alternate", "type" => "text/html", "href" => post_link(entry)
+ xml.link('rel' => 'alternate', 'type' => 'text/html',
+ 'href' => post_link(entry))
- xml.content entry.body_html, "type" => "text/html", "mode" => "escaped"
+ xml.content entry.body_html, 'type' => 'text/html', 'mode' => 'escaped'
end
end
end
View
12 app/views/syndicate/rss.rxml
@@ -1,10 +1,10 @@
-xml.rss "version"=>"2.0", "xmlns:dc"=>"http://purl.org/dc/elements/1.1/" do
+xml.rss 'version' => '2.0', 'xmlns:dc' => 'http://purl.org/dc/elements/1.1/' do
xml.channel do
- xml.title "Hieraki recent changes"
- xml.link server_url_for(:controller => "shelf")
- xml.description "Hieraki recent changes"
- xml.language "en-us"
- xml.ttl "40"
+ xml.title 'Hieraki recent changes'
+ xml.link shelf_url
+ xml.description 'Hieraki recent changes'
+ xml.language 'en-us'
+ xml.ttl '40'
for entry in @posts
xml.item do
View
4 app/views/user/approve.html.erb
@@ -16,8 +16,8 @@
<%= user.note %>
</div>
<br/>
- <%= link_to "approve", :controller => "account", :action => "approve", :id => user.id %> |
- <%= link_to "delete", :controller => "account", :action => "delete", :id => user.id %>
+ <%= link_to 'approve', :controller => 'account', :action => 'approve', :id => user.id %> |
+ <%= link_to 'delete', delete_user_path(user) %>
</div>
<br/>
View
52 config/routes.rb
@@ -1,5 +1,55 @@
ActionController::Routing::Routes.draw do |map|
- map.connect 'syndicate/:action/feed.xml', :controller => 'syndicate'
+ map.with_options :controller => 'account' do |account|
+ account.approve '/account/approve', :action => 'approve'
+ account.delete_user '/account/delete/:id', :action => 'delete'
+ account.login '/account/login', :action => 'login'
+ account.logout '/account/logout', :action => 'logout'
+ account.signup '/account/signup', :action => 'signup'
+ end
+
+ map.with_options :controller => 'book' do |book|
+ book.delete_book '/book/delete/:id', :action => 'delete'
+ book.edit_book '/book/edit/:id', :action => 'edit'
+ book.new_book '/book/new/', :action => 'new'
+ end
+
+ map.with_options :controller => 'chapter' do |chapter|
+ chapter.delete_chapter '/chapter/delete/:id', :action => 'delete'
+ chapter.edit_chapter '/chapter/edit/:id', :action => 'edit'
+ chapter.new_chapter '/chapter/new/:book_id', :action => 'new'
+
+ chapter.new_sub_chapter '/chapter/new/:book_id/:chapter_id', :action => 'new'
+ end
+
+ map.with_options :controller => 'export' do |export|
+ export.export_book '/export/book/:id', :action => 'book'
+
+ export.html_export '/export/html/:id', :action => 'html'
+ export.text_export '/export/text/:id', :action => 'text'
+ export.textile_export '/export/textile/:id', :action => 'textile'
+ export.yaml_export '/export/yaml/:id', :action => 'yaml'
+ end
+
+ map.with_options :controller => 'page' do |page|
+ page.delete_page '/page/delete/:id', :action => 'delete'
+ page.edit_page '/page/edit/:id', :action => 'edit'
+ page.history_page '/page/history/:id', :action => 'history'
+ page.new_page '/page/new/:id', :action => 'new'
+ end
+
+ map.with_options :controller => 'read' do |read|
+ read.book '/read/book/:id', :action => 'book'
+ read.chapter '/read/chapter/:id', :action => 'chapter'
+ end
+
+ map.with_options :controller => 'syndicate' do |syndicate|
+ syndicate.atom_feed '/syndicate/atom/feed.xml', :action => 'atom'
+ syndicate.rss_feed '/syndicate/rss/feed.xml', :action => 'rss'
+ end
+
+ map.shelf '/shelf/index', :controller => 'shelf', :action => 'index'
+ map.recent '/shelf/recent', :controller => 'shelf', :action => 'recent'
+
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
View
4 lib/login_system.rb
@@ -9,7 +9,7 @@ module LoginSystem
# a popup window might just close itself for instance
def access_denied
- redirect_to :controller => 'account', :action => 'login'
+ redirect_to login_path
end
# overwrite this if you want to restrict access to only a few actions or if
@@ -55,7 +55,7 @@ def redirect_back_or_default(default)
if session[:return_to].nil? then
redirect_to default
else
- redirect_to_url session[:return_to]
+ redirect_to session[:return_to]
session[:return_to] = nil
end
end
View
224 public/javascripts/markup.js
@@ -1,17 +1,16 @@
- var searchFieldId = '';
- var resultFieldId = '';
- var processURI = '/markup/preview';
- var emptyString = '';
- var liveReq = false;
- var t = null;
- var liveReqLast = "";
- var isIE = false;
-
- function addEvent(obj, evType, fn, useCapture){
- if (obj.addEventListener){
+var searchFieldId = '';
+var resultFieldId = '';
+var processURI = '/markup/preview';
+var emptyString = '';
+var liveReq = false;
+var t = null;
+var liveReqLast = "";
+
+function addEvent(obj, evType, fn, useCapture) {
+ if (obj.addEventListener) {
obj.addEventListener(evType, fn, useCapture);
return true;
- } else if (obj.attachEvent){
+ } else if (obj.attachEvent) {
var r = obj.attachEvent("on"+evType, fn);
return r;
} else {
@@ -31,118 +30,105 @@ function addLoadEvent(func) {
}
}
-function removeEvent(obj, evType, fn, useCapture){
- if (obj.removeEventListener){
+function removeEvent(obj, evType, fn, useCapture) {
+ if (obj.removeEventListener) {
obj.removeEventListener(evType, fn, useCapture);
return true;
- } else if (obj.detachEvent){
+ } else if (obj.detachEvent) {
var r = obj.detachEvent("on"+evType, fn);
return r;
} else {
alert("Handler could not be removed");
}
-}
-
-
- // on !IE we only have to initialize it once
- if (window.XMLHttpRequest) {
- liveReq = new XMLHttpRequest();
- }
-
- function liveReqInit() {
-
- if (navigator.userAgent.indexOf("Safari") > 0) {
- document.getElementById(searchFieldId).addEventListener("keydown",liveReqStart,false);
-
- } else if (navigator.product == "Gecko") {
- document.getElementById(searchFieldId).addEventListener("keypress",liveReqStart,false);
-
- } else {
- document.getElementById(searchFieldId).attachEvent('onkeydown',liveReqStart);
- isIE = true;
- }
-
- if(resultFieldId == '') {
- // if a result field isn't on the page, this will sneak one in...
- resultFieldId = "liveRequestResults";
- displayArea = document.createElement('div');
- displayArea.id = "liveRequestResults";
- document.getElementsByTagName('body')[0].appendChild(displayArea);
- }
-
- if(emptyString == '') {
- // set the result field to hidden, or to default string
- document.getElementById(resultFieldId).style.display = "none";
- } else {
- document.getElementById(resultFieldId).innerHTML = emptyString;
- }
- liveReqDoReq();
- }
-
- function liveReqStart() {
- if (t) {
- window.clearTimeout(t);
- }
- t = window.setTimeout("liveReqDoReq()",400);
- }
-
- function liveReqDoReq() {
- if (liveReqLast != document.getElementById(searchFieldId).value && document.getElementById(searchFieldId).value != "") {
- if (liveReq && liveReq.readyState < 4) {
- liveReq.abort();
- }
- if (window.XMLHttpRequest) {
- // branch for IE/Windows ActiveX version
- } else if (window.ActiveXObject) {
- liveReq = new ActiveXObject("Microsoft.XMLHTTP");
- }
-
- liveReq.onreadystatechange = liveReqProcessReqChange;
- liveReq.open("POST", processURI );
- liveReqLast = document.getElementById(searchFieldId).value;
- liveReq.send(document.getElementById(searchFieldId).value);
- } else if(document.getElementById(searchFieldId).value == "") {
- if(emptyString == '') {
- document.getElementById(resultFieldId).innerHTML = '';
- document.getElementById(resultFieldId).style.display = "none";
- } else {
- document.getElementById(resultFieldId).innerHTML = emptyString;
- }
- }
- }
-
- function liveReqProcessReqChange() {
- if (liveReq.readyState == 4) {
- document.getElementById(resultFieldId).innerHTML = liveReq.responseText;
- if(emptyString == '') {
- document.getElementById(resultFieldId).style.display = "block";
- }
- }
- }
-function initPreview(fieldid, previewid, def ) {
- searchFieldId = fieldid;
- resultFieldId = previewid;
- emptyString = def;
- addLoadEvent(liveReqInit);
- }
-
- function quickRedReference() {
- window.open(
- "/markup/popup",
- "redRef",
- "height=600,width=550,channelmode=0,dependent=0," +
- "directories=0,fullscreen=0,location=0,menubar=0," +
- "resizable=0,scrollbars=1,status=1,toolbar=0"
- );
- }
-
-function setActiveStyleSheet(title) {
- var i, a, main;
- for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
- if(a.getAttribute("rel").indexOf("style") != -1
- && a.getAttribute("title")) {
- a.disabled = true;
- if(a.getAttribute("title") == title) a.disabled = false;
- }
- }
}
+
+// on !IE we only have to initialize it once
+if (window.XMLHttpRequest) {
+ liveReq = new XMLHttpRequest();
+}
+
+function liveReqInit() {
+ if (navigator.userAgent.indexOf("Safari") > 0) {
+ document.getElementById(searchFieldId).addEventListener("keydown", liveReqStart, false);
+
+ } else if (navigator.product == "Gecko") {
+ document.getElementById(searchFieldId).addEventListener("keypress", liveReqStart, false);
+
+ } else {
+ document.getElementById(searchFieldId).attachEvent('onkeydown', liveReqStart);
+ }
+
+ if (resultFieldId == '') {
+ // if a result field isn't on the page, this will sneak one in...
+ resultFieldId = "liveRequestResults";
+ displayArea = document.createElement('div');
+ displayArea.id = "liveRequestResults";
+ document.getElementsByTagName('body')[0].appendChild(displayArea);
+ }
+
+ if (emptyString == '') {
+ // set the result field to hidden, or to default string
+ document.getElementById(resultFieldId).style.display = "none";
+ } else {
+ document.getElementById(resultFieldId).innerHTML = emptyString;
+ }
+ liveReqDoReq();
+}
+
+function liveReqStart() {
+ if (t) {
+ window.clearTimeout(t);
+ }
+ t = window.setTimeout("liveReqDoReq()", 400);
+}
+
+function liveReqDoReq() {
+ if (liveReqLast != document.getElementById(searchFieldId).value && document.getElementById(searchFieldId).value != "") {
+ if (liveReq && liveReq.readyState < 4) {
+ liveReq.abort();
+ }
+ if (window.XMLHttpRequest) {
+ // branch for IE/Windows ActiveX version
+ } else if (window.ActiveXObject) {
+ liveReq = new ActiveXObject("Microsoft.XMLHTTP");
+ }
+
+ liveReq.onreadystatechange = liveReqProcessReqChange;
+ liveReq.open("POST", processURI);
+ liveReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')
+ liveReqLast = document.getElementById(searchFieldId).value;
+ liveReq.send("text=" + encodeURI(document.getElementById(searchFieldId).value));
+ } else if (document.getElementById(searchFieldId).value == "") {
+ if (emptyString == '') {
+ document.getElementById(resultFieldId).innerHTML = '';
+ document.getElementById(resultFieldId).style.display = "none";
+ } else {
+ document.getElementById(resultFieldId).innerHTML = emptyString;
+ }
+ }
+}
+
+function liveReqProcessReqChange() {
+ if (liveReq.readyState == 4) {
+ document.getElementById(resultFieldId).innerHTML = liveReq.responseText;
+ if (emptyString == '') {
+ document.getElementById(resultFieldId).style.display = "block";
+ }
+ }
+}
+
+function initPreview(fieldid, previewid, def) {
+ searchFieldId = fieldid;
+ resultFieldId = previewid;
+ emptyString = def;
+ addLoadEvent(liveReqInit);
+}
+
+function quickRedReference() {
+ window.open("/markup/popup",
+ "redRef",
+ "height=600,width=550,channelmode=0,dependent=0," +
+ "directories=0,fullscreen=0,location=0,menubar=0," +
+ "resizable=0,scrollbars=1,status=1,toolbar=0");
+}
+
View
2  vendor/plugins/acts_as_list/lib/active_record/acts/list.rb
@@ -123,7 +123,7 @@ def move_to_top
def remove_from_list
if in_list?
decrement_positions_on_lower_items
- update_attribute position_column, nil
+ update_attribute position_column, -1
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.