Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r61988 - in website/public_html/beta: common/code doc
From: daniel_james_at_[hidden]
Date: 2010-05-15 06:49:07


Author: danieljames
Date: 2010-05-15 06:49:06 EDT (Sat, 15 May 2010)
New Revision: 61988
URL: http://svn.boost.org/trac/boost/changeset/61988

Log:
Automatically detect redirect files in documentation.
Text files modified:
   website/public_html/beta/common/code/boost_archive.php | 45 ++++++++++++++++++++++++++++++++++++++++
   website/public_html/beta/doc/display_libs.php | 39 ----------------------------------
   2 files changed, 45 insertions(+), 39 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-05-15 06:49:06 EDT (Sat, 15 May 2010)
@@ -112,6 +112,13 @@
         return;
     }
 
+ if($type == 'text/html') {
+ if(html_headers($archive->content_)) {
+ echo $archive->content_;
+ exit(0);
+ }
+ }
+
     if ($preprocess) {
         $archive->content_ = call_user_func($preprocess, $archive->content_);
     }
@@ -393,6 +400,44 @@
  * HTML processing functions
  */
 
+function html_headers($content)
+{
+ if(preg_match(
+ '@<meta\s+http-equiv\s*=\s*["\']?refresh["\']?\s+content\s*=\s*["\']0;\s*URL=([^"\']*)["\']\s*/?>@i',
+ $content,
+ $redirect))
+ {
+ header('Location: '.resolve_url($redirect[1]), TRUE, 301);
+ return true;
+ }
+}
+
+// Not a full implementation. Just good enough for redirecting.
+function resolve_url($url) {
+ $url = parse_url($url);
+
+ if(isset($url['schme'])) return $url;
+
+ $url['scheme'] = 'http'; # Detect other schemes?
+
+ if(!isset($url['host'])) {
+ $url['host'] = $_SERVER['SERVER_NAME'];
+
+ if($url['path'][0] != '/') {
+ $path = explode('/', $_SERVER['REQUEST_URI']);
+ array_pop($path);
+ $rel_path = explode('/', $url['path']);
+ while(isset($rel_path[0]) && $rel_path[0] == '..') {
+ array_pop($path);
+ array_shift($rel_path);
+ }
+ $url['path'] = implode('/', $path).'/'.implode('/', $rel_path);
+ }
+ }
+
+ return $url['scheme'].'://'.$url['host'] . $url['path'];
+}
+
 function html_init($archive)
 {
     preg_match('@text/html; charset=([^\s"\']+)@i',$archive->content_,$charset);

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-05-15 06:49:06 EDT (Sat, 15 May 2010)
@@ -46,53 +46,14 @@
 display_from_archive(
   $location,
   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(
- '@1_('.implode('|',array(
- '34','35',
- )).')_[0-9]@',
- '@^libs/('.implode('|',array(
- 'accumulators','algorithm/string','any','array','asio','assign','bind','bimap',
- 'circular_buffer',
- 'concept_check','config','date_time','date_time/doc','disjoint_sets',
- 'dynamic_bitset','exception','filesystem','foreach','function',
- 'functional/factory','functional/forward','functional/hash',
- 'function_types','fusion','graph','interprocess','intrusive',
- 'io','iostreams','iterator','lambda',
- 'lambda/doc','math','math/doc','mem_fn','mpl',
- 'multi_array','multi_index','numeric','numeric/conversion','numeric/interval/doc',
- 'numeric/ublas','unmeric/ublas/doc','optional','parameter','pool','preprocessor',
- 'program_options','program_options/doc','property_map','proto','ptr_container','python',
- 'python/doc/tutorial','python/doc/v2','regex','serialization','signals',
- 'signals/doc','smart_ptr','statechart','static_assert','system','test',
- 'thread','thread/doc','tr1','tuple','typeof',
- 'type_traits','units','unordered','variant','xpressive'
- )).')/index.(html|htm)$@i',
- 'raw','text/html'),
   //~ special cases that can't be processed at all (some redirects)
- array('@.*@','@^libs/index.html$@i','raw','text/html'),
- array('@.*@','@^libs/bind/ref.html$@i','raw','text/html'),
- array('@.*@','@^libs/config/config.htm$@i','raw','text/html'),
   array('@.*@','@^libs/gil/doc/.*(html|htm)$@i','raw','text/html'),
- array('@.*@','@^libs/math/doc/common_factor.html$@i','raw','text/html'),
   array('@.*@','@^libs/preprocessor/doc/.*(html|htm)$@i','raw','text/html'),
   array('@.*@','@^libs/test/doc/components/test_tools/reference/.*(html|htm)$@i','raw','text/html'),
- array('@.*@','@^libs/python/doc/PyConDC_2003/bpl.html$@i','raw','text/html'),
   array('@.*@','@^libs/spirit/.*(html|htm)$@i','simple','text/html', 'add_spirit_analytics'),
   array('@.*@','@^libs/fusion/.*(html|htm)$@i','basic','text/html', 'add_spirit_analytics'),
- array('@.*@','@^libs/static_assert/static_assert.htm$@i','raw','text/html'),
- array('@.*@','@^libs/type_traits/cxx_type_traits.htm$@i','raw','text/html'),
- array('@.*@','@^libs/utility/iterator_adaptors.htm$@i','raw','text/html'),
   array('@.*@','@^libs/wave/.*(html|htm)$@i','raw','text/html'),
   array('@.*@','@^libs/range/doc/.*(html|htm)$@i','raw','text/html'),
- array('@.*@','@^status/index.html$@i','raw','text/html'),
- array('@.*@','@^tools/boostbook/index.html$@i','raw','text/html'),
- array('@.*@','@^tools/build/index.html$@i','raw','text/html'),
- array('@.*@','@^tools/jam/index.html$@i','raw','text/html'),
- array('@.*@','@^tools/quickbook/index.html$@i','raw','text/html'),
- array('@.*@','@^tools/regression/index.html?$@i','raw','text/html'),
- array('@.*@','@^wiki/index.html$@i','raw','text/html'),
   //~ special cases that can't be embeded in the standard frame
   array('@.*@','@^libs/iostreams/doc/.*(html|htm)$@i','simple','text/html'),
   array('@.*@','@^libs/serialization/doc/.*(html|htm)$@i','simple','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