microformats-helper 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +1 -1
- data/lib/microformats-helper.rb +45 -7
- data/lib/microformats-helper/version.rb +1 -1
- data/microformats-helper.gemspec +1 -0
- metadata +18 -2
data/LICENSE.txt
CHANGED
data/lib/microformats-helper.rb
CHANGED
@@ -1,58 +1,96 @@
|
|
1
1
|
require "microformats-helper/version"
|
2
|
+
require "actionpack"
|
2
3
|
|
3
4
|
module MicroformatsHelper
|
4
|
-
module Helper
|
5
5
|
|
6
|
+
module Helper
|
6
7
|
|
7
8
|
PROP_TYPE_BASE_URL = "http://data-vocabulary.org/"
|
8
9
|
|
10
|
+
|
9
11
|
def generate_microformats(container,props,childs=nil)
|
10
12
|
|
13
|
+
"#{span_outer(container)}#{parse_props(props)}#{childs}</span>".html_safe
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
def microformats(container,props,childs=nil)
|
18
|
+
|
19
|
+
generate_microformats(container,props,childs)
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
def og_for(type,value,namespace="og")
|
24
|
+
|
25
|
+
content_for type do
|
26
|
+
|
27
|
+
meta_tag("#{namespace}:#{type}",value)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
def og_tag(type,value,namespace="og")
|
33
|
+
|
34
|
+
meta_tag("#{namespace}:#{type}",value)
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
def meta_tag(property,value)
|
11
39
|
|
12
|
-
"#{
|
40
|
+
"<meta property='#{property}' content='#{value}'>".html_safe
|
13
41
|
end
|
14
42
|
|
43
|
+
|
15
44
|
def type_url(type)
|
16
45
|
|
17
46
|
"#{PROP_TYPE_BASE_URL}#{type}"
|
18
47
|
end
|
19
48
|
|
49
|
+
|
20
50
|
def span_outer(container)
|
51
|
+
|
21
52
|
"<span style='display:none' #{parse_itemprop(container[:itemprop])} #{type_prop(container[:type])}>"
|
22
53
|
end
|
23
54
|
|
55
|
+
|
24
56
|
def parse_itemprop(itemprop)
|
57
|
+
|
25
58
|
"itemprop='#{itemprop}'" if itemprop
|
26
59
|
end
|
27
60
|
|
28
|
-
def span_end
|
29
|
-
"</span>"
|
30
|
-
end
|
31
61
|
|
32
62
|
def span(key,content)
|
33
|
-
"<span style='display:none' itemprop='#{key.to_s}' #{parse_content(content)}>"
|
34
63
|
|
64
|
+
"<span itemprop='#{key.to_s}' #{parse_content(content)}>"
|
35
65
|
end
|
36
66
|
|
67
|
+
|
37
68
|
def parse_content(content)
|
69
|
+
|
38
70
|
"content='#{content}'" if content
|
39
71
|
end
|
40
72
|
|
73
|
+
|
41
74
|
def parse_props(props)
|
75
|
+
|
42
76
|
html=""
|
77
|
+
|
43
78
|
props.each do |key,prop|
|
44
79
|
|
45
|
-
html+="#{span(key,prop[:content])}#{prop[:value]}
|
80
|
+
html+="#{span(key,prop[:content])}#{prop[:value]}</span>"
|
46
81
|
end
|
82
|
+
|
47
83
|
return html
|
48
84
|
end
|
49
85
|
|
50
86
|
def type_prop(type)
|
87
|
+
|
51
88
|
"itemscope itemtype='#{type_url(type)}'"
|
52
89
|
end
|
53
90
|
end
|
54
91
|
end
|
55
92
|
|
56
93
|
ActiveSupport.on_load(:action_view) do
|
94
|
+
|
57
95
|
include MicroformatsHelper::Helper
|
58
96
|
end
|
data/microformats-helper.gemspec
CHANGED
@@ -12,6 +12,7 @@ Gem::Specification.new do |gem|
|
|
12
12
|
gem.summary = "Helper for microformats, possibility of nesting."
|
13
13
|
gem.homepage = "http://github.com/AlexCppns/microformats-helper"
|
14
14
|
gem.add_runtime_dependency "activesupport"
|
15
|
+
gem.add_dependency "actionpack"
|
15
16
|
gem.files = `git ls-files`.split($/)
|
16
17
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: microformats-helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -27,6 +27,22 @@ dependencies:
|
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: actionpack
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
30
46
|
description: Helper for microformats, possibility of nesting.
|
31
47
|
email:
|
32
48
|
- alexcppns@gmail.com
|