ba-webby-pingback 1.1 → 1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +12 -4
- data/tasks/pingback.rake +42 -16
- data/webby-pingback.gemspec +1 -1
- metadata +2 -2
data/README.textile
CHANGED
@@ -45,13 +45,21 @@ Now you've to install the rake tasks. Do this by either copying the
|
|
45
45
|
pingback.rake file from the gem installation directory or create a new
|
46
46
|
file with this content:
|
47
47
|
|
48
|
-
|
48
|
+
<pre>
|
49
|
+
<code>
|
50
|
+
require 'webby-pingback-rake'
|
49
51
|
|
50
|
-
|
52
|
+
Loquacious.configuration_for(:webby) do
|
53
|
+
desc 'The find attributes to search for new blog posts to ping with the webby-pingback gem'
|
54
|
+
pingback_find [:all, {:blog_post => true, :pingback_done => false}]
|
51
55
|
|
52
|
-
|
56
|
+
desc 'The xpath expression used to find links in your new post to ping with the webby-pingback gem'
|
57
|
+
pingback_find_links_expression '/html/body//a[@href]'
|
58
|
+
end
|
59
|
+
</code>
|
60
|
+
</pre>
|
53
61
|
|
54
|
-
|
62
|
+
Remember to change the configuration options to suit your needs. :)
|
55
63
|
|
56
64
|
You also have to set the @SITE.base@ option in your Sitefile which together with your blog posts gives the task an absolute URL to your post. Without it the sender won't be able to send URLs that the receiver can do a lookup on and your pingbacks will not be received.
|
57
65
|
|
data/tasks/pingback.rake
CHANGED
@@ -1,30 +1,35 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
|
+
require 'webby-pingback'
|
4
|
+
|
3
5
|
Loquacious.configuration_for(:webby) do
|
4
6
|
desc 'The find attributes to search for new blog posts to ping with the webby-pingback gem'
|
5
7
|
pingback_find [:all, {:blog_post => true, :pingback_done => false}]
|
6
|
-
end
|
7
8
|
|
8
|
-
|
9
|
+
desc 'The xpath expression used to find links in your new post to ping with the webby-pingback gem'
|
10
|
+
pingback_find_links_expression '/html/body//a[@href]'
|
11
|
+
end
|
9
12
|
|
10
13
|
namespace :pingback do
|
11
14
|
desc 'Ping all links in all new blogposts which hasn\'t been processed'
|
12
15
|
task :ping do
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end.uniq # /doc
|
16
|
+
urls = Pingback.find_links
|
17
|
+
|
18
|
+
unless urls.empty?
|
19
|
+
urls.each do |page, urls|
|
20
|
+
pinger = Pingback::Sender.new("#{Webby.site.base}#{page.url}", urls)
|
21
|
+
pinger.start
|
22
|
+
Pingback.toggle_trackback_done(page.path)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
-
|
27
|
+
desc 'Print out links to ping next time you send out pings'
|
28
|
+
task :print_outgoing_links do
|
29
|
+
urls = Pingback.find_links
|
30
|
+
urls.each do |page, urls|
|
31
|
+
puts page.url + ':'
|
32
|
+
urls.each {|url| puts "\t#{url}" }
|
28
33
|
end
|
29
34
|
end
|
30
35
|
|
@@ -60,3 +65,24 @@ namespace :pingback do
|
|
60
65
|
end
|
61
66
|
end
|
62
67
|
end
|
68
|
+
|
69
|
+
module Pingback
|
70
|
+
def self.find_links
|
71
|
+
Webby.load_files
|
72
|
+
db = Webby::Resources.pages.find(*Webby.site.pingback_find)
|
73
|
+
output = []
|
74
|
+
db.each do |page|
|
75
|
+
doc = Hpricot(File.read(File.join(Webby.site.output_dir, page.url)))
|
76
|
+
urls = doc.search(Webby.site.pingback_find_links_expression).inject([]) do |memo, a|
|
77
|
+
if a['href'] == ("#{Webby.site.base}/")
|
78
|
+
memo
|
79
|
+
else
|
80
|
+
memo << a['href']
|
81
|
+
end
|
82
|
+
end.uniq # /doc
|
83
|
+
output << [page, urls]
|
84
|
+
end
|
85
|
+
|
86
|
+
output
|
87
|
+
end
|
88
|
+
end
|
data/webby-pingback.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
Gem::Specification.new do |s|
|
3
3
|
s.name = "webby-pingback"
|
4
|
-
s.version = "1.
|
4
|
+
s.version = "1.2"
|
5
5
|
s.date = Time.now.strftime('%Y-%m-%d')
|
6
6
|
s.description = "Using Webby and some custom meta-data tags enable pingbacks to blogs and pages"
|
7
7
|
s.authors = ["Björn Andersson"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ba-webby-pingback
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: "1.
|
4
|
+
version: "1.2"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Bj\xC3\xB6rn Andersson"
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-08-
|
12
|
+
date: 2009-08-26 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|