rubymarks 0.1.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/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,62 @@
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
+ Documentation: http://docs.github.com/Floppy/rubymarks/
13
+
14
+ == INSTALLATION
15
+
16
+ 1) Enable gems from gemcutter, if you haven't already done so:
17
+ > sudo gem install gemcutter
18
+ > sudo gem tumble
19
+
20
+ 2) Install gem
21
+ > sudo gem install rubymarks
22
+
23
+ == RAILS PLUGIN
24
+
25
+ This gem can be used as a Rails plugin. You can either extract it into
26
+ vendor/plugins, or use the new-style config.gem command in environment.rb. For
27
+ example:
28
+
29
+ config.gem "Floppy-rubymarks", :lib => "rubymarks", :source => "http://gems.github.com", :version => '>= 0.0.1'
30
+
31
+ == USAGE
32
+
33
+ Once you've done that, you can use bookmark_tag in your views and controllers to
34
+ generate an HTML link tag, or bookmark_url to just generate the URL.
35
+ Examples:
36
+
37
+ bookmark_url :tinyurl, "http://www.google.com"
38
+ bookmark_tag :facebook, "http://www.google.com", :title => "Google"
39
+
40
+ Both functions accepts the following options - not all work with all services.
41
+
42
+ :title - a title for the link (string)
43
+ :text - some explanatory text to go with the link (string)
44
+ :new_window - open the bookmark link in a new window (true or false)
45
+
46
+ Services supported are:
47
+
48
+ :facebook
49
+ :digg
50
+ :delicious
51
+ :stumbleupon
52
+ :twitter
53
+ :reddit
54
+ :windowslive
55
+ :google
56
+ :myaol
57
+ :magnolia
58
+ :technorati
59
+ :newsvine
60
+ :myspace
61
+ :tinyurl
62
+ :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,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: 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 +01: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
+ licenses: []
34
+
35
+ post_install_message:
36
+ rdoc_options: []
37
+
38
+ require_paths:
39
+ - lib
40
+ required_ruby_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: "0"
45
+ version:
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: "0"
51
+ version:
52
+ requirements: []
53
+
54
+ rubyforge_project:
55
+ rubygems_version: 1.3.5
56
+ signing_key:
57
+ specification_version: 3
58
+ summary: A Ruby gem (and Rails plugin) which generates URLs for social bookmarking services
59
+ test_files: []
60
+