Index: openacs-4/packages/search/search.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/search/search.info,v
diff -u -r1.18 -r1.19
--- openacs-4/packages/search/search.info 17 May 2004 15:15:26 -0000 1.18
+++ openacs-4/packages/search/search.info 26 Jul 2004 13:04:55 -0000 1.19
@@ -7,7 +7,7 @@
t
f
-
+
OpenACS
2004-04-29
Site wide search
@@ -17,7 +17,7 @@
Site wide search implemented with service contracts, currently
only supports postgres via the OpenFTS driver.
-
+
@@ -27,6 +27,7 @@
+
Index: openacs-4/packages/search/sql/oracle/search-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/search/sql/oracle/search-create.sql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/search/sql/oracle/search-create.sql 2 Jul 2002 01:52:38 -0000 1.1
+++ openacs-4/packages/search/sql/oracle/search-create.sql 26 Jul 2004 13:04:56 -0000 1.2
@@ -1,3 +1,4 @@
@@ search-tables-create.sql
@@ search-packages-create.sql
@@ search-sc-create.sql
+@@ syndication-create.sql
Index: openacs-4/packages/search/sql/oracle/syndication-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/search/sql/oracle/syndication-create.sql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/search/sql/oracle/syndication-create.sql 26 Jul 2004 13:04:56 -0000 1.1
@@ -0,0 +1,15 @@
+create table syndication (
+ object_id integer
+ constraint syndication_object_id_fk
+ references acs_objects (object_id) on delete cascade
+ constraint syndication_pk
+ primary key,
+ last_updated date default sysdate not null,
+ rss_xml_frag blob,
+ body blob,
+ url blob
+);
+
+
+comment on table syndication is 'stores xml fragments for consolidating into rss feeds. Also stores an html version of the content item
+ and it''s url from the link field of the rss';
Index: openacs-4/packages/search/sql/oracle/upgrade/upgrade-5.2.0d2-5.2.0d3.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/search/sql/oracle/upgrade/upgrade-5.2.0d2-5.2.0d3.sql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/search/sql/oracle/upgrade/upgrade-5.2.0d2-5.2.0d3.sql 26 Jul 2004 13:04:56 -0000 1.1
@@ -0,0 +1,3 @@
+-- Create the syndication table
+
+@@ ../syndication-create.sql
Index: openacs-4/packages/search/sql/postgresql/syndication-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/search/sql/postgresql/syndication-create.sql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/search/sql/postgresql/syndication-create.sql 26 Jul 2004 13:04:57 -0000 1.1
@@ -0,0 +1,18 @@
+create table syndication (
+ object_id integer
+ constraint syndication_object_id_fk
+ references acs_objects (object_id) on delete cascade
+ constraint syndication_pk
+ primary key,
+ last_updated timestamptz
+ constraint syndication_last_updated_nn
+ not null
+ default now(),
+ rss_xml_frag text,
+ body text,
+ url text
+);
+
+
+comment on table syndication is 'stores xml fragments for consolidating into rss feeds. Also stores an html version of the content item
+ and it''s url from the link field of the rss';
Index: openacs-4/packages/search/sql/postgresql/upgrade/upgrade-5.2.0d2-5.2.0d3.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/search/sql/postgresql/upgrade/upgrade-5.2.0d2-5.2.0d3.sql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/search/sql/postgresql/upgrade/upgrade-5.2.0d2-5.2.0d3.sql 26 Jul 2004 13:04:57 -0000 1.1
@@ -0,0 +1,3 @@
+-- Create the syndication table
+
+\i ../syndication-create.sql
Index: openacs-4/packages/search/tcl/search-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/search/tcl/search-procs.tcl,v
diff -u -r1.13 -r1.14
--- openacs-4/packages/search/tcl/search-procs.tcl 14 May 2004 10:17:36 -0000 1.13
+++ openacs-4/packages/search/tcl/search-procs.tcl 26 Jul 2004 13:04:58 -0000 1.14
@@ -60,6 +60,8 @@
} {
set driver [ad_parameter -package_id [apm_package_id_from_key search] FtsEngineDriver]
+ set driver [ad_parameter -package_id [apm_package_id_from_key search] Syndicate -default 0]
+
if {[empty_string_p $driver]
|| ! [acs_sc_binding_exists_p FtsEngineDriver $driver]} {
# Nothing to do if no driver
@@ -75,6 +77,9 @@
set object_type [acs_object_type $object_id]
if {[acs_sc_binding_exists_p FtsContentProvider $object_type]} {
array set datasource [acs_sc_call FtsContentProvider datasource [list $object_id] $object_type]
+ if {$syndicate} {
+ search::syndicate -array datasource
+ }
search::content_get txt $datasource(content) $datasource(mime) $datasource(storage_type)
acs_sc_call FtsEngineDriver index [list $datasource(object_id) $txt $datasource(title) $datasource(keywords)] $driver
array unset datasource
@@ -85,6 +90,7 @@
}
DELETE {
acs_sc_call FtsEngineDriver unindex [list $object_id] $driver
+ db_dml nuke_syn {delete from syndication where object_id = :object_id}
# unset seen since you could conceivably delete one but then subsequently
# insert it (eg when rolling back/forward the live revision).
if {[info exists seen($object_id)]} {
@@ -98,6 +104,9 @@
if {[acs_sc_binding_exists_p FtsContentProvider $object_type]} {
array set datasource [acs_sc_call FtsContentProvider datasource [list $object_id] $object_type]
search::content_get txt $datasource(content) $datasource(mime) $datasource(storage_type)
+ if {$syndicate} {
+ search::syndicate -array datasource
+ }
acs_sc_call FtsEngineDriver update_index [list $datasource(object_id) $txt $datasource(title) $datasource(keywords)] $driver
array unset datasource
}
@@ -191,3 +200,45 @@
}
}
+
+ad_proc -private search::syndicate {
+ -datasource
+} {
+ create or replace the record in the syndication table for
+ a given item id.
+
+ called by the search::indexer. See photo-album-search-procs for an example of
+ what you need to provide to make something syndicable.
+
+ JCD: to fix: should not just glue together XML this way, also assumes rss 2.0, no provision for
+ alternate formats, assumes content:encoded will be defined in the wrapper.
+
+} {
+ upvar $datasource d
+
+ if {![info exists d(syndication)]} {
+ return
+ }
+ array set syn $d(syndication)
+
+ set object_id $d(object_id)
+ set url $syn(link)
+ set body $d(content)
+
+ set published [lc_time_fmt $syn(pubDate) "%a, %d %b %Y %H:%M:%S GMT"]
+
+ set rss_xml_frag " -
+ $d(title)
+ $url
+ $syn(guid)
+ $syn(description)
+ $syn(author)
+
+ $syn(category)
+ $published
+
"
+
+ db_dml nuke {delete from syndication where object_id = :object_id}
+ db_dml ins {insert into syndication(object_id, rss_xml_frag, body, url) values (:object_id, :rss_xml_frag, :body, :url)}
+
+}