padrino-helpers 0.11.3 → 0.11.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.rdoc +1 -1
- data/lib/padrino-helpers.rb +3 -5
- data/lib/padrino-helpers/asset_tag_helpers.rb +32 -40
- data/lib/padrino-helpers/breadcrumb_helpers.rb +21 -39
- data/lib/padrino-helpers/form_builder/abstract_form_builder.rb +121 -118
- data/lib/padrino-helpers/form_builder/standard_form_builder.rb +6 -9
- data/lib/padrino-helpers/form_helpers.rb +190 -193
- data/lib/padrino-helpers/format_helpers.rb +29 -42
- data/lib/padrino-helpers/locale/cs.yml +14 -14
- data/lib/padrino-helpers/locale/da.yml +1 -1
- data/lib/padrino-helpers/locale/de.yml +1 -1
- data/lib/padrino-helpers/locale/en.yml +16 -16
- data/lib/padrino-helpers/locale/es.yml +16 -16
- data/lib/padrino-helpers/locale/fr.yml +1 -2
- data/lib/padrino-helpers/locale/hu.yml +16 -16
- data/lib/padrino-helpers/locale/it.yml +2 -2
- data/lib/padrino-helpers/locale/ja.yml +16 -16
- data/lib/padrino-helpers/locale/lv.yml +16 -16
- data/lib/padrino-helpers/locale/nl.yml +1 -1
- data/lib/padrino-helpers/locale/no.yml +1 -1
- data/lib/padrino-helpers/locale/pl.yml +7 -7
- data/lib/padrino-helpers/locale/pt_br.yml +16 -16
- data/lib/padrino-helpers/locale/ro.yml +16 -16
- data/lib/padrino-helpers/locale/ru.yml +16 -16
- data/lib/padrino-helpers/locale/sv.yml +16 -16
- data/lib/padrino-helpers/locale/tr.yml +16 -16
- data/lib/padrino-helpers/locale/uk.yml +16 -16
- data/lib/padrino-helpers/locale/zh_cn.yml +16 -16
- data/lib/padrino-helpers/locale/zh_tw.yml +16 -16
- data/lib/padrino-helpers/number_helpers.rb +10 -15
- data/lib/padrino-helpers/output_helpers.rb +49 -57
- data/lib/padrino-helpers/output_helpers/abstract_handler.rb +16 -18
- data/lib/padrino-helpers/output_helpers/erb_handler.rb +11 -12
- data/lib/padrino-helpers/output_helpers/haml_handler.rb +9 -9
- data/lib/padrino-helpers/output_helpers/slim_handler.rb +11 -13
- data/lib/padrino-helpers/render_helpers.rb +5 -6
- data/lib/padrino-helpers/tag_helpers.rb +18 -21
- data/lib/padrino-helpers/translation_helpers.rb +4 -6
- data/test/fixtures/markup_app/app.rb +7 -3
- data/test/fixtures/render_app/app.rb +1 -0
- data/test/test_asset_tag_helpers.rb +1 -1
- data/test/test_form_builder.rb +5 -6
- data/test/test_form_helpers.rb +24 -12
- data/test/test_format_helpers.rb +3 -3
- data/test/test_number_helpers.rb +4 -0
- data/test/test_output_helpers.rb +1 -1
- data/test/test_render_helpers.rb +1 -1
- data/test/test_tag_helpers.rb +1 -1
- metadata +9 -15
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: ef68c8d06903529b8d8f51c05b1290487a392463
         | 
| 4 | 
            +
              data.tar.gz: e7a25b76bffb3892afd7f4a4820e0507670c608a
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: 66cda324d865e815ec7bbdd1e93ac7dae958d5ec3db1e7b1f53a409f2aa825c76c58bcab9f632da80c2dce5f48d532a04aa77f9d7c632f72fea4d7955d5b1e19
         | 
| 7 | 
            +
              data.tar.gz: c01aaa4bdb41938c530acb00cc1784490a06b462f1ff315c53514f3915a959bc76214c4a5142213e1ebe01abd5407fc498782663ea811368db9c2a9fc0b61671
         | 
    
        data/README.rdoc
    CHANGED
    
    
    
        data/lib/padrino-helpers.rb
    CHANGED
    
    | @@ -8,8 +8,6 @@ require 'active_support/core_ext/object/with_options' # with_options | |
