making models styled using scribbish

git-svn-id: http://svn.barleysodas.com/barleysodas/trunk@29 0f7b21a7-9e3a-4941-bbeb-ce5c7c368fa7
master
andrew 2007-11-16 00:57:44 +00:00
parent 34fb69e444
commit 4670fc1a8a
21 changed files with 95 additions and 94 deletions

View File

@ -5,6 +5,8 @@ class BeersController < ApplicationController
# GET /beers # GET /beers
# GET /beers.xml # GET /beers.xml
def index def index
@content_title = 'The Beers'
@secondary_title = 'Browsing all beers'
@pages, @beers = paginate :beers, :include => 'page', :per_page => 50, @pages, @beers = paginate :beers, :include => 'page', :per_page => 50,
:order => 'beers.title ASC' :order => 'beers.title ASC'
respond_to do |format| respond_to do |format|
@ -24,12 +26,14 @@ class BeersController < ApplicationController
# GET /beers/new # GET /beers/new
def new def new
@secondary_title = 'Create a new beer'
@beer = Beer.new @beer = Beer.new
@page = Page.new @page = Page.new
end end
# GET /beers/1;edit # GET /beers/1;edit
def edit def edit
@secondary_title = 'Update existing beer'
end end
# POST /beers # POST /beers

View File

@ -5,6 +5,8 @@ class BreweriesController < ApplicationController
# GET /breweries # GET /breweries
# GET /breweries.xml # GET /breweries.xml
def index def index
@content_title = 'The Breweries'
@secondary_title = 'Browsing all breweries'
@pages, @breweries = paginate :breweries, :include => 'page', @pages, @breweries = paginate :breweries, :include => 'page',
:order => 'breweries.title ASC', :per_page => 50 :order => 'breweries.title ASC', :per_page => 50
respond_to do |format| respond_to do |format|

View File

@ -3,16 +3,15 @@ module ApplicationHelper
# Returns the title for a page. This could be a Page title or something else. # Returns the title for a page. This could be a Page title or something else.
# #
def page_title def page_title
"BarleySodas :: #{controller.class.to_s.gsub(/Controller/, '')}" "BarleySodas :: #{content_title} :: #{secondary_title}"
end end
## ##
# Returns a pretty name for the current chunk. # Returns a pretty name for the current chunk.
# #
def content_title def content_title
return @page_title if @page_title return @content_title if @content_title
return @page.title if @page controller.class.to_s.gsub(/Controller/, '')
"BarleySodas"
end end
## ##
@ -21,7 +20,7 @@ module ApplicationHelper
# #
def secondary_title def secondary_title
return @secondary_title if @secondary_title return @secondary_title if @secondary_title
return params[:action].to_s.capitalize.gsub(/_/) do |x| params[:action].to_s.capitalize.gsub(/_/) do |x|
$1.capitalize $1.capitalize
end end
end end

View File

@ -1,8 +1,4 @@
module BeersHelper module BeersHelper
def new_beer_link
link_to "Beer Me!", new_beer_path, { :title => 'Create a new beer' }
end
def abv(beer) def abv(beer)
number_to_percentage(beer.abv, { :precision => 1 }) number_to_percentage(beer.abv, { :precision => 1 })
end end

View File

@ -10,6 +10,4 @@
<p> <p>
<label for="beer_final_gravity">Final Gravity</label> <%= text_field 'beer', 'final_gravity' %> <label for="beer_final_gravity">Final Gravity</label> <%= text_field 'beer', 'final_gravity' %>
</p> </p>
<p> <%= render :partial => 'pages/page_form' %>
<label for="page_redcloth">Description</label> <%= text_area 'page', 'redcloth' %>
</p>

View File

@ -1,5 +1,3 @@
<h1>Editing beer</h1>
<%= 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 => beer_path(@beer.page.title_for_url), :html => { :method => :put }) do |f| %>
@ -9,7 +7,7 @@
</p> </p>
<% end -%> <% end -%>
<div id="related_links"> <% content_for :sidebar do -%>
<%= link_to 'Show', beer_path(@beer.page.title_for_url) %> | <%= link_to 'New Beer', new_beer_path -%><br />
<%= link_to 'Beers', beers_path %> <%= link_to 'Show', beer_path(@beer.page.title_for_url) -%><br />
</div> <% end -%>

