[Commits] [svn:einsteintoolkit] www/documentation/ThornDoc/ (Rev. 1146)

barry.wardell at gmail.com barry.wardell at gmail.com
Fri Mar 14 10:15:33 CDT 2014


User: barry.wardell
Date: 2014/03/14 10:15 AM

Modified:
 /documentation/ThornDoc/
  docpage.php, index.php

Log:
 Add support for showing thorn documentation as a single HTML file

File Changes:

Directory: /documentation/ThornDoc/
===================================

File [modified]: docpage.php
Delta lines: +23 -10
===================================================================
--- documentation/ThornDoc/docpage.php	2014-03-14 14:47:32 UTC (rev 1145)
+++ documentation/ThornDoc/docpage.php	2014-03-14 15:15:32 UTC (rev 1146)
@@ -1,7 +1,24 @@
 <?php
 $page = $_GET['page']."/documentation.html";
 
-if(! file_exists($page)) {
+function get_page_contents ($filename) {
+  echo '<div style="thorndoc">';
+  $contents = file_get_contents($filename);
+  preg_match('/.*<body[^>]*>(.*)<\/body>.*/sm', $contents, $body);
+  echo preg_replace('/src="documentation([a-z0-9]*)/', 'src="/documentation/ThornDoc/'.dirname($filename).'/documentation$1', $body[1]);
+  echo '</div>';
+  echo '<hr />';
+}
+
+if($page == "All/documentation.html") {
+  $pages = array_merge(glob('*/documentation/html'), glob('*/*/documentation.html'));
+  include_once($_SERVER['DOCUMENT_ROOT'].'/global/header.php');
+  echo '<link rel="stylesheet" type="text/css" href="/global/documentation.css">';
+  foreach ($pages as $thornpage){
+    get_page_contents($thornpage);
+  }
+  include_once($_SERVER['DOCUMENT_ROOT'].'/global/footer.php');
+} elseif (! file_exists($page)) {
   header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
   header("Status: 404 Not Found");
   $_SERVER['REDIRECT_STATUS'] = 404;
@@ -9,15 +26,11 @@
   echo "Error 404: Documentation page for thorn $page does not exist.";
   include_once($_SERVER['DOCUMENT_ROOT'].'/global/footer.php');
   exit();
+} else {
+  include_once($_SERVER['DOCUMENT_ROOT'].'/global/header.php');
+  echo '<link rel="stylesheet" type="text/css" href="/global/documentation.css">';
+  get_page_contents($page);
+  include_once($_SERVER['DOCUMENT_ROOT'].'/global/footer.php');
 }
 
-include_once($_SERVER['DOCUMENT_ROOT'].'/global/header.php');
-echo '<link rel="stylesheet" type="text/css" href="/global/documentation.css">';
-echo '<div style="thorndoc">';
-$contents = file_get_contents($page);
-preg_match('/.*<body[^>]*>(.*)<\/body>.*/sm', $contents, $body);
-echo $body[1];
-echo '</div>';
-include_once($_SERVER['DOCUMENT_ROOT'].'/global/footer.php');
-
 ?>

File [modified]: index.php
Delta lines: +3 -0
===================================================================
--- documentation/ThornDoc/index.php	2014-03-14 14:47:32 UTC (rev 1145)
+++ documentation/ThornDoc/index.php	2014-03-14 15:15:32 UTC (rev 1146)
@@ -17,6 +17,9 @@
 -->
 
 <!-- <gcse:search></gcse:search> -->
+Thorn documentation is available for the individual thorns and arrangements listed below.
+It is alternatively available as a <a href="All/">single HTML file</a>.
+
 <h4>Arrangements</h4>
 
 <?php



More information about the Commits mailing list