mirror of https://github.com/tLDP/LDP
website updates
This commit is contained in:
parent
86f8930d1d
commit
fe5124c46f
|
@ -240,7 +240,7 @@ print "<td colspan=5><textarea name=abstract rows=8 cols=60 style='width:100%' w
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
print "<tr>\n";
|
print "<tr>\n";
|
||||||
print "<th><a href='document_wiki_big.pl?doc_id=$doc_id'>WikiText</a></th>\n";
|
print "<th><a href='document_wiki.pl?doc_id=$doc_id'>WikiText</a></th>\n";
|
||||||
print "<td colspan=4>I am working on ways to provide easy online collaborative editing,
|
print "<td colspan=4>I am working on ways to provide easy online collaborative editing,
|
||||||
and always for new ways to make writing for the LDP easier.
|
and always for new ways to make writing for the LDP easier.
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#! /usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
$workpath = "/tmp";
|
|
||||||
$editcols = 80;
|
$editcols = 80;
|
||||||
$editrows = 25;
|
$editrows = 25;
|
||||||
|
|
||||||
|
@ -10,18 +9,35 @@ use Pg;
|
||||||
$query = new CGI;
|
$query = new CGI;
|
||||||
$dbmain = "ldp";
|
$dbmain = "ldp";
|
||||||
@row;
|
@row;
|
||||||
|
$section_max = 25;
|
||||||
|
|
||||||
# Read parameters
|
# Read parameters
|
||||||
$doc_id = param('doc_id');
|
$doc_id = param('doc_id');
|
||||||
$wiki = param('wiki');
|
|
||||||
$notes = param('notes');
|
$notes = param('notes');
|
||||||
$revision = param('revision');
|
$revision = param('revision');
|
||||||
|
|
||||||
|
$logfile = '/tmp/ldp.log';
|
||||||
|
open (LOG, "> $logfile");
|
||||||
|
print LOG "document_wiki opened by $username.\n";
|
||||||
|
|
||||||
|
|
||||||
|
$section = 0;
|
||||||
|
while ($section <= $section_max) {
|
||||||
|
$section++;
|
||||||
|
$wiki_section = param("wiki$section");
|
||||||
|
if ($wiki_section) {
|
||||||
|
# if ($wiki) {
|
||||||
|
# $wiki .= "\n";
|
||||||
|
# }
|
||||||
|
$wiki .= $wiki_section;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$section = 0;
|
||||||
|
|
||||||
$save = param('Save');
|
$save = param('Save');
|
||||||
$preview = param('Preview');
|
$preview = param('Preview');
|
||||||
$docbook = param('DocBook');
|
$docbook = param('DocBook');
|
||||||
|
$splitup = param('SplitUp');
|
||||||
$username = $query->remote_user();
|
|
||||||
|
|
||||||
$conn=Pg::connectdb("dbname=$dbmain");
|
$conn=Pg::connectdb("dbname=$dbmain");
|
||||||
die $conn->errorMessage unless PGRES_CONNECTION_OK eq $conn->status;
|
die $conn->errorMessage unless PGRES_CONNECTION_OK eq $conn->status;
|
||||||
|
@ -33,13 +49,27 @@ if ($username ne $row[0]) {
|
||||||
print $query->redirect("../newaccount.html");
|
print $query->redirect("../newaccount.html");
|
||||||
exit;
|
exit;
|
||||||
} else {
|
} else {
|
||||||
if (($row[1] ne 't') and ($row[2] != $doc_id)) {
|
if ($row[1] ne 't') {
|
||||||
print $query->redirect("../wrongpermission.html");
|
$maintainer_id = $row[2];
|
||||||
exit;
|
$result=$conn->exec("SELECT count(*) FROM document_maintainer WHERE maintainer_id=$maintainer_id AND doc_id=$doc_id AND active='t'");
|
||||||
|
@row = $result->fetchrow;
|
||||||
|
unless ($row[0]) {
|
||||||
|
print $query->redirect("../wrongpermission.html");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print LOG "Opening document_wiki by $username.\n";
|
||||||
|
|
||||||
if ($save) {
|
if ($save) {
|
||||||
|
print LOG "Saving document_wiki by $username.\n";
|
||||||
|
while ($wiki =~ /\\/) {
|
||||||
|
$wiki =~ s/\\/a1s2d3f4/;
|
||||||
|
}
|
||||||
|
while ($wiki =~ /a1s2d3f4/) {
|
||||||
|
$wiki =~ s/a1s2d3f4/\\\\/;
|
||||||
|
}
|
||||||
while ($wiki =~ /&/) {
|
while ($wiki =~ /&/) {
|
||||||
$wiki =~ s/&/a1s2d3f4/;
|
$wiki =~ s/&/a1s2d3f4/;
|
||||||
}
|
}
|
||||||
|
@ -65,11 +95,20 @@ if ($save) {
|
||||||
@row = $result->fetchrow;
|
@row = $result->fetchrow;
|
||||||
$revisions = $row[0];
|
$revisions = $row[0];
|
||||||
|
|
||||||
|
# &printheader;
|
||||||
|
# print $wiki;
|
||||||
|
# print end_html;
|
||||||
|
# exit;
|
||||||
|
|
||||||
if ($revisions >= $revision ) {
|
if ($revisions >= $revision ) {
|
||||||
&printheader;
|
&printheader;
|
||||||
print "<p>Edit conflict!\n";
|
print "<p>Edit conflict!\n";
|
||||||
print "<p>You were editing version $revisions, but trying to save to version $revision\n";
|
print "<p>You were editing version $revisions, but trying to save to version $revision\n";
|
||||||
print end_html;
|
print end_html;
|
||||||
|
} elsif ($wiki eq '') {
|
||||||
|
&printheader;
|
||||||
|
print "<p>No content to save!\n";
|
||||||
|
print end_html;
|
||||||
} else {
|
} else {
|
||||||
$revision = $revisions + 1;
|
$revision = $revisions + 1;
|
||||||
$sql = "INSERT INTO document_wiki(doc_id, revision, date_entered, wiki, notes, username) VALUES ($doc_id, $revision, now(), '$wiki', '$notes', '$username')";
|
$sql = "INSERT INTO document_wiki(doc_id, revision, date_entered, wiki, notes, username) VALUES ($doc_id, $revision, now(), '$wiki', '$notes', '$username')";
|
||||||
|
@ -96,7 +135,7 @@ die $conn->errorMessage unless PGRES_TUPLES_OK eq $result->resultStatus;
|
||||||
$revisions = $row[0];
|
$revisions = $row[0];
|
||||||
|
|
||||||
#if we're not previewing, load data from database and determine version
|
#if we're not previewing, load data from database and determine version
|
||||||
unless ($preview or $docbook) {
|
unless (($preview) or ($docbook)) {
|
||||||
$result = $conn->exec("SELECT wiki FROM document_wiki WHERE doc_id = $doc_id ORDER BY revision DESC LIMIT 1, 0");
|
$result = $conn->exec("SELECT wiki FROM document_wiki WHERE doc_id = $doc_id ORDER BY revision DESC LIMIT 1, 0");
|
||||||
die $conn->errorMessage unless PGRES_TUPLES_OK eq $result->resultStatus;
|
die $conn->errorMessage unless PGRES_TUPLES_OK eq $result->resultStatus;
|
||||||
@row = $result->fetchrow;
|
@row = $result->fetchrow;
|
||||||
|
@ -111,28 +150,53 @@ unless ($preview or $docbook) {
|
||||||
}
|
}
|
||||||
|
|
||||||
&printheader;
|
&printheader;
|
||||||
|
|
||||||
print "<form method=POST action='document_wiki.pl' name='edit'>\n";
|
print "<form method=POST action='document_wiki.pl' name='edit'>\n";
|
||||||
print "<input type=hidden name=doc_id value='$doc_id'>\n";
|
print "<input type=hidden name=doc_id value='$doc_id'>\n";
|
||||||
print "<input type=hidden name=revision value=$revision>\n";
|
print "<input type=hidden name=revision value=$revision>\n";
|
||||||
|
print "<input type=submit value='Separate Sections' name=SplitUp>\n";
|
||||||
|
print "<input type=submit value='One Section' name=Combine>\n";
|
||||||
|
print "<input type=submit value=Save name=Save>\n";
|
||||||
|
print "<input type=submit value=Preview name=Preview>\n";
|
||||||
|
print "<input type=submit value=DocBook name=DocBook>\n";
|
||||||
print "<table width='100%'>\n";
|
print "<table width='100%'>\n";
|
||||||
print "<tr><th>Document Text</th></tr>\n";
|
print "<tr><th>Document Text</th></tr>\n";
|
||||||
print "<tr><td><textarea name=wiki rows=$editrows cols=$editcols style='width:100%' wrap>$wiki</textarea></td></tr>\n";
|
|
||||||
print "<tr><td>Comments: <input type=text name=notes size=$editcols></input></td></tr>\n";
|
|
||||||
|
$tempfile = "/tmp/document_wiki" . rand();
|
||||||
|
open (TMP, "> $tempfile");
|
||||||
|
print TMP $wiki;
|
||||||
|
close(TMP);
|
||||||
|
|
||||||
|
open (TMP, $tempfile);
|
||||||
|
$wiki = "";
|
||||||
|
$section = 0;
|
||||||
|
while ($line = <TMP>) {
|
||||||
|
if ($splitup) {
|
||||||
|
if ($line =~ /^===/) {
|
||||||
|
} elsif ($line =~ /^==/) {
|
||||||
|
} elsif ($line =~ /^=/) {
|
||||||
|
&printwiki;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$wiki .= $line;
|
||||||
|
}
|
||||||
|
close TMP;
|
||||||
|
unlink $tempfile;
|
||||||
|
&printwiki;
|
||||||
|
print "<tr><td>Comments: <input type=text name=notes size=$editcols style='width:100%' wrap></input></td></tr>\n";
|
||||||
if ($revisions == 0) {
|
if ($revisions == 0) {
|
||||||
print "<tr><td>There are no previous versions of this document. Your changes will be saved as version $revision</td></tr>\n";
|
print "<tr><td>There are no previous versions of this document. Your changes will be saved as version $revision</td></tr>\n";
|
||||||
} else {
|
} else {
|
||||||
print "<tr><td>You are editing version $revisions. Your changes will be saved as version $revision</td></tr>\n";
|
print "<tr><td>You are editing version $revisions. Your changes will be saved as version $revision</td></tr>\n";
|
||||||
}
|
}
|
||||||
print "</table>\n";
|
print "</table>\n";
|
||||||
print "<input type=submit value=Save name=Save>\n";
|
|
||||||
print "<input type=submit value=Preview name=Preview>\n";
|
|
||||||
print "<input type=submit value=DocBook name=DocBook>\n";
|
|
||||||
print "</form>\n";
|
print "</form>\n";
|
||||||
print end_html;
|
print end_html;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($preview or $docbook) {
|
if ($preview or $docbook) {
|
||||||
$txtfile = "$workpath/" . rand . ".txt";
|
$txtfile = "/tmp/" . rand() . ".txt";
|
||||||
$sgmlfile = $txtfile;
|
$sgmlfile = $txtfile;
|
||||||
$sgmlfile =~ s/\.txt/\.sgml/;
|
$sgmlfile =~ s/\.txt/\.sgml/;
|
||||||
$htmlfile = $txtfile;
|
$htmlfile = $txtfile;
|
||||||
|
@ -141,15 +205,16 @@ if ($preview or $docbook) {
|
||||||
$abstractfile =~ s/\./abs\./;
|
$abstractfile =~ s/\./abs\./;
|
||||||
$abstractsgmlfile = $sgmlfile;
|
$abstractsgmlfile = $sgmlfile;
|
||||||
$abstractsgmlfile =~ s/\./abs\./;
|
$abstractsgmlfile =~ s/\./abs\./;
|
||||||
system("rm $sgmlfile");
|
|
||||||
|
|
||||||
open(TXT, "> $txtfile");
|
open(TXT, "> $txtfile");
|
||||||
print TXT $wiki;
|
print TXT $wiki;
|
||||||
close(TXT);
|
close(TXT);
|
||||||
|
|
||||||
$cmd = "/usr/lib/cgi-bin/gldp.org/txt2db.pl -o $sgmlfile $txtfile";
|
$cmd = "/usr/local/bin/wt2db -o $sgmlfile $txtfile";
|
||||||
system($cmd);
|
system($cmd);
|
||||||
|
|
||||||
|
print LOG "Wrote wt file to $txtfile for document $doc_id by $username.\n";
|
||||||
|
|
||||||
$sgml = '<!DOCTYPE ARTICLE PUBLIC "-//OASIS//DTD DocBook V4.1//EN">' . "\n";
|
$sgml = '<!DOCTYPE ARTICLE PUBLIC "-//OASIS//DTD DocBook V4.1//EN">' . "\n";
|
||||||
if ($class eq 'FAQ') {
|
if ($class eq 'FAQ') {
|
||||||
$sgml .= "<article class='FAQ'>\n";
|
$sgml .= "<article class='FAQ'>\n";
|
||||||
|
@ -170,7 +235,7 @@ if ($preview or $docbook) {
|
||||||
print ABSTRACT $abstract;
|
print ABSTRACT $abstract;
|
||||||
close(ABSTRACT);
|
close(ABSTRACT);
|
||||||
|
|
||||||
$cmd = "/usr/lib/cgi-bin/gldp.org/txt2db.pl -o $abstractsgmlfile $abstractfile";
|
$cmd = "/usr/local/bin/wt2db -o $abstractsgmlfile $abstractfile";
|
||||||
system($cmd);
|
system($cmd);
|
||||||
|
|
||||||
$abstract = "";
|
$abstract = "";
|
||||||
|
@ -202,10 +267,15 @@ if ($preview or $docbook) {
|
||||||
|
|
||||||
$sgml .= "</articleinfo>\n";
|
$sgml .= "</articleinfo>\n";
|
||||||
|
|
||||||
|
print LOG "Opening sgml file $sgmlfile for document $doc_id by $username.\n";
|
||||||
|
|
||||||
|
$sgmlfileline = 0;
|
||||||
open(SGML, $sgmlfile);
|
open(SGML, $sgmlfile);
|
||||||
while (<SGML>) {
|
while (<SGML>) {
|
||||||
|
print LOG ".";
|
||||||
$line = $_;
|
$line = $_;
|
||||||
$sgml .= $line;
|
$sgml .= $line;
|
||||||
|
$sgmlfileline++;
|
||||||
while ($line =~ /</) {
|
while ($line =~ /</) {
|
||||||
$line =~ s/</</;
|
$line =~ s/</</;
|
||||||
}
|
}
|
||||||
|
@ -215,12 +285,18 @@ if ($preview or $docbook) {
|
||||||
$buf .= "<br>$line";
|
$buf .= "<br>$line";
|
||||||
}
|
}
|
||||||
close(SGML);
|
close(SGML);
|
||||||
|
print LOG "\n";
|
||||||
|
|
||||||
|
print LOG "Read $sgmlfileline lines from $sgmlfile for document $doc_id by $username.\n";
|
||||||
|
|
||||||
$sgml .= "</article>\n";
|
$sgml .= "</article>\n";
|
||||||
|
|
||||||
open(SGML, "> $sgmlfile");
|
open(SGML, "> $sgmlfile");
|
||||||
print SGML $sgml;
|
print SGML $sgml;
|
||||||
close(SGML);
|
close(SGML);
|
||||||
|
|
||||||
|
print LOG "Wrote composite sgml file $sgmlfile for document $doc_id by $username.\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($docbook) {
|
if ($docbook) {
|
||||||
|
@ -230,19 +306,23 @@ if ($docbook) {
|
||||||
|
|
||||||
print "Content-Type: text/plain; charset=ISO-8859-1\n\n";
|
print "Content-Type: text/plain; charset=ISO-8859-1\n\n";
|
||||||
|
|
||||||
while ($sgml =~ /\</) {
|
# while ($sgml =~ /</) {
|
||||||
$sgml =~ s/\</</;
|
# $sgml =~ s/</</;
|
||||||
}
|
# }
|
||||||
while ($sgml =~ /\>/) {
|
# while ($sgml =~ />/) {
|
||||||
$sgml =~ s/\>/>/;
|
# $sgml =~ s/>/>/;
|
||||||
}
|
# }
|
||||||
print $sgml;
|
print $sgml;
|
||||||
# print "</pre>\n";
|
# print "</pre>\n";
|
||||||
# print "</html>\n";
|
# print "</html>\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($preview) {
|
if ($preview) {
|
||||||
|
|
||||||
|
print LOG "Previewing $sgmlfile for document $doc_id by $username.\n";
|
||||||
|
|
||||||
|
print LOG "Running xsltproc on $sgmlfile, into $htmlfile.\n";
|
||||||
|
|
||||||
$cmd = "xsltproc --docbook /usr/share/sgml/docbook/stylesheet/xsl/nwalsh/html/docbook.xsl $sgmlfile > $htmlfile";
|
$cmd = "xsltproc --docbook /usr/share/sgml/docbook/stylesheet/xsl/nwalsh/html/docbook.xsl $sgmlfile > $htmlfile";
|
||||||
system($cmd);
|
system($cmd);
|
||||||
|
|
||||||
|
@ -252,11 +332,12 @@ if ($preview) {
|
||||||
while (<HTML>) {
|
while (<HTML>) {
|
||||||
$line = $_;
|
$line = $_;
|
||||||
$i += 1;
|
$i += 1;
|
||||||
# if ($i > 8) {
|
print $line;
|
||||||
print $line;
|
|
||||||
# }
|
|
||||||
}
|
}
|
||||||
close(HTML);
|
close(HTML);
|
||||||
|
|
||||||
|
print LOG "HTML display of $htmlfile complete.\n";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,3 +358,18 @@ sub printheader {
|
||||||
print " | ";
|
print " | ";
|
||||||
print "<a href='document_wiki_list.pl?doc_id=$doc_id'>Version History</a>\n";
|
print "<a href='document_wiki_list.pl?doc_id=$doc_id'>Version History</a>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub printwiki {
|
||||||
|
if (($wiki) or ($section == 0)) {
|
||||||
|
$section++;
|
||||||
|
print "<tr><td align='center'>Section $section</td></tr>\n";
|
||||||
|
print "<tr><td><textarea name=wiki$section rows=$editrows cols=$editcols style='width:100%' wrap>$wiki</textarea></td></tr>\n";
|
||||||
|
if ($section == $section_max) {
|
||||||
|
print "Aborting due to loop control.\n";
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
$wiki = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
#
|
||||||
|
# Generates a navigation bar suitable for display across the top or bottom of a page.
|
||||||
|
#
|
||||||
use CGI qw(:standard);
|
use CGI qw(:standard);
|
||||||
use Pg;
|
use Pg;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue