Module: FL::MetaHelper
- Defined in:
- app/helpers/fl/meta_helper.rb
Instance Method Summary collapse
-
#csrf ⇒ Object
> CSRF.
-
#css(*args) ⇒ Object
> CSS.
- #favicon(img = "icons/favicon.ico", *args) ⇒ Object
-
#js(*args) ⇒ Object
> JS.
-
#meta(type, *args) ⇒ Object
> Meta => SPLAT OPERATOR for multiple “when” cases – stackoverflow.com/a/10197397/1143732.
-
#robots(*args) ⇒ Object
Robots => noarchive.net/meta/.
-
#title(args) ⇒ Object
> Title (needs to be more succinct).
Instance Method Details
#csrf ⇒ Object
> CSRF
49 50 51 |
# File 'app/helpers/fl/meta_helper.rb', line 49 def csrf :csrf end |
#css(*args) ⇒ Object
> CSS
39 40 41 |
# File 'app/helpers/fl/meta_helper.rb', line 39 def css *args :css, *args end |
#favicon(img = "icons/favicon.ico", *args) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'app/helpers/fl/meta_helper.rb', line 94 def favicon img="icons/favicon.ico", *args # => Accepts all styles of icon defaults = { "apple-touch-icon" => [57,60,72,76,114,120,144,152,167,180], "icon" => [16,32] } = args..merge!(defaults) { |key, v1, v2| v1 } case when :all when true else :favicon, img end end |
#js(*args) ⇒ Object
> JS
44 45 46 |
# File 'app/helpers/fl/meta_helper.rb', line 44 def js *args :js, *args end |
#meta(type, *args) ⇒ Object
> Meta
> SPLAT OPERATOR for multiple “when” cases – stackoverflow.com/a/10197397/1143732
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/helpers/fl/meta_helper.rb', line 13 def type, *args case type when :js, :javascript, :javascripts, :script, :scripts javascript_include_tag *args.compact #-> splat operator http://stackoverflow.com/questions/13795627/ruby-send-method-passing-multiple-parameters when :css, :stylesheet, :stylesheets stylesheet_link_tag *args.compact #-> splat operator http://stackoverflow.com/questions/13795627/ruby-send-method-passing-multiple-parameters when :title Haml::Engine.new("%title #{args.join(' ')}").render when :favicon favicon_link_tag when :csrf else Haml::Engine.new("%meta{ name: \"#{type}\", content: \"#{args.join(', ')}\" }").render #-> http://stackoverflow.com/questions/9143761/meta-descritpion-in-haml-with-outside-variable end end |
#robots(*args) ⇒ Object
Robots
> noarchive.net/meta/
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'app/helpers/fl/meta_helper.rb', line 58 def robots *args # => Blank for all true # => Possible inputs: # => { index: true, follow: true, nofollow: false, noindex: false } # => :index, :follow, :noindex, :nofollow # => "index", "follow", "noindex", "nofollow" # => Inputs # => No input = all # => If true and false are present, only true is passed = args. # => Don't need defaults # => Results results = Array.new(2) # No options / args = "index, follow" # First check for one of the following :index, index: true, noindex: false == "index" # Second check for one of the following :follow, follow: true, nofollow: false == "follow" # Third check for one of the following :noindex, noindex: true == "noindex" # Forth check for one of the following :nofollow, nofollow: true == "nofollow" results[0] = "index" if [:index] || args.include?(:index) || [:noindex] == false || (.empty? && args.empty?) results[1] = "follow" if [:follow] || args.include?(:follow) || [:nofollow] == false || (.empty? && args.empty?) results[0] = "noindex" if ([:noindex] || args.include?(:noindex) || [:index] == false) && (!args.include?(:index)) results[1] = "nofollow" if ([:nofollow] || args.include?(:nofollow) || [:follow] == false) && (!args.include?(:follow)) results.delete_at(0) if ([:index] == false) && ([:index] != true || !args.include?(:index)) results.delete_at(1) if ([:follow] == false) && ([:follow] != true || !args.include?(:follow)) # => Return # => Options only accepts actual content (array) :robots, results.compact.join(",") if results.any? end |
#title(args) ⇒ Object
> Title (needs to be more succinct)
34 35 36 |
# File 'app/helpers/fl/meta_helper.rb', line 34 def title args :title, args end |