Floppy-rubymarks 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/COPYING ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2008 James Smith (james@floppy.org.uk)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,59 @@
1
+ == Rubymarks
2
+
3
+ A Ruby gem (and Rails plugin) which generates links for social bookmarking
4
+ services.
5
+
6
+ Licensed under the MIT license (See COPYING file for details)
7
+
8
+ Author: James Smith (james@floppy.org.uk / http://www.floppy.org.uk)
9
+
10
+ Homepage: http://github.com/Floppy/rubymarks
11
+
12
+ == INSTALLATION
13
+
14
+ 1) Enable gems from github, if you haven't already done so (rubygems >= 1.2):
15
+ > sudo gem sources -a http://gems.github.com
16
+
17
+ 2) Install gem
18
+ > sudo gem install Floppy-rubymarks
19
+
20
+ == RAILS PLUGIN
21
+
22
+ This gem can be used as a Rails plugin. You can either extract it into
23
+ vendor/plugins, or use the new-style config.gem command in environment.rb. For
24
+ example:
25
+
26
+ config.gem "Floppy-rubymarks", :lib => "rubymarks", :source => "http://gems.github.com", :version => '>= 0.0.1'
27
+
28
+ == USAGE
29
+
30
+ Once you've done that, you can use bookmark_tag in your views and controllers to
31
+ generate an HTML link tag, or bookmark_url to just generate the URL.
32
+ Examples:
33
+
34
+ bookmark_url :tinyurl, "http://www.google.com"
35
+ bookmark_tag :facebook, "http://www.google.com", :title => "Google"
36
+
37
+ Both functions accepts the following options - not all work with all services.
38
+
39
+ :title - a title for the link (string)
40
+ :text - some explanatory text to go with the link (string)
41
+ :new_window - open the bookmark link in a new window (true or false)
42
+
43
+ Services supported are:
44
+
45
+ :facebook
46
+ :digg
47
+ :delicious
48
+ :stumbleupon
49
+ :twitter
50
+ :reddit
51
+ :windowslive
52
+ :google
53
+ :myaol
54
+ :magnolia
55
+ :technorati
56
+ :newsvine
57
+ :myspace
58
+ :tinyurl
59
+ :snurl
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require File.dirname(__FILE__) + "/rails/init"
data/lib/rubymarks.rb ADDED
@@ -0,0 +1,21 @@
1
+ require 'rubymarks/services'
2
+
3
+ module Rubymarks
4
+
5
+ def bookmark_url(service, url, options = {})
6
+ service = RUBYMARKS_SERVICES[service]
7
+ url_parts = ["#{service[:url_param]}=#{URI.encode(url)}"]
8
+ url_parts << "#{service[:title_param]}=#{URI.encode(options[:title])}" if options[:title] && service[:title_param]
9
+ url_parts << "#{service[:text_param]}=#{URI.encode(options[:text])}" if options[:text] && service[:text_param]
10
+ service[:base_url] + url_parts.join('&')
11
+ end
12
+
13
+ def bookmark_tag(service, url, options = {})
14
+ "<a href='#{bookmark_url(service, url, options)}'#{" target='new'" if options[:new_window] == true}>#{RUBYMARKS_SERVICES[service][:name]}</a>"
15
+ end
16
+
17
+ def rubymarks_services
18
+ RUBYMARKS_SERVICES
19
+ end
20
+
21
+ end
@@ -0,0 +1,94 @@
1
+ module Rubymarks
2
+
3
+ RUBYMARKS_SERVICES = {
4
+ :facebook => {
5
+ :name => 'Facebook',
6
+ :base_url => 'http://www.facebook.com/share.php?',
7
+ :url_param => 'u'
8
+ },
9
+ :digg => {
10
+ :name => 'Digg',
11
+ :base_url => 'http://digg.com/submit?phase=2&',
12
+ :url_param => 'url',
13
+ :title_param => 'title'
14
+ },
15
+ :delicious => {
16
+ :name => 'Delicious',
17
+ :base_url => 'http://del.icio.us/post?',
18
+ :url_param => 'url',
19
+ :title_param => 'title'
20
+ },
21
+ :stumbleupon => {
22
+ :name => 'StumbleUpon',
23
+ :base_url => 'http://www.stumbleupon.com/submit?',
24
+ :url_param => 'url',
25
+ :title_param => 'title'
26
+ },
27
+ :twitter => {
28
+ :name => 'Twitter',
29
+ :base_url => 'http://twitthis.com/twit?',
30
+ :url_param => 'url',
31
+ :title_param => 'title'
32
+ },
33
+ :reddit => {
34
+ :name => 'Reddit',
35
+ :base_url => 'http://reddit.com/submit',
36
+ :url_param => 'url',
37
+ :title_param => 'title'
38
+ },
39
+ :windowslive => {
40
+ :name => 'Windows Live',
41
+ :base_url => 'https://favorites.live.com/quickadd.aspx?marklet=1&mkt=en-gb&top=0&',
42
+ :url_param => 'url',
43
+ :title_param => 'title'
44
+ },
45
+ :google => {
46
+ :name => 'Google Bookmarks',
47
+ :base_url => 'http://www.google.com/bookmarks/mark?op=edit&output=popup&',
48
+ :url_param => 'bkmk',
49
+ :title_param => 'title'
50
+ },
51
+ :myaol => {
52
+ :name => 'My AOL',
53
+ :base_url => 'http://favorites.my.aol.com/ffclient/AddBookmark?favelet=true&',
54
+ :url_param => 'url',
55
+ :title_param => 'title'
56
+ },
57
+ :magnolia => {
58
+ :name => 'Magnolia',
59
+ :base_url => 'http://ma.gnolia.com/bookmarklet/add?',
60
+ :url_param => 'url',
61
+ :title_param => 'title'
62
+ },
63
+ :technorati => {
64
+ :name => 'Technorati',
65
+ :base_url => 'http://technorati.com/faves?sub=addfavbtn&',
66
+ :url_param => 'add'
67
+ },
68
+ :newsvine => {
69
+ :name => 'Newsvine',
70
+ :base_url => 'http://www.newsvine.com/_tools/seed&save?',
71
+ :url_param => 'u',
72
+ :title_param => 'h'
73
+ },
74
+ :myspace => {
75
+ :name => 'MySpace',
76
+ :base_url => 'http://www.myspace.com/index.cfm?fuseaction=postto&l=1&',
77
+ :url_param => 'u',
78
+ :title_param => 't',
79
+ :text_param => 'c'
80
+ },
81
+ :tinyurl => {
82
+ :name => "TinyURL",
83
+ :base_url => 'http://tinyurl.com/create.php?',
84
+ :url_param => 'url'
85
+ },
86
+ :snurl => {
87
+ :name => "Snurl",
88
+ :base_url => 'http://snipr.com/site/snip?r=simple&',
89
+ :url_param => 'link',
90
+ :title_param => 'title'
91
+ }
92
+ }
93
+
94
+ end
data/rails/init.rb ADDED
@@ -0,0 +1,2 @@
1
+ ActionController::Base.send :include, Rubymarks
2
+ ActionView::Base.send :include, Rubymarks
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: Floppy-rubymarks
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Smith
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-10-02 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: james@floppy.org.uk
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - README
26
+ - COPYING
27
+ - lib/rubymarks.rb
28
+ - lib/rubymarks/services.rb
29
+ - init.rb
30
+ - rails/init.rb
31
+ has_rdoc: true
32
+ homepage: http://github.com/Floppy/rubymarks
33
+ post_install_message:
34
+ rdoc_options: []
35
+
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: "0"
43
+ version:
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: "0"
49
+ version:
50
+ requirements: []
51
+
52
+ rubyforge_project:
53
+ rubygems_version: 1.2.0
54
+ signing_key:
55
+ specification_version: 2
56
+ summary: A Ruby gem (and Rails plugin) which generates URLs for social bookmarking services
57
+ test_files: []
58
+