Boost logo

Boost-Commit :

From: grafikrobot_at_[hidden]
Date: 2007-12-17 13:10:50


Author: grafik
Date: 2007-12-17 13:10:49 EST (Mon, 17 Dec 2007)
New Revision: 42128
URL: http://svn.boost.org/trac/boost/changeset/42128

Log:
Add 'simple' format for archive files to allow for almost raw pages while still rewriting self links.
Added:
   website/public_html/beta/common/code/boost_archive.php
      - copied, changed from r42126, /website/public_html/beta/common/code/archive_file.php
Removed:
   website/public_html/beta/common/code/archive_file.php
Text files modified:
   website/public_html/beta/common/code/boost_archive.php | 24 +++++++++++++++++++++---
   website/public_html/beta/development/testing_results.php | 2 +-
   website/public_html/beta/doc/display_build.php | 6 +++---
   website/public_html/beta/doc/display_jam.php | 4 ++--
   website/public_html/beta/doc/display_libs.php | 10 +++++-----
   5 files changed, 32 insertions(+), 14 deletions(-)

Deleted: website/public_html/beta/common/code/archive_file.php
==============================================================================
--- website/public_html/beta/common/code/archive_file.php 2007-12-17 13:10:49 EST (Mon, 17 Dec 2007)
+++ (empty file)
@@ -1,450 +0,0 @@
-<?php
-/*
- Copyright 2005-2007 Redshift Software, Inc.
- Distributed under the Boost Software License, Version 1.0.
- (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
-*/
-require_once(dirname(__FILE__) . '/boost.php');
-
-class archive_file
-{
- var $key_ = NULL;
- var $file_ = NULL;
- var $archive_ = NULL;
- var $extractor_ = NULL;
- var $type_ = NULL;
- var $head_content_ = NULL;
- var $content_ = NULL;
-
- function archive_file(
- $pattern,
- $vpath,
- $content_map = array(),
- $get_as_raw = false,
- $archive_subdir = true,
- $archive_dir = ARCHIVE_DIR,
- $archive_file_prefix = ARCHIVE_FILE_PREFIX)
- {
- $path_parts = array();
- preg_match($pattern, $vpath, $path_parts);
-
- $info_map = array_merge($content_map, array(
- array('@[.](txt|py|rst|jam|v2|bat|sh)$@i','text','text/plain'),
- array('@[.](cpp|hpp)$@i','cpp','text/plain'),
- array('@[.]png$@i','raw','image/png'),
- array('@[.]gif$@i','raw','image/gif'),
- array('@[.](jpg|jpeg|jpe)$@i','raw','image/jpeg'),
- array('@[.]css$@i','raw','text/css'),
- array('@[.]js$@i','raw','application/x-javascript'),
- array('@[.]pdf$@i','raw','application/pdf'),
- array('@[.](html|htm)$@i','raw','text/html'),
- ));
-
- $this->key_ = $path_parts[2];
- if ($archive_subdir)
- {
- $this->file_ = $archive_file_prefix . $path_parts[1] . '/' . $path_parts[2];
- }
- else
- {
- $this->file_ = $archive_file_prefix . $path_parts[2];
- }
- $this->archive_ = str_replace('\\','/', $archive_dir . '/' . $path_parts[1] . '.zip');
-
- foreach ($info_map as $i)
- {
- if (preg_match($i[0],$this->key_))
- {
- $this->extractor_ = $i[1];
- $this->type_ = $i[2];
- break;
- }
- }
-
- $unzip = UNZIP . ' -p ' . escapeshellarg($this->archive_) . ' ' . escapeshellarg($this->file_);
- if (! $this->extractor_)
- {
- # File doesn't exist, or we don't know how to handle it.
- header("HTTP/1.0 404 Not Found");
- $this->extractor_ = 'raw';
- }
- else if ($get_as_raw || $this->extractor_ == 'raw')
- {
- $this->_extract_raw($unzip);
- //~ print "--- $unzip";
- }
- else
- {
- /* We pre-extract so we can get this like meta tag information
- before we have to print it out. */
- $this->content_ = $this->_extract_string($unzip);
- $f = '_init_'.$this->extractor_;
- $this->$f();
- }
- }
-
- function content_head()
- {
- if ($this->head_content_)
- {
- print $this->head_content_;
- }
- else
- {
- print <<<HTML
- <title>Boost C++ Libraries</title>
- <meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
-HTML
- ;
- }
- }
-
- function is_raw()
- {
- return $this->extractor_ == 'raw';
- }
-
- function _extract_string($unzip)
- {
- $file_handle = popen($unzip,'r');
- $text = '';
- while ($file_handle && !feof($file_handle)) {
- $text .= fread($file_handle,8*1024);
- }
- pclose($file_handle);
- return $text;
- }
-
- function _extract_raw($unzip)
- {
- header('Content-type: '.$this->type_);
- ## header('Content-Disposition: attachment; filename="downloaded.pdf"');
- $file_handle = popen($unzip,'rb');
- fpassthru($file_handle);
- pclose($file_handle);
- }
-
- function content()
- {
- if ($this->extractor_)
- {
- $f = '_content_'.$this->extractor_;
- $this->$f();
- }
- }
-
- function _init_text()
- {
- }
-
- function _content_text()
- {
- print "<h3>".$this->key_."</h3>\n";
- print "<pre>\n";
- print htmlentities($this->content_);
- print "</pre>\n";
- }
-
- function _init_cpp()
- {
- }
-
- function _content_cpp()
- {
- $text = htmlentities($this->content_);
-
- print "<h3>".$this->key_."</h3>\n";
- print "<pre>\n";
- $root = dirname(preg_replace('@([^/]+/)@','../',$this->key_));
- $text = preg_replace(
- '@(#[ ]*include[ ]+&lt;)(boost[^&]+)@Ssm',
- '${1}${2}',
- $text );
- $text = preg_replace(
- '@(#[ ]*include[ ]+&quot;)(boost[^&]+)@Ssm',
- '${1}${2}',
- $text );
- print $text;
- print "</pre>\n";
- }
-
- function _init_html_pre()
- {
- $h = '';
-
- preg_match('@text/html; charset=([^\s"]+)@i',$this->content_,$charset);
- if (isset($charset[1]))
- {
- $h .= <<<HTML
- <meta http-equiv="Content-Type" content="text/html; charset=${charset[1]}" />
-HTML
- ;
- }
-
- preg_match('@<title>([^<]+)</title>@i',$this->content_,$title);
- if (isset($title[1]))
- {
- $h .= <<<HTML
- <title>Boost C++ Libraries - ${title[1]}</title>
-HTML
- ;
- }
- else if ($h !== '')
- {
- $h .= <<<HTML
- <title>Boost C++ Libraries</title>
-HTML
- ;
- }
-
- if ($h !== '')
- {
- $this->head_content_ = $h;
- }
- }
-
- function _content_html_pre()
- {
- $text = $this->content_;
-
- $text = preg_replace(
- '@href="?http://www.boost.org/?([^"\s]*)"?@i',
- 'href="/${1}"',
- $text );
- $text = preg_replace(
- '@href="?(?:\.\./)+people/(.*\.htm)"?@i',
- 'href="/users/people/${1}l"',
- $text );
- $text = preg_replace(
- '@href="?(?:\.\./)+(LICENSE_.*\.txt)"?@i',
- 'href="/${1}"',
- $text );
- $text = preg_replace(
- '@<a\s+(class="[^"]+")?\s*href="?(http|mailto)(:[^"\s]*)"?@i',
- '<a class="external" href="${2}${3}"',
- $text );
-
- return $text;
- }
-
- function _init_boost_book_html()
- {
- $this->_init_html_pre();
- }
-
- function _content_boost_book_html()
- {
- $text = $this->_content_html_pre();
-
- $text = substr($text,strpos($text,'<div class="spirit-nav">'));
- $text = substr($text,0,strpos($text,'</body>'));
- for ($i = 0; $i < 8; $i++) {
- $text = preg_replace(
- '@<img src="[\./]*images/(.*\.png)" alt="(.*)"([ ][/])?>@Ssm',
- '<img src="/style/css_0/${1}" alt="${2}" />',
- $text );
- }
- $text = str_replace('<hr>','',$text);
- $text = str_replace('<table width="100%">','<table class="footer-table">',$text);
- $text = preg_replace(
- '@[\s]+(border|cellpadding|cellspacing|width|height|valign|frame|rules|naturalsizeflag|background)=[^\s>]+@i',
- '',
- $text );
-
- print $text;
- }
-
- function _init_boost_libs_html()
- {
- $this->_init_html_pre();
- }
-
- function _content_boost_libs_html()
- {
- $text = $this->_content_html_pre();
-
- preg_match('@<body[^>]*>@i',$text,$body_begin,PREG_OFFSET_CAPTURE);
- preg_match('@</body>@i',$text,$body_end,PREG_OFFSET_CAPTURE);
- if (!isset($body_begin[0]))
- {
- return;
- }
- else if (!isset($body_end[0]))
- {
- $text = substr($text,
- $body_begin[0][1]+strlen($body_begin[0][0]));
- }
- else
- {
- $text = substr($text,
- $body_begin[0][1]+strlen($body_begin[0][0]),
- $body_end[0][1]-($body_begin[0][1]+strlen($body_begin[0][0])) );
- }
-
- # nasty code, because (?!fubar) causes an ICE...
- preg_match('@<table_at_i',$text,$table_begin,PREG_OFFSET_CAPTURE);
- preg_match('@</table>@i',$text,$table_end,PREG_OFFSET_CAPTURE);
- if (isset($table_begin[0]) && isset($table_end[0]) &&
- strpos(substr($text,0,$table_end[0][1]),'boost.png',$table_begin[0][1]) !== FALSE)
- {
- $text = substr($text,$table_end[0][1]+strlen($table_end[0][0]));
- }
-
- preg_match('@<h[12]@i',$text,$h1_begin,PREG_OFFSET_CAPTURE);
- preg_match('@</h[12]>@i',$text,$h1_end,PREG_OFFSET_CAPTURE);
- preg_match('@<table_at_i',$text,$table_begin,PREG_OFFSET_CAPTURE);
- preg_match('@</table>@i',$text,$table_end,PREG_OFFSET_CAPTURE);
- if (isset($h1_begin[0]) && isset($table_end[0]) &&
- $table_begin[0][1] < $h1_begin[0][1] && $h1_begin[0][1] < $table_end[0][1]+8)
- {
- $text = substr($text,$h1_begin[0][1],
- $h1_begin[0][1]-$h1_end[0][1]+5) . substr($text,$table_end[0][1]+8);
- }
- #else
- #{
- # $text = substr($text,$h1_begin[0][1]);
- #}
- #if (isset($title[1]))
- #{
- # $text = "<h1>${title[1]}</h1>\n" . $text;
- #}
- $text = preg_replace(
- '@(<a[^>]+>[\s]*)?<img.*boost\.png[^>]*>([\s]*</a>)?@i',
- '',
- $text );
- $text = preg_replace(
- '@<img(.*)align="?right"?[^>]*>@i',
- '<img${1} class="right-inset" />',
- $text );
- $text = preg_replace(
- '@<img(.*)align="?absmiddle"?[^>]*>@i',
- '<img${1} class="inline" />',
- $text );
- $text = preg_replace(
- '@[\s]+(border|cellpadding|cellspacing|width|height|valign|align|frame|rules|naturalsizeflag|background)=[^\s>]+@i',
- '',
- $text );
- $text = preg_replace(
- '@<table[\s]+(border)[^\s>]*@i',
- '<table',
- $text );
- $text = preg_replace(
- '@<[/]?(font|hr)[^>]*>@i',
- '',
- $text );
- $text = preg_replace(
- '@<([^\s]+)[\s]+>@i',
- '<${1}>',
- $text );
- $text = _preg_replace_bounds(
- '@<blockquote>[\s]*(<pre>)@i','@(</pre>)[\s]*</blockquote>@i',
- '${1}','${1}',
- $text );
- $text = _preg_replace_bounds(
- '@<blockquote>[\s]*(<p>)@i','@(</p>)[\s]*</blockquote>@i',
- '${1}','${1}',
- $text );
- $text = _preg_replace_bounds(
- '@<blockquote>[\s]*(<table>)@i','@(</table>)[\s]*</blockquote>@i',
- '${1}','${1}',
- $text );
- $text = _preg_replace_bounds(
- '@<blockquote>[\s]*<li>@i','@</li>[\s]*</blockquote>@i',
- '<ul><li>','</li></ul>',
- $text );
- $text = _preg_replace_bounds(
- '@(?:<blockquote>[\s]*)+<h2>@i','@</h2>(?:[\s]*</blockquote>)+@i',
- '<h2>','</h2>',
- $text );
- $text = preg_replace(
- '@(<a name=[^\s>]+[\s]*>)[\s]*(</?[^a])@i',
- '${1}</a>${2}',
- $text );
- $text = preg_replace(
- '@<table>([\s]+<tr>[\s]+<td>.*_arr.*</td>[\s]+<td>.*</td>[\s]+<td>.*</td>[\s]+</tr>[\s]+)</table>@i',
- '<table class="pyste-nav">${1}</table>',
- $text );
- $text = preg_replace(
- '@<table>([\s]+<tr>[\s]+<td)[\s]+class="note_box">@i',
- '<table class="note_box">${1}>',
- $text );
- $text = preg_replace(
- '@<table>([\s]+<tr>[\s]+<td[\s]+class="table_title">)@i',
- '<table class="toc">${1}',
- $text );
- $text = preg_replace(
- '@src=".*theme/u_arr\.gif"@i',
- 'src="/style/css_0/up.png"',
- $text );
- $text = preg_replace(
- '@src=".*theme/l_arr\.gif"@i',
- 'src="/style/css_0/prev.png"',
- $text );
- $text = preg_replace(
- '@src=".*theme/r_arr\.gif"@i',
- 'src="/style/css_0/next.png"',
- $text );
- $text = preg_replace(
- '@src=".*theme/u_arr_disabled\.gif"@i',
- 'src="/style/css_0/up_disabled.png"',
- $text );
- $text = preg_replace(
- '@src=".*theme/l_arr_disabled\.gif"@i',
- 'src="/style/css_0/prev_disabled.png"',
- $text );
- $text = preg_replace(
- '@src=".*theme/r_arr_disabled\.gif"@i',
- 'src="/style/css_0/next_disabled.png"',
- $text );
- $text = preg_replace(
- '@src=".*theme/note\.gif"@i',
- 'src="/style/css_0/note.png"',
- $text );
- $text = preg_replace(
- '@src=".*theme/alert\.gif"@i',
- 'src="/style/css_0/caution.png"',
- $text );
- $text = preg_replace(
- '@src=".*theme/bulb\.gif"@i',
- 'src="/style/css_0/tip.png"',
- $text );
- $text = preg_replace(
- '@<img src=".*theme/(?:bullet|lens)\.gif">@i',
- '',
- $text );
- $text = preg_replace(
- '@(<img src=".*theme/(?:arrow)\.gif")>@i',
- '${1} class="inline">',
- $text );
-
- print $text;
- }
-
- function _init_boost_frame1_html()
- {
- $this->_init_html_pre();
- }
-
- function _content_boost_frame1_html()
- {
- $text = $this->_content_html_pre();
-
- $text = substr($text,strpos($text,'<div class="spirit-nav">'));
- $text = substr($text,0,strpos($text,'</body>'));
- for ($i = 0; $i < 8; $i++) {
- $text = preg_replace(
- '@<img src="[\./]*images/(.*\.png)" alt="(.*)"([ ][/])?>@Ssm',
- '<img src="/style/css_0/${1}" alt="${2}" />',
- $text );
- }
- $text = str_replace('<hr>','',$text);
- $text = str_replace('<table width="100%">','<table class="footer-table">',$text);
- $text = preg_replace(
- '@[\s]+(border|cellpadding|cellspacing|width|height|valign|frame|rules|naturalsizeflag|background)=[^\s>]+@i',
- '',
- $text );
-
- print $text;
- }
-}
-?>

