Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r59887 - in website/public_html/beta: common/code development doc
From: daniel_james_at_[hidden]
Date: 2010-02-25 03:41:47


Author: danieljames
Date: 2010-02-25 03:41:46 EST (Thu, 25 Feb 2010)
New Revision: 59887
URL: http://svn.boost.org/trac/boost/changeset/59887

Log:
Extract the logic for finding the archive location.
Text files modified:
   website/public_html/beta/common/code/boost_archive.php | 67 +++++++++++++++++++----------
   website/public_html/beta/development/testing_results.php | 14 +++--
   website/public_html/beta/doc/display_build.php | 90 ++++-----------------------------------
   website/public_html/beta/doc/display_jam.php | 84 ++-----------------------------------
   website/public_html/beta/doc/display_libs.php | 6 +
   5 files changed, 71 insertions(+), 190 deletions(-)

Modified: website/public_html/beta/common/code/boost_archive.php
==============================================================================
--- website/public_html/beta/common/code/boost_archive.php (original)
+++ website/public_html/beta/common/code/boost_archive.php 2010-02-25 03:41:46 EST (Thu, 25 Feb 2010)
@@ -6,6 +6,38 @@
 */
 require_once(dirname(__FILE__) . '/boost.php');
 
+function get_archive_location(
+ $pattern,
+ $vpath,
+ $archive_subdir = true,
+ $archive_dir = ARCHIVE_DIR,
+ $archive_file_prefix = ARCHIVE_FILE_PREFIX)
+{
+ $path_parts = array();
+ preg_match($pattern, $vpath, $path_parts);
+
+ $version = $path_parts[1];
+ $key = $path_parts[2];
+
+ if ($archive_subdir)
+ {
+ $file = $archive_file_prefix . $version . '/' . $key;
+ }
+ else
+ {
+ $file = $archive_file_prefix . $key;
+ }
+
+ $archive = str_replace('\\','/', $archive_dir . '/' . $version . '.zip');
+
+ return array(
+ 'version' => $version,
+ 'key' => $key,
+ 'file' => $file,
+ 'archive' => $archive
+ );
+}
+
 class boost_archive
 {
     var $version_ = NULL;
@@ -21,17 +53,15 @@
     var $content_ = NULL;
     
     function boost_archive(
- $pattern,
- $vpath,
+ $archive_location_details,
         $content_map = array(),
- $get_as_raw = false,
- $archive_subdir = true,
- $archive_dir = ARCHIVE_DIR,
- $archive_file_prefix = ARCHIVE_FILE_PREFIX)
+ $get_as_raw = false)
     {
- $path_parts = array();
- preg_match($pattern, $vpath, $path_parts);
-
+ $this->version_ = $archive_location_details['version'];
+ $this->key_ = $archive_location_details['key'];
+ $this->file_ = $archive_location_details['file'];
+ $this->archive_ = $archive_location_details['archive'];
+
         $info_map = array_merge($content_map, array(
             array('@.*@','@[.](txt|py|rst|jam|v2|bat|sh|xml|qbk)$@i','text','text/plain'),
             array('@.*@','@[.](c|h|cpp|hpp)$@i','cpp','text/plain'),
@@ -45,18 +75,6 @@
             array('@.*@','@[^.](Jamroot|Jamfile|ChangeLog)$@i','text','text/plain'),
             array('@.*@','@[.]dtd$@i','raw','application/xml-dtd'),
             ));
-
- $this->version_ = $path_parts[1];
- $this->key_ = $path_parts[2];
- if ($archive_subdir)
- {
- $this->file_ = $archive_file_prefix . $this->version_ . '/' . $this->key_;
- }
- else
- {
- $this->file_ = $archive_file_prefix . $this->key_;
- }
- $this->archive_ = str_replace('\\','/', $archive_dir . '/' . $this->version_ . '.zip');
 
         foreach ($info_map as $i)
         {
@@ -73,6 +91,7 @@
           UNZIP
           .' -p '.escapeshellarg($this->archive_)
           .' '.escapeshellarg($this->file_);
+
         if (! $this->extractor_)
         {
             # File doesn't exist, or we don't know how to handle it.
@@ -91,6 +110,7 @@
             /* 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);
+
             $extractor_name = $this->extractor_.'_filter';
             $this->extractor_instance_ = new $extractor_name;
             $this->extractor_instance_->init($this);
@@ -133,11 +153,12 @@
             $text .= fread($file_handle,8*1024);
         }
         $exit_status = pclose($file_handle);
+
         if($exit_status == 0) {
             return $text;
         }
         else {
- $this->extractor_ = '404';
+ $this->extractor_ = 'h404';
             return strstr($_SERVER['HTTP_HOST'], 'beta')
                 ? unzip_error($exit_status) : '';
         }
@@ -277,7 +298,7 @@
     }
 }
 
-class boost_book_filter extends html_base_filter
+class boost_book_html_filter extends html_base_filter
 {
     function init($archive)
     {

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 2010-02-25 03:41:46 EST (Thu, 25 Feb 2010)
@@ -2,11 +2,13 @@
 require_once(dirname(__FILE__) . '/../common/code/boost_archive.php');
 
 $_file = new boost_archive(
- '/^[\/]([^\/]+)[\/](.*)$/',$_SERVER["PATH_INFO"],
+ get_archive_location(
+ '/^[\/]([^\/]+)[\/](.*)$/',$_SERVER["PATH_INFO"],
+ false, // the result zips don't have the tag subdir
+ RESULTS_DIR
+ ),
   array(
   //~ array(version-regex,path-regex,raw|simple|text|cpp|boost_book_html|boost_libs_html,mime-type),
- ),
- true, // we always want raw output
- false, // the result zips don't have the tag subdir
- RESULTS_DIR);
-?>
+ ),
+ true // we always want raw output
+);

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 2010-02-25 03:41:46 EST (Thu, 25 Feb 2010)
@@ -20,87 +20,17 @@
     return stripos($content, '_uacct = "UA-2917240-2"') !== FALSE ? $content :
         str_ireplace('</head>', $analytics.'</head>', $content);
 }
-$_file = new boost_archive('@^[/]([^/]+)[/](.*)$@',$_SERVER["PATH_INFO"],array(
+
+$_file = new boost_archive(
+ get_archive_location(
+ '@^[/]([^/]+)[/](.*)$@',
+ $_SERVER["PATH_INFO"],
+ ,false,false
+ ),
+ array(
   //~ array(version-regex,path-regex,raw|simple|text|cpp|boost_book_html|boost_libs_html,mime-type[,preprocess hook]),
   array('@.*@','@^boost-build/index[.]html$@i','simple','text/html', 'add_boost_build_analytics'),
   array('@.*@','@[.](html|htm)$@i','boost_book_html','text/html')
- ),false,false);
-
-if (!$_file->is_raw()) {
-?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
-<head>
- <?php $_file->content_head(); ?>
- <link rel="icon" href="/favicon.ico" type="image/ico" />
- <link rel="stylesheet" type="text/css" href="/style/section-doc.css" />
- <!--[if IE 7]> <style type="text/css"> body { behavior: url(/style/csshover3.htc); } </style> <![endif]-->
- <?php #~ pwn_head(); ?>
- <style type="text/css">
-/*<![CDATA[*/
-div.sidebar {
- margin: 0em 0em 1em 1em !important;
- width: 40%;
- float: right;
- clear: right;
-}
- /*]]>*/
- </style>
-<script type="text/javascript">
- var _gaq = _gaq || [];
- _gaq.push(['_setAccount', 'UA-2917240-2']);
- _gaq.push(['_trackPageview']);
-
- (function() {
- var ga = document.createElement('script');
- ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
- ga.setAttribute('async', 'true');
- document.documentElement.firstChild.appendChild(ga);
- })();
-</script>
-</head><!-- <?php print $_file->file_; ?> -->
-
-<body>
- <div id="heading">
- <?php virtual("/common/heading.html");?>
- </div>
-
- <div id="body">
- <div id="body-inner">
- <div id="content">
- <div class="section" id="docs">
- <div class="section-0">
- <div class="section-body">
- <?php $_file->content(); ?>
- </div>
- </div>
- </div>
- </div>
-
- <div class="clear"></div>
- </div>
- </div>
-
- <div id="footer">
- <div id="footer-left">
- <div id="revised">
- <p>Revised $Date$</p>
- </div>
-
- <div id="copyright">
- <p>Copyright Beman Dawes, David Abrahams, 1998-2005.</p>
-
- <p>Copyright Rene Rivera 2004-2007.</p>
- </div><?php virtual("/common/footer-license.html");?>
- </div>
-
- <div id="footer-right">
- <?php virtual("/common/footer-banners.html");?>
- </div>
+));
 
- <div class="clear"></div>
- </div>
-</body>
-</html><?php } ?>
\ No newline at end of file
+$_file->render();
\ No newline at end of file

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 2010-02-25 03:41:46 EST (Thu, 25 Feb 2010)
@@ -1,85 +1,11 @@
 <?php
 require_once(dirname(__FILE__) . '/../common/code/boost_archive.php');
 
