From: Jeremy Laine Date: Fri, 21 Jul 2006 22:57:22 +0000 (+0000) Subject: add 'scripts' directory X-Git-Url: http://git.polytechnique.org/?p=diogenes.git;a=commitdiff_plain;h=7d7400eafcf18fddfd6df14b7d0a3a1700455ea7 add 'scripts' directory --- diff --git a/Makefile b/Makefile index 42d1278..56009e4 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ LIB_DIST = libdiogenes-$(VERSION) PKG_FILES = AUTHORS ChangeLog COPYING README Makefile \ cvs.pl -PKG_DIRS = config htdocs include locale po plugins styles templates +PKG_DIRS = config htdocs include locale po plugins scripts styles templates LIB_FILES = COPYING LIB_BASE = include/diogenes diff --git a/debian/rules b/debian/rules index f1c4e06..7305ff1 100755 --- a/debian/rules +++ b/debian/rules @@ -33,7 +33,7 @@ binary-install/diogenes:: # PHP files, templates, locales et al. dh_install -X.svn -pdiogenes -Xdiogenes.globals.inc.php.in \ cvs.pl \ - htdocs include locale plugins styles templates \ + htdocs include locale plugins scripts styles templates \ usr/share/diogenes # remove library files diff --git a/scripts/diogenes-importpod.php b/scripts/diogenes-importpod.php new file mode 100755 index 0000000..678efe8 --- /dev/null +++ b/scripts/diogenes-importpod.php @@ -0,0 +1,92 @@ +#!/usr/bin/php +barrel; + + $pid = $barrel->makePath($docdir, $caller); + $page = Diogenes_Barrel_Page::fromDb($barrel, $pid); + if (!$page->props['PID']) { + echo "failed to get Page $pid\n"; + exit(1); + } + + # produce HTML from POD + $pod = realpath($pod); + if (($tmpdir = System::mktemp('-d')) == false) { + $this->kill("Error : could not create temporary directory!"); + } + $content = shell_exec("cd $tmpdir && pod2html --htmlroot=FOODOCBASE --infile=".escapeshellarg($pod)); + $content = str_replace('
', '', $content); + $content = preg_replace('/FOODOCBASE(.*).html/', "/$docbase$1/", $content); + + # extract title + if (preg_match("/(.*)<\/title>/si", $content, $matches)) + { + $page->props['title'] = addslashes($matches[1]); + if ($template) + $page->props['template'] = $template; + $page->toDb(0, $caller); + } + + # strip un-needed info + $rcs = $caller->getRcs(); + $content = $rcs->importHtmlString($content); + if (preg_match("/<h1><a name=\"synopsis\">.*/si", $content, $matches)) + $content = $matches[0]; + + $content = str_replace("h1>", "h2>", $content); + $rcs->commit($pid,$globals->htmlfile,$content,"automatic import"); +} + + +/** Import a set of Perl POD files. + * + * @param $caller + * @param $docarray + * @param $docbase + * @param $template + */ +function importPods(&$caller, $docarray, $docbase, $template = '') +{ + foreach ($docarray as $pod => $docdir) + { + importPod($caller, $pod, $docdir, $docbase, $template); + } +} + + +/** Print program usage and exit. + */ +function usage() +{ + echo "Usage : pod2diogenes.php + exit(1); +} + + +function main() +{ + $alias = "umts_tools"; + $script = new Diogenes_Script($alias, "sharky"); + $podmap = array(); + importPods($script, $docs, "docs", "barrel:pod.tpl"); +} + +main(); +?>