| 8 8 | 
             
            require 'active_support/inflector'                    # humanize
         | 
| 9 9 |  | 
| 10 10 | 
             
            FileSet.glob_require('padrino-helpers/**/*.rb', __FILE__)
         | 
| 11 | 
            -
             | 
| 12 | 
            -
            # Load our locales
         | 
| 13 11 | 
             
            I18n.load_path += Dir["#{File.dirname(__FILE__)}/padrino-helpers/locale/*.yml"]
         | 
| 14 12 |  | 
| 15 13 | 
             
            module Padrino
         | 
| @@ -33,7 +31,7 @@ module Padrino | |
| 33 31 | 
             
                  #   Padrino::Helpers::Breadcrumbs
         | 
| 34 32 | 
             
                  #
         | 
| 35 33 | 
             
                  # @param [Sinatra::Application] app
         | 
| 36 | 
            -
                  #   The specified  | 
| 34 | 
            +
                  #   The specified Padrino application.
         | 
| 37 35 | 
             
                  #
         | 
| 38 36 | 
             
                  # @example Register the helper module
         | 
| 39 37 | 
             
                  #   require 'padrino-helpers'
         | 
| @@ -55,5 +53,5 @@ module Padrino | |
| 55 53 | 
             
                  end
         | 
| 56 54 | 
             
                  alias :included :registered
         | 
| 57 55 | 
             
                end
         | 
| 58 | 
            -
              end | 
| 59 | 
            -
            end | 
| 56 | 
            +
              end
         | 
| 57 | 
            +
            end
         | 
| @@ -1,21 +1,21 @@ | |
| 1 1 | 
             
            module Padrino
         | 
| 2 2 | 
             
              module Helpers
         | 
| 3 3 | 
             
                ###
         | 
| 4 | 
            -
                # Helpers related to producing assets (images,stylesheets,js,etc) within templates.
         | 
| 4 | 
            +
                # Helpers related to producing assets (images, stylesheets, js, etc) within templates.
         | 
| 5 5 | 
             
                #
         | 
| 6 6 | 
             
                module AssetTagHelpers
         | 
| 7 7 | 
             
                  FRAGMENT_HASH = "#".html_safe.freeze
         | 
| 8 | 
            -
                  APPEND_ASSET_EXTENSIONS = ["js", "css"] | 