-$_file = new boost_archive('@^[/]([^/]+)[/](.*)$@',$_SERVER["PATH_INFO"],array(
+$_file = new boost_archive(
+ get_archive_location('@^[/]([^/]+)[/](.*)$@',$_SERVER["PATH_INFO"]),
+ array(
   //~ array(version-regex,path-regex,raw|simple|text|cpp|boost_book_html|boost_libs_html,mime-type[,preprocess hook]),
   array('@.*@','@[.](html|htm)$@i','boost_book_html','text/html'),
- ));
+));
 
-if (!$_file->is_raw()) { #~ require_once(dirname(__FILE__) . '/../common/code/webnotes.php');
-?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
-<head>
- <?php $_file->content_head(); ?>
- <link rel="icon" href="/favicon.ico" type="image/ico" />
- <link rel="stylesheet" type="text/css" href="/style/section-doc.css" />
- <!--[if IE 7]> <style type="text/css"> body { behavior: url(/style/csshover3.htc); } </style> <![endif]-->
- <?php #~ pwn_head(); ?>
-
-<script type="text/javascript">
- var _gaq = _gaq || [];
- _gaq.push(['_setAccount', 'UA-2917240-2']);
- _gaq.push(['_trackPageview']);
-
- (function() {
- var ga = document.createElement('script');
- ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
- ga.setAttribute('async', 'true');
- document.documentElement.firstChild.appendChild(ga);
- })();
-</script>
-</head><!-- <?php print $_file->file_; ?> -->
-
-<body>
- <div id="heading">
- <?php virtual("/common/heading.html");?>
- </div>
-
- <div id="body">
- <div id="body-inner">
- <div id="content">
- <div class="section" id="docs">
- <div class="section-0">
- <div class="section-body">
- <?php $_file->content(); ?>
- </div>
- </div>
- </div>
-
- <div class="section" id="notes">
- <div class="section-0">
- <div class="section-body">
- <?php #~ pwn_body($_file->key_,$_SERVER['PHP_SELF']); ?>
- </div>
- </div>
- </div>
- </div>
-
- <div class="clear"></div>
- </div>
- </div>
-
- <div id="footer">
- <div id="footer-left">
- <div id="revised">
- <p>Revised $Date$</p>
- </div>
-
- <div id="copyright">
- <p>Copyright Beman Dawes, David Abrahams, 1998-2005.</p>
-
- <p>Copyright Rene Rivera 2004-2005.</p>
- </div><?php virtual("/common/footer-license.html");?>
- </div>
-
- <div id="footer-right">
- <?php virtual("/common/footer-banners.html");?>
- </div>
-
- <div class="clear"></div>
- </div>
-</body>
-</html><?php } ?>
+$_file->render();

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 2010-02-25 03:41:46 EST (Thu, 25 Feb 2010)
@@ -32,7 +32,9 @@
     return str_ireplace('</head>', $analytics.'</head>', $content);
 }
 
-$_file = new boost_archive('@^[/]([^/]+)[/](.*)$@',$_SERVER["PATH_INFO"],array(
+$_file = new boost_archive(
+ get_archive_location('@^[/]([^/]+)[/](.*)$@',$_SERVER["PATH_INFO"]),
+ array(
   //~ array(version-regex,path-regex,raw|simple|text|cpp|boost_book_html|boost_libs_html,mime-type[,preprocess hook]),
   //~ this handles most of the simple cases of index.htm(l) redirect files
   array(
@@ -95,6 +97,6 @@
   array('@.*@','@^more/.*html$@i','basic','text/html'),
   //~ the headers are text files displayed in an embeded page
   array('@.*@','@^boost/.*$@i','cpp','text/plain')
- ));
+));
 
 $_file->render();


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