1. 10 12月, 2013 2 次提交
    • Ł
      Inline variants syntax · edacdbfa
      Łukasz Strzałkowski 提交于
      In most cases, when setting variant specific code, you're not sharing any code
      within format.
      
      Inline syntax can vastly simplify defining variants in those situations:
      
        respond_to do |format|
          format.js { render "trash" }
          format.html do |variant|
            variant.phone { redirect_to progress_path }
            variant.none  { render "trash" }
          end
        end
      
      Becomes:
      
        respond_to do |format|
          format.js         { render "trash" }
          format.html.phone { redirect_to progress_path }
          format.html.none  { render "trash" }
        end
      edacdbfa
    • Ł
      Simplify @responses hash initialization · fbb6be50
      Łukasz Strzałkowski 提交于
      @responses hash needs to be initialized with mime types that we get from
      Collector#collect_mimes_from_class_level. Mime::Type class as key and nil as
      value. This need to happen before content negotiation. Before that, it was
      looping though mime types and executing mime-type-generated method inside
      collector (see
      AbstractController::Collector#generate_method_for_mime). That approach resulted
      in 2 unnecessary method calls for each mime type
      collected by Collector#collect_mimes_from_class_level.
      
      Now hash is initialized in place, without usage of Collector#custom method.
      fbb6be50
  2. 09 12月, 2013 3 次提交
    • D
      Revert "Merge pull request #13235 from strzalek/variants-inline" -- needs a little more work! · 4aae538d
      David Heinemeier Hansson 提交于
      This reverts commit 18616114, reversing
      changes made to cad9eb17.
      4aae538d
    • Ł
      Inline variants syntax · 2647d2f6
      Łukasz Strzałkowski 提交于
      In most cases, when setting variant specific code, you're not sharing any code
      within format.
      
      Inline syntax can vastly simplify defining variants in those sitiations:
      
        respond_to do |format|
          format.js { render "trash" }
          format.html do |variant|
            variant.phone { redirect_to progress_path }
            variant.none  { render "trash" }
          end
        end
      `
      Becomes:
      
        respond_to do |format|
          format.js         { render "trash" }
          format.html.phone { redirect_to progress_path }
          format.html.none  { render "trash" }
        end
      2647d2f6
    • Ł
      Simplify @responses hash initialization · 9b8c0ff3
      Łukasz Strzałkowski 提交于
      @responses hash needs to be initialized with mime types that we get from
      Collector#collect_mimes_from_class_level. Mime::Type class as key and nil as
      value. This need to happen before content negotiation. Before that, it was
      looping though mime types and executing mime-type-generated method inside
      collector (see
      AbstractController::Collector#generate_method_for_mime). That approach resulted
      in 2 unnecessary method calls for each mime type
      collected by Collector#collect_mimes_from_class_level.
      
      Now hash is initialized in place, without usage of Collector#custom method.
      9b8c0ff3
  3. 08 12月, 2013 2 次提交
  4. 04 12月, 2013 3 次提交
    • C
      Improve a couple exception messages related to variants and mime types · 3b40a5d8
      Carlos Antonio da Silva 提交于
      Avoid one-liner conditionals when they are too big. Avoid concatenating
      strings to build error messages. Improve messages a bit.
      3b40a5d8
    • C
      Add nodoc to added VariantFilter class · bc26f442
      Carlos Antonio da Silva 提交于
      bc26f442
    • Ł
      Action Pack Variants · 2d3a6a0c
      Łukasz Strzałkowski 提交于
      By default, variants in the templates will be picked up if a variant is set
      and there's a match. The format will be:
      
        app/views/projects/show.html.erb
        app/views/projects/show.html+tablet.erb
        app/views/projects/show.html+phone.erb
      
      If request.variant = :tablet is set, we'll automatically be rendering the
      html+tablet template.
      
      In the controller, we can also tailer to the variants with this syntax:
      
        class ProjectsController < ActionController::Base
          def show
            respond_to do |format|
              format.html do |html|
                @stars = @project.stars
      
                html.tablet { @notifications = @project.notifications }
                html.phone  { @chat_heads    = @project.chat_heads }
              end
      
              format.js
              format.atom
            end
          end
        end
      
      The variant itself is nil by default, but can be set in before filters, like
      so:
      
        class ApplicationController < ActionController::Base
          before_action do
            if request.user_agent =~ /iPad/
              request.variant = :tablet
            end
          end
        end
      
      This is modeled loosely on custom mime types, but it's specifically not
      intended to be used together. If you're going to make a custom mime type,
      you don't need a variant. Variants are for variations on a single mime
      types.
      2d3a6a0c
  5. 15 11月, 2013 2 次提交
  6. 11 11月, 2013 1 次提交
  7. 09 10月, 2013 1 次提交
  8. 09 9月, 2013 1 次提交
  9. 25 2月, 2013 1 次提交
  10. 01 2月, 2013 1 次提交
  11. 07 1月, 2013 1 次提交
  12. 03 1月, 2013 1 次提交
  13. 02 1月, 2013 1 次提交
  14. 02 12月, 2012 2 次提交
  15. 28 10月, 2012 1 次提交
  16. 27 10月, 2012 1 次提交
  17. 06 8月, 2012 1 次提交
  18. 03 8月, 2012 2 次提交
  19. 21 7月, 2012 1 次提交
  20. 19 7月, 2012 1 次提交
  21. 24 5月, 2012 1 次提交
    • V
      Revert "Remove blank trailing comments" · 1ad0b378
      Vijay Dev 提交于
      This reverts commit fa6d921e.
      
      Reason: Not a fan of such massive changes. We usually close such changes
      if made to Rails master as a pull request. Following the same principle
      here and reverting.
      
      [ci skip]
      1ad0b378
  22. 20 5月, 2012 1 次提交
    • H
      Remove blank trailing comments · fa6d921e
      Henrik Hodne 提交于
      For future reference, this is the regex I used: ^\s*#\s*\n(?!\s*#). Replace
      with the first match, and voilà! Note that the regex matches a little bit too
      much, so you probably want to `git add -i .` and go through every single diff
      to check if it actually should be changed.
      fa6d921e
  23. 15 5月, 2012 1 次提交
  24. 06 5月, 2012 2 次提交
  25. 03 4月, 2012 1 次提交
  26. 18 3月, 2012 3 次提交
  27. 13 3月, 2012 2 次提交