murlsh 0.5.2 → 0.6.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.textile +1 -0
- data/Rakefile +3 -3
- data/VERSION +1 -1
- data/bin/murlsh +30 -1
- data/config.yaml +2 -1
- data/lib/murlsh/atom_feed.rb +5 -3
- data/lib/murlsh/url.rb +2 -9
- data/lib/murlsh/url_body.rb +1 -1
- data/murlsh.gemspec +21 -20
- data/plugins/{update_feed.rb → add_post_50_update_feed.rb} +3 -2
- data/plugins/add_post_60_notify_hubs.rb +36 -0
- data/plugins/{lookup_content_type_title.rb → add_pre_50_lookup_content_type_title.rb} +1 -1
- data/plugins/{hostrec_redundant.rb → hostrec_50_redundant.rb} +1 -1
- data/plugins/{hostrec_skip.rb → hostrec_60_skip.rb} +1 -1
- data/public/css/screen.css +6 -1
- data/public/js/jquery-1.4.2.min.js +154 -0
- data/public/js/js.js +24 -5
- data/spec/atom_feed_spec.rb +79 -0
- data/spec/auth_spec.rb +35 -0
- data/spec/markup_spec.rb +133 -0
- data/spec/uri_ask_spec.rb +93 -0
- data/spec/uri_spec.rb +16 -0
- data/spec/xhtml_response_spec.rb +112 -0
- metadata +86 -50
- data/public/js/jquery-1.4.min.js +0 -151
- data/test/atom_feed_test.rb +0 -101
- data/test/auth_test.rb +0 -34
- data/test/markup_test.rb +0 -144
- data/test/uri_ask_test.rb +0 -100
- data/test/uri_test.rb +0 -21
- data/test/xhtml_response_test.rb +0 -139
@@ -0,0 +1,93 @@
|
|
1
|
+
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
|
3
|
+
require 'murlsh'
|
4
|
+
|
5
|
+
require 'uri'
|
6
|
+
|
7
|
+
describe Murlsh::UriAsk do
|
8
|
+
|
9
|
+
def asker(s)
|
10
|
+
URI(s).extend(Murlsh::UriAsk)
|
11
|
+
end
|
12
|
+
|
13
|
+
# content type
|
14
|
+
|
15
|
+
def content_type(s, options={})
|
16
|
+
asker(s).content_type(options)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should return an empty string for the content type of an empty string' do
|
20
|
+
content_type('').should be_empty
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should return an empty string for the content type of a URI with an invalid hostname' do
|
24
|
+
content_type('http://a.b/test/').should be_empty
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should return an empty string for the content type of a URI with a nonexistant path' do
|
28
|
+
content_type(
|
29
|
+
'http://matthewm.boedicker.org/does_not_exist/').should be_empty
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should return text/html for the content type of a valid URI that is text/html' do
|
33
|
+
content_type('http://www.google.com/').should match /^text\/html/
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should return text/html for the content type of a valid https URI that is text/html' do
|
37
|
+
content_type('https://msp.f-secure.com/web-test/common/test.html'
|
38
|
+
).should match /^text\/html/
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should return text/html for the content type of a URI that returns HTTP 203' do
|
42
|
+
content_type('http://www.youtube.com/watch?v=Vxq9yj2pVWk'
|
43
|
+
).should match /^text\/html/
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should return an empty string for the content type of an invalid URI when given failproof option true' do
|
47
|
+
content_type('http://x.boedicker.org/', :failproof => true).should be_empty
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should raise a SocketError when getting the content type of an invalid URI when given failproof option false' do
|
51
|
+
lambda { content_type('http://x.boedicker.org/', :failproof => false)
|
52
|
+
}.should raise_error(SocketError)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should limit redirects when getting content type' do
|
56
|
+
content_type('http://matthewm.boedicker.org/redirect_test/'
|
57
|
+
).should == 'text/html'
|
58
|
+
end
|
59
|
+
|
60
|
+
# title
|
61
|
+
|
62
|
+
def title(s, options={})
|
63
|
+
asker(s).title(options)
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should return an empty title for an empty URI' do
|
67
|
+
title('').should be_empty
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'should return the URI as title for an invalid URI' do
|
71
|
+
title('foo').should == 'foo'
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should return the URI as title for a URI with an invalid host' do
|
75
|
+
title('http://28fac7a1ac51976c90016509d97c89ba.edu/'
|
76
|
+
).should == 'http://28fac7a1ac51976c90016509d97c89ba.edu/'
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'should return the page title as title for a valid URI' do
|
80
|
+
title('http://www.google.com/').should == 'Google'
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'should return the URI as title for an invalid URI when the failproof option is true' do
|
84
|
+
title('http://x.boedicker.org/', :failproof => true
|
85
|
+
).should == 'http://x.boedicker.org/'
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'should raise a SocketError when trying to get the title of an invalid URI when given failproof option false' do
|
89
|
+
lambda { title('http://x.boedicker.org/', :failproof => false)
|
90
|
+
}.should raise_error(SocketError)
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
data/spec/uri_spec.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
|
3
|
+
require 'murlsh'
|
4
|
+
|
5
|
+
describe URI do
|
6
|
+
|
7
|
+
it 'should have its domain set to the domain of its URI if it is a valid HTTP URI' do
|
8
|
+
URI('http://foo.com/').domain.should == 'foo.com'
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should have its domain set nil if it is no a valid HTTP URI' do
|
12
|
+
URI('foo').domain.should be_nil
|
13
|
+
URI('http://foo.com.').domain.should be_nil
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
|
3
|
+
require 'murlsh'
|
4
|
+
|
5
|
+
describe Murlsh::XhtmlResponse do
|
6
|
+
Ie_ua = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)'
|
7
|
+
|
8
|
+
Non_ie_ua = 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.10) Gecko/2009042523 Ubuntu/9.04 (jaunty) Firefox/3.0.10'
|
9
|
+
|
10
|
+
def get_content_type(accept, ua)
|
11
|
+
req = Murlsh::XhtmlResponse.new
|
12
|
+
req.set_content_type(accept, ua)
|
13
|
+
req['Content-Type']
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should return application/xhtml+xml when accept is */* and it is not IE' do
|
17
|
+
get_content_type('*/*', Non_ie_ua).should == 'application/xhtml+xml'
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should return text/html when accept is */* and it is IE' do
|
21
|
+
get_content_type('*/*', Ie_ua).should == 'text/html'
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should return application/xhtml+xml when accept is */* and user agent is empty' do
|
25
|
+
get_content_type('*/*', '').should == 'application/xhtml+xml'
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should return application/xhtml+xml when accept is */* and user agent is nil' do
|
29
|
+
get_content_type('*/*', nil).should == 'application/xhtml+xml'
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should return application/xhtml+xml when accept is application/* and it is not IE' do
|
33
|
+
get_content_type('application/*', Non_ie_ua).should == 'application/xhtml+xml'
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should return text/html when accept is application/* and it is IE' do
|
37
|
+
get_content_type('application/*', Ie_ua).should == 'text/html'
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should return application/xhtml+xml when accept is application/* and user agent is empty' do
|
41
|
+
get_content_type('application/*', '').should == 'application/xhtml+xml'
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should return application/xhtml+xml when accept is application/* and user agent is empty' do
|
45
|
+
get_content_type('application/*', nil).should == 'application/xhtml+xml'
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should return application/xhtml+xml when accept is application/xhtml+xml and it is not IE' do
|
49
|
+
get_content_type('application/xhtml+xml', Non_ie_ua).should == 'application/xhtml+xml'
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should return text/html when accept is application/xhtml+xml and it is not IE' do
|
53
|
+
get_content_type('application/xhtml+xml', Ie_ua).should == 'text/html'
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should return application/xhtml+xml when accept is application/xhtml+xml and user agent is empty' do
|
57
|
+
get_content_type('application/xhtml+xml', '').should == 'application/xhtml+xml'
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should return application/xhtml+xml when accept is application/xhtml+xml and user agent is nil' do
|
61
|
+
get_content_type('application/xhtml+xml', nil).should == 'application/xhtml+xml'
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should return text/html when accept is text/html and it is not IE' do
|
65
|
+
get_content_type('text/html', Non_ie_ua).should == 'text/html'
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should return text/html when accept is text/html and it is IE' do
|
69
|
+
get_content_type('text/html', Ie_ua).should == 'text/html'
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should return text/html when accept is text/html and user agent is empty' do
|
73
|
+
get_content_type('text/html', '').should == 'text/html'
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'should return text/html when accept is text/html and user agent is nil' do
|
77
|
+
get_content_type('text/html', nil).should == 'text/html'
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should return text/html when accept is empty and it is not IE' do
|
81
|
+
get_content_type('', Non_ie_ua).should == 'text/html'
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'should return text/html when accept is empty and it is IE' do
|
85
|
+
get_content_type('', Ie_ua).should == 'text/html'
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'should return text/html when accept is empty and user agent is empty' do
|
89
|
+
get_content_type('', '').should == 'text/html'
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'should return text/html when accept is empty and user agent is nil' do
|
93
|
+
get_content_type('', nil).should == 'text/html'
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'should return text/html when accept is nil and it is not IE' do
|
97
|
+
get_content_type(nil, Non_ie_ua).should == 'text/html'
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'should return text/html when accept is nil and it is IE' do
|
101
|
+
get_content_type(nil, Ie_ua).should == 'text/html'
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'should return text/html when accept is nil and user agent is empty' do
|
105
|
+
get_content_type(nil, '').should == 'text/html'
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'should return text/html when accept is nil and user agent is nil' do
|
109
|
+
get_content_type(nil, nil).should == 'text/html'
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: murlsh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 6
|
8
|
+
- 0
|
9
|
+
version: 0.6.0
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Matthew M. Boedicker
|
@@ -9,79 +14,107 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date: 2010-
|
17
|
+
date: 2010-03-10 00:00:00 -05:00
|
13
18
|
default_executable: murlsh
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: activerecord
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - ">="
|
22
26
|
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 2
|
29
|
+
- 3
|
30
|
+
- 4
|
23
31
|
version: 2.3.4
|
24
|
-
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
25
34
|
- !ruby/object:Gem::Dependency
|
26
35
|
name: bcrypt-ruby
|
27
|
-
|
28
|
-
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
38
|
requirements:
|
31
39
|
- - ">="
|
32
40
|
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 2
|
43
|
+
- 1
|
44
|
+
- 2
|
33
45
|
version: 2.1.2
|
34
|
-
|
46
|
+
type: :runtime
|
47
|
+
version_requirements: *id002
|
35
48
|
- !ruby/object:Gem::Dependency
|
36
49
|
name: builder
|
37
|
-
|
38
|
-
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
40
52
|
requirements:
|
41
53
|
- - ">="
|
42
54
|
- !ruby/object:Gem::Version
|
55
|
+
segments:
|
56
|
+
- 2
|
57
|
+
- 1
|
58
|
+
- 2
|
43
59
|
version: 2.1.2
|
44
|
-
|
60
|
+
type: :runtime
|
61
|
+
version_requirements: *id003
|
45
62
|
- !ruby/object:Gem::Dependency
|
46
63
|
name: hpricot
|
47
|
-
|
48
|
-
|
49
|
-
version_requirements: !ruby/object:Gem::Requirement
|
64
|
+
prerelease: false
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
50
66
|
requirements:
|
51
67
|
- - ">="
|
52
68
|
- !ruby/object:Gem::Version
|
69
|
+
segments:
|
70
|
+
- 0
|
71
|
+
- 8
|
72
|
+
- 1
|
53
73
|
version: 0.8.1
|
54
|
-
|
74
|
+
type: :runtime
|
75
|
+
version_requirements: *id004
|
55
76
|
- !ruby/object:Gem::Dependency
|
56
77
|
name: htmlentities
|
57
|
-
|
58
|
-
|
59
|
-
version_requirements: !ruby/object:Gem::Requirement
|
78
|
+
prerelease: false
|
79
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
60
80
|
requirements:
|
61
81
|
- - ">="
|
62
82
|
- !ruby/object:Gem::Version
|
83
|
+
segments:
|
84
|
+
- 4
|
85
|
+
- 2
|
86
|
+
- 0
|
63
87
|
version: 4.2.0
|
64
|
-
|
88
|
+
type: :runtime
|
89
|
+
version_requirements: *id005
|
65
90
|
- !ruby/object:Gem::Dependency
|
66
91
|
name: rack
|
67
|
-
|
68
|
-
|
69
|
-
version_requirements: !ruby/object:Gem::Requirement
|
92
|
+
prerelease: false
|
93
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
70
94
|
requirements:
|
71
95
|
- - ">="
|
72
96
|
- !ruby/object:Gem::Version
|
97
|
+
segments:
|
98
|
+
- 1
|
99
|
+
- 0
|
100
|
+
- 0
|
73
101
|
version: 1.0.0
|
74
|
-
|
102
|
+
type: :runtime
|
103
|
+
version_requirements: *id006
|
75
104
|
- !ruby/object:Gem::Dependency
|
76
105
|
name: sqlite3-ruby
|
77
|
-
|
78
|
-
|
79
|
-
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
prerelease: false
|
107
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
80
108
|
requirements:
|
81
109
|
- - ">="
|
82
110
|
- !ruby/object:Gem::Version
|
111
|
+
segments:
|
112
|
+
- 1
|
113
|
+
- 2
|
114
|
+
- 1
|
83
115
|
version: 1.2.1
|
84
|
-
|
116
|
+
type: :runtime
|
117
|
+
version_requirements: *id007
|
85
118
|
description: url sharing site framework with easy adding, title lookup, atom feed, thumbnails and embedding
|
86
119
|
email: matthewm@boedicker.org
|
87
120
|
executables:
|
@@ -118,23 +151,24 @@ files:
|
|
118
151
|
- lib/murlsh/url_server.rb
|
119
152
|
- lib/murlsh/xhtml_response.rb
|
120
153
|
- murlsh.gemspec
|
121
|
-
- plugins/
|
122
|
-
- plugins/
|
123
|
-
- plugins/
|
124
|
-
- plugins/
|
154
|
+
- plugins/add_post_50_update_feed.rb
|
155
|
+
- plugins/add_post_60_notify_hubs.rb
|
156
|
+
- plugins/add_pre_50_lookup_content_type_title.rb
|
157
|
+
- plugins/hostrec_50_redundant.rb
|
158
|
+
- plugins/hostrec_60_skip.rb
|
125
159
|
- public/css/jquery.jgrowl.css
|
126
160
|
- public/css/screen.css
|
127
|
-
- public/js/jquery-1.4.min.js
|
161
|
+
- public/js/jquery-1.4.2.min.js
|
128
162
|
- public/js/jquery.cookie.js
|
129
163
|
- public/js/jquery.jgrowl_compressed.js
|
130
164
|
- public/js/js.js
|
131
165
|
- public/swf/player_mp3_mini.swf
|
132
|
-
-
|
133
|
-
-
|
134
|
-
-
|
135
|
-
-
|
136
|
-
-
|
137
|
-
-
|
166
|
+
- spec/atom_feed_spec.rb
|
167
|
+
- spec/auth_spec.rb
|
168
|
+
- spec/markup_spec.rb
|
169
|
+
- spec/uri_ask_spec.rb
|
170
|
+
- spec/uri_spec.rb
|
171
|
+
- spec/xhtml_response_spec.rb
|
138
172
|
has_rdoc: true
|
139
173
|
homepage: http://github.com/mmb/murlsh
|
140
174
|
licenses: []
|
@@ -148,25 +182,27 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
148
182
|
requirements:
|
149
183
|
- - ">="
|
150
184
|
- !ruby/object:Gem::Version
|
185
|
+
segments:
|
186
|
+
- 0
|
151
187
|
version: "0"
|
152
|
-
version:
|
153
188
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
189
|
requirements:
|
155
190
|
- - ">="
|
156
191
|
- !ruby/object:Gem::Version
|
192
|
+
segments:
|
193
|
+
- 0
|
157
194
|
version: "0"
|
158
|
-
version:
|
159
195
|
requirements: []
|
160
196
|
|
161
197
|
rubyforge_project:
|
162
|
-
rubygems_version: 1.3.
|
198
|
+
rubygems_version: 1.3.6
|
163
199
|
signing_key:
|
164
200
|
specification_version: 3
|
165
201
|
summary: url sharing site framework
|
166
202
|
test_files:
|
167
|
-
-
|
168
|
-
-
|
169
|
-
-
|
170
|
-
-
|
171
|
-
-
|
172
|
-
-
|
203
|
+
- spec/xhtml_response_spec.rb
|
204
|
+
- spec/atom_feed_spec.rb
|
205
|
+
- spec/auth_spec.rb
|
206
|
+
- spec/uri_ask_spec.rb
|
207
|
+
- spec/markup_spec.rb
|
208
|
+
- spec/uri_spec.rb
|