ba-webby-pingback 1.0.1 → 1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/README.textile +55 -24
- data/tasks/pingback.rake +6 -1
- data/webby-pingback.gemspec +2 -2
- metadata +3 -2
data/History.txt
ADDED
data/README.textile
CHANGED
@@ -7,69 +7,100 @@ So this gem can send pingbacks and also receive pingbacks through "Disqus":http:
|
|
7
7
|
h2. Usage
|
8
8
|
|
9
9
|
Make sure that all your posts that you want to be able to ping
|
10
|
-
other sites have a meta-data key that is called
|
10
|
+
other sites have a meta-data key that is called _pingback_done_ and
|
11
11
|
set it to false. When the ping has been done, successful or otherwise,
|
12
|
-
it will be set to true.
|
12
|
+
it will be set to true. Example meta-data:
|
13
13
|
|
14
14
|
<pre>
|
15
15
|
<code>
|
16
16
|
---
|
17
17
|
title: a spiffy blogpost
|
18
|
-
|
18
|
+
[..]
|
19
|
+
blog_post: true
|
20
|
+
pingback_done: false
|
19
21
|
---
|
20
22
|
</code>
|
21
23
|
</pre>
|
22
24
|
|
23
|
-
Write your
|
25
|
+
Write your post, deploy and then run:
|
24
26
|
|
25
27
|
@webby pingback:ping@
|
26
28
|
|
27
|
-
*Note:* _You've to deploy because of how the pingback protocol works
|
29
|
+
*Note:* _You've to deploy because of how the pingback protocol works, the receiving end must be able to retrieve the page trying to send it a pingback_
|
28
30
|
|
29
31
|
h2. Installation
|
30
32
|
|
31
|
-
Install it through rubygems:
|
33
|
+
Install it through rubygems:
|
32
34
|
|
33
35
|
@gem install ba-webby-pingback --source http://gems.github.com@
|
34
36
|
|
37
|
+
This library depends on these gems:
|
38
|
+
* @amalgalite@ for SQLite database support
|
39
|
+
* @json@ for parsing received JSON-data from Disqus
|
40
|
+
* @hpricot@ for parsing HTML-sites and finding whether there's a link to your site in the pingback receiver
|
41
|
+
|
35
42
|
h3. Installing the sender
|
36
43
|
|
37
44
|
Now you've to install the rake tasks. Do this by either copying the
|
38
45
|
pingback.rake file from the gem installation directory or create a new
|
39
|
-
file with this content:
|
46
|
+
file with this content:
|
40
47
|
|
41
48
|
@require 'webby-pingback-rake'@
|
42
49
|
|
50
|
+
The sender has an option for finding which posts you want to send pingbacks for, as with any other Webby options you set it in your Sitefile as:
|
51
|
+
|
52
|
+
@SITE.pingback_find = [:all, {:blog_post => true, :pingback_done => false}]@
|
53
|
+
|
54
|
+
The above is the default search parameter and it gets passed into the @Webby::Resources.pages.find@ method directly.
|
55
|
+
|
56
|
+
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
|
+
|
58
|
+
@SITE.base = 'http://example.com/blog'@
|
59
|
+
|
43
60
|
h3. Installing the receiver
|
44
61
|
|
45
62
|
To receive pingbacks you've to run a script that can act as a XML-RPC server, I've written a CGI-script using Rubys built-in XML-RPC package (which also can run it as a standalone server or WEBrick servlet), which can be used with a CGI-script that looks like this: (a copy exists in the _ext_ folder)
|
46
63
|
|
47
64
|
<pre>
|
48
65
|
<code>
|
49
|
-
#!/usr/bin/env ruby
|
50
|
-
# -*- coding: utf-8 -*-
|
51
|
-
$KCODE = 'u'
|
52
|
-
|
53
|
-
module Pingback
|
54
|
-
Conf = {
|
55
|
-
:db => 'path-to-sqlite-datbase-that-is-writable-by-server'
|
56
|
-
:forum_api_key => 'long string from disqus, use rake task to get'
|
57
|
-
}
|
58
|
-
end
|
59
|
-
|
60
|
-
require 'rubygems'
|
61
|
-
require 'webby-pingback-xmlrpc.cgi'
|
66
|
+
#!/usr/bin/env ruby
|
67
|
+
# -*- coding: utf-8 -*-
|
68
|
+
$KCODE = 'u'
|
69
|
+
|
70
|
+
module Pingback
|
71
|
+
Conf = {
|
72
|
+
:db => 'path-to-sqlite-datbase-that-is-writable-by-server'
|
73
|
+
:forum_api_key => 'long string from disqus, use rake task to get'
|
74
|
+
}
|
75
|
+
end
|
76
|
+
|
77
|
+
require 'rubygems'
|
78
|
+
require 'webby-pingback-xmlrpc.cgi'
|
62
79
|
</code>
|
63
80
|
</pre>
|
64
81
|
|
65
|
-
*Note*: _The pingback database, a sqlite database, has to be writable by the server running the cgi-script._
|
82
|
+
*Note*: _The pingback database, a sqlite database, has to be writable by the server running the cgi-script. The database will be created if it doesn't exist, so you don't have to do anything to create it. The database is used to record incoming pingbacks so that we don't send multiple trackbacks to Disqus for the same link._
|
66
83
|
|
67
|
-
To get the Disqus forum api key you can use a rake-task that is included in the
|
84
|
+
To get the Disqus forum api key you can use a rake-task that is included in the rakefile for this gem. Just run:
|
68
85
|
|
69
86
|
@webby pingback:fetch_disqus_forum_key@
|
70
87
|
|
71
|
-
The user key you can get at http://disqus.com/api/get_my_key/ when you're logged in.
|
88
|
+
The user key which the task asks for you can get at http://disqus.com/api/get_my_key/ when you're logged in to Disqus.
|
72
89
|
|
73
90
|
When the CGI-script is setup and is working you only have to add a @<link>@ tag to your blogposts that points to the CGI-script and we're done:
|
74
91
|
|
75
|
-
@<link rel="pingback" href="http://example.com/cgi-bin/pingback-xmlrpc.cgi.rb" />@
|
92
|
+
@<link rel="pingback" href="http://example.com/cgi-bin/pingback-xmlrpc.cgi.rb" />@
|
93
|
+
|
94
|
+
h3. Setting up CGI with Lighttpd
|
95
|
+
|
96
|
+
To get CGI-scripts to work with "ligghttpd":http://lighttpd.net you just have to activate the CGI module and then tell lighty the path to where you store the script, aka the cgi-bin directory.
|
97
|
+
|
98
|
+
Note that the receiver proxy doesn't in any way require webby, so if you have any other static site you can as well use this script to get pingbacks with Disqus. :)
|
99
|
+
|
100
|
+
<pre>
|
101
|
+
<code>
|
102
|
+
server.modules += ("mod_cgi")
|
103
|
+
alias.url += ("cgi-bin" => "/var/www/cgi-bin/")
|
104
|
+
cgi.assign = ("" => "")
|
105
|
+
</code>
|
106
|
+
</pre>
|
data/tasks/pingback.rake
CHANGED
@@ -1,12 +1,17 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
|
+
Loquacious.configuration_for(:webby) do
|
4
|
+
desc 'The find attributes to search for new blog posts to ping with the webby-pingback gem'
|
5
|
+
pingback_find [:all, {:blog_post => true, :pingback_done => false}]
|
6
|
+
end
|
7
|
+
|
3
8
|
require 'webby-pingback'
|
4
9
|
|
5
10
|
namespace :pingback do
|
6
11
|
desc 'Ping all links in all new blogposts which hasn\'t been processed'
|
7
12
|
task :ping do
|
8
13
|
Webby.load_files
|
9
|
-
db = Webby::Resources.pages.find(
|
14
|
+
db = Webby::Resources.pages.find(*Webby.site.pingback_find)
|
10
15
|
db.each do |page|
|
11
16
|
doc = Hpricot(File.read(Webby.site.output_dir + page.url))
|
12
17
|
urls = (doc/'/html/body//a[@href]').inject([]) do |memo, a|
|
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.1"
|
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"]
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.summary = s.description
|
11
11
|
s.require_path = 'lib'
|
12
12
|
s.has_rdoc = false
|
13
|
-
s.files = %w[README.textile tasks/pingback.rake webby-pingback.gemspec ext/pingback.cgi lib/webby-pingback-rake.rb lib/webby-pingback-xmlrpc.cgi.rb lib/webby-pingback.rb]
|
13
|
+
s.files = %w[README.textile History.txt tasks/pingback.rake webby-pingback.gemspec ext/pingback.cgi lib/webby-pingback-rake.rb lib/webby-pingback-xmlrpc.cgi.rb lib/webby-pingback.rb]
|
14
14
|
s.add_dependency('amalgalite', '>= 0.10.2')
|
15
15
|
s.add_dependency('json', '>= 1.1.7')
|
16
16
|
s.add_dependency('hpricot', '>= 0.8.1')
|
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.1"
|
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-25 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -52,6 +52,7 @@ extra_rdoc_files: []
|
|
52
52
|
|
53
53
|
files:
|
54
54
|
- README.textile
|
55
|
+
- History.txt
|
55
56
|
- tasks/pingback.rake
|
56
57
|
- webby-pingback.gemspec
|
57
58
|
- ext/pingback.cgi
|