nested routes and to_param for pages
git-svn-id: http://svn.barleysodas.com/barleysodas/trunk@154 0f7b21a7-9e3a-4941-bbeb-ce5c7c368fa7master
parent
adacded47a
commit
3ce5d102e9
|
@ -59,9 +59,9 @@ class BeersController < ApplicationController
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @beer.save
|
if @beer.save
|
||||||
flash[:notice] = 'Beer was successfully created.'
|
flash[:notice] = 'Beer was successfully created.'
|
||||||
format.html { redirect_to beer_url(@beer.page.title_for_url) }
|
format.html { redirect_to brewery_beer_path(brewery, @beer) }
|
||||||
format.xml { head :created,
|
format.xml { head :created,
|
||||||
:location => beer_url(@beer.page.title_for_url) }
|
:location => brewery_beer_path(brewery, @beer) }
|
||||||
else
|
else
|
||||||
format.html { render :action => "new" }
|
format.html { render :action => "new" }
|
||||||
format.xml { render :xml => @beer.errors.to_xml }
|
format.xml { render :xml => @beer.errors.to_xml }
|
||||||
|
@ -80,7 +80,7 @@ class BeersController < ApplicationController
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @beer.save
|
if @beer.save
|
||||||
flash[:notice] = 'Beer was successfully updated.'
|
flash[:notice] = 'Beer was successfully updated.'
|
||||||
format.html { redirect_to beer_url(@beer.page.title_for_url) }
|
format.html { redirect_to brewery_beer_url(@beer.brewery, @beer) }
|
||||||
format.xml { head :ok }
|
format.xml { head :ok }
|
||||||
else
|
else
|
||||||
format.html { render :action => "edit" }
|
format.html { render :action => "edit" }
|
||||||
|
@ -94,7 +94,7 @@ class BeersController < ApplicationController
|
||||||
def destroy
|
def destroy
|
||||||
@beer.destroy
|
@beer.destroy
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to beers_url }
|
format.html { redirect_to :action => :index }
|
||||||
format.xml { head :ok }
|
format.xml { head :ok }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -53,9 +53,9 @@ class BreweriesController < ApplicationController
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @brewery.save
|
if @brewery.save
|
||||||
flash[:notice] = 'Brewery was successfully created.'
|
flash[:notice] = 'Brewery was successfully created.'
|
||||||
format.html { redirect_to brewery_url(@brewery.page.title_for_url) }
|
format.html { redirect_to brewery_url(@brewery) }
|
||||||
format.xml { head :created,
|
format.xml { head :created,
|
||||||
:location => brewery_url(@brewery.page.title_for_url) }
|
:location => brewery_url(@brewery) }
|
||||||
else
|
else
|
||||||
format.html { render :action => "new" }
|
format.html { render :action => "new" }
|
||||||
format.xml { render :xml => @brewery.errors.to_xml }
|
format.xml { render :xml => @brewery.errors.to_xml }
|
||||||
|
@ -71,7 +71,7 @@ class BreweriesController < ApplicationController
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @brewery.save
|
if @brewery.save
|
||||||
flash[:notice] = 'Brewery was successfully updated.'
|
flash[:notice] = 'Brewery was successfully updated.'
|
||||||
format.html { redirect_to brewery_url(@brewery.page.title_for_url) }
|
format.html { redirect_to brewery_url(@brewery) }
|
||||||
format.xml { head :ok }
|
format.xml { head :ok }
|
||||||
else
|
else
|
||||||
format.html { render :action => "edit" }
|
format.html { render :action => "edit" }
|
||||||
|
|
|
@ -21,7 +21,7 @@ class FriendsController < ApplicationController
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @friend.save
|
if @friend.save
|
||||||
flash[:notice] = 'Successfully added the new friend'
|
flash[:notice] = 'Successfully added the new friend'
|
||||||
format.html { redirect_to people_path(@dest.page.title_for_url) }
|
format.html { redirect_to people_path(@dest) }
|
||||||
else
|
else
|
||||||
format.html { render :action => "new" }
|
format.html { render :action => "new" }
|
||||||
end
|
end
|
||||||
|
@ -37,7 +37,7 @@ class FriendsController < ApplicationController
|
||||||
@friend.destroy if @friend
|
@friend.destroy if @friend
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
flash[:notice] = 'Removed the friend'
|
flash[:notice] = 'Removed the friend'
|
||||||
format.html { redirect_to people_path(@people.page.title_for_url) }
|
format.html { redirect_to people_path(@people) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -53,9 +53,9 @@ class PagesController < ApplicationController
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @page.save
|
if @page.save
|
||||||
flash[:notice] = 'Page was successfully created.'
|
flash[:notice] = 'Page was successfully created.'
|
||||||
format.html { redirect_to page_url({ :id => @page.title_for_url }) }
|
format.html { redirect_to page_url(@page) }
|
||||||
format.xml { head :created,
|
format.xml { head :created,
|
||||||
:location => page_url({ :id => @page.title_for_url }) }
|
:location => page_url(@page) }
|
||||||
else
|
else
|
||||||
format.html { render :action => "new" }
|
format.html { render :action => "new" }
|
||||||
format.xml { render :xml => @page.errors.to_xml }
|
format.xml { render :xml => @page.errors.to_xml }
|
||||||
|
@ -74,7 +74,7 @@ class PagesController < ApplicationController
|
||||||
if @page.title == 'HomePage'
|
if @page.title == 'HomePage'
|
||||||
redirect_to pages_url
|
redirect_to pages_url
|
||||||
else
|
else
|
||||||
redirect_to page_url({ :id => @page.title_for_url })
|
redirect_to page_url(@page)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
format.xml { head :ok }
|
format.xml { head :ok }
|
||||||
|
|
|
@ -55,9 +55,9 @@ class PeoplesController < ApplicationController
|
||||||
if invitation and @people.save
|
if invitation and @people.save
|
||||||
invitation.destroy
|
invitation.destroy
|
||||||
flash[:notice] = 'People was successfully created.'
|
flash[:notice] = 'People was successfully created.'
|
||||||
format.html { redirect_to people_url(@people.page.title_for_url) }
|
format.html { redirect_to people_url(@people) }
|
||||||
format.xml { head :created,
|
format.xml { head :created,
|
||||||
:location => people_url(@people.page.title_for_url) }
|
:location => people_url(@people) }
|
||||||
else
|
else
|
||||||
format.html { render :action => "new" }
|
format.html { render :action => "new" }
|
||||||
format.xml { render :xml => @people.errors.to_xml }
|
format.xml { render :xml => @people.errors.to_xml }
|
||||||
|
@ -74,7 +74,7 @@ class PeoplesController < ApplicationController
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @people.update_attributes(params[:people])
|
if @people.update_attributes(params[:people])
|
||||||
flash[:notice] = 'People was successfully updated.'
|
flash[:notice] = 'People was successfully updated.'
|
||||||
format.html { redirect_to people_url(@people.page.title_for_url) }
|
format.html { redirect_to people_url(@people) }
|
||||||
format.xml { head :ok }
|
format.xml { head :ok }
|
||||||
else
|
else
|
||||||
format.html { render :action => "edit" }
|
format.html { render :action => "edit" }
|
||||||
|
|
|
@ -45,7 +45,7 @@ class StylesController < ApplicationController
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @style.save
|
if @style.save
|
||||||
flash[:notice] = 'Style was successfully created.'
|
flash[:notice] = 'Style was successfully created.'
|
||||||
format.html { redirect_to style_url(@style.page.title_for_url) }
|
format.html { redirect_to style_url(@style) }
|
||||||
format.xml { head :created, :location => style_url(@style) }
|
format.xml { head :created, :location => style_url(@style) }
|
||||||
else
|
else
|
||||||
format.html { render :action => "new" }
|
format.html { render :action => "new" }
|
||||||
|
@ -64,7 +64,7 @@ class StylesController < ApplicationController
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @style.save
|
if @style.save
|
||||||
flash[:notice] = 'Style was successfully updated.'
|
flash[:notice] = 'Style was successfully updated.'
|
||||||
format.html { redirect_to style_url(@style.page.title_for_url) }
|
format.html { redirect_to style_url(@style) }
|
||||||
format.xml { head :ok }
|
format.xml { head :ok }
|
||||||
else
|
else
|
||||||
format.html { render :action => "edit" }
|
format.html { render :action => "edit" }
|
||||||
|
|
|
@ -11,7 +11,7 @@ module ApplicationHelper
|
||||||
#
|
#
|
||||||
def content_title
|
def content_title
|
||||||
return h(@content_title) if @content_title
|
return h(@content_title) if @content_title
|
||||||
controller.class.to_s.gsub(/Controller/, '')
|
controller.controller_name.camelcase
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -27,7 +27,7 @@ module ApplicationHelper
|
||||||
# Returns a link for a Page model.
|
# Returns a link for a Page model.
|
||||||
#
|
#
|
||||||
def link_to_page(page)
|
def link_to_page(page)
|
||||||
link_to h(page.title), page_path({ :id => page.title_for_url })
|
link_to h(page.title), page_path(page)
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
|
@ -2,16 +2,16 @@ module BeersHelper
|
||||||
include BreweriesHelper
|
include BreweriesHelper
|
||||||
|
|
||||||
def new_beer_link
|
def new_beer_link
|
||||||
link_to 'New Beer', new_beer_path, { :title => 'Create a new beer' }
|
link_to 'New Beer', new_brewery_beer_url, { :title => 'Create a new beer' }
|
||||||
end
|
end
|
||||||
|
|
||||||
def show_beer_link(beer)
|
def show_beer_link(beer)
|
||||||
link_to beer.title, beer_path(beer.page.title_for_url),
|
link_to beer.title, brewery_beer_path(beer.brewery, beer),
|
||||||
{ :title => beer.title }
|
{ :title => beer.title }
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit_beer_link(beer)
|
def edit_beer_link(beer)
|
||||||
link_to 'Edit Beer', edit_beer_path(beer.page.title_for_url),
|
link_to 'Edit Beer', edit_brewery_beer_path(beer.brewery, beer),
|
||||||
{ :title => "Edit #{beer.title}" }
|
{ :title => "Edit #{beer.title}" }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,12 +5,12 @@ module BreweriesHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def show_brewery_link(brewery)
|
def show_brewery_link(brewery)
|
||||||
link_to brewery.title, brewery_path(brewery.page.title_for_url),
|
link_to brewery.title, brewery_path(brewery),
|
||||||
{ :title => brewery.title }
|
{ :title => brewery.title }
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit_brewery_link(brewery)
|
def edit_brewery_link(brewery)
|
||||||
link_to 'Edit Brewery', edit_brewery_path(brewery.page.title_for_url),
|
link_to 'Edit Brewery', edit_brewery_path(brewery),
|
||||||
{ :title => "Edit #{brewery.title}" }
|
{ :title => "Edit #{brewery.title}" }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,9 +4,14 @@ module DiscussionsHelper
|
||||||
#
|
#
|
||||||
def page_or_parent_link(page)
|
def page_or_parent_link(page)
|
||||||
if page.owner_type.to_s.empty?
|
if page.owner_type.to_s.empty?
|
||||||
return link_to('Show Wiki Page', page_path(page.title_for_url))
|
return link_to('Show Wiki Page', page_path(page))
|
||||||
end
|
end
|
||||||
|
if page.owner_type == 'Beer'
|
||||||
|
link_to "Show Beer Page",
|
||||||
|
brewery_beer_path(page.owner.brewery, page.owner)
|
||||||
|
else
|
||||||
link_to("Show #{page.owner_type} Page",
|
link_to("Show #{page.owner_type} Page",
|
||||||
send("#{page.owner_type.downcase}_path", page.title_for_url))
|
send("#{page.owner_type.downcase}_path", page))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,12 +4,11 @@ module PagesHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def show_page_link(page, better_title = 'Show')
|
def show_page_link(page, better_title = 'Show')
|
||||||
link_to better_title, page_path(page.title_for_url),
|
link_to better_title, page_path(page), { :title => page.title }
|
||||||
{ :title => page.title }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit_page_link(page)
|
def edit_page_link(page)
|
||||||
link_to 'Edit Page', edit_page_path(page.title_for_url),
|
link_to 'Edit Page', edit_page_path(page),
|
||||||
{ :title => "Edit #{page.title}" }
|
{ :title => "Edit #{page.title}" }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,18 +4,17 @@ module PeoplesHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def show_people_link(people)
|
def show_people_link(people)
|
||||||
link_to people.title, people_path(people.page.title_for_url),
|
link_to people.title, people_path(people), { :title => people.title }
|
||||||
{ :title => people.title }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit_people_link(people)
|
def edit_people_link(people)
|
||||||
link_to 'Edit People', edit_people_path(people.page.title_for_url),
|
link_to 'Edit People', edit_people_path(people),
|
||||||
{ :title => "Edit #{people.title}" }
|
{ :title => "Edit #{people.title}" }
|
||||||
end
|
end
|
||||||
|
|
||||||
def show_friends_link(people)
|
def show_friends_link(people)
|
||||||
link_to "#{people.title}'s Friends (#{people.actual_friends.size})",
|
link_to "#{people.title}'s Friends (#{people.actual_friends.size})",
|
||||||
friend_path(people.page.title_for_url)
|
friend_path(people)
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_friend_link(people)
|
def add_friend_link(people)
|
||||||
|
@ -26,7 +25,6 @@ module PeoplesHelper
|
||||||
|
|
||||||
def remove_friend_link(people)
|
def remove_friend_link(people)
|
||||||
link_to "#{image_tag('list-remove.png')} Friend",
|
link_to "#{image_tag('list-remove.png')} Friend",
|
||||||
friend_url(:id => people.page.title_for_url, :d => session[:people_id]),
|
friend_url(people, :d => session[:people_id]), :method => :delete
|
||||||
:method => :delete
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,12 +4,11 @@ module StylesHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def show_style_link(style)
|
def show_style_link(style)
|
||||||
link_to style.title, style_path(style.page.title_for_url),
|
link_to style.title, style_path(style), { :title => style.title }
|
||||||
{ :title => style.title }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit_style_link(style)
|
def edit_style_link(style)
|
||||||
link_to 'Edit Style', edit_style_path(style.page.title_for_url),
|
link_to 'Edit Style', edit_style_path(style),
|
||||||
{ :title => "Edit #{style.title}" }
|
{ :title => "Edit #{style.title}" }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
# This model will represent a beverage produced by a Brewery.
|
# This model will represent a beverage produced by a Brewery.
|
||||||
#
|
#
|
||||||
class Beer < ActiveRecord::Base
|
class Beer < ActiveRecord::Base
|
||||||
|
include WordyParameter
|
||||||
belongs_to :brewery
|
belongs_to :brewery
|
||||||
has_one_tuxwiki_page :owner_class => 'Beer'
|
has_one_tuxwiki_page :owner_class => 'Beer'
|
||||||
belongs_to :style
|
belongs_to :style
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
# This model represents a company that produces Beer.
|
# This model represents a company that produces Beer.
|
||||||
#
|
#
|
||||||
class Brewery < ActiveRecord::Base
|
class Brewery < ActiveRecord::Base
|
||||||
|
include WordyParameter
|
||||||
has_many :beers
|
has_many :beers
|
||||||
has_one_tuxwiki_page :owner_class => 'Brewery'
|
has_one_tuxwiki_page :owner_class => 'Brewery'
|
||||||
has_many_tagged_images
|
has_many_tagged_images
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
# * Uses [[ and ]] for WikiWord representation.
|
# * Uses [[ and ]] for WikiWord representation.
|
||||||
#
|
#
|
||||||
class Page < ActiveRecord::Base
|
class Page < ActiveRecord::Base
|
||||||
|
include WordyParameter
|
||||||
acts_as_versioned
|
acts_as_versioned
|
||||||
acts_as_taggable
|
acts_as_taggable
|
||||||
|
|
||||||
|
@ -32,13 +33,6 @@ class Page < ActiveRecord::Base
|
||||||
|
|
||||||
attr_protected :allow_discussions, :created_by, :updated_by
|
attr_protected :allow_discussions, :created_by, :updated_by
|
||||||
|
|
||||||
##
|
|
||||||
# Returns an url-friendly title for making links.
|
|
||||||
#
|
|
||||||
def title_for_url
|
|
||||||
self.title.gsub(/ /, '_')
|
|
||||||
end
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Gets a title from an url name.
|
# Gets a title from an url name.
|
||||||
#
|
#
|
||||||
|
|
|
@ -28,7 +28,8 @@ class People < ActiveRecord::Base
|
||||||
# Friend of this instance.
|
# Friend of this instance.
|
||||||
#
|
#
|
||||||
def friend_of?(people_id)
|
def friend_of?(people_id)
|
||||||
Friend.count([ 'source_id = ? AND destination_id = ?', people_id, id ]) > 0
|
Friend.count(:conditions => [ 'source_id = ? AND destination_id = ?',
|
||||||
|
people_id, id ]) > 0
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
|
@ -12,8 +12,8 @@ xml.rss(:version=>"2.0"){
|
||||||
xml.description(beer.brewery.title)
|
xml.description(beer.brewery.title)
|
||||||
xml.author(beer.page.created_by.title)
|
xml.author(beer.page.created_by.title)
|
||||||
xml.pubDate(beer.created_at.strftime("%a, %d %b %Y %H:%M:%S %z"))
|
xml.pubDate(beer.created_at.strftime("%a, %d %b %Y %H:%M:%S %z"))
|
||||||
xml.link(beer_url(beer.page.title_for_url))
|
xml.link(brewery_beer_url(beer.brewery, beer))
|
||||||
xml.guid(beer_url(beer.page.title_for_url))
|
xml.guid(brewery_beer_url(beer.brewery, beer))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<%= error_messages_for :beer %>
|
<%= error_messages_for :beer %>
|
||||||
|
|
||||||
<% form_for(:beer, :url => beer_path(@beer.page.title_for_url), :html => { :method => :put }) do |f| %>
|
<% form_for(:beer, :url => brewery_beer_path(@beer.brewery, @beer), :html => { :method => :put }) do |f| %>
|
||||||
<%= render :partial => 'beer_form' %>
|
<%= render :partial => 'beer_form' %>
|
||||||
<p>
|
<p>
|
||||||
<%= submit_tag "Update" %>
|
<%= submit_tag "Update" %>
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<%= render :partial => 'shared/pagination_links' %>
|
<%= render :partial => 'shared/pagination_links' %>
|
||||||
|
|
||||||
<% content_for :sidebar do -%>
|
<% content_for :sidebar do -%>
|
||||||
<%= link_to "New Beer", new_beer_path, { :title => 'Create a new beer' } -%><br />
|
<%= link_to "New Beer", { :action => :new }, { :title => 'Create a new beer' } -%><br />
|
||||||
<%= render :partial => 'shared/tag_cloud' %>
|
<%= render :partial => 'shared/tag_cloud' %>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<%= error_messages_for :beer %>
|
<%= error_messages_for :beer %>
|
||||||
|
|
||||||
<% form_for(:beer, :url => beers_path, :html => { :method => :post }) do |f| %>
|
<% form_for(:beer, brewery_beers_path(:brewery_id => nil), :html => { :method => :post }) do |f| %>
|
||||||
<%= render :partial => 'beer_form' %>
|
<%= render :partial => 'beer_form' %>
|
||||||
<p>
|
<p>
|
||||||
<%= submit_tag "Create" %>
|
<%= submit_tag "Create" %>
|
||||||
|
|
|
@ -33,7 +33,7 @@ after_opens['experienceDialog'] = function(){
|
||||||
<% content_for :sidebar do -%>
|
<% content_for :sidebar do -%>
|
||||||
<%= new_beer_link -%><br />
|
<%= new_beer_link -%><br />
|
||||||
<%= edit_beer_link(@beer) -%><br />
|
<%= edit_beer_link(@beer) -%><br />
|
||||||
<%= link_to 'Destroy', beer_path(@beer.page.title_for_url), :confirm => 'Are you sure?', :method => :delete %><br />
|
<%= link_to 'Destroy', brewery_beer_path(@beer.brewery, @beer), :confirm => 'Are you sure?', :method => :delete %><br />
|
||||||
<% unless @beer.tagged_images.empty? -%><%= tagged_image_browser_link(@beer) -%><br /><% end %>
|
<% unless @beer.tagged_images.empty? -%><%= tagged_image_browser_link(@beer) -%><br /><% end %>
|
||||||
<span id="experience_container"><% if @experience -%><%= remove_experience_link(@experience) -%><% else -%><%= add_experience_link -%><% end %></span><br />
|
<span id="experience_container"><% if @experience -%><%= remove_experience_link(@experience) -%><% else -%><%= add_experience_link -%><% end %></span><br />
|
||||||
<strong><%= pluralize(@beer.people.size, 'people') -%></strong> have experienced this beer.<br />
|
<strong><%= pluralize(@beer.people.size, 'people') -%></strong> have experienced this beer.<br />
|
||||||
|
|
|
@ -12,8 +12,8 @@ xml.rss(:version=>"2.0"){
|
||||||
xml.description(brewery.homepage)
|
xml.description(brewery.homepage)
|
||||||
xml.author(brewery.page.created_by.title)
|
xml.author(brewery.page.created_by.title)
|
||||||
xml.pubDate(brewery.created_at.strftime("%a, %d %b %Y %H:%M:%S %z"))
|
xml.pubDate(brewery.created_at.strftime("%a, %d %b %Y %H:%M:%S %z"))
|
||||||
xml.link(brewery_url(brewery.page.title_for_url))
|
xml.link(brewery_url(brewery))
|
||||||
xml.guid(brewery_url(brewery.page.title_for_url))
|
xml.guid(brewery_url(brewery))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<%= error_messages_for :brewery %>
|
<%= error_messages_for :brewery %>
|
||||||
|
|
||||||
<% form_for(:brewery, :url => brewery_path(@brewery.page.title_for_url), :html => { :method => :put }) do |f| %>
|
<% form_for(:brewery, :url => brewery_path(@brewery), :html => { :method => :put }) do |f| %>
|
||||||
<%= render :partial => 'brewery_form' %>
|
<%= render :partial => 'brewery_form' %>
|
||||||
<p>
|
<p>
|
||||||
<%= submit_tag "Update" %>
|
<%= submit_tag "Update" %>
|
||||||
|
@ -9,5 +9,5 @@
|
||||||
|
|
||||||
<% content_for :sidebar do -%>
|
<% content_for :sidebar do -%>
|
||||||
<%= link_to 'New Brewery', new_brewery_path -%><br />
|
<%= link_to 'New Brewery', new_brewery_path -%><br />
|
||||||
<%= link_to 'Show', brewery_path(@brewery.page.title_for_url) -%><br />
|
<%= link_to 'Show', brewery_path(@brewery) -%><br />
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
<% content_for :sidebar do -%>
|
<% content_for :sidebar do -%>
|
||||||
<%= new_brewery_link -%><br />
|
<%= new_brewery_link -%><br />
|
||||||
<%= edit_brewery_link(@brewery) -%><br />
|
<%= edit_brewery_link(@brewery) -%><br />
|
||||||
<%= link_to 'Destroy', brewery_path(@brewery.page.title_for_url), :confirm => 'Are you sure?', :method => :delete %><br />
|
<%= link_to 'Destroy', brewery_path(@brewery), :confirm => 'Are you sure?', :method => :delete %><br />
|
||||||
<% unless @brewery.tagged_images.empty? -%><%= tagged_image_browser_link -%><br /><% end -%>
|
<% unless @brewery.tagged_images.empty? -%><%= tagged_image_browser_link -%><br /><% end -%>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
|
@ -2,7 +2,7 @@ xml.instruct! :xml, :version=>"1.0"
|
||||||
xml.rss(:version=>"2.0"){
|
xml.rss(:version=>"2.0"){
|
||||||
xml.channel{
|
xml.channel{
|
||||||
xml.title("#{@people.title}'s Newest Beers")
|
xml.title("#{@people.title}'s Newest Beers")
|
||||||
xml.link(experience_url(@people.page.title_for_url))
|
xml.link(experience_url(@people))
|
||||||
xml.description("Most recently added beers.")
|
xml.description("Most recently added beers.")
|
||||||
xml.language('en-us')
|
xml.language('en-us')
|
||||||
xml.lastBuildDate((@experiences.first.created_at.strftime("%a, %d %b %Y %H:%M:%S %z") rescue nil))
|
xml.lastBuildDate((@experiences.first.created_at.strftime("%a, %d %b %Y %H:%M:%S %z") rescue nil))
|
||||||
|
@ -12,8 +12,8 @@ xml.rss(:version=>"2.0"){
|
||||||
xml.description(experience.beer.brewery.title)
|
xml.description(experience.beer.brewery.title)
|
||||||
xml.author(experience.beer.page.created_by.title)
|
xml.author(experience.beer.page.created_by.title)
|
||||||
xml.pubDate(experience.created_at.strftime("%a, %d %b %Y %H:%M:%S %z"))
|
xml.pubDate(experience.created_at.strftime("%a, %d %b %Y %H:%M:%S %z"))
|
||||||
xml.link(beer_url(experience.beer.page.title_for_url))
|
xml.link(brewery_beer_url(experience.beer.brewery, experience.beer))
|
||||||
xml.guid(beer_url(experience.beer.page.title_for_url))
|
xml.guid(brewery_beer_url(experience.beer.brewery, experience.beer))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<% for friend in @friends do -%>
|
<% for friend in @friends do -%>
|
||||||
<div class="friend_box"><%= link_to friend.title, people_path(friend.page.title_for_url) -%></div>
|
<div class="friend_box"><%= link_to friend.title, people_path(friend) -%></div>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
<% content_for :sidebar do -%>
|
<% content_for :sidebar do -%>
|
||||||
|
|
|
@ -35,15 +35,15 @@
|
||||||
</div>
|
</div>
|
||||||
<% unless @hide_sidebar -%>
|
<% unless @hide_sidebar -%>
|
||||||
<div id="sidebar">
|
<div id="sidebar">
|
||||||
<%= link_to_unless_current 'Browse The Beer Wiki', pages_path -%><br />
|
<%= link_to_unless_current 'Beer Wiki', pages_path -%><br />
|
||||||
<%= link_to_unless_current 'Browse Beers', beers_path -%><br />
|
<%= link_to_unless_current 'Beers', :controller => :beers, :action => :index, :brewery_id => nil -%><br />
|
||||||
<% if logged_in? -%><%= link_to_unless_current 'My Beer Experiences', experience_path(:id => session[:people_title_for_url]) -%><br /><% end %>
|
<% if logged_in? -%><%= link_to_unless_current 'My Beers', experience_path(:id => session[:people_title_for_url]) -%><br /><% end %>
|
||||||
<%= link_to_unless_current 'Beverage Styles', styles_path -%><br />
|
<%= link_to_unless_current 'Styles', styles_path -%><br />
|
||||||
<%= link_to_unless_current 'Browse Breweries', breweries_path -%><br />
|
<%= link_to_unless_current 'Breweries', breweries_path -%><br />
|
||||||
<%= link_to_unless_current 'BarleySodas People', peoples_path -%><br />
|
<%= link_to_unless_current 'Peoples', peoples_path -%><br />
|
||||||
<%= link_to_unless_current 'Gallery', galleries_path -%><br />
|
<%= link_to_unless_current 'Gallery', galleries_path -%><br />
|
||||||
<% if has_permission_for_action?(:index, :roles) -%><%= link_to_unless_current 'Roles', roles_path -%><br /><% end -%>
|
<% if has_permission_for_action?(:index, :roles) -%><%= link_to_unless_current 'Roles', roles_path -%><br /><% end -%>
|
||||||
<% unless logged_in? -%><%= link_to_unless_current 'Login', new_session_path -%><% else -%><%= link_to 'My Page', people_path(session[:people_title_for_url]) -%><br /><%= link_to "Logout #{session[:people_title]}", session_path(:id => session[:people_title]), :method => :delete -%><% end %>
|
<% unless logged_in? -%><%= link_to_unless_current 'Login', new_session_path -%><% else -%><%= link_to 'My Page', people_path(session[:people_title_for_url]) -%><br /><%= link_to 'Logout', session_path(:id => session[:people_title]), :method => :delete -%><% end %>
|
||||||
<hr />
|
<hr />
|
||||||
<%= yield :sidebar %>
|
<%= yield :sidebar %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -22,6 +22,6 @@
|
||||||
|
|
||||||
<% content_for 'sidebar' do -%>
|
<% content_for 'sidebar' do -%>
|
||||||
<% if @page.allow_discussions? or !@page.discussions.empty? -%>
|
<% if @page.allow_discussions? or !@page.discussions.empty? -%>
|
||||||
<%= link_to "Discuss", discussion_path(@page) -%> (<%= @page.discussions.size -%>)<br />
|
<%= link_to "Discuss", discussion_path(@page.id) -%> (<%= @page.discussions.size -%>)<br />
|
||||||
<% end -%>
|
<% end -%>
|
||||||
<% end -%>
|
<% end -%>
|
|
@ -12,8 +12,8 @@ xml.rss(:version=>"2.0"){
|
||||||
xml.description(page.title)
|
xml.description(page.title)
|
||||||
xml.author(page.created_by.title)
|
xml.author(page.created_by.title)
|
||||||
xml.pubDate(page.created_at.strftime("%a, %d %b %Y %H:%M:%S %z"))
|
xml.pubDate(page.created_at.strftime("%a, %d %b %Y %H:%M:%S %z"))
|
||||||
xml.link(page_url(page.title_for_url))
|
xml.link(page_url(page))
|
||||||
xml.guid(page_url(page.title_for_url))
|
xml.guid(page_url(page))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
<%= error_messages_for :page %>
|
<%= error_messages_for :page %>
|
||||||
|
|
||||||
<% form_for(:page, :url => page_path({ :id => @page.title_for_url }), :html => { :method => :put }) do |f| %>
|
<% form_for(:page, :url => page_path(@page), :html => { :method => :put }) do |f| %>
|
||||||
<%= render :partial => 'page_form' %>
|
<%= render :partial => 'page_form' %>
|
||||||
<p>
|
<p>
|
||||||
<%= submit_tag "Update" %>
|
<%= submit_tag "Update" %>
|
||||||
|
|
|
@ -11,8 +11,8 @@ xml.rss(:version=>"2.0"){
|
||||||
xml.title(people.title)
|
xml.title(people.title)
|
||||||
xml.description(people.title)
|
xml.description(people.title)
|
||||||
xml.pubDate(people.created_at.strftime("%a, %d %b %Y %H:%M:%S %z"))
|
xml.pubDate(people.created_at.strftime("%a, %d %b %Y %H:%M:%S %z"))
|
||||||
xml.link(people_url(people.page.title_for_url))
|
xml.link(people_url(people))
|
||||||
xml.guid(people_url(people.page.title_for_url))
|
xml.guid(people_url(people))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<%= error_messages_for :people %>
|
<%= error_messages_for :people %>
|
||||||
|
|
||||||
<% form_for(:people, :url => people_path(@people.page.title_for_url), :html => { :method => :put }) do |f| %>
|
<% form_for(:people, :url => people_path(@people), :html => { :method => :put }) do |f| %>
|
||||||
<%= render :partial => 'people_form' %>
|
<%= render :partial => 'people_form' %>
|
||||||
<p>
|
<p>
|
||||||
<%= submit_tag "Update" %>
|
<%= submit_tag "Update" %>
|
||||||
|
|
|
@ -15,12 +15,12 @@
|
||||||
<% content_for :sidebar do -%>
|
<% content_for :sidebar do -%>
|
||||||
<%= new_people_link -%><br />
|
<%= new_people_link -%><br />
|
||||||
<%= edit_people_link(@people) %><br />
|
<%= edit_people_link(@people) %><br />
|
||||||
<%= link_to 'Destroy', people_path(@people.page.title_for_url), :confirm => 'Are you sure?', :method => :delete %><br />
|
<%= link_to 'Destroy', people_path(@people), :confirm => 'Are you sure?', :method => :delete %><br />
|
||||||
<% unless @people.tagged_images.empty? -%><%= tagged_image_browser_link -%><br /><% end -%>
|
<% unless @people.tagged_images.empty? -%><%= tagged_image_browser_link -%><br /><% end -%>
|
||||||
<%= show_friends_link(@people) -%><br />
|
<%= show_friends_link(@people) -%><br />
|
||||||
<% unless @people.id == session[:people_id] or @people.friend_of?(session[:people_id]) -%><%= add_friend_link(@people) -%><br /><% end -%>
|
<% unless @people.id == session[:people_id] or @people.friend_of?(session[:people_id]) -%><%= add_friend_link(@people) -%><br /><% end -%>
|
||||||
<% if @people.friend_of?(session[:people_id]) -%><%= remove_friend_link(@people) -%><br /><% end -%>
|
<% if @people.friend_of?(session[:people_id]) -%><%= remove_friend_link(@people) -%><br /><% end -%>
|
||||||
<%= link_to "#{pluralize(@people.beers.size, 'Beer')} Experience", experience_path(:id => @people.page.title_for_url) -%><br />
|
<%= link_to "#{pluralize(@people.beers.size, 'Beer')} Experience", experience_path(@people) -%><br />
|
||||||
<% if @people.beers.size == Beer.count -%><em><%= @people.title -%> is a god among men, having tried every beer.</em><br /><% end -%>
|
<% if @people.beers.size == Beer.count -%><em><%= @people.title -%> is a god among men, having tried every beer.</em><br /><% end -%>
|
||||||
<span id="person_invitations"><%= render :partial => 'invitations/invitations' -%></span><br />
|
<span id="person_invitations"><%= render :partial => 'invitations/invitations' -%></span><br />
|
||||||
<% if has_permission_for_action?(:create, :invitations) -%><%= link_to_remote "#{image_tag('list-add.png')} Invitation", :update => 'person_invitations', :url => invitations_path, :with => "'people_id=#{@people.id}'", :success => "new Effect.Highlight('person_invitations', { duration: 2.0 })" -%><br /><% end -%>
|
<% if has_permission_for_action?(:create, :invitations) -%><%= link_to_remote "#{image_tag('list-add.png')} Invitation", :update => 'person_invitations', :url => invitations_path, :with => "'people_id=#{@people.id}'", :success => "new Effect.Highlight('person_invitations', { duration: 2.0 })" -%><br /><% end -%>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<%= error_messages_for :style %>
|
<%= error_messages_for :style %>
|
||||||
|
|
||||||
<% form_for(:style, :url => style_path(@style.page.title_for_url), :html => { :method => :put }) do |f| %>
|
<% form_for(:style, :url => style_path(@style), :html => { :method => :put }) do |f| %>
|
||||||
<%= render :partial => 'style_form' %>
|
<%= render :partial => 'style_form' %>
|
||||||
<p>
|
<p>
|
||||||
<%= submit_tag "Update" %>
|
<%= submit_tag "Update" %>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<% if @styles.empty? -%>
|
<% if @styles.empty? -%>
|
||||||
<ul><li>No styles found.</li></ul>
|
<ul><li>No styles found.</li></ul>
|
||||||
<% else -%>
|
<% else -%>
|
||||||
<ol><%= @styles.collect { |s| '<li>' + link_to(s.title, style_path(:id => s.page.title_for_url)) + '</li>' } %></ol>
|
<ol><%= @styles.collect { |s| '<li>' + link_to(s.title, style_path(s)) + '</li>' } %></ol>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
<% content_for :sidebar do -%>
|
<% content_for :sidebar do -%>
|
||||||
|
|
|
@ -8,5 +8,5 @@
|
||||||
<% content_for :sidebar do -%>
|
<% content_for :sidebar do -%>
|
||||||
<%= new_style_link -%><br />
|
<%= new_style_link -%><br />
|
||||||
<%= edit_style_link(@style) -%><br />
|
<%= edit_style_link(@style) -%><br />
|
||||||
<%= link_to 'Destroy', style_path(@style.page.title_for_url), :confirm => 'Are you sure?', :method => :delete -%><br />
|
<%= link_to 'Destroy', style_path(@style), :confirm => 'Are you sure?', :method => :delete -%><br />
|
||||||
<% end -%>
|
<% end -%>
|
|
@ -1,4 +1,3 @@
|
||||||
RAILS_GEM_VERSION = '1.2.3' unless defined? RAILS_GEM_VERSION
|
|
||||||
require File.join(File.dirname(__FILE__), 'boot')
|
require File.join(File.dirname(__FILE__), 'boot')
|
||||||
|
|
||||||
Rails::Initializer.run do |config|
|
Rails::Initializer.run do |config|
|
||||||
|
|
|
@ -8,9 +8,6 @@ config.cache_classes = false
|
||||||
# Log error messages when you accidentally call methods on nil.
|
# Log error messages when you accidentally call methods on nil.
|
||||||
config.whiny_nils = true
|
config.whiny_nils = true
|
||||||
|
|
||||||
# Enable the breakpoint server that script/breakpointer connects to
|
|
||||||
config.breakpoint_server = true
|
|
||||||
|
|
||||||
# Show full error reports and disable caching
|
# Show full error reports and disable caching
|
||||||
config.action_controller.consider_all_requests_local = true
|
config.action_controller.consider_all_requests_local = true
|
||||||
config.action_controller.perform_caching = false
|
config.action_controller.perform_caching = false
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
ActionController::Routing::Routes.draw do |map|
|
ActionController::Routing::Routes.draw do |map|
|
||||||
map.resources :beers, :breweries, :pages, :discussions, :peoples, :roles,
|
map.connect '', :controller => 'pages', :action => 'default_action'
|
||||||
:sessions, :styles, :galleries, :tag_images, :friends, :experiences,
|
map.resources :pages, :roles, :sessions, :styles, :galleries, :tag_images,
|
||||||
:invitations
|
:friends, :experiences, :invitations, :peoples, :discussions
|
||||||
|
map.resources :breweries do |breweries|
|
||||||
|
breweries.resources :beers
|
||||||
|
end
|
||||||
map.connect ':controller/:action/:id.:format'
|
map.connect ':controller/:action/:id.:format'
|
||||||
map.connect ':controller/:action/:id'
|
map.connect ':controller/:action/:id'
|
||||||
map.connect '/', :controller => 'pages', :action => 'default_action'
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
module WordyParameter
|
||||||
|
def to_param
|
||||||
|
if self.respond_to?("page")
|
||||||
|
title = page.title
|
||||||
|
else
|
||||||
|
title = self.title
|
||||||
|
end
|
||||||
|
title.gsub(/ /, '_')
|
||||||
|
end
|
||||||
|
end
|
Reference in New Issue