Copied: website/public_html/beta/common/code/boost_archive.php (from r42126, /website/public_html/beta/common/code/archive_file.php)
==============================================================================
--- /website/public_html/beta/common/code/archive_file.php (original)
+++ website/public_html/beta/common/code/boost_archive.php 2007-12-17 13:10:49 EST (Mon, 17 Dec 2007)
@@ -6,7 +6,7 @@
 */
 require_once(dirname(__FILE__) . '/boost.php');
 
-class archive_file
+class boost_archive
 {
     var $key_ = NULL;
     var $file_ = NULL;
@@ -16,7 +16,7 @@
     var $head_content_ = NULL;
     var $content_ = NULL;
     
- function archive_file(
+ function boost_archive(
         $pattern,
         $vpath,
         $content_map = array(),
@@ -80,6 +80,11 @@
             $this->content_ = $this->_extract_string($unzip);
             $f = '_init_'.$this->extractor_;
             $this->$f();
+ if ($this->extractor_ == 'simple')
+ {
+ $f = '_content_'.$this->extractor_;
+ $this->$f();
+ }
         }
     }
     
@@ -101,7 +106,7 @@
     
     function is_raw()
     {
- return $this->extractor_ == 'raw';
+ return $this->extractor_ == 'raw' || $this->extractor_ == 'simple';
     }
 
     function _extract_string($unzip)
@@ -212,6 +217,10 @@
             'href="/${1}"',
             $text );
         $text = preg_replace(
+ '@href="?http://boost.org/?([^"\s]*)"?@i',
+ 'href="/${1}"',
+ $text );
+ $text = preg_replace(
             '@href="?(?:\.\./)+people/(.*\.htm)"?@i',
             'href="/users/people/${1}l"',
             $text );
