read_later 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +32 -0
- data/examples/application.rb +31 -0
- data/lib/read_later.rb +65 -0
- data/read_later.gemspec +16 -0
- data/test/test_read_later.rb +8 -0
- metadata +67 -0
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
*Here is an example Sinatra application to get you going:*
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'sinatra'
|
5
|
+
require 'read_later'
|
6
|
+
|
7
|
+
get '/' do
|
8
|
+
read_later = ReadLater.new
|
9
|
+
|
10
|
+
# Application variables
|
11
|
+
# Example URL:
|
12
|
+
# h post_path(@post)
|
13
|
+
url = "http://writing.bryanwoods4e.com/1-poor-poor-child"
|
14
|
+
|
15
|
+
# Example title:
|
16
|
+
# h @post.title
|
17
|
+
title = "Poor, poor child. You have no idea."
|
18
|
+
|
19
|
+
# Can customize the following iframe parameters:
|
20
|
+
# Border, scrolling, width, height, transparency,
|
21
|
+
# And frameborder. For example:
|
22
|
+
read_later.height = 100
|
23
|
+
read_later.transparency = false
|
24
|
+
|
25
|
+
# Create an instance variable for button with required
|
26
|
+
# URL and optional title arguments
|
27
|
+
@instapaper_button = read_later.instapaper_button(url, title)
|
28
|
+
|
29
|
+
# Tell Sinatra to render button in the view:
|
30
|
+
# <%= @instapaper_button %>
|
31
|
+
@instapaper_button
|
32
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'sinatra'
|
3
|
+
require 'read_later'
|
4
|
+
|
5
|
+
get '/' do
|
6
|
+
read_later = ReadLater.new
|
7
|
+
|
8
|
+
# Application variables
|
9
|
+
# Example URL:
|
10
|
+
# h post_path(@post)
|
11
|
+
url = "http://writing.bryanwoods4e.com/1-poor-poor-child"
|
12
|
+
|
13
|
+
# Example title:
|
14
|
+
# h @post.title
|
15
|
+
title = "Poor, poor child. You have no idea."
|
16
|
+
|
17
|
+
# Can customize the following iframe parameters:
|
18
|
+
# Border, scrolling, width, height, transparency,
|
19
|
+
# And frameborder. For example:
|
20
|
+
read_later.height = 100
|
21
|
+
read_later.transparency = false
|
22
|
+
|
23
|
+
# Create an instance variable for button with required
|
24
|
+
# URL and optional title arguments
|
25
|
+
@instapaper_button = read_later.instapaper_button(url, title)
|
26
|
+
|
27
|
+
# Tell Sinatra to render button in the view:
|
28
|
+
# <%= @instapaper_button %>
|
29
|
+
@instapaper_button
|
30
|
+
end
|
31
|
+
|
data/lib/read_later.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
class ReadLater
|
2
|
+
attr_accessor :url,
|
3
|
+
:title,
|
4
|
+
:border,
|
5
|
+
:scrolling,
|
6
|
+
:width,
|
7
|
+
:height,
|
8
|
+
:transparency,
|
9
|
+
:frameborder
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@url = url
|
13
|
+
@title = title
|
14
|
+
@border = border
|
15
|
+
@scrolling = scrolling
|
16
|
+
@width = width
|
17
|
+
@height = height
|
18
|
+
@transparency = transparency
|
19
|
+
@frameborder = frameborder
|
20
|
+
end
|
21
|
+
|
22
|
+
def border
|
23
|
+
@border.nil? ? 0 : @border
|
24
|
+
end
|
25
|
+
|
26
|
+
def scrolling
|
27
|
+
@scrolling.nil? ? "no" : @scrolling
|
28
|
+
end
|
29
|
+
|
30
|
+
def width
|
31
|
+
@width.nil? ? 87 : @width
|
32
|
+
end
|
33
|
+
|
34
|
+
def height
|
35
|
+
@height.nil? ? 17 : @height
|
36
|
+
end
|
37
|
+
|
38
|
+
def transparency
|
39
|
+
@transparency.nil? ? true : @transparency
|
40
|
+
end
|
41
|
+
|
42
|
+
def frameborder
|
43
|
+
@frameborder.nil? ? 0 : @frameborder
|
44
|
+
end
|
45
|
+
|
46
|
+
def instapaper_button(url, title = nil, *args)
|
47
|
+
button = <<-EOF
|
48
|
+
<script type='text/javascript'>
|
49
|
+
//<![CDATA[
|
50
|
+
if ('readlater'.indexOf('readlater') >= 0) {
|
51
|
+
document.write('<iframe border="#{@border}" scrolling="#{scrolling}"' +
|
52
|
+
'width="#{width}" height="#{height}", allowtransparency="#{transparency}"' +
|
53
|
+
'frameborder="#{frameborder}" style="margin-bottom: -3px; z-index: 1338;' +
|
54
|
+
'border: 0px; background-color: transparent; overflow: hidden;"' +
|
55
|
+
'src="http://www.instapaper.com/e2?url=#{url.to_s.gsub("/", "%2f")}' +
|
56
|
+
'&title=#{title}"></iframe>');
|
57
|
+
}
|
58
|
+
//]]>
|
59
|
+
</script>
|
60
|
+
EOF
|
61
|
+
end
|
62
|
+
|
63
|
+
alias_method :read_later_button, :instapaper_button
|
64
|
+
end
|
65
|
+
|
data/read_later.gemspec
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
SPEC = Gem::Specification.new do |s|
|
4
|
+
s.name = "read_later"
|
5
|
+
s.version = "0.1.0"
|
6
|
+
s.author = "Bryan Woods"
|
7
|
+
s.email = "bryanwoods4e@gmail.com"
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.description = "Read Later buttons for Instapaper."
|
10
|
+
s.summary = "Generates a Read Later button from a URL for saving to Instapaper."
|
11
|
+
s.rubyforge_project = "read_later"
|
12
|
+
s.homepage = "http://github.com/bryanwoods/read_later"
|
13
|
+
s.files = Dir.glob("**/*")
|
14
|
+
s.require_path = "lib"
|
15
|
+
s.has_rdoc = false
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: read_later
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Bryan Woods
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-06-16 00:00:00 -04:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: Read Later buttons for Instapaper.
|
22
|
+
email: bryanwoods4e@gmail.com
|
23
|
+
executables: []
|
24
|
+
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files: []
|
28
|
+
|
29
|
+
files:
|
30
|
+
- examples/application.rb
|
31
|
+
- lib/read_later.rb
|
32
|
+
- read_later-0.1.0.gem
|
33
|
+
- read_later.gemspec
|
34
|
+
- README.md
|
35
|
+
- test/test_read_later.rb
|
36
|
+
has_rdoc: true
|
37
|
+
homepage: http://github.com/bryanwoods/read_later
|
38
|
+
licenses: []
|
39
|
+
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
segments:
|
50
|
+
- 0
|
51
|
+
version: "0"
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
segments:
|
57
|
+
- 0
|
58
|
+
version: "0"
|
59
|
+
requirements: []
|
60
|
+
|
61
|
+
rubyforge_project: read_later
|
62
|
+
rubygems_version: 1.3.6
|
63
|
+
signing_key:
|
64
|
+
specification_version: 3
|
65
|
+
summary: Generates a Read Later button from a URL for saving to Instapaper.
|
66
|
+
test_files: []
|
67
|
+
|