View File

@ -1,5 +1,3 @@
<h1>The Beers</h1>
<% unless @beers.empty? -%> <% unless @beers.empty? -%>
<table> <table>
<tr> <tr>
@ -16,10 +14,10 @@
</tr> </tr>
<% end %> <% end %>
</table> </table>
<% else -%>
<p>No beers, yet</p>
<% end -%> <% end -%>
<br /> <% content_for :sidebar do -%>
<%= link_to "New Beer", new_beer_path, { :title => 'Create a new beer' } -%><br />
<div id="related_links"> <% end -%>
<%= new_beer_link %>
</div>

View File

@ -1,5 +1,3 @@
<h1>Create a new beer</h1>
<%= error_messages_for :beer %> <%= error_messages_for :beer %>
<% form_for(:beer, :url => beers_path, :html => { :method => :post }) do |f| %> <% form_for(:beer, :url => beers_path, :html => { :method => :post }) do |f| %>
@ -8,7 +6,3 @@
<%= submit_tag "Create" %> <%= submit_tag "Create" %>
</p> </p>
<% end -%> <% end -%>
<div id="related_links">
<%= link_to 'Beers', beers_path %>
</div>

View File

@ -1,4 +1,4 @@
<h1><%= @beer.title -%></h1> <%= render :partial => 'pages/page' %>
<% <%
attributes = [] attributes = []
@ -13,9 +13,7 @@
</div> </div>
<% end -%> <% end -%>
<%= @page.html %> <% content_for :sidebar do -%>
<%= link_to 'New Beer', new_beer_path -%><br />
<div id="related_links"> <%= link_to 'Edit Beer', edit_beer_path(@beer.page.title_for_url) -%><br />
<%= link_to 'Edit', edit_beer_path(@beer) %> | <% end -%>
<%= link_to 'Beers', beers_path %>
</div>

View File

@ -16,6 +16,4 @@
<p> <p>
<label for="brewery_county">Country</label> <%= country_select 'brewery', 'country', [ 'United States', 'United Kingdom', 'Germany' ] %> <label for="brewery_county">Country</label> <%= country_select 'brewery', 'country', [ 'United States', 'United Kingdom', 'Germany' ] %>
</p> </p>
<p> <%= render :partial => 'pages/page_form' %>
<label for="page_redcloth">Description</label> <%= text_area 'page', 'redcloth' %>
</p>

View File

@ -1,5 +1,3 @@
<h1>Editing brewery</h1>
<%= 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.page.title_for_url), :html => { :method => :put }) do |f| %>
@ -9,7 +7,7 @@
</p> </p>
<% end %> <% end %>
<div id="related_links"> <% content_for :sidebar do -%>
<%= link_to 'Show', brewery_path(@brewery.page.title_for_url) %> | <%= link_to 'New Brewery', new_brewery_path -%><br />
<%= link_to 'Breweries', breweries_path %> <%= link_to 'Show', brewery_path(@brewery.page.title_for_url) -%><br />
</div> <% end -%>

View File

@ -1,5 +1,4 @@
<h1>Breweries</h1> <% unless @breweries.empty? -%>
<table> <table>
<tr> <tr>
<th>Title</th> <th>Title</th>
@ -16,9 +15,10 @@
</tr> </tr>
<% end %> <% end %>
</table> </table>
<% else -%>
<p>No breweries, yet.</p>
<% end -%>
<br /> <% content_for :sidebar do -%>
<%= link_to 'New brewery', new_brewery_path -%><br />
<div id="related_links"> <% end -%>
<%= link_to 'New brewery', new_brewery_path %>
</div>

View File

@ -1,5 +1,3 @@
<h1>New brewery</h1>
<%= error_messages_for :brewery %> <%= error_messages_for :brewery %>
<% form_for(:brewery, :url => breweries_path, :html => { :method => :post }) do |f| %> <% form_for(:brewery, :url => breweries_path, :html => { :method => :post }) do |f| %>
@ -8,7 +6,3 @@
<%= submit_tag "Create" %> <%= submit_tag "Create" %>
</p> </p>
<% end %> <% end %>
<div id="related_links">
<%= link_to 'Breweries', breweries_path %>
</div>

View File

