Index: openacs-4/packages/lars-blogger/sql/postgresql/lars-blogger-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lars-blogger/sql/postgresql/lars-blogger-create.sql,v diff -u -r1.9 -r1.10 --- openacs-4/packages/lars-blogger/sql/postgresql/lars-blogger-create.sql 8 Dec 2003 05:10:23 -0000 1.9 +++ openacs-4/packages/lars-blogger/sql/postgresql/lars-blogger-create.sql 13 Dec 2003 20:02:28 -0000 1.10 @@ -79,6 +79,21 @@ unique (package_id, user_id) ); +-- Add a table for ping URLs i.e. services that use the weblogs.com +-- ping interface. +create table weblogger_ping_urls ( + package_id integer + constraint weblogger_ping_urls_package_id_fk + references apm_packages(package_id) + on delete cascade, + ping_url varchar(500) + constraint weblogger_ping_urls_ping_url_nn + not null, + creation_date timestamptz default now(), + constraint weblogger_ping_urls_pk + primary key(package_id, ping_url) +); + \i lars-blogger-pb.sql \i rss-register.sql Index: openacs-4/packages/lars-blogger/sql/postgresql/upgrade/upgrade-1.0a3-1.0a4.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lars-blogger/sql/postgresql/upgrade/Attic/upgrade-1.0a3-1.0a4.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/lars-blogger/sql/postgresql/upgrade/upgrade-1.0a3-1.0a4.sql 13 Dec 2003 18:03:35 -0000 1.1 +++ openacs-4/packages/lars-blogger/sql/postgresql/upgrade/upgrade-1.0a3-1.0a4.sql 13 Dec 2003 20:02:28 -0000 1.2 @@ -3,7 +3,8 @@ create table weblogger_ping_urls ( package_id integer constraint weblogger_ping_urls_package_id_fk - references apm_packages(package_id), + references apm_packages(package_id) + on delete cascade, ping_url varchar(500) constraint weblogger_ping_urls_ping_url_nn not null, Index: openacs-4/packages/lars-blogger/tcl/weblogs-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lars-blogger/tcl/weblogs-procs.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/lars-blogger/tcl/weblogs-procs.tcl 8 Dec 2003 05:19:49 -0000 1.6 +++ openacs-4/packages/lars-blogger/tcl/weblogs-procs.tcl 13 Dec 2003 20:02:27 -0000 1.7 @@ -6,6 +6,114 @@ @cvs-id $Id$ } +namespace eval lars_blogger::instance {} + +ad_proc -public lars_blogger::instance::add_ping_url { + -package_id + -ping_url:required +} { + Adds a ping URL to a weblogger instance. + + @author Guan Yang +} { + if { ![info exists package_id] } { + set package_id [ad_conn package_id] + } + + db_dml add_ping_url "" +} + +ad_proc -public lars_blogger::instance::remove_ping_url { + -package_id + -ping_url:required +} { + Removes a ping URL from a weblogger instance. + + @author Guan Yang +} { + if { ![info exists package_id] } { + set package_id [ad_conn package_id] + } + + db_dml remove_ping_url "" +} + +ad_proc -public lars_blogger::instance::get_ping_urls { + -package_id +} { + Returns the ping URLs associated with a weblogger instance. + + @author Guan Yang +} { + if { ![info exists package_id] } { + set package_id [ad_conn package_id] + } + + set ping_urls [db_list get_ping_urls ""] + + return $ping_urls +} + +ad_proc -private lars_blogger::instance::send_pings { + -package_id +} { + Send XML-RPC pings to all the URLs that are registered for + the present lars_blogger instance. + + @author Guan Yang (guan@unicast.org) + @author Jerry Asher (jerry@theashergroup.com) + @author Lars Pind (lars@pinds.com) +} { + if { ![info exists package_id] } { + set package_id [ad_conn package_id] + } + + # Should we ping? + set ping_p [parameter::get -boolean \ + -package_id $package_id \ + -parameter "weblogs_update_ping_p" \ + -default 0] + + if { !$ping_p } { + return + } + + set package_url [lars_blog_public_package_url -package_id $package_id] + + set blog_title [lars_blog_name] + set blog_url "[ad_url]$package_url" + + set ping_urls [lars_blogger::instance::get_ping_urls \ + -package_id $package_id] + + set success_p 1 + + ns_log debug "lars_blogger::instance::send_pings:" + foreach ping_url $ping_urls { + ns_log debug "lars_blogger::instance::send_pings: call is \n[list xmlrpc::remote_call $ping_url weblogUpdates.ping -string [ad_quotehtml $blog_title] -string [ad_quotehtml $blog_url]]" + if { [catch {xmlrpc::remote_call $ping_url weblogUpdates.ping -string [ad_quotehtml $blog_title] -string [ad_quotehtml $blog_url] } errmsg ] } { + ns_log warning "lars_blogger::instance::send_pings error: $errmsg" + set success_p 0 + } else { + array set result $errmsg + if { $result(flerror) } { + # got an error + ns_log warning "lars_blogger::instance::send_pings error: $result(message)" + set success_p 0 + } else { + # success + ns_log debug "lars_blogger::instance::send_pings success: $result(message)" + } + } + } + + if { $success_p } { + return 1 + } else { + return -1 + } +} + ad_proc -private lars_blog_weblogs_com_update_ping { {-package_id ""} {-location} @@ -44,10 +152,7 @@ set blog_url "[ad_url]$package_url" ns_log debug "lars_blog_weblogs_com_update_ping:" - if { [catch {xmlrpc::remote_call \ - $location weblogUpdates.ping \ - -string [ad_quotehtml $blog_title] \ - -string [ad_quotehtml $blog_url] } errmsg ] } { + if { [catch {xmlrpc::remote_call -timeout 60 $location weblogUpdates.ping -string [ad_quotehtml $blog_title] -string [ad_quotehtml $blog_url]} errmsg ] } { ns_log warning "lars_blog_weblogs_com_update_ping error: $errmsg" return -1 } else { Index: openacs-4/packages/lars-blogger/www/admin/ping-url-add.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lars-blogger/www/admin/ping-url-add.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/lars-blogger/www/admin/ping-url-add.adp 13 Dec 2003 20:02:28 -0000 1.1 @@ -0,0 +1,5 @@ + +@blog_name@: Add Ping URL +@context;noquote@ + + \ No newline at end of file Index: openacs-4/packages/lars-blogger/www/admin/ping-url-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lars-blogger/www/admin/ping-url-add.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/lars-blogger/www/admin/ping-url-add.tcl 13 Dec 2003 20:02:28 -0000 1.1 @@ -0,0 +1,31 @@ +ad_page_contract { + Add a ping URL. + + @author Guan Yang (guan@unicast.org) + @creation-date 2003-12-13 +} + +set package_id [ad_conn package_id] + +set context [list [list "ping-urls" "Ping URLs"] "Add Ping URL"] + +set blog_name [lars_blog_name] +set default_ping_url [parameter::get -package_id $package_id \ + -parameter "weblogs_ping_url"] + +ad_form -name ping_url_add -form { + {ping_url:text {label "URL"} + {help_text "For example $default_ping_url"} + {html {size 40}}} +} -validate { + {ping_url + {[util_url_valid_p $ping_url]} + "Ping URL must be a valid URL"} +} -on_submit { + + lars_blogger::instance::add_ping_url \ + -package_id $package_id \ + -ping_url $ping_url +} -after_submit { + ad_returnredirect "ping-urls" +} Index: openacs-4/packages/lars-blogger/www/admin/ping-url-remove.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lars-blogger/www/admin/ping-url-remove.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/lars-blogger/www/admin/ping-url-remove.tcl 13 Dec 2003 20:02:28 -0000 1.1 @@ -0,0 +1,18 @@ +ad_page_contract { + Remove a ping URL. + + @author Guan Yang (guan@unicast.org) + @creation-date 2003-12-13 +} { + ping_url:notnull +} + +set package_id [ad_conn package_id] + +catch { + lars_blogger::instance::remove_ping_url \ + -package_id $package_id \ + -ping_url $ping_url +} + +ad_returnredirect "ping-urls" \ No newline at end of file Index: openacs-4/packages/lars-blogger/www/admin/ping-urls.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lars-blogger/www/admin/ping-urls.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/lars-blogger/www/admin/ping-urls.adp 13 Dec 2003 20:02:28 -0000 1.1 @@ -0,0 +1,18 @@ + +@blog_name;noquote@ Ping URLs +@context;noquote@ + +

+ Whenever you update your weblog this server will automatically + contact the listed sites and notify them that your weblog has + changed. Some services, such as + Weblogs.Com or + blo.gs, use this information to + compile lists of recently updated weblogs. Other services, + such as Technorati, + will crawl your weblog shortly after it has been updated. + You can read more + about the ping API. +

+ + \ No newline at end of file Index: openacs-4/packages/lars-blogger/www/admin/ping-urls.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lars-blogger/www/admin/ping-urls.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/lars-blogger/www/admin/ping-urls.tcl 13 Dec 2003 20:02:28 -0000 1.1 @@ -0,0 +1,36 @@ +ad_page_contract { + Set up ping URLs for this blogger instance. + + @author Guan Yang (guan@unicast.org) + @creation-date 2003-12-13 +} + +set package_id [ad_conn package_id] + +set ping_urls [lars_blogger::instance::get_ping_urls -package_id $package_id] + +list::create \ + -name ping_urls \ + -multirow ping_urls \ + -key ping_url \ + -row_pretty_plural "URLs" \ + -actions { + "Add Ping URL" "ping-url-add" "Add another ping-compatible site" + } -elements { + ping_url { + label "Ping URL" + } + remove_url { + label "" + display_template {Remove} + } + } + +set blog_name [lars_blog_name] +set context "Ping URLs" + +multirow create ping_urls ping_url remove_url + +foreach ping_url $ping_urls { + multirow append ping_urls $ping_url "ping-url-remove?[export_vars -url ping_url]" +}