viewfu 1.0.1 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -0
- data/Gemfile.lock +10 -0
- data/Rakefile +18 -16
- data/lib/view_fu/tag_helper.rb +42 -42
- data/viewfu.gemspec +26 -0
- metadata +16 -17
- data/VERSION +0 -1
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/Rakefile
CHANGED
@@ -1,18 +1,20 @@
|
|
1
|
+
require "bundler"
|
2
|
+
Bundler.setup
|
3
|
+
|
1
4
|
require 'rake'
|
5
|
+
require 'rake/gempackagetask'
|
6
|
+
|
7
|
+
gemspec = eval(File.read('viewfu.gemspec'))
|
8
|
+
Rake::GemPackageTask.new(gemspec) do |pkg|
|
9
|
+
pkg.gem_spec = gemspec
|
10
|
+
end
|
2
11
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
s.files = FileList["[A-Z]*", "{bin,generators,lib,test}/**/*"]
|
13
|
-
end
|
14
|
-
Jeweler::GemcutterTasks.new
|
15
|
-
|
16
|
-
rescue LoadError
|
17
|
-
# puts "Jeweler, or one of its dependencies, is not available. Install it with: gem install jeweler"
|
18
|
-
end
|
12
|
+
desc "build the gem and release it to rubygems.org"
|
13
|
+
task :release => :gem do
|
14
|
+
puts "Tagging #{gemspec.version}..."
|
15
|
+
system "git tag -a #{gemspec.version} -m 'Tagging #{gemspec.version}'"
|
16
|
+
puts "Pushing to Github..."
|
17
|
+
system "git push --tags"
|
18
|
+
puts "Pushing to rubygems.org..."
|
19
|
+
system "gem push pkg/#{gemspec.name}-#{gemspec.version}.gem"
|
20
|
+
end
|
data/lib/view_fu/tag_helper.rb
CHANGED
@@ -9,17 +9,17 @@ module ViewFu
|
|
9
9
|
def hr
|
10
10
|
"<hr />".html_safe
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
# Writes a nonbreaking space
|
14
14
|
def nbsp
|
15
15
|
" ".html_safe
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
# Writes an anchor tag
|
19
19
|
def anchor(anchor_name, options = {})
|
20
20
|
content_tag(:a, "", options.merge(:name => anchor_name))
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
# Writes a clear tag
|
24
24
|
def clear_tag(tag, direction = nil)
|
25
25
|
if tag == :br
|
@@ -28,7 +28,7 @@ module ViewFu
|
|
28
28
|
"<#{tag} class=\"clear#{direction}\"></#{tag}>".html_safe
|
29
29
|
end
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
def current_year
|
33
33
|
Time.now.strftime("%Y")
|
34
34
|
end
|
@@ -37,41 +37,39 @@ module ViewFu
|
|
37
37
|
def clear(direction = nil)
|
38
38
|
clear_tag(:div, direction)
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
# Return some lorem text
|
42
42
|
def lorem
|
43
43
|
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
# provides a slick way to add classes inside haml attribute collections
|
47
|
-
#
|
47
|
+
#
|
48
48
|
# examples:
|
49
|
-
# %div{add_class("current")}
|
49
|
+
# %div{add_class("current")}
|
50
50
|
# #=> adds the "current" class to the div
|
51
|
-
#
|
52
|
-
# %div{add_class("current", :if => current?)}
|
53
|
-
# #=> adds the "current" class to the div if current? method
|
54
51
|
#
|
55
|
-
# %div{add_class("
|
52
|
+
# %div{add_class("current", :if => current?)}
|
53
|
+
# #=> adds the "current" class to the div if current? method
|
54
|
+
#
|
55
|
+
# %div{add_class("highlight", :unless => logged_in?)}
|
56
56
|
# #=> adds the "highlight" class to the div unless logged_in? method returns true
|
57
57
|
def add_class(css_class, options = {})
|
58
58
|
return {} unless css_class
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
if options.has_key?(:if) && options[:if]
|
65
|
-
return {:class => css_class}
|
59
|
+
|
60
|
+
attributes = {:class => css_class}
|
61
|
+
|
62
|
+
if options.has_key?(:unless)
|
63
|
+
return options[:unless] ? {} : attributes
|
66
64
|
end
|
67
|
-
|
68
|
-
if
|
69
|
-
|
70
|
-
else
|
71
|
-
{}
|
65
|
+
|
66
|
+
if options.has_key?(:if)
|
67
|
+
return options[:if] ? attributes : {}
|
72
68
|
end
|
69
|
+
|
70
|
+
attributes
|
73
71
|
end
|
74
|
-
|
72
|
+
|
75
73
|
def add_class_if(css_class, condition)
|
76
74
|
add_class(css_class, :if => condition)
|
77
75
|
end
|
@@ -79,53 +77,55 @@ module ViewFu
|
|
79
77
|
def add_class_unless(css_class, condition)
|
80
78
|
add_class(css_class, :unless => condition)
|
81
79
|
end
|
82
|
-
|
80
|
+
|
83
81
|
# Return a hidden attribute hash (useful in Haml tags - %div{hidden})
|
84
82
|
def hide(options = {})
|
85
|
-
|
86
|
-
|
83
|
+
attributes = {:style => "display:none"}
|
84
|
+
|
85
|
+
if options.has_key?(:unless)
|
86
|
+
return options[:unless] ? {} : attributes
|
87
87
|
end
|
88
|
-
|
89
|
-
if options.has_key?(:if)
|
90
|
-
return {}
|
88
|
+
|
89
|
+
if options.has_key?(:if)
|
90
|
+
return options[:if] ? attributes : {}
|
91
91
|
end
|
92
|
-
|
93
|
-
|
92
|
+
|
93
|
+
attributes
|
94
94
|
end
|
95
95
|
alias :hidden :hide
|
96
|
-
|
96
|
+
|
97
97
|
# Return a hidden attribute hash if a condition evaluates to true
|
98
98
|
def hide_if(condition)
|
99
99
|
hide(:if => condition)
|
100
100
|
end
|
101
101
|
alias :hidden_if :hide_if
|
102
102
|
alias :show_unless :hide_if
|
103
|
-
|
103
|
+
|
104
104
|
# Return a hidden attribute hash if a condition evaluates to false
|
105
105
|
def hide_unless(condition)
|
106
106
|
hide(:unless => condition)
|
107
107
|
end
|
108
108
|
alias :hidden_unless :hide_unless
|
109
|
-
alias :show_if :hide_unless
|
110
|
-
|
109
|
+
alias :show_if :hide_unless
|
110
|
+
|
111
111
|
# Wrap a delete link
|
112
112
|
def delete_link(*args)
|
113
113
|
options = {:method => :delete, :confirm => "Are you sure you want to delete this?"}.merge(extract_options_from_args!(args)||{})
|
114
114
|
args << options
|
115
115
|
link_to(*args)
|
116
116
|
end
|
117
|
-
|
117
|
+
|
118
118
|
# Wrap a block with a link
|
119
119
|
def link_to_block(*args, &block)
|
120
120
|
content = capture(&block)
|
121
121
|
return link_to(content, *args)
|
122
122
|
end
|
123
|
-
|
123
|
+
|
124
124
|
# Check if we're on production environment
|
125
125
|
def production?
|
126
126
|
Rails.env.production?
|
127
127
|
end
|
128
|
-
|
128
|
+
|
129
129
|
# clearbit icons
|
130
130
|
def clearbit_icon(icon, color, options = {})
|
131
131
|
image_tag "clearbits/#{icon}.gif", {:class => "clearbits #{color}", :alt => icon}.merge(options)
|
@@ -135,11 +135,11 @@ module ViewFu
|
|
135
135
|
def pixel(options = {})
|
136
136
|
image_tag "pixel.png", options
|
137
137
|
end
|
138
|
-
|
138
|
+
|
139
139
|
# check to see if an index is the first item in a collection
|
140
140
|
def is_first(i)
|
141
141
|
i.to_i.zero? ? {:class => "first"} : {}
|
142
142
|
end
|
143
|
-
|
143
|
+
|
144
144
|
end
|
145
145
|
end
|
data/viewfu.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "viewfu"
|
3
|
+
s.version = "1.0.3"
|
4
|
+
|
5
|
+
s.summary = "rails3 view helpers"
|
6
|
+
s.email = "railsjedi@gmail.com"
|
7
|
+
s.homepage = "http://github.com/railsjedi/viewfu"
|
8
|
+
s.description = "Lots of little tidbits for tidying up your views"
|
9
|
+
s.authors = ["Jacques Crocker"]
|
10
|
+
|
11
|
+
s.require_paths = ["lib"]
|
12
|
+
|
13
|
+
s.files = Dir['lib/**/*',
|
14
|
+
'viewfu.gemspec',
|
15
|
+
'Gemfile',
|
16
|
+
'Gemfile.lock',
|
17
|
+
'LICENSE',
|
18
|
+
'Rakefile',
|
19
|
+
'README']
|
20
|
+
|
21
|
+
s.extra_rdoc_files = [
|
22
|
+
"LICENSE",
|
23
|
+
"README"
|
24
|
+
]
|
25
|
+
end
|
26
|
+
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: viewfu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 1
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
version: 1.0.1
|
4
|
+
prerelease:
|
5
|
+
version: 1.0.3
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Jacques Crocker
|
@@ -14,7 +10,7 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date:
|
13
|
+
date: 2011-02-27 00:00:00 -08:00
|
18
14
|
default_executable:
|
19
15
|
dependencies: []
|
20
16
|
|
@@ -28,42 +24,45 @@ extra_rdoc_files:
|
|
28
24
|
- LICENSE
|
29
25
|
- README
|
30
26
|
files:
|
31
|
-
- LICENSE
|
32
|
-
- README
|
33
|
-
- Rakefile
|
34
|
-
- VERSION
|
35
|
-
- lib/view_fu.rb
|
36
27
|
- lib/view_fu/browser_detect.rb
|
37
28
|
- lib/view_fu/meta_helper.rb
|
38
29
|
- lib/view_fu/tag_helper.rb
|
30
|
+
- lib/view_fu.rb
|
39
31
|
- lib/viewfu.rb
|
32
|
+
- viewfu.gemspec
|
33
|
+
- Gemfile
|
34
|
+
- Gemfile.lock
|
35
|
+
- LICENSE
|
36
|
+
- Rakefile
|
37
|
+
- README
|
40
38
|
has_rdoc: true
|
41
39
|
homepage: http://github.com/railsjedi/viewfu
|
42
40
|
licenses: []
|
43
41
|
|
44
42
|
post_install_message:
|
45
|
-
rdoc_options:
|
46
|
-
|
43
|
+
rdoc_options: []
|
44
|
+
|
47
45
|
require_paths:
|
48
46
|
- lib
|
49
47
|
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
none: false
|
50
49
|
requirements:
|
51
50
|
- - ">="
|
52
51
|
- !ruby/object:Gem::Version
|
52
|
+
hash: -1872913082937101856
|
53
53
|
segments:
|
54
54
|
- 0
|
55
55
|
version: "0"
|
56
56
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
57
58
|
requirements:
|
58
59
|
- - ">="
|
59
60
|
- !ruby/object:Gem::Version
|
60
|
-
segments:
|
61
|
-
- 0
|
62
61
|
version: "0"
|
63
62
|
requirements: []
|
64
63
|
|
65
64
|
rubyforge_project:
|
66
|
-
rubygems_version: 1.
|
65
|
+
rubygems_version: 1.5.2
|
67
66
|
signing_key:
|
68
67
|
specification_version: 3
|
69
68
|
summary: rails3 view helpers
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.0.1
|