Changeset 87

Show
Ignore:
Timestamp:
04/16/08 22:13:27 (7 months ago)
Author:
jweiss
Message:

apply #76 - preview of recipe edit

Location:
trunk
Files:
1 added
7 modified

Legend:

Unmodified
Added
Removed
  • trunk/CHANGELOG.txt

    r85 r87  
    11 
    22* SVN * 
     3 
     4* Ajax-Preview on recipe edit. Provided by Mathias Meyer 
    35 
    46* Update Capistrano to 2.2.0 and Net::SFTP to 1.1.1 
  • trunk/app/controllers/recipes_controller.rb

    r60 r87  
    8080    end 
    8181  end 
     82   
     83  def preview 
     84    @recipe = Recipe.new(params[:recipe]) 
     85    respond_to do |format| 
     86      format.js {  
     87        render :update do |page| 
     88          page.replace_html :preview, :partial => "preview", :locals => {:recipe => @recipe} 
     89          page.show :preview_fieldset 
     90        end 
     91      } 
     92    end 
     93  end 
    8294end 
  • trunk/app/helpers/recipes_helper.rb

    r1 r87  
    11module RecipesHelper 
     2  def highlight_syntax(code) 
     3    Syntax::Convertors::HTML.for_syntax("ruby").convert(code) 
     4  end 
    25end 
  • trunk/app/views/recipes/_form.html.erb

    r73 r87  
    1414  <%= text_area 'recipe', 'body', :style =>'width:600px; height: 400px;' %> 
    1515</p> 
     16 
     17<%= observe_field "recipe_body", :frequency => 2.5, :with => "Form.Element.serialize('recipe_body')", :url => preview_recipes_url%> 
     18 
     19<fieldset class="fieldset" id="preview_fieldset" style="display:none"> 
     20  <legend>Code-Preview</legend> 
     21  <div id="preview" style="display"></div> 
     22</fieldset> 
     23<br/> 
  • trunk/app/views/recipes/show.html.erb

    r73 r87  
    4949<fieldset class="fieldset"> 
    5050  <legend>Body</legend> 
    51   <div class="log_output ruby"> 
    52     <%= Syntax::Convertors::HTML.for_syntax("ruby").convert(@recipe.body) %> 
    53   </div> 
     51  <%= render :partial => 'preview', :locals => {:recipe => @recipe} %> 
    5452</fieldset> 
  • trunk/config/routes.rb

    r77 r87  
    1919   
    2020  map.resources :hosts 
    21   map.resources :recipes 
     21  map.resources :recipes, :collection => {:preview => :get} 
    2222  map.resources :projects, :member => {:dashboard => :get} do |projects| 
    2323    projects.resources :project_configurations 
  • trunk/test/functional/recipes_controller_test.rb

    r44 r87  
    120120  end 
    121121   
     122  def test_should_preview_the_recipe 
     123    @user = admin_login 
     124     
     125    xhr :get, :preview, :recipe => {:body => @recipe.body} 
     126    assert_select_rjs :replace_html, "preview" 
     127  end 
     128   
    122129end