Changeset 953

Show
Ignore:
Timestamp:
11/11/07 20:04:48 (1 year ago)
Author:
jimfree..@gmail.com
Message:

Applied new code from afrench

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • apps/merki/trunk/app/controllers/application.rb

    r930 r953  
    11# all your other controllers should inherit from this one to share code. 
    22class Application < Merb::Controller 
     3  before :load_pages 
     4  def load_pages 
     5    @pages = Page.all(:order => "id DESC") 
     6  end 
    37end   
  • apps/merki/trunk/app/controllers/pages.rb

    r944 r953  
    66      redirect url(:page, @page) 
    77    else 
    8       "Uh oh!  Home Page not found." 
     8      redirect url(:new_page) 
    99    end 
    1010  end 
    1111   
    1212  def show(id) 
    13     @page = Page.find_by_slug(id) 
     13    @page = Page.find_by_slug(id) || Page[id] 
    1414    raise NotFound unless @page 
    1515    render @page 
     
    3737   
    3838  def update(id, page) 
    39     @page = Page[id] 
    40     raise BadRequest unless @page 
     39    @page = Page.find id 
     40    # puts @page 
     41    # raise BadRequest if @page.nil? 
    4142    if @page.update_attributes(page) 
    4243      redirect url(:page, @page) 
  • apps/merki/trunk/app/models/page.rb

    r952 r953  
    55   
    66  ## props 
    7   property :title, :string 
    8   property :body, :text 
    9   property :converted_body, :text 
     7  property :title, :string, :lazy => false 
     8  property :body, :text, :lazy => false 
     9  property :converted_body, :text, :lazy => false 
     10   
     11  # attribs 
     12  property :created_at, :datetime 
     13  property :updated_at, :datetime 
    1014   
    1115  ## relationships 
  • apps/merki/trunk/app/views/layout/application.html.erb

    r931 r953  
    22<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us" lang="en-us"> 
    33  <head> 
    4     <title>Fresh Merb App</title> 
     4    <title>Merki :: <%= catch_content(:page_title) -%></title> 
    55    <meta http-equiv="content-type" content="text/html; charset=utf-8" /> 
    6     <link rel="stylesheet" href="/stylesheets/master.css" type="text/css" media="screen" charset="utf-8"> 
     6    <link rel="stylesheet" href="/stylesheets/site.css" type="text/css" media="screen" charset="utf-8"> 
    77  </head> 
    88  <body> 
    9     <%= catch_content :layout %> 
     9     
     10    <div id="sidebar"> 
     11      <%= partial("layout/sidebar") -%> 
     12    </div> <!-- close: sidebar --> 
     13     
     14    <div id="content"> 
     15      <%= catch_content :layout %> 
     16    </div> <!-- close: content --> 
     17     
    1018  </body> 
    1119</html> 
  • apps/merki/trunk/app/views/pages/edit.html.erb

    r943 r953  
    1 Edit for Pages 
     1<h1 id="edit">Edit Page</h1> 
     2<% form_for @page, :action => url(:page, @page) do -%> 
     3<%= partial "form" -%> 
     4<div class="form-row"> 
     5  <label></label> 
     6  <%= submit_button "Edit" -%> 
     7</div> <!-- close:  --> 
     8<% end -%> 
  • apps/merki/trunk/app/views/pages/new.html.erb

    r943 r953  
    1 New for Pages 
     1<h1>Create Page</h1> 
     2 
     3<% form_for @page, :action => url(:pages) do -%> 
     4  <%= partial("form") -%> 
     5   
     6  <div class="form-row"> 
     7    <label></label> 
     8    <%= submit_button "Create" -%> 
     9  </div> <!-- close:  --> 
     10<% end -%> 
  • apps/merki/trunk/config/router.rb

    r942 r953  
    2525 
    2626  r.match('/').to(:controller => 'pages', :action =>'index') 
     27   
     28  r.default_routes 
    2729end 
  • apps/merki/trunk/spec/controllers/pages_spec.rb

    r943 r953  
    3131   
    3232  it "should display an error" do 
     33    pending "now forwards to NewPage" 
    3334    @controller.body.should match(/Home Page not found/) 
    3435  end