| 9 | 
            -
                  ABSOLUTE_URL_PATTERN = %r{^(https?://)} | 
| 8 | 
            +
                  APPEND_ASSET_EXTENSIONS = ["js", "css"]
         | 
| 9 | 
            +
                  ABSOLUTE_URL_PATTERN = %r{^(https?://)}
         | 
| 10 10 |  | 
| 11 11 | 
             
                  ##
         | 
| 12 | 
            -
                  # Creates a div to display the flash of given type if it exists
         | 
| 12 | 
            +
                  # Creates a div to display the flash of given type if it exists.
         | 
| 13 13 | 
             
                  #
         | 
| 14 14 | 
             
                  # @param [Symbol] kind
         | 
| 15 15 | 
             
                  #   The type of flash to display in the tag.
         | 
| 16 16 | 
             
                  # @param [Hash] options
         | 
| 17 17 | 
             
                  #   The html options for this section.
         | 
| 18 | 
            -
                  #   use :bootstrap => true to support Twitter's bootstrap dismiss alert button
         | 
| 18 | 
            +
                  #   use :bootstrap => true to support Twitter's bootstrap dismiss alert button.
         | 
| 19 19 | 
             
                  #
         | 
| 20 20 | 
             
                  # @return [String] Flash tag html with specified +options+.
         | 
| 21 21 | 
             
                  #
         | 
| @@ -26,7 +26,6 @@ module Padrino | |
| 26 26 | 
             
                  #   # Generates: <div class="error">flash-error</div>
         | 
| 27 27 | 
             
                  #   # <div class="success">flash-success</div>
         | 
| 28 28 | 
             
                  #
         | 
| 29 | 
            -
                  # @api public
         | 
| 30 29 | 
             
                  def flash_tag(*args)
         | 
| 31 30 | 
             
                    options = args.extract_options!
         | 
| 32 31 | 
             
                    bootstrap = options.delete(:bootstrap) if options[:bootstrap]
         | 
| @@ -39,7 +38,7 @@ module Padrino | |
| 39 38 | 
             
                  end
         | 
| 40 39 |  | 
| 41 40 | 
             
                  ##
         | 
| 42 | 
            -
                  # Creates a link element with given name, url and options
         | 
| 41 | 
            +
                  # Creates a link element with given name, url and options.
         | 
| 43 42 | 
             
                  #
         | 
| 44 43 | 
             
                  # @overload link_to(caption, url, options={})
         | 
| 45 44 | 
             
                  #   @param [String]  caption  The text caption.
         | 
| @@ -51,15 +50,15 @@ module Padrino | |
| 51 50 | 
             
                  #   @param [Proc]    block    The link content.
         | 
| 52 51 | 
             
                  #
         | 
| 53 52 | 
             
                  # @option options [String] :anchor
         | 
| 54 | 
            -
                  #   The anchor for the link (i.e #something)
         | 
| 53 | 
            +
                  #   The anchor for the link (i.e #something).
         | 
| 55 54 | 
             
                  # @option options [String] :fragment
         | 
| 56 | 
            -
                  #   Synonym for anchor
         | 
| 55 | 
            +
                  #   Synonym for anchor.
         | 
| 57 56 | 
             
                  # @option options [Boolean] :if
         | 
| 58 | 
            -
                  #   If true, the link will appear, otherwise not | 
| 57 | 
            +
                  #   If true, the link will appear, otherwise not.
         | 
| 59 58 | 
             
                  # @option options [Boolean] :unless
         | 
| 60 | 
            -
                  #   If false, the link will appear, otherwise not | 
| 59 | 
            +
                  #   If false, the link will appear, otherwise not.
         | 
| 61 60 | 
             
                  # @option options [Boolean] :remote
         | 
| 62 | 
            -
                  #   If true, this link should be handled by  | 
| 61 | 
            +
                  #   If true, this link should be handled by an ajax ujs handler.
         | 
| 63 62 | 
             
                  # @option options [String] :confirm
         | 
| 64 63 | 
             
                  #   Instructs ujs handler to alert confirm message.
         | 
| 65 64 | 
             
                  # @option options [Symbol] :method
         | 
| @@ -74,13 +73,12 @@ module Padrino | |
| 74 73 | 
             
                  #   link_to('click me', :class => 'blocky') do; end
         | 
| 75 74 | 
             
                  #
         | 
| 76 75 | 
             
                  # Note that you can pass :+if+ or :+unless+ conditions, but if you provide :current as
         | 
| 77 | 
            -
                  # condition padrino return true/false if the request.path_info match the given url
         | 
| 76 | 
            +
                  # condition padrino return true/false if the request.path_info match the given url.
         | 
| 78 77 | 
             
                  #
         | 
| 79 | 
            -
                  # @api public
         | 
| 80 78 | 
             
                  def link_to(*args, &block)
         | 
| 81 | 
            -
                    options | 
| 82 | 
            -
                    fragment | 
| 83 | 
            -
                    fragment | 
| 79 | 
            +
                    options  = args.extract_options!
         | 
| 80 | 
            +
                    fragment = options.delete(:anchor).to_s if options[:anchor]
         | 
| 81 | 
            +
                    fragment = options.delete(:fragment).to_s if options[:fragment]
         | 
| 84 82 |  | 
| 85 83 | 
             
                    url = ActiveSupport::SafeBuffer.new
         | 
| 86 84 | 
             
                    if block_given?
         | 
| @@ -121,11 +119,11 @@ module Padrino | |
| 121 119 | 
             
                  # @param[Hash] options
         | 
| 122 120 | 
             
                  #   The options for the feed tag.
         | 
| 123 121 | 
             
                  # @option options [String] :rel ("alternate")
         | 
| 124 | 
            -
                  #   Specify the relation of this link
         | 
| 122 | 
            +
                  #   Specify the relation of this link.
         | 
| 125 123 | 
             
                  # @option options [String] :type
         | 
| 126 | 
            -
                  #   Override the auto-generated mime type
         | 
| 124 | 
            +
                  #   Override the auto-generated mime type.
         | 
| 127 125 | 
             
                  # @option options [String] :title
         | 
| 128 | 
            -
                  #   Specify the title of the link, defaults to the type
         | 
| 126 | 
            +
                  #   Specify the title of the link, defaults to the type.
         | 
| 129 127 | 
             
                  #
         | 
| 130 128 | 
             
                  # @return [String] Feed link html tag with specified +options+.
         | 
| 131 129 | 
             
                  #
         | 
| @@ -135,7 +133,6 @@ module Padrino | |
| 135 133 | 
             
                  #   feed_tag :rss, url(:blog, :posts, :format => :rss)
         | 
| 136 134 | 
             
                  #   # Generates: <link type="application/rss+xml" rel="alternate" href="/blog/posts.rss" title="rss" />
         | 
| 137 135 | 
             
                  #
         | 
| 138 | 
            -
                  # @api public
         | 
| 139 136 | 
             
                  def feed_tag(mime, url, options={})
         | 
| 140 137 | 
             
                    full_mime = (mime == :atom) ? 'application/atom+xml' : 'application/rss+xml'
         | 
| 141 138 | 
             
                    tag(:link, options.reverse_merge(:rel => 'alternate', :type => full_mime, :title => mime, :href => url))
         | 
| @@ -163,7 +160,6 @@ module Padrino | |
| 163 160 | 
             
                  #   # Generates: <a href="mailto:me@demo.com">My Email</a>
         | 
| 164 161 | 
             
                  #   mail_to "me@demo.com", "My Email"
         | 
| 165 162 | 
             
                  #
         | 
| 166 | 
            -
                  # @api public
         | 
| 167 163 | 
             
                  def mail_to(email, caption=nil, mail_options={})
         | 
| 168 164 | 
             
                    html_options = mail_options.slice!(:cc, :bcc, :subject, :body)
         | 
| 169 165 | 
             
                    mail_query = Rack::Utils.build_query(mail_options).gsub(/\+/, '%20').gsub('%40', '@').gsub('&', '&')
         | 
| @@ -188,14 +184,13 @@ module Padrino | |
| 188 184 | 
             
                  #   # Generates: <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
         | 
| 189 185 | 
             
                  #   meta_tag "text/html; charset=UTF-8", 'http-equiv' => "Content-Type"
         | 
| 190 186 | 
             
                  #
         | 
| 191 | 
            -
                  # @api public
         | 
| 192 187 | 
             
                  def meta_tag(content, options={})
         | 
| 193 188 | 
             
                    options.reverse_merge!("content" => content)
         | 
| 194 189 | 
             
                    tag(:meta, options)
         | 
| 195 190 | 
             
                  end
         | 
| 196 191 |  | 
| 197 192 | 
             
                  ##
         | 
| 198 | 
            -
                  # Generates a favicon link.  | 
| 193 | 
            +
                  # Generates a favicon link. Looks inside images folder
         | 
| 199 194 | 
             
                  #
         | 
| 200 195 | 
             
                  # @param [String] source
         | 
| 201 196 | 
             
                  #   The source image path for the favicon link tag.
         | 
| @@ -210,7 +205,6 @@ module Padrino | |
| 210 205 | 
             
                  #   # or override some options
         | 
| 211 206 | 
             
                  #   favicon_tag 'favicon.png', :type => 'image/ico'
         | 
| 212 207 | 
             
                  #
         | 
| 213 | 
            -
                  # @api public
         | 
| 214 208 | 
             
                  def favicon_tag(source, options={})
         | 
| 215 209 | 
             
                    type = File.extname(source).gsub('.','')
         | 
| 216 210 | 
             
                    options = options.dup.reverse_merge!(:href => image_path(source), :rel => 'icon', :type => "image/#{type}")
         | 
| @@ -218,7 +212,7 @@ module Padrino | |
| 218 212 | 
             
                  end
         | 
| 219 213 |  | 
| 220 214 | 
             
                  ##
         | 
| 221 | 
            -
                  # Creates an image element with given url and options
         | 
| 215 | 
            +
                  # Creates an image element with given url and options.
         | 
| 222 216 | 
             
                  #
         | 
| 223 217 | 
             
                  # @param [String] url
         | 
| 224 218 | 
             
                  #   The source path for the image tag.
         | 
| @@ -230,7 +224,6 @@ module Padrino | |
| 230 224 | 
             
                  # @example
         | 
| 231 225 | 
             
                  #   image_tag('icons/avatar.png')
         | 
| 232 226 | 
             
                  #
         | 
| 233 | 
            -
                  # @api public
         | 
| 234 227 | 
             
                  def image_tag(url, options={})
         | 
| 235 228 | 
             
                    options.reverse_merge!(:src => image_path(url))
         | 
| 236 229 | 
             
                    tag(:img, options)
         | 
| @@ -250,7 +243,7 @@ module Padrino | |
| 250 243 | 
             
                  # @example
         | 
| 251 244 | 
             
                  #   stylesheet_link_tag 'style', 'application', 'layout'
         | 
| 252 245 | 
             
                  #
         | 
| 253 | 
            -
                  # @api public
         | 
| 246 | 
            +
                  # @api public.
         | 
| 254 247 | 
             
                  def stylesheet_link_tag(*sources)
         | 
| 255 248 | 
             
                    options = sources.extract_options!.symbolize_keys
         | 
| 256 249 | 
             
                    options.reverse_merge!(:media => 'screen', :rel => 'stylesheet', :type => 'text/css')
         | 
| @@ -273,7 +266,6 @@ module Padrino | |
| 273 266 | 
             
                  # @example
         | 
| 274 267 | 
             
                  #   javascript_include_tag 'application', :extjs
         | 
| 275 268 | 
             
                  #
         | 
| 276 | 
            -
                  # @api public
         | 
| 277 269 | 
             
                  def javascript_include_tag(*sources)
         | 
| 278 270 | 
             
                    options = sources.extract_options!.symbolize_keys
         | 
| 279 271 | 
             
                    options.reverse_merge!(:type => 'text/javascript')
         | 
| @@ -287,7 +279,7 @@ module Padrino | |
| 287 279 | 
             
                  # like app/public/images for inclusion. You can provide also a full path.
         | 
| 288 280 | 
             
                  #
         | 
| 289 281 | 
             
                  # @param [String] src
         | 
| 290 | 
            -
                  #   The path to the image file (relative or absolute)
         | 
| 282 | 
            +
                  #   The path to the image file (relative or absolute).
         | 
| 291 283 | 
             
                  #
         | 
| 292 284 | 
             
                  # @return [String] Path to an image given the +kind+ and +source+.
         | 
| 293 285 | 
             
                  #
         | 
| @@ -301,10 +293,10 @@ module Padrino | |
| 301 293 | 
             
                  end
         | 
| 302 294 |  | 
| 303 295 | 
             
                  ##
         | 
| 304 | 
            -
                  # Returns the path to the specified asset (css or javascript)
         | 
| 296 | 
            +
                  # Returns the path to the specified asset (css or javascript).
         | 
| 305 297 | 
             
                  #
         | 
| 306 298 | 
             
                  # @param [String] kind
         | 
| 307 | 
            -
                  #   The kind of asset (i.e :images, :js, :css)
         | 
| 299 | 
            +
                  #   The kind of asset (i.e :images, :js, :css).
         | 
| 308 300 | 
             
                  # @param [String] source
         | 
| 309 301 | 
             
                  #   The path to the asset (relative or absolute).
         | 
| 310 302 | 
             
                  #
         | 
| @@ -320,7 +312,6 @@ module Padrino | |
| 320 312 | 
             
                  #   # Generates: /images/example.jpg?1269008689
         | 
| 321 313 | 
             
                  #   asset_path :images, 'example.jpg'
         | 
| 322 314 | 
             
                  #
         | 
| 323 | 
            -
                  # @api semipublic
         | 
| 324 315 | 
             
                  def asset_path(kind, source)
         | 
| 325 316 | 
             
                    source = asset_normalize_extension(kind, URI.escape(source.to_s))
         | 
| 326 317 | 
             
                    return source if source =~ ABSOLUTE_URL_PATTERN || source =~ /^\// # absolute source
         | 
| @@ -332,7 +323,7 @@ module Padrino | |
| 332 323 |  | 
| 333 324 | 
             
                  private
         | 
| 334 325 | 
             
                  ##
         | 
| 335 | 
            -
                  # Returns the  | 
| 326 | 
            +
                  # Returns the URI root of the application with optional paths appended.
         | 
| 336 327 | 
             
                  #
         | 
| 337 328 | 
             
                  # @example
         | 
| 338 329 | 
             
                  #   uri_root_path("/some/path") => "/root/some/path"
         | 
| @@ -344,7 +335,7 @@ module Padrino | |
| 344 335 | 
             
                  end
         | 
| 345 336 |  | 
| 346 337 | 
             
                  ##
         | 
| 347 | 
            -
                  # Returns the timestamp mtime for an asset
         | 
| 338 | 
            +
                  # Returns the timestamp mtime for an asset.
         | 
| 348 339 | 
             
                  #
         | 
| 349 340 | 
             
                  # @example
         | 
| 350 341 | 
             
                  #   asset_timestamp("some/path/to/file.png") => "?154543678"
         | 
| @@ -375,7 +366,8 @@ module Padrino | |
| 375 366 | 
             
                    end
         | 
| 376 367 | 
             
                  end
         | 
| 377 368 |  | 
| 378 | 
            -
                   | 
| 369 | 
            +
                  ##
         | 
| 370 | 
            +
                  # Normalizes the extension for a given asset.
         | 
| 379 371 | 
             
                  #
         | 
| 380 372 | 
             
                  #  @example
         | 
| 381 373 | 
             
                  #
         | 
| @@ -389,7 +381,7 @@ module Padrino | |
| 389 381 | 
             
                  end
         | 
| 390 382 |  | 
| 391 383 | 
             
                  ##
         | 
| 392 | 
            -
                  # Parses link_to options for given correct conditions
         | 
| 384 | 
            +
                  # Parses link_to options for given correct conditions.
         | 
| 393 385 | 
             
                  #
         | 
| 394 386 | 
             
                  # @example
         | 
| 395 387 | 
             
                  #   parse_conditions("/some/url", :if => false) => true
         | 
| @@ -404,6 +396,6 @@ module Padrino | |
| 404 396 | 
             
                      true
         | 
| 405 397 | 
             
                    end
         | 
| 406 398 | 
             
                  end
         | 
| 407 | 
            -
                end | 
| 408 | 
            -
              end | 
| 409 | 
            -
            end | 
| 399 | 
            +
                end
         | 
| 400 | 
            +
              end
         | 
| 401 | 
            +
            end
         | 
| @@ -1,30 +1,28 @@ | |
| 1 1 | 
             
            module Padrino
         | 
| 2 2 | 
             
              module Helpers
         | 
| 3 3 | 
             
                class Breadcrumb
         | 
| 4 | 
            -
             | 
| 5 4 | 
             
                  attr_accessor :home, :items
         | 
| 6 5 |  | 
| 7 6 | 
             
                  DEFAULT_URL = "/"
         | 
| 8 7 | 
             
                  DEFAULT_CAPTION ="Home Page"
         | 
| 9 8 |  | 
| 10 9 | 
             
                  ##
         | 
| 11 | 
            -
                  #  | 
| 10 | 
            +
                  # Initialize breadcrumbs with default value.
         | 
| 12 11 | 
             
                  #
         | 
| 13 12 | 
             
                  # @example
         | 
| 14 13 | 
             
                  #   before do
         | 
| 15 14 | 
             
                  #     @breadcrumbs = breadcrumbs.new
         | 
| 16 15 | 
             
                  #   end
         | 
| 17 16 | 
             
                  #
         | 
| 18 | 
            -
                  # @api public
         | 
| 19 17 | 
             
                  def initialize
         | 
| 20 18 | 
             
                    reset!
         | 
| 21 19 | 
             
                  end
         | 
| 22 20 |  | 
| 23 21 | 
             
                  ##
         | 
| 24 | 
            -
                  # Set the custom home (Parent) link
         | 
| 22 | 
            +
                  # Set the custom home (Parent) link.
         | 
| 25 23 | 
             
                  #
         | 
| 26 24 | 
             
                  # @param [String] url
         | 
| 27 | 
            -
                  #  The url href
         | 
| 25 | 
            +
                  #  The url href.
         | 
| 28 26 | 
             
                  #
         | 
| 29 27 | 
             
                  # @param [String] caption
         | 
| 30 28 | 
             
                  #   The  text caption.
         | 
| @@ -35,8 +33,6 @@ module Padrino | |
| 35 33 | 
             
                  # @example
         | 
| 36 34 | 
             
                  #   breadcrumbs.set_home "/HomeFoo", "Foo Home", :id => "home-breadcrumb"
         | 
| 37 35 | 
             
                  #
         | 
| 38 | 
            -
                  #
         | 
| 39 | 
            -
                  # @api public
         | 
| 40 36 | 
             
                  def set_home(url, caption, options = {})
         | 
| 41 37 | 
             
                    self.home = {
         | 
| 42 38 | 
             
                      :url     => url.to_s,
         | 
| @@ -48,24 +44,22 @@ module Padrino | |
| 48 44 | 
             
                  end
         | 
| 49 45 |  | 
| 50 46 | 
             
                  ##
         | 
| 51 | 
            -
                  # Reset breadcrumbs to default or personal | 
| 47 | 
            +
                  # Reset breadcrumbs to default or personal home.
         | 
| 52 48 | 
             
                  #
         | 
| 53 49 | 
             
                  # @example
         | 
| 54 50 | 
             
                  #   breadcrumbs.reset
         | 
| 55 51 | 
             
                  #
         | 
| 56 | 
            -
                  # @api public
         | 
| 57 52 | 
             
                  def reset
         | 
| 58 53 | 
             
                    self.items = []
         | 
| 59 54 | 
             
                    self.items << home
         | 
| 60 55 | 
             
                  end
         | 
| 61 56 |  | 
| 62 57 | 
             
                  ##
         | 
| 63 | 
            -
                  # Reset breadcrumbs to default home
         | 
| 58 | 
            +
                  # Reset breadcrumbs to default home.
         | 
| 64 59 | 
             
                  #
         | 
| 65 60 | 
             
                  # @example
         | 
| 66 61 | 
             
                  #   breadcrumbs.reset!
         | 
| 67 62 | 
             
                  #
         | 
| 68 | 
            -
                  # @api public
         | 
| 69 63 | 
             
                  def reset!
         | 
| 70 64 | 
             
                    self.home = {
         | 
| 71 65 | 
             
                      :name    => :home,
         | 
| @@ -77,7 +71,7 @@ module Padrino | |
| 77 71 | 
             
                  end
         | 
| 78 72 |  | 
| 79 73 | 
             
                  ##
         | 
| 80 | 
            -
                  # Add a new | 
| 74 | 
            +
                  # Add a new breadcrumbs.
         | 
| 81 75 | 
             
                  #
         | 
| 82 76 | 
             
                  # @param [String] name
         | 
| 83 77 | 
             
                  #   The name of resource.
         | 
| @@ -97,7 +91,6 @@ module Padrino | |
| 97 91 | 
             
                  #   breadcrumbs.add "foo", "/foo", "Foo Link", :id => "foo-id"
         | 
| 98 92 | 
             
                  #   breadcrumbs.add :foo, "/foo", "Foo Link", :class => "foo-class"
         | 
| 99 93 | 
             
                  #
         | 
| 100 | 
            -
                  # @api public
         | 
| 101 94 | 
             
                  def add(name, url, caption, options = {})
         | 
| 102 95 | 
             
                    items << {
         | 
| 103 96 | 
             
                      :name    => name.to_sym,
         | 
| @@ -106,42 +99,35 @@ module Padrino | |
| 106 99 | 
             
                      :options => options
         | 
| 107 100 | 
             
                    }
         | 
| 108 101 | 
             
                  end
         | 
| 109 | 
            -
             | 
| 110 102 | 
             
                  alias :<< :add
         | 
| 111 103 |  | 
| 112 104 | 
             
                  ##
         | 
| 113 | 
            -
                  # Remove a  | 
| 105 | 
            +
                  # Remove a breadcrumb.
         | 
| 114 106 | 
             
                  #
         | 
| 115 107 | 
             
                  # @param [String] name
         | 
| 116 | 
            -
                  #  The name of resource to delete from breadcrumbs list
         | 
| 117 | 
            -
                  #
         | 
| 118 | 
            -
                  # @param [Symbol] name
         | 
| 119 | 
            -
                  #  The name of resource to delete from breadcrumbs list
         | 
| 108 | 
            +
                  #  The name of resource to delete from breadcrumbs list.
         | 
| 120 109 | 
             
                  #
         | 
| 121 110 | 
             
                  # @example
         | 
| 122 111 | 
             
                  #   breadcrumbs.del "foo"
         | 
| 123 112 | 
             
                  #   breadcrumbs.del :foo
         | 
| 124 113 | 
             
                  #
         | 
| 125 | 
            -
                  # @api public
         | 
| 126 114 | 
             
                  def del(name)
         | 
| 127 115 | 
             
                    items.delete_if { |item| item[:name] == name.to_sym }
         | 
| 128 116 | 
             
                  end
         | 
| 129 | 
            -
             | 
| 130 | 
            -
                end # Breadcrumb
         | 
| 131 | 
            -
             | 
| 117 | 
            +
                end
         | 
| 132 118 |  | 
| 133 119 | 
             
                module Breadcrumbs
         | 
| 134 | 
            -
             | 
| 135 | 
            -
                  # Render breadcrumbs to view
         | 
| 120 | 
            +
                  ##
         | 
| 121 | 
            +
                  # Render breadcrumbs to view.
         | 
| 136 122 | 
             
                  #
         | 
| 137 123 | 
             
                  # @param [Breadcrumbs] breadcrumbs
         | 
| 138 | 
            -
                  #   The breadcrumbs to render into view
         | 
| 124 | 
            +
                  #   The breadcrumbs to render into view.
         | 
| 139 125 | 
             
                  #
         | 
| 140 126 | 
             
                  # @param [Boolean] bootstrap
         | 
| 141 | 
            -
                  #  If true, render separation ( | 
| 127 | 
            +
                  #  If true, render separation (useful with Twitter Bootstrap).
         | 
| 142 128 | 
             
                  #
         | 
| 143 129 | 
             
                  # @param [String] active
         | 
| 144 | 
            -
                  #   | 
| 130 | 
            +
                  #  CSS class style set to active breadcrumb.
         | 
| 145 131 | 
             
                  #
         | 
| 146 132 | 
             
                  # @param [Hash] options
         | 
| 147 133 | 
             
                  #   The HTML options to include in ul.
         | 
| @@ -156,8 +142,6 @@ module Padrino | |
| 156 142 | 
             
                  #  #   <li class="active"><a href="/bar">Bar Link</a></li>
         | 
| 157 143 | 
             
                  #  # </ul>
         | 
| 158 144 | 
             
                  #
         | 
| 159 | 
            -
                  #
         | 
| 160 | 
            -
                  # @api public
         | 
| 161 145 | 
             
                  def breadcrumbs(breadcrumbs, bootstrap = false, active = "active", options = {})
         | 
| 162 146 | 
             
                    content = ""
         | 
| 163 147 | 
             
                    breadcrumbs.items[0..-2].each do |item|
         | 
| @@ -178,24 +162,22 @@ module Padrino | |
| 178 162 |  | 
| 179 163 | 
             
                  private
         | 
| 180 164 | 
             
                  ##
         | 
| 181 | 
            -
                  # Private method to return list item
         | 
| 165 | 
            +
                  # Private method to return list item.
         | 
| 182 166 | 
             
                  #
         | 
| 183 167 | 
             
                  # @param [Hash] item
         | 
| 184 | 
            -
                  #   The breadcrumb item
         | 
| 168 | 
            +
                  #   The breadcrumb item.
         | 
| 185 169 | 
             
                  #
         | 
| 186 170 | 
             
                  # @param [Boolean] bootstrap
         | 
| 187 | 
            -
                  #   If true, render separation ( | 
| 171 | 
            +
                  #   If true, render separation (useful with Twitter Bootstrap).
         | 
| 188 172 | 
             
                  #
         | 
| 189 | 
            -
                  # @return [String] List item with  | 
| 173 | 
            +
                  # @return [String] List item with breadcrumb
         | 
| 190 174 | 
             
                  #
         | 
| 191 | 
            -
                  # @api public
         | 
| 192 175 | 
             
                  def render_item(item, bootstrap)
         | 
| 193 176 | 
             
                    content = ""
         | 
| 194 177 | 
             
                    content << link_to(item[:caption], item[:url])
         | 
| 195 178 | 
             
                    content << safe_content_tag(:span, "/", :class => "divider") if bootstrap
         | 
| 196 179 | 
             
                    safe_content_tag(:li, content, item[:options])
         | 
| 197 180 | 
             
                  end
         | 
| 198 | 
            -
             | 
| 199 | 
            -
             | 
| 200 | 
            -
             | 
| 201 | 
            -
            end # Padrino
         | 
| 181 | 
            +
                end
         | 
| 182 | 
            +
              end
         | 
| 183 | 
            +
            end
         |