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
data/README.textile
CHANGED
data/Rakefile
CHANGED
@@ -11,7 +11,7 @@ yaml
|
|
11
11
|
rubygems
|
12
12
|
|
13
13
|
flog
|
14
|
-
rake/
|
14
|
+
spec/rake/spectask
|
15
15
|
sqlite3
|
16
16
|
|
17
17
|
murlsh
|
@@ -94,8 +94,8 @@ task :flog do
|
|
94
94
|
end
|
95
95
|
|
96
96
|
desc "Run test suite."
|
97
|
-
Rake::
|
98
|
-
t.
|
97
|
+
Spec::Rake::SpecTask.new('test') do |t|
|
98
|
+
t.spec_files = FileList['spec/*_spec.rb']
|
99
99
|
t.verbose = true
|
100
100
|
t.warning = true
|
101
101
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.0
|
data/bin/murlsh
CHANGED
@@ -2,7 +2,36 @@
|
|
2
2
|
|
3
3
|
require 'fileutils'
|
4
4
|
|
5
|
-
|
5
|
+
def ask(prompt, default)
|
6
|
+
print "#{prompt} [#{default}] "
|
7
|
+
answer = gets.strip
|
8
|
+
answer = default if answer.empty?
|
9
|
+
answer
|
10
|
+
end
|
11
|
+
|
12
|
+
def cp_r_safe(sources, dest, options)
|
13
|
+
sources.each do |source|
|
14
|
+
new = File.join(dest, File.split(File.expand_path(source)).last)
|
15
|
+
|
16
|
+
if File.directory?(source)
|
17
|
+
FileUtils.mkdir_p(new, options)
|
18
|
+
cp_r_safe(Dir.foreach(source).
|
19
|
+
reject { |f| %w{. ..}.include?(f) }.
|
20
|
+
collect { |f| File.join(source, f) }, new, options)
|
21
|
+
else
|
22
|
+
answer = if File.exists?(new)
|
23
|
+
ask("#{new} exists. Overwrite?", 'n')
|
24
|
+
else
|
25
|
+
'y'
|
26
|
+
end
|
27
|
+
|
28
|
+
FileUtils.copy(source, new, options) if answer == 'y'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
cp_r_safe(
|
6
35
|
%w{.htaccess config.ru config.yaml plugins/ public/ Rakefile}.collect { |x|
|
7
36
|
File.join(File.dirname(__FILE__), '..', x) }, '.', :verbose => true)
|
8
37
|
|
data/config.yaml
CHANGED
data/lib/murlsh/atom_feed.rb
CHANGED
@@ -16,10 +16,12 @@ module Murlsh
|
|
16
16
|
def initialize(root_url, options={})
|
17
17
|
options = {
|
18
18
|
:filename => 'atom.xml',
|
19
|
-
:title => 'Atom feed'
|
19
|
+
:title => 'Atom feed',
|
20
|
+
:hubs => []}.merge(options)
|
20
21
|
@root_url = root_url
|
21
22
|
@filename = options[:filename]
|
22
23
|
@title = options[:title]
|
24
|
+
@hubs = options[:hubs]
|
23
25
|
|
24
26
|
root_uri = URI(@root_url)
|
25
27
|
|
@@ -40,6 +42,7 @@ module Murlsh
|
|
40
42
|
xm.feed(:xmlns => 'http://www.w3.org/2005/Atom') {
|
41
43
|
xm.id(@root_url)
|
42
44
|
xm.link(:href => URI.join(@root_url, @filename), :rel => 'self')
|
45
|
+
@hubs.each { |hub| xm.link(:href => hub, :rel => 'hub') }
|
43
46
|
xm.title(@title)
|
44
47
|
xm.updated(entries.collect { |mu| mu.time }.max.xmlschema)
|
45
48
|
entries.each do |mu|
|
@@ -69,10 +72,9 @@ module Murlsh
|
|
69
72
|
end
|
70
73
|
|
71
74
|
def via(xm, mu)
|
72
|
-
|
75
|
+
Murlsh::failproof do
|
73
76
|
xm.link(:rel => 'via', :type => 'text/html', :href => mu.via,
|
74
77
|
:title => URI(mu.via).domain) if mu.via
|
75
|
-
rescue Exception
|
76
78
|
end
|
77
79
|
end
|
78
80
|
|
data/lib/murlsh/url.rb
CHANGED
@@ -25,7 +25,7 @@ module Murlsh
|
|
25
25
|
|
26
26
|
# Return text showing what domain a link goes to.
|
27
27
|
def hostrec
|
28
|
-
domain =
|
28
|
+
domain = Murlsh::failproof { URI(url).domain }
|
29
29
|
|
30
30
|
domain = Murlsh::Plugin.hooks('hostrec').inject(domain) {
|
31
31
|
|result,plugin| plugin.run(result, url, title) }
|
@@ -34,14 +34,7 @@ module Murlsh
|
|
34
34
|
end
|
35
35
|
|
36
36
|
# Yield the url that the url came from.
|
37
|
-
def viarec
|
38
|
-
if via
|
39
|
-
begin
|
40
|
-
yield URI(via)
|
41
|
-
rescue Exception
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
37
|
+
def viarec; Murlsh::failproof { yield URI(via) } if via; end
|
45
38
|
|
46
39
|
# Return true if this url is an image.
|
47
40
|
def is_image?
|
data/lib/murlsh/url_body.rb
CHANGED
data/murlsh.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{murlsh}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.6.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Matthew M. Boedicker"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-03-10}
|
13
13
|
s.default_executable = %q{murlsh}
|
14
14
|
s.description = %q{url sharing site framework with easy adding, title lookup, atom feed, thumbnails and embedding}
|
15
15
|
s.email = %q{matthewm@boedicker.org}
|
@@ -45,36 +45,37 @@ Gem::Specification.new do |s|
|
|
45
45
|
"lib/murlsh/url_server.rb",
|
46
46
|
"lib/murlsh/xhtml_response.rb",
|
47
47
|
"murlsh.gemspec",
|
48
|
-
"plugins/
|
49
|
-
"plugins/
|
50
|
-
"plugins/
|
51
|
-
"plugins/
|
48
|
+
"plugins/add_post_50_update_feed.rb",
|
49
|
+
"plugins/add_post_60_notify_hubs.rb",
|
50
|
+
"plugins/add_pre_50_lookup_content_type_title.rb",
|
51
|
+
"plugins/hostrec_50_redundant.rb",
|
52
|
+
"plugins/hostrec_60_skip.rb",
|
52
53
|
"public/css/jquery.jgrowl.css",
|
53
54
|
"public/css/screen.css",
|
54
|
-
"public/js/jquery-1.4.min.js",
|
55
|
+
"public/js/jquery-1.4.2.min.js",
|
55
56
|
"public/js/jquery.cookie.js",
|
56
57
|
"public/js/jquery.jgrowl_compressed.js",
|
57
58
|
"public/js/js.js",
|
58
59
|
"public/swf/player_mp3_mini.swf",
|
59
|
-
"
|
60
|
-
"
|
61
|
-
"
|
62
|
-
"
|
63
|
-
"
|
64
|
-
"
|
60
|
+
"spec/atom_feed_spec.rb",
|
61
|
+
"spec/auth_spec.rb",
|
62
|
+
"spec/markup_spec.rb",
|
63
|
+
"spec/uri_ask_spec.rb",
|
64
|
+
"spec/uri_spec.rb",
|
65
|
+
"spec/xhtml_response_spec.rb"
|
65
66
|
]
|
66
67
|
s.homepage = %q{http://github.com/mmb/murlsh}
|
67
68
|
s.rdoc_options = ["--charset=UTF-8"]
|
68
69
|
s.require_paths = ["lib"]
|
69
|
-
s.rubygems_version = %q{1.3.
|
70
|
+
s.rubygems_version = %q{1.3.6}
|
70
71
|
s.summary = %q{url sharing site framework}
|
71
72
|
s.test_files = [
|
72
|
-
"
|
73
|
-
"
|
74
|
-
"
|
75
|
-
"
|
76
|
-
"
|
77
|
-
"
|
73
|
+
"spec/xhtml_response_spec.rb",
|
74
|
+
"spec/atom_feed_spec.rb",
|
75
|
+
"spec/auth_spec.rb",
|
76
|
+
"spec/uri_ask_spec.rb",
|
77
|
+
"spec/markup_spec.rb",
|
78
|
+
"spec/uri_spec.rb"
|
78
79
|
]
|
79
80
|
|
80
81
|
if s.respond_to? :specification_version then
|
@@ -3,7 +3,7 @@ require 'murlsh'
|
|
3
3
|
module Murlsh
|
4
4
|
|
5
5
|
# regenerate atom feed after a new url has been added
|
6
|
-
class
|
6
|
+
class AddPost50UpdateFeed < Plugin
|
7
7
|
|
8
8
|
Hook = 'add_post'
|
9
9
|
|
@@ -13,7 +13,8 @@ module Murlsh
|
|
13
13
|
|
14
14
|
feed = Murlsh::AtomFeed.new(config.fetch('root_url'),
|
15
15
|
:filename => config.fetch('feed_file'),
|
16
|
-
:title => config.fetch('page_title', '')
|
16
|
+
:title => config.fetch('page_title', ''),
|
17
|
+
:hubs => config.fetch('pubsubhubbub_hubs', []).collect { |x| x['subscribe_url'] } )
|
17
18
|
|
18
19
|
feed.write(latest, config.fetch('feed_file'))
|
19
20
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'murlsh'
|
2
|
+
|
3
|
+
module Murlsh
|
4
|
+
|
5
|
+
# notify PubSubHubbub hubs that feed has been updated
|
6
|
+
class AddPost60NotifyHubs < Plugin
|
7
|
+
|
8
|
+
Hook = 'add_post'
|
9
|
+
|
10
|
+
def self.run(config)
|
11
|
+
hubs = config.fetch('pubsubhubbub_hubs', [])
|
12
|
+
|
13
|
+
unless hubs.empty?
|
14
|
+
require 'rubygems'
|
15
|
+
require 'eventmachine'
|
16
|
+
require 'pubsubhubbub'
|
17
|
+
|
18
|
+
feed_url = URI.join(config['root_url'], config['feed_file'])
|
19
|
+
|
20
|
+
hubs.each do |hub|
|
21
|
+
EventMachine.run {
|
22
|
+
pub = EventMachine::PubSubHubbub.new(hub['publish_url']).publish(
|
23
|
+
feed_url)
|
24
|
+
|
25
|
+
pub.callback { EventMachine.stop }
|
26
|
+
pub.errback { EventMachine.stop }
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
data/public/css/screen.css
CHANGED
@@ -49,9 +49,12 @@ div.name {
|
|
49
49
|
img.thumb, li object {
|
50
50
|
float : left;
|
51
51
|
margin-right : 10px;
|
52
|
+
border : 1px solid #808080;
|
53
|
+
-moz-border-radius : 5px;
|
54
|
+
-webkit-border-radius : 5px;
|
52
55
|
}
|
53
56
|
|
54
|
-
|
57
|
+
span.host {
|
55
58
|
color : #808080;
|
56
59
|
font-family : monospace;
|
57
60
|
}
|
@@ -113,6 +116,8 @@ div.jGrowl div.jGrowl-closer {
|
|
113
116
|
body {
|
114
117
|
margin : 0;
|
115
118
|
padding : 0;
|
119
|
+
font-size : 1.25em;
|
120
|
+
line-height : 1.875em;
|
116
121
|
}
|
117
122
|
|
118
123
|
#urls {
|