mirror of https://github.com/tLDP/LDP
database updates for wiki
allow single-document xml requests by doc_id or name
This commit is contained in:
parent
1c925ecabf
commit
ba0f078f1d
|
@ -9,9 +9,42 @@ $dbmain='ldp';
|
|||
$count = 0;
|
||||
$query = new CGI;
|
||||
|
||||
$doc_id_arg = 0;
|
||||
$name_arg = "";
|
||||
$error = 0;
|
||||
|
||||
# load arguments
|
||||
#
|
||||
while (1) {
|
||||
if ($ARGV[0] eq '') {
|
||||
last;
|
||||
}
|
||||
|
||||
if($ARGV[0] eq "-d" or $ARGV[0] eq "--doc-id") {
|
||||
shift(@ARGV);
|
||||
$doc_id_arg = $ARGV[0];
|
||||
shift(@ARGV);
|
||||
} elsif($ARGV[0] eq "-n" or $ARGV[0] eq "--doc-name") {
|
||||
shift(@ARGV);
|
||||
$name_arg = uc($ARGV[0]);
|
||||
shift(@ARGV);
|
||||
} elsif($ARGV[0] eq "-h" or $ARGV[0] eq "--help") {
|
||||
&usage;
|
||||
} else {
|
||||
$error = 1;
|
||||
&usage;
|
||||
}
|
||||
}
|
||||
|
||||
# Connect and load the tuples
|
||||
$conn=Pg::connectdb("dbname=$dbmain");
|
||||
$sql = "SELECT doc_id, title, pub_status_name, class, format, tickle_date, dtd, lr.review_status_name, tr.review_status_name as tech_review_status_name, url, pub_date, last_update, maintained, license, version, abstract, filename FROM document, pub_status, review_status lr, review_status tr WHERE document.pub_status=pub_status.pub_status AND document.review_status = lr.review_status and document.tech_review_status = tr.review_status and document.pub_status='N' ORDER BY doc_id";
|
||||
$sql = "SELECT doc_id, title, pub_status_name, class, format, tickle_date, dtd, lr.review_status_name, tr.review_status_name as tech_review_status_name, url, pub_date, last_update, maintained, license, version, abstract, filename FROM document, pub_status, review_status lr, review_status tr WHERE document.pub_status=pub_status.pub_status AND document.review_status = lr.review_status and document.tech_review_status = tr.review_status and document.pub_status='N'";
|
||||
if ($doc_id_arg) {
|
||||
$sql .= " AND doc_id=$doc_id_arg";
|
||||
} elsif ($name_arg) {
|
||||
$sql .= " AND upper(filename)='$name_arg'";
|
||||
}
|
||||
$sql .= " ORDER BY doc_id";
|
||||
$doc=$conn->exec("$sql");
|
||||
die $conn->errorMessage unless PGRES_TUPLES_OK eq $doc->resultStatus;
|
||||
|
||||
|
@ -190,18 +223,28 @@ while (@row = $doc->fetchrow) {
|
|||
print "</resource>\n";
|
||||
}
|
||||
|
||||
$sql = "SELECT maintainer_id, maintainer_name, email FROM maintainer";
|
||||
$maintainer=$conn->exec("$sql");
|
||||
die $conn->errorMessage unless PGRES_TUPLES_OK eq $maintainer->resultStatus;
|
||||
while (@maintainer_row = $maintainer->fetchrow) {
|
||||
$maintainer_id = $maintainer_row[0];
|
||||
$maintainer_name = $maintainer_row[1];
|
||||
$maintainer_name =~ s/\&/\&\;/;
|
||||
$maintainer_email = $maintainer_row[2];
|
||||
print "<maintainer id='$maintainer_id'>\n";
|
||||
print " <name>$maintainer_name</name>\n";
|
||||
print " <email>$maintainer_email</email>\n";
|
||||
print "</maintainer>\n";
|
||||
unless (($doc_id_arg) or ($name_arg)) {
|
||||
$sql = "SELECT maintainer_id, maintainer_name, email FROM maintainer";
|
||||
$maintainer=$conn->exec("$sql");
|
||||
die $conn->errorMessage unless PGRES_TUPLES_OK eq $maintainer->resultStatus;
|
||||
while (@maintainer_row = $maintainer->fetchrow) {
|
||||
$maintainer_id = $maintainer_row[0];
|
||||
$maintainer_name = $maintainer_row[1];
|
||||
$maintainer_name =~ s/\&/\&\;/;
|
||||
$maintainer_email = $maintainer_row[2];
|
||||
print "<maintainer id='$maintainer_id'>\n";
|
||||
print " <name>$maintainer_name</name>\n";
|
||||
print " <email>$maintainer_email</email>\n";
|
||||
print "</maintainer>\n";
|
||||
}
|
||||
}
|
||||
print "</ldp>\n";
|
||||
|
||||
|
||||
sub usage {
|
||||
print "Usage: xml.pl [-h|-d <doc_id>|-n <doc_name>]\n";
|
||||
print "-h, --help show this usage message.\n";
|
||||
print "-d, --doc-id output one document by id number.\n";
|
||||
print "-n, --doc-name output one document by short name.\n";
|
||||
exit($error);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
These are the scripts for generating, saving, restoring, and managing
|
||||
the LDP Database which is available online at http://db.linuxdoc.org.
|
||||
|
||||
The database stores meta-data on LDP documents.
|
||||
|
||||
It also provides for Wiki-like editing of documents, with full versioning
|
||||
and accountability for changes.
|
||||
|
||||
Security
|
||||
--------
|
||||
|
||||
Anyone may browse and search the database.
|
||||
|
||||
Only registered users can make changes to the database at this time.
|
||||
|
||||
Each user is recorded in the `username' table. If the 'admin' field is True,
|
||||
the user may alter anything in the database. If the 'maintainer_id' field
|
||||
is set to a value, the user may modify any documents which are being actively
|
||||
maintained by that maintainer.
|
||||
|
||||
Admins may add new maintainers and documents.
|
||||
|
||||
Only admins and authors may edit documents, and authors may only edit their
|
||||
own documents.
|
|
@ -14,6 +14,8 @@ psql ldp -f document.sql
|
|||
|
||||
psql ldp -f notes.sql
|
||||
|
||||
psql ldp -f document_wiki.sql
|
||||
|
||||
psql ldp -f document_topic.sql
|
||||
|
||||
psql ldp -f maintainer.sql
|
||||
|
@ -36,6 +38,8 @@ psql ldp -f license.sql
|
|||
|
||||
psql ldp -f volunteer.sql
|
||||
|
||||
psql ldp -f username.sql
|
||||
|
||||
#views
|
||||
psql ldp -f vw_gfdl_emails.sql
|
||||
psql ldp -f vw_gfdl_docs.sql
|
||||
|
|
|
@ -11,8 +11,8 @@ copy document from '/tmp/ldp_document.txt';
|
|||
|
||||
copy notes from '/tmp/ldp_notes.txt';
|
||||
|
||||
copy document_wiki from '/tmp/ldp_document_wiki.txt';
|
||||
copy document_topic from '/tmp/ldp_document_topic.txt';
|
||||
|
||||
copy maintainer from '/tmp/ldp_maintainer.txt';
|
||||
copy maintainer_notes from '/tmp/ldp_maintainer_notes.txt';
|
||||
copy document_maintainer from '/tmp/ldp_document_maintainer.txt';
|
||||
|
@ -31,3 +31,4 @@ copy stats_cdf from '/tmp/ldp_stats_cdf.txt';
|
|||
copy license from '/tmp/ldp_license.txt';
|
||||
|
||||
copy volunteer from '/tmp/ldp_volunteer.txt';
|
||||
copy username from '/tmp/ldp_username.txt';
|
||||
|
|
|
@ -2,6 +2,7 @@ copy audience to '/tmp/ldp_audience.txt';
|
|||
copy class to '/tmp/ldp_class.txt';
|
||||
copy doc_vote to '/tmp/ldp_doc_vote.txt';
|
||||
copy document to '/tmp/ldp_document.txt';
|
||||
copy document_wiki to '/tmp/ldp_document_wiki.txt';
|
||||
copy document_audience to '/tmp/ldp_document_audience.txt';
|
||||
copy document_editor to '/tmp/ldp_document_editor.txt';
|
||||
copy document_maintainer to '/tmp/ldp_document_maintainer.txt';
|
||||
|
@ -22,3 +23,4 @@ copy stats_cdf to '/tmp/ldp_stats_cdf.txt';
|
|||
copy subtopic to '/tmp/ldp_subtopic.txt';
|
||||
copy topic to '/tmp/ldp_topic.txt';
|
||||
copy volunteer to '/tmp/ldp_volunteer.txt';
|
||||
copy username to '/tmp/ldp_username.txt';
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
DROP TABLE username;
|
||||
|
||||
CREATE TABLE username (
|
||||
username TEXT NOT NULL,
|
||||
first_name CHAR(20),
|
||||
surname CHAR(20),
|
||||
maintainer_id INT4,
|
||||
email TEXT,
|
||||
admin BOOLEAN,
|
||||
|
||||
PRIMARY KEY (username)
|
||||
);
|
||||
|
||||
GRANT ALL ON username TO "www-data";
|
||||
GRANT SELECT ON username TO root;
|
||||
|
||||
INSERT INTO username(username, first_name, surname, maintainer_id, email, admin)
|
||||
VALUES ('david', 'David', 'Merrill', 254, 'david@lupercalia.net', 't');
|
Loading…
Reference in New Issue