icon_links 0.1.1 → 0.2.0
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.
- data/README.md +4 -28
- data/lib/icon_links.rb +5 -1
- data/lib/icon_links/method_missing.rb +13 -12
- data/lib/icon_links/view_helpers.rb +5 -5
- metadata +6 -6
data/README.md
CHANGED
@@ -1,34 +1,10 @@
|
|
1
1
|
IconLinks
|
2
2
|
=========
|
3
|
-
Easily link icons of your choosing
|
3
|
+
Easily link icons of your choosing with handy helpers. Works great with Silk icons.
|
4
|
+
|
4
5
|
|
5
6
|
Example
|
6
7
|
=======
|
7
|
-
|
8
|
-
|
9
|
-
link_to 'Show', post_path(@post)
|
10
|
-
link_to 'Edit', edit_posts_path(@post)
|
11
|
-
link_to 'Destroy', posts_path(@post), :confirm => 'Are you sure?', :method => :delete
|
12
|
-
link_to 'Back', posts_path
|
13
|
-
|
14
|
-
To:
|
15
|
-
|
16
|
-
icon_to :show, post_path(@post)
|
17
|
-
icon_to :edit, edit_post_path(@post)
|
18
|
-
icon_to :delete, post_path(@post), :confirm => 'Are you sure?', :method => :delete
|
19
|
-
icon_to :back, posts_path
|
20
|
-
|
21
|
-
And you'll get snazzy, linked silk icons that will make you cry.
|
22
|
-
|
23
|
-
You can even go one fancier, and use REST route helpers with an `_icon` suffix:
|
24
|
-
|
25
|
-
post_icon(@post)
|
26
|
-
edit_post_icon(@post)
|
27
|
-
delete_post_icon(@post, :confirm => 'Are you sure?', :method => :delete)
|
28
|
-
|
29
|
-
Yeah, this plugin is simple and sweet. Sugary, like candy.
|
8
|
+
Example goes here.
|
30
9
|
|
31
|
-
|
32
|
-
======
|
33
|
-
Copyright (c) 2008-2010 [Nate Wiger](http://nateware.com). All Rights Reserved.
|
34
|
-
Released under the MIT license.
|
10
|
+
Copyright (c) 2008-2010 [Nate Wiger](http://nateware.com), released under the MIT license.
|
data/lib/icon_links.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# IconLinks
|
2
2
|
require 'active_support/core_ext/module/attribute_accessors'
|
3
|
+
|
3
4
|
module IconLinks
|
4
5
|
# Relative path to the icons
|
5
6
|
mattr_accessor :icon_image_url
|
@@ -28,4 +29,7 @@ module IconLinks
|
|
28
29
|
end
|
29
30
|
end
|
30
31
|
|
31
|
-
|
32
|
+
require 'icon_links/view_helpers'
|
33
|
+
require 'icon_links/method_missing'
|
34
|
+
|
35
|
+
ActionView::Base.send :include, IconLinks if defined?(ActionView::Base)
|
@@ -32,25 +32,25 @@ module IconLinks
|
|
32
32
|
url = send("new_#{meth}_path", options)
|
33
33
|
#options[:rel] = "gb_page_center[600, 500]" # greybox
|
34
34
|
options[:title] ||= "Create a new #{label}"
|
35
|
-
return
|
35
|
+
return link_icon(icon, url, options)
|
36
36
|
|
37
37
|
when 'ajaxnew'
|
38
38
|
url = send("new_#{meth}_path", options)
|
39
39
|
#options[:rel] = "gb_page_center[600, 500]" # greybox
|
40
40
|
options[:title] ||= "Create a new #{label}"
|
41
|
-
return
|
41
|
+
return link_icon(icon, url, options)
|
42
42
|
|
43
43
|
when 'edit'
|
44
44
|
url = send("edit_#{meth}_path", args)
|
45
45
|
#options[:rel] = "gb_page_center[600, 500]" # greybox
|
46
46
|
options[:title] ||= "Edit this #{label}"
|
47
|
-
return
|
47
|
+
return link_icon(icon, url, options)
|
48
48
|
|
49
49
|
when 'delete'
|
50
50
|
url = send("#{meth}_path", args)
|
51
51
|
options[:method] ||= :delete
|
52
52
|
options[:title] ||= "Delete this #{label}"
|
53
|
-
return
|
53
|
+
return link_icon(icon, url, options)
|
54
54
|
|
55
55
|
when 'ajaxdelete'
|
56
56
|
# Delete a record with an id, ala user_path(user)
|
@@ -142,7 +142,7 @@ module IconLinks
|
|
142
142
|
# main index, this does NOT have an id
|
143
143
|
url = send("#{meth}_path", args)
|
144
144
|
options[:title] ||= "View this #{label}"
|
145
|
-
return
|
145
|
+
return link_icon(icon, url, options)
|
146
146
|
else
|
147
147
|
# This generic handler handles all other actions
|
148
148
|
options[:title] ||= "#{type.titleize} this #{label}"
|
@@ -164,7 +164,7 @@ module IconLinks
|
|
164
164
|
options[:url] = url
|
165
165
|
return link_to_remote(icon_tag(icon), options, htmlopt)
|
166
166
|
else
|
167
|
-
return
|
167
|
+
return link_icon(icon, url, options)
|
168
168
|
end
|
169
169
|
end
|
170
170
|
end
|
@@ -174,9 +174,10 @@ module IconLinks
|
|
174
174
|
end
|
175
175
|
|
176
176
|
# Override Rails CDATA JS wrapper because it kills AJAX requests (doh!)
|
177
|
-
module ActionView::Helpers::JavaScriptHelper
|
178
|
-
def javascript_tag(content, html_options = {})
|
179
|
-
content_tag("script", content,
|
180
|
-
html_options.merge(:type => "text/javascript"))
|
181
|
-
end
|
182
|
-
end
|
177
|
+
#module ActionView::Helpers::JavaScriptHelper
|
178
|
+
# def javascript_tag(content, html_options = {})
|
179
|
+
# content_tag("script", content,
|
180
|
+
# html_options.merge(:type => "text/javascript"))
|
181
|
+
# end
|
182
|
+
#end
|
183
|
+
|
@@ -5,7 +5,7 @@ module IconLinks
|
|
5
5
|
|
6
6
|
# This creates a link using the specified type of icon. The args
|
7
7
|
# accepted are the exact same as the args for +link_to+.
|
8
|
-
def
|
8
|
+
def link_icon(text, *args)
|
9
9
|
if args.first.is_a?(Hash)
|
10
10
|
return icon_tag(:clear) unless args[0].delete(:if)
|
11
11
|
end
|
@@ -14,20 +14,20 @@ module IconLinks
|
|
14
14
|
|
15
15
|
# This creates a link using the specified type of icon. The args
|
16
16
|
# accepted are the exact same as the args for +link_to_remote+.
|
17
|
-
def
|
17
|
+
def link_icon_remote(text, *args)
|
18
18
|
if args.first.is_a?(Hash)
|
19
19
|
return icon_tag(:clear) unless args[0].delete(:if)
|
20
20
|
end
|
21
21
|
link_to_remote(icon_for(text), *args)
|
22
22
|
end
|
23
23
|
|
24
|
-
# This is similar to
|
24
|
+
# This is similar to link_icon, only it is designed to call a JS function
|
25
25
|
def function_icon(text, function)
|
26
26
|
link_to(icon_for(text), '#', :onclick => function)
|
27
27
|
end
|
28
28
|
|
29
29
|
# This expands the text and returns the icon path. It is used internally
|
30
|
-
# by +
|
30
|
+
# by +link_icon+ and +link_icon_remote+ to render the link text.
|
31
31
|
def icon_for(text, excess=nil)
|
32
32
|
link = nil
|
33
33
|
if text.is_a? Array
|
@@ -61,7 +61,7 @@ module IconLinks
|
|
61
61
|
}.update(options)
|
62
62
|
end
|
63
63
|
|
64
|
-
# This returns a help link similar to +
|
64
|
+
# This returns a help link similar to +link_icon+, only using the help
|
65
65
|
# from the system_help table. If no help is found, then an empty
|
66
66
|
# string is returned (allowing you to randomly call this on any
|
67
67
|
# object, without having to check if help exists first).
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 0.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Nate Wiger
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-05-
|
17
|
+
date: 2010-05-07 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
version: "2.3"
|
31
31
|
type: :runtime
|
32
32
|
version_requirements: *id001
|
33
|
-
description:
|
33
|
+
description: Easily replace text links with icons in Rails views with handy link_icon helpers.
|
34
34
|
email: nate@wiger.org
|
35
35
|
executables: []
|
36
36
|
|
@@ -78,6 +78,6 @@ rubyforge_project: icon_links
|
|
78
78
|
rubygems_version: 1.3.6
|
79
79
|
signing_key:
|
80
80
|
specification_version: 3
|
81
|
-
summary: Replace
|
81
|
+
summary: Replace text links with icons in Rails views with handy icon_links helpers.
|
82
82
|
test_files: []
|
83
83
|
|