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 CHANGED
@@ -9,6 +9,7 @@ Simple site for a small group of people to share or archive urls.
9
9
  * looks good on iPhone
10
10
  * rack interface
11
11
  * plug-in interface
12
+ * PubSubHubbub notification
12
13
 
13
14
  See "http://urls.matthewm.boedicker.org/":http://urls.matthewm.boedicker.org/ for example.
14
15
 
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ yaml
11
11
  rubygems
12
12
 
13
13
  flog
14
- rake/testtask
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::TestTask.new do |t|
98
- t.pattern = 'test/*_test.rb'
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.5.2
1
+ 0.6.0
data/bin/murlsh CHANGED
@@ -2,7 +2,36 @@
2
2
 
3
3
  require 'fileutils'
4
4
 
5
- FileUtils.cp_r(
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
@@ -13,7 +13,8 @@ css_files:
13
13
  - css/jquery.jgrowl.css
14
14
  - css/screen.css
15
15
  js_files:
16
- - js/jquery-1.4.min.js
16
+ - js/jquery-1.4.2.min.js
17
17
  - js/jquery.cookie.js
18
18
  - js/jquery.jgrowl_compressed.js
19
19
  - js/js.js
20
+ pubsubhubbub_hubs: []
@@ -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' }.merge(options)
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
- begin
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 = begin; URI(url).domain; rescue Exception; end
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?
@@ -57,7 +57,7 @@ module Murlsh
57
57
  a(mu.title_stripped, :href => mu.url)
58
58
 
59
59
  mu.hostrec do |hostrec|
60
- self.sub(" [#{hostrec}]", :class => 'host')
60
+ self.span(" [#{hostrec}]", :class => 'host')
61
61
  end
62
62
  mu.viarec do |via|
63
63
  span(:class => 'via') {
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.5.2"
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-01-17}
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/hostrec_redundant.rb",
49
- "plugins/hostrec_skip.rb",
50
- "plugins/lookup_content_type_title.rb",
51
- "plugins/update_feed.rb",
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
- "test/atom_feed_test.rb",
60
- "test/auth_test.rb",
61
- "test/markup_test.rb",
62
- "test/uri_ask_test.rb",
63
- "test/uri_test.rb",
64
- "test/xhtml_response_test.rb"
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.5}
70
+ s.rubygems_version = %q{1.3.6}
70
71
  s.summary = %q{url sharing site framework}
71
72
  s.test_files = [
72
- "test/xhtml_response_test.rb",
73
- "test/uri_ask_test.rb",
74
- "test/markup_test.rb",
75
- "test/uri_test.rb",
76
- "test/atom_feed_test.rb",
77
- "test/auth_test.rb"
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 UpdateFeed < Plugin
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
@@ -3,7 +3,7 @@ require 'murlsh'
3
3
  module Murlsh
4
4
 
5
5
  # try to fetch the content type and title of a url
6
- class LookupContentTypeTitle < Plugin
6
+ class AddPre50LookupContentTypeTitle < Plugin
7
7
 
8
8
  Hook = 'add_pre'
9
9
 
@@ -1,7 +1,7 @@
1
1
  module Murlsh
2
2
 
3
3
  # skip showing host record if domain is contained in title
4
- class HostrecRedundant < Plugin
4
+ class Hostrec50Redundant < Plugin
5
5
 
6
6
  Hook = 'hostrec'
7
7
 
@@ -1,7 +1,7 @@
1
1
  module Murlsh
2
2
 
3
3
  # skip showing host record for some domains
4
- class HostrecSkip < Plugin
4
+ class Hostrec60Skip < Plugin
5
5
 
6
6
  Hook = 'hostrec'
7
7
 
@@ -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
- sub.host {
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 {