[svn] r5606 - in trunk/tools: . wascii

packagers at lists.rpmforge.net packagers at lists.rpmforge.net
Fri Jul 13 09:04:27 CEST 2007


Author: dag
Date: 2007-07-13 09:04:26 +0200 (Fri, 13 Jul 2007)
New Revision: 5606

Added:
   trunk/tools/wascii/
   trunk/tools/wascii/AUTHORS
   trunk/tools/wascii/ChangeLog
   trunk/tools/wascii/README
   trunk/tools/wascii/TODO
   trunk/tools/wascii/wascii.php
Log:
Initial import of wascii.

Added: trunk/tools/wascii/AUTHORS
===================================================================

Added: trunk/tools/wascii/ChangeLog
===================================================================
--- trunk/tools/wascii/ChangeLog	                        (rev 0)
+++ trunk/tools/wascii/ChangeLog	2007-07-13 07:04:26 UTC (rev 5606)
@@ -0,0 +1,8 @@
+* Thu Jul 12 Dag Wieers <dag at wieers.com>
+- Added Content-Disposition header.
+- Replaced hardcoded /wascii/ by dynamic $apache_alias.
+- Don't use dirname for $apache_alias so it works with /wascii.php.
+
+* Wed Jul 11 Dag Wieers <dag at wieers.com>
+- Create .subversion on the fly.
+- Initial public release.

Added: trunk/tools/wascii/README
===================================================================
--- trunk/tools/wascii/README	                        (rev 0)
+++ trunk/tools/wascii/README	2007-07-13 07:04:26 UTC (rev 5606)
@@ -0,0 +1,7 @@
+wascii - Web frontend for AsciiDoc documentation repository
+
+WAscii is a web frontend intended to display an AsciiDoc documentation
+repository. It allows to search and browse your documentation files and
+automatically converts AsciiDoc to HTML, PDF and ODF documents. It is
+intended to work directly from a subversion repository containing your
+AsciiDoc files.

Added: trunk/tools/wascii/TODO
===================================================================
--- trunk/tools/wascii/TODO	                        (rev 0)
+++ trunk/tools/wascii/TODO	2007-07-13 07:04:26 UTC (rev 5606)
@@ -0,0 +1,12 @@
+### Backend support
++ Allow for other backends like filesystem, git, mercurial, cvs
+
+### Repositories
++ Allow to configure more than one repository (much like viewvc)
+
+### Document support
++ Add support for converting other documents (eg. doc, tex, xls)
++ Add XSL support to change document look to corporate standards
+
+### Main features
++ Search capabilities