@ -1,4 +1,4 @@
<h1><%= @brewery.title -%></h1> <%= render :partial => 'pages/page' %>
<div id="attributes"> <div id="attributes">
<ul> <ul>
@ -6,9 +6,7 @@
</ul> </ul>
</div> </div>
<%= @page.html %> <% content_for :sidebar do -%>
<%= link_to 'New Brewery', new_brewery_path -%><br />
<div id="related_links"> <%= link_to 'Edit', edit_brewery_path(@brewery.page.title_for_url) -%><br />
<%= link_to 'Edit', edit_brewery_path(@brewery.page.title_for_url) %> | <% end -%>
<%= link_to 'Breweries', breweries_path %>
</div>

View File

@ -28,7 +28,11 @@
<%= yield %> <%= yield %>
</div> </div>
<div id="sidebar"> <div id="sidebar">
<p>todo</p> <%= link_to_unless_current 'Browse The Beer Wiki', pages_path -%><br />
<%= link_to_unless_current 'Browse Beers', beers_path -%><br />
<%= link_to_unless_current 'Browse Breweries', breweries_path -%><br />
<hr />
<%= yield :sidebar %>
</div> </div>
<br style="clear:both;" /> <br style="clear:both;" />
</div> </div>

View File

@ -1,9 +1,19 @@
<div id="page_container"> <div class="hentry" id="article-<%= @page.id %>">
<h1><%= link_to_page(@page) -%></h1> <h2 class="entry-title">
<div class="page_container_content"> <%= @page.title %>
<span class="comment_count">Comment Size Here</span>
</h2>
<div class="vcard">
Posted by <span class="fn">Author Name Here</span>
</div>
<br class="clear" />
<div class="entry-content">
<%= @page.html %> <%= @page.html %>
</div> </div>
<div class="page_container_controls"> <ul class="meta">
Current Version: <%= @page.version %> <li>Add Tags here</li>
</div> <li>Meta
Version: <%= @page.version -%> / <%= @page.versions.size %>
</li>
</ul>
</div> </div>

View File

@ -0,0 +1,3 @@
<p>
<label for="page_redcloth">Description</label> <%= text_area 'page', 'redcloth' %>
</p>

View File

@ -3,16 +3,13 @@
<%= 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({ :id => @page.title_for_url }), :html => { :method => :put }) do |f| %>
<p> <%= render :partial => 'page_form' %>
<label for="page_title">Title</label> <%= text_field 'page', 'title' %>
</p>
<p>
<label for="page_redcloth">Description</label> <%= text_area 'page', 'redcloth' %>
</p>
<p> <p>
<%= submit_tag "Update" %> <%= submit_tag "Update" %>
</p> </p>
<% end %> <% end %>
<%= link_to 'Show', page_path({ :id => @page.title_for_url }) %> | <% content_for :sidebar do -%>
<%= link_to 'Back', pages_path %> <%= link_to 'Show', page_path({ :id => @page.title_for_url }) %><br />
<%= link_to 'Browse Pages', pages_path %><br />
<% end -%>

View File

@ -1 +1,5 @@
<%= render :partial => 'page' -%> <%= render :partial => 'page' -%>
<% content_for :sidebar do -%>
<%= link_to 'New Page', new_page_path -%><br />
<% end -%>

View File

@ -3,9 +3,15 @@
<%= error_messages_for :page %> <%= error_messages_for :page %>
<% form_for(:page, :url => pages_path) do |f| %> <% form_for(:page, :url => pages_path) do |f| %>
<p>
<label for="page_title">Title</label> <%= text_field 'page', 'title' %>
</p>
<%= render :partial => 'page_form' %>
<p> <p>
<%= submit_tag "Create" %> <%= submit_tag "Create" %>
</p> </p>
<% end %> <% end %>
<%= link_to 'Back', pages_path %> <% content_for :sidebar do -%>
<%= link_to 'Browse Pages', pages_path %><br />
<% end -%>

View File

@ -1,4 +1,6 @@
<%= render :partial => 'page' %> <%= render :partial => 'page' %>
<%= link_to 'Edit', edit_page_path({ :id => @page.title_for_url }) %> | <% content_for :sidebar do -%>
<%= link_to 'Back', pages_path %> <%= link_to 'Edit Page', edit_page_path({ :id => @page.title_for_url }) %><br />
<%= link_to 'Browse Pages', pages_path %><br />
<% end -%>