@@ -446,5 +455,14 @@
         
         print $text;
     }
+
+ function _init_simple()
+ {
+ }
+
+ function _content_simple()
+ {
+ print $this->_content_html_pre();
+ }
 }
 ?>

Modified: website/public_html/beta/development/testing_results.php
==============================================================================
--- website/public_html/beta/development/testing_results.php (original)
+++ website/public_html/beta/development/testing_results.php 2007-12-17 13:10:49 EST (Mon, 17 Dec 2007)
@@ -1,5 +1,5 @@
 <?php
-require_once(dirname(__FILE__) . '/../common/code/archive_file.php');
+require_once(dirname(__FILE__) . '/../common/code/boost_archive.php');
 
 $_file = new archive_file(
   '/^[\/]([^\/]+)[\/](.*)$/',$_SERVER["PATH_INFO"],array(),

Modified: website/public_html/beta/doc/display_build.php
==============================================================================
--- website/public_html/beta/doc/display_build.php (original)
+++ website/public_html/beta/doc/display_build.php 2007-12-17 13:10:49 EST (Mon, 17 Dec 2007)
@@ -1,8 +1,8 @@
 <?php
-require_once(dirname(__FILE__) . '/../common/code/archive_file.php');
+require_once(dirname(__FILE__) . '/../common/code/boost_archive.php');
 
-$_file = new archive_file('@^[/]([^/]+)[/](.*)$@',$_SERVER["PATH_INFO"],array(
- array('@^boost-build/index[.]html$@i','raw','text/html'),
+$_file = new boost_archive('@^[/]([^/]+)[/](.*)$@',$_SERVER["PATH_INFO"],array(
+ array('@^boost-build/index[.]html$@i','simple','text/html'),
   array('@[.](html|htm)$@i','boost_book_html','text/html')
   ),false,false);
 

Modified: website/public_html/beta/doc/display_jam.php
==============================================================================
--- website/public_html/beta/doc/display_jam.php (original)
+++ website/public_html/beta/doc/display_jam.php 2007-12-17 13:10:49 EST (Mon, 17 Dec 2007)
@@ -1,7 +1,7 @@
 <?php
-require_once(dirname(__FILE__) . '/../common/code/archive_file.php');
+require_once(dirname(__FILE__) . '/../common/code/boost_archive.php');
 
-$_file = new archive_file('@^[/]([^/]+)[/](.*)$@',$_SERVER["PATH_INFO"],array(
+$_file = new boost_archive('@^[/]([^/]+)[/](.*)$@',$_SERVER["PATH_INFO"],array(
   array('@[.](html|htm)$@i','boost_book_html','text/html'),
   ));
 

Modified: website/public_html/beta/doc/display_libs.php
==============================================================================
--- website/public_html/beta/doc/display_libs.php (original)
+++ website/public_html/beta/doc/display_libs.php 2007-12-17 13:10:49 EST (Mon, 17 Dec 2007)
@@ -1,10 +1,10 @@
 <?php
-require_once(dirname(__FILE__) . '/../common/code/archive_file.php');
+require_once(dirname(__FILE__) . '/../common/code/boost_archive.php');
 
-$_file = new archive_file('@^[/]([^/]+)[/](.*)$@',$_SERVER["PATH_INFO"],array(
- array('@^libs/iostreams/doc/.*(html|htm)$@i','raw','text/html'),
- array('@^libs/preprocessor/doc\.*(html|htm)$@i','raw','text/html'),
- array('@^libs/serialization/doc/.*(html|htm)$@i','raw','text/html'),
+$_file = new boost_archive('@^[/]([^/]+)[/](.*)$@',$_SERVER["PATH_INFO"],array(
+ array('@^libs/iostreams/doc/.*(html|htm)$@i','simple','text/html'),
+ array('@^libs/preprocessor/doc\.*(html|htm)$@i','simple','text/html'),
+ array('@^libs/serialization/doc/.*(html|htm)$@i','simple','text/html'),
   //~ array('@^libs/serialization/doc/index.html$@i','boost_frame1_html','text/html'),
   //~ array('@^libs/preprocessor/doc/.*(html|htm)$@i','boost_frame1_html','text/html'),
   array('@^libs.*(html|htm)$@i','boost_libs_html','text/html'),


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk