Module: MicroHelper
- Defined in:
- lib/micro_helper.rb,
lib/micro_helper/version.rb
Constant Summary collapse
- PROP_TYPE_BASE_URL =
"http://data-vocabulary.org/"- VERSION =
"0.5.0"
Instance Method Summary collapse
- #generate_microformats(container, props, childs = nil) ⇒ Object
- #meta_tag(property, value) ⇒ Object
- #microformats(container, props, childs = nil) ⇒ Object
- #og_for(type, value, namespace = "og") ⇒ Object
- #og_tag(type, value, namespace = "og") ⇒ Object
- #parse_content(content) ⇒ Object
- #parse_itemprop(itemprop) ⇒ Object
- #parse_props(props) ⇒ Object
- #span(key, content) ⇒ Object
- #span_outer(container) ⇒ Object
- #type_prop(type) ⇒ Object
- #type_url(type) ⇒ Object
Instance Method Details
#generate_microformats(container, props, childs = nil) ⇒ Object
11 12 13 14 |
# File 'lib/micro_helper.rb', line 11 def generate_microformats(container,props,childs=nil) "#{span_outer(container)}#{parse_props(props)}#{childs}</span>".html_safe end |
#meta_tag(property, value) ⇒ Object
38 39 40 41 |
# File 'lib/micro_helper.rb', line 38 def (property,value) "<meta property='#{property}' content='#{value}'>".html_safe end |
#microformats(container, props, childs = nil) ⇒ Object
17 18 19 20 |
# File 'lib/micro_helper.rb', line 17 def microformats(container,props,childs=nil) generate_microformats(container,props,childs) end |
#og_for(type, value, namespace = "og") ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/micro_helper.rb', line 23 def og_for(type,value,namespace="og") content_for type do ("#{namespace}:#{type}",value) end end |
#og_tag(type, value, namespace = "og") ⇒ Object
32 33 34 35 |
# File 'lib/micro_helper.rb', line 32 def og_tag(type,value,namespace="og") ("#{namespace}:#{type}",value) end |
#parse_content(content) ⇒ Object
68 69 70 71 |
# File 'lib/micro_helper.rb', line 68 def parse_content(content) "content='#{content}'" if content end |
#parse_itemprop(itemprop) ⇒ Object
56 57 58 59 |
# File 'lib/micro_helper.rb', line 56 def parse_itemprop(itemprop) "itemprop='#{itemprop}'" if itemprop end |
#parse_props(props) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/micro_helper.rb', line 74 def parse_props(props) html="" props.each do |key,prop| html+="#{span(key,prop[:content])}#{prop[:value]}</span>" end return html end |
#span(key, content) ⇒ Object
62 63 64 65 |
# File 'lib/micro_helper.rb', line 62 def span(key,content) "<span itemprop='#{key.to_s}' #{parse_content(content)}>" end |
#span_outer(container) ⇒ Object
50 51 52 53 |
# File 'lib/micro_helper.rb', line 50 def span_outer(container) "<span style='display:none' #{parse_itemprop(container[:itemprop])} #{type_prop(container[:type])}>" end |
#type_prop(type) ⇒ Object
86 87 88 89 |
# File 'lib/micro_helper.rb', line 86 def type_prop(type) "itemscope itemtype='#{type_url(type)}'" end |
#type_url(type) ⇒ Object
44 45 46 47 |
# File 'lib/micro_helper.rb', line 44 def type_url(type) "#{PROP_TYPE_BASE_URL}#{type}" end |