Added: trunk/tools/wascii/wascii.php
===================================================================
--- trunk/tools/wascii/wascii.php	                        (rev 0)
+++ trunk/tools/wascii/wascii.php	2007-07-13 07:04:26 UTC (rev 5606)
@@ -0,0 +1,178 @@
+<?php
+### WAscii is a Web frontend for an AsciiDoc documentation repository
+
+### You can define your subversion repository locally, over http or over ssh
+$svn = "file:///srv/svn/shelf/documentation";
+#$svn = "http://protput/shelf/documentation";
+
+### Author information
+$author = "IT Operations";
+$email = "eit at punchtelematix";
+
+ini_set("display_errors", "1");
+#ini_set("display_startup_errors", "1");
+ini_set("html_errors", "0");
+#ini_set("track_errors", "1");
+ini_set("log_errors", "0");
+ini_set("error_reporting", "E_ALL|E_PARSE|E_STRICT");
+error_reporting(E_ALL|E_PARSE|E_STRICT|E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR);
+
+### Apache alias
+$script_name = $_SERVER['SCRIPT_NAME'];
+if (basename($script_name) == "index.php")
+    $script_name = dirname($_SERVER['SCRIPT_NAME']);
+$script_dir = dirname($_SERVER['SCRIPT_NAME']);
+
+### Get information from svn
+function svn_info($svnpath) {
+    $cwd = getcwd();
+    $svninfo = Array();
+    exec("svn --config-dir $cwd/.subversion info $svnpath", $lines);
+    foreach ($lines as $line) {
+        $l = explode(':', $line, 2);
+        if (count($l) >= 2)
+            $svninfo[$l[0]] = $l[1];
+    }
+    return $svninfo;
+}
+
+### Create temporary directory name
+function tempdir($dir, $prefix='', $mode=0700) {
+    if (substr($dir, -1) != '/') $dir .= '/';
+
+    do $path = $dir.$prefix.mt_rand(0, 9999999);
+    while (!mkdir($path, $mode));
+
+    return $path;
+  }
+
+if (empty($_REQUEST['path'])) $_REQUEST['path'] = '';
+if (empty($_REQUEST['to'])) $_REQUEST['to'] = 'html';
+
+### Convert local paths
+$cwd = getcwd();
+$svnbase = strtr($svn, ":/", "--");
+$svnpath = "$cwd/$svnbase";
+
+#mkdir("$cwd/.subversion");
+
+$path = "$svnpath/$_REQUEST[path]";
+
+### Check out from SVN if required
+if (!is_dir($svnpath))
+	system("svn -q --config-dir $cwd/.subversion co $svn $svnpath 2>&1");
+
+if (!is_dir($svnpath))
+    print "<b>Error checking out subversion.</b><br>";
+
+### Update from SVN always
+system("svn -q --config-dir $cwd/.subversion up $path 2>&1");
+
+### Show directory index if directory
+if (is_dir($path)) {
+    $svninfo = svn_info($svnpath);
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<meta name="generator" content="AsciiDoc 8.2.1" />
+<style type="text/css">
+<?php readfile('/usr/share/asciidoc/stylesheets/xhtml11.css')?>
+</style>
+<title>Punch Telematix: Documentation Index</title>
+</head>
+<body>
+<div id="header">
+<h1>Punch Telematix: Documentation Index</h1>
+<span id="author"><?php echo $author?></span><br />
+<span id="email"><tt>&lt;<a href="<?php echo $email?>"><?php echo $email?></a>&gt;</tt></span><br />
+
+<?php
+	print "<div id=\"toc\">\n";
+	print "<div id=\"toctitle\">Table Of Contents ($_REQUEST[path]/)</div>\n";
+	$files = scandir("$path/");
+	foreach ($files as $filename)
+		if ($filename == '.' or $filename == '..' or $filename == '.svn')
+			continue;
+		elseif (is_dir("$path/$filename"))
+			print "<b><a href=\"$script_name?path=$_REQUEST[path]/$filename\">$filename/</a></b><br>\n";
+        elseif (is_file("$path/$filename") and preg_match('/\.txt$/', "$path/$filename")) {
+			print "<a href=\"$script_name?path=$_REQUEST[path]/$filename\">$filename</a>\n";
+			print " <small>(<a href=\"$script_name?path=$_REQUEST[path]/$filename&to=pdf\">PDF</a>)</small>\n";
+			print " <small>(<a href=\"$script_name?path=$_REQUEST[path]/$filename&to=odt\">ODF</a>)</small>\n";
+            if ($filename != $files[count($files)-1])
+                print "<br>\n";
+        } elseif (is_file("$path/$filename") and preg_match('/\.(htm|html|pdf|odt)$/', "$path/$filename")) {
+			print "<a href=\"$script_name?path=$_REQUEST[path]/$filename\">$filename</a><br>\n";
+        }
+#		else
+#			print "$filename<br>\n";
+	print "</div>\n";
+	print "</div>\n";
+?>
+<div id="preamble">
+<div class="sectionbody">
+<p>This is an overview of the documentation that currently resides in the subversion repository located at <a href="<?php echo $svn?>"><?php echo $svn?></a> currently at <b>revision <?php echo $svninfo["Revision"]?></b>.</p>
+</div>
+</div>
+<div id="footer">
+<div id="footer-text">
+Last updated <?php echo $svninfo['Last Changed Date']?>
+</div>
+</div>
+</body>
+</html>
+<?php
+} elseif (is_file($path) and preg_match('/\.txt$/', $path)) {
+    if ($_REQUEST['to'] == 'pdf') {
+        $tempdir = tempdir('/tmp', 'phpdoc');
+        $output = shell_exec("/usr/bin/a2x -f pdf --icons --icons-dir=../icons/ -d article -D $tempdir/ $path 2>&1");
+        $tempbase = basename($path, ".txt").".pdf";
+        $tempfile = "$tempdir/$tempbase";
+        if (is_file($tempfile)) {
+            header("Content-type: application/pdf");
+            header("Content-Disposition: attachment; filename=\"$tempbase\"");
+            readfile($tempfile);
+        } else {
+            print "Error: File could not be converted. Possibly syntax error.<br>\n";
+            print "<pre>$output</pre>";
+        }
+    } elseif ($_REQUEST['to'] == 'odt') {
+        $tempdir = tempdir('/tmp', 'phpdoc');
+        $output = system("/usr/bin/a2x -f odt --icons --icons-dir=../icons/ -d article -D $tempdir/ $path 2>&1");
+        $tempbase = basename($path, ".txt").".odt";
+        $tempfile = "$tempdir/$tempbase";
+        if (is_file($tempfile)) {
+            header("Content-type: application/vnd.oasis.opendocument.text");
+            header("Content-Disposition: attachment; filename=\"$tempbase\"");
+            readfile($tempfile);
+        } else {
+            print "Error: File could not be converted. Possibly syntax error.<br>\n";
+            print "<pre>$output</pre>";
+        }
+    } else {
+    	passthru("asciidoc -b xhtml11 -a toc -a toclevels=2 -a icons -a iconsdir=$script_dir/icons/ -d article -o- $path");
+    }
+} elseif (is_file($path) and preg_match('/\.(htm|html)$/', $path)) {
+	readfile($path);
+} elseif (is_file($path) and preg_match('/\.pdf$/', $path)) {
+    $tempbase = basename($path);
+    header("Content-type: application/pdf");
+    header("Content-Disposition: attachment; filename=\"$tempbase\"");
+    readfile($path);
+} elseif (is_file($path) and preg_match('/\.odt$/', $path)) {
+    $tempbase = basename($path);
+    header("Content-type: application/vnd.oasis.opendocument.text");
+    header("Content-Disposition: attachment; filename=\"$tempbase\"");
+    readfile($path);
+} elseif (is_file($path)) {
+	print "File '$_REQUEST[path]' can not be displayed.";
+} elseif (is_dir($path)) {
+	print "Directory '$_REQUEST[path]/' is missing.";
+} else {
+    print "Unknown error.";
+}
+
+?>




More information about the commits mailing list