Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r59891 - website/public_html/beta/common/code
From: daniel_james_at_[hidden]
Date: 2010-02-25 03:42:32


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

Log:
Move html preperation into a separate function. The base method didn't really match the interface.
Text files modified:
   website/public_html/beta/common/code/boost_archive.php | 63 +++++++++++++++++++--------------------
   1 files changed, 30 insertions(+), 33 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:42:31 EST (Thu, 25 Feb 2010)
@@ -256,34 +256,6 @@
             $archive->title_ = $title[1];
         }
     }
-
- function content($archive)
- {
- $text = $archive->content_;
-
- $text = preg_replace(
- '@href="?http://www.boost.org/?([^"\s]*)"?@i',
- '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 );
- $text = preg_replace(
- '@href="?(?:\.\./)+(LICENSE_[^"\s]*\.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;
- }
 }
 
 class boost_book_html_filter extends html_base_filter
@@ -295,7 +267,7 @@
 
     function content($archive)
     {
- $text = parent::content($archive);
+ $text = prepare_html($archive->content_);
         
         $text = substr($text,strpos($text,'<div class="spirit-nav">'));
         $text = substr($text,0,strpos($text,'</body>'));
@@ -332,7 +304,7 @@
 
     function content($archive)
     {
- $text = parent::content($archive);
+ $text = prepare_html($archive->content_);
         
         preg_match('@<body[^>]*>@i',$text,$body_begin,PREG_OFFSET_CAPTURE);
         preg_match('@</body>@i',$text,$body_end,PREG_OFFSET_CAPTURE);
@@ -516,7 +488,7 @@
 
     function content($archive)
     {
- $text = parent::content($archive);
+ $text = prepare_html($archive->content_);
         
         $text = substr($text,strpos($text,'<div class="spirit-nav">'));
         $text = substr($text,0,strpos($text,'</body>'));
@@ -549,7 +521,7 @@
 
     function content($archive)
     {
- print parent::content($archive);
+ print prepare_html($archive->content_);
     }
     
     function render($archive)
@@ -566,7 +538,7 @@
 
     function content($archive)
     {
- $text = parent::content($archive);
+ $text = prepare_html($archive->content_);
 
         $is_xhtml = preg_match('@<!DOCTYPE[^>]*xhtml_at_i', $text);
         $tag_end = $is_xhtml ? '/>' : '>';
@@ -632,6 +604,31 @@
     }
 }
 
+function prepare_html($text) {
+ $text = preg_replace(
+ '@href="?http://www.boost.org/?([^"\s]*)"?@i',
+ '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 );
+ $text = preg_replace(
+ '@href="?(?:\.\./)+(LICENSE_[^"\s]*\.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;
+}
+
 // Return a readable error message for unzip exit state.
 
 function unzip_error($exit_status) {


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