summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid A. Madore <david+git@madore.org>2010-03-07 23:51:14 (GMT)
committerDavid A. Madore <david+git@madore.org>2010-03-07 23:51:14 (GMT)
commitf4b8fb5721a3c796faf34944061f6aeb5a28b6e3 (patch)
treefabcfbfed96b9e640ffed1d681b3b7f5c720dc78
parentb8e0d8ef0c8513c18b010218f704df10420d7726 (diff)
downloadblogengine-f4b8fb5721a3c796faf34944061f6aeb5a28b6e3.zip
blogengine-f4b8fb5721a3c796faf34944061f6aeb5a28b6e3.tar.gz
blogengine-f4b8fb5721a3c796faf34944061f6aeb5a28b6e3.tar.bz2
Also keep an XML version of entry title.
-rwxr-xr-xinsert-entries.pl17
-rw-r--r--weblog.sql1
2 files changed, 10 insertions, 8 deletions
diff --git a/insert-entries.pl b/insert-entries.pl
index 427e8da..4a6344a 100755
--- a/insert-entries.pl
+++ b/insert-entries.pl
@@ -95,11 +95,11 @@ $dbh->do("SET TIME ZONE 0");
my ($sth_check, $sth_insert, $sth_update, $sth_clear_cat, $sth_set_cat);
$sth_check = $dbh->prepare("SELECT sha1 FROM entries WHERE id=?");
if ( $obtain_cdates ) {
- $sth_insert = $dbh->prepare("INSERT INTO entries(id,edate,lang,title,content,sha1,cdate) VALUES (?,?,?,?,?,?,?)");
- $sth_update = $dbh->prepare("UPDATE entries SET (edate,mdate,lang,title,content,sha1,cdate)=(?,DEFAULT,?,?,?,?,?) WHERE id=?");
+ $sth_insert = $dbh->prepare("INSERT INTO entries(id,edate,lang,title,title_xml,content,sha1,cdate) VALUES (?,?,?,?,?,?,?,?)");
+ $sth_update = $dbh->prepare("UPDATE entries SET (edate,mdate,lang,title,title_xml,content,sha1,cdate)=(?,DEFAULT,?,?,?,?,?,?) WHERE id=?");
} else {
- $sth_insert = $dbh->prepare("INSERT INTO entries(id,edate,lang,title,content,sha1) VALUES (?,?,?,?,?,?)");
- $sth_update = $dbh->prepare("UPDATE entries SET (edate,mdate,lang,title,content,sha1)=(?,DEFAULT,?,?,?,?) WHERE id=?");
+ $sth_insert = $dbh->prepare("INSERT INTO entries(id,edate,lang,title,title_xml,content,sha1) VALUES (?,?,?,?,?,?,?)");
+ $sth_update = $dbh->prepare("UPDATE entries SET (edate,mdate,lang,title,title_xml,content,sha1)=(?,DEFAULT,?,?,?,?,?) WHERE id=?");
}
$sth_clear_cat = $dbh->prepare("DELETE FROM incat WHERE id=?");
$sth_set_cat = $dbh->prepare("INSERT INTO incat(id,code) VALUES (?,?)");
@@ -131,6 +131,7 @@ foreach my $node ( $entry_list->get_nodelist ) {
next if $exists && ($sth_check->fetchrow_array)[0] eq $sha1;
my $title_node = ($xpc->findnodes("title", $node))[0];
my $title = defined($title_node)?$title_node->textContent:undef;
+ my $title_xml = defined($title_node)?$title_node->serialize:undef;
my $cdate;
if ( $obtain_cdates ) {
if ( $date =~ /^(\d+)-03-32$/ ) {
@@ -143,16 +144,16 @@ foreach my $node ( $entry_list->get_nodelist ) {
if ( $exists ) {
print STDERR "Updating entry $id\n";
if ( $obtain_cdates ) {
- $sth_update->execute($date, $lang, $title, $str, $sha1, $cdate, $id);
+ $sth_update->execute($date, $lang, $title, $title_xml, $str, $sha1, $cdate, $id);
} else {
- $sth_update->execute($date, $lang, $title, $str, $sha1, $id);
+ $sth_update->execute($date, $lang, $title, $title_xml, $str, $sha1, $id);
}
} else {
print STDERR "Registering entry $id\n";
if ( $obtain_cdates ) {
- $sth_insert->execute($id, $date, $lang, $title, $str, $sha1, $cdate);
+ $sth_insert->execute($id, $date, $lang, $title, $title_xml, $str, $sha1, $cdate);
} else {
- $sth_insert->execute($id, $date, $lang, $title, $str, $sha1);
+ $sth_insert->execute($id, $date, $lang, $title, $title_xml, $str, $sha1);
}
}
$sth_clear_cat->execute($id);
diff --git a/weblog.sql b/weblog.sql
index 25f1680..ab4146d 100644
--- a/weblog.sql
+++ b/weblog.sql
@@ -6,6 +6,7 @@ CREATE TABLE entries (
mdate timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP ,
lang text ,
title text ,
+ title_xml xml ,
content xml NOT NULL,
sha1 text NOT NULL
) ;