function main()
{
    $args = $_SERVER['argv'];
    $boost_root = null;
    switch (count($args)) {
        case 2:
            $boost_root = $args[1];
            break;
        default:
            echo "Usage: create-module-metadata.php boost_root\n";
            exit(1);
    }
    $library_details = BoostLibraries::from_xml_file(__DIR__ . '/../doc/libraries.xml')->get_for_version(BoostVersion::develop());
    $super_project = new BoostSuperProject($boost_root);
    $git_submodules = $super_project->get_modules();
    // Split the libraries up into modules.
    $libraries_by_module = array();
    foreach ($library_details as $library) {
        $module = $library['module'];
        if (!isset($git_submodules[$module])) {
            echo "Unknown module: {$module}\n";
            continue;
        }
        if (isset($library['documentation'])) {
            $doc_url = $library['documentation'];
            $module_base = $git_submodules[$module]['path'];
            if ($doc_url == $module_base) {
                $doc_url = '';
            } else {
                if (strpos($doc_url, "{$module_base}/") === 0) {
                    $doc_url = substr($doc_url, strlen("{$module_base}/"));
                } else {
                    $doc_url = "/{$doc_url}";
                }
            }
            if (!$doc_url) {
                unset($library['documentation']);
            } else {
                $library['documentation'] = $doc_url;
            }
        }
        $libraries_by_module[$module][] = $library;
    }
    // Write the module metadata
    foreach ($libraries_by_module as $module => $libraries) {
        $module_libraries = BoostLibraries::from_array($libraries);
        $module_dir = "{$boost_root}/{$git_submodules[$module]['path']}";
        $meta_dir = "{$module_dir}/meta";
        $meta_file = "{$module_dir}/meta/libraries.json";
        if (!is_dir($module_dir)) {
            echo "Module '{$module}' doesn't exist at '{$module_dir}'\n";
            continue;
        }
        if (!is_dir($meta_dir)) {
            mkdir($meta_dir);
        }
        file_put_contents($meta_file, $module_libraries->to_json(array('boost-version', 'update-version', 'module')) . "\n");
    }
}
示例#2
0
 function display()
 {
     // TODO: Specifying the version only works *after* a release, as
     //       new libraries will still have develop/master as their
     //       version. This works for now as version is always
     //       master/develop, but might change in the future.
     $version = BoostVersion::from(array_key_exists('version', $this->args) ? $this->args['version'] : 'master');
     $page = $this->args['page'];
     $libs = BoostLibraries::load();
     $categorized = $libs->get_categorized_for_version($version, 'name', 'BoostLibraries::filter_released');
     // TODO: Shouldn't really have to sort this here.
     uasort($categorized, function ($a, $b) {
         $a = $a['title'];
         $b = $b['title'];
         if ($a === 'Miscellaneous') {
             $a = 'ZZZZZZZZ';
         }
         if ($b === 'Miscellaneous') {
             $b = 'ZZZZZZZZ';
         }
         return $a > $b ?: ($a < $b ? -1 : 0);
     });
     $alphabetic = $libs->get_for_version($version, 'name', 'BoostLibraries::filter_released');
     $params = array('categorized' => array(), 'alphabetic' => array(), 'unreleased_libs' => array(), 'unreleased_lib_count' => 0);
     foreach ($categorized as $category) {
         $template_value = $category;
         $template_value['libraries'] = array();
         foreach ($category['libraries'] as $index => $library) {
             $template_value['libraries'][] = $this->rewrite_library($library, $index);
         }
         $params['categorized'][] = $template_value;
     }
     foreach ($alphabetic as $index => $library) {
         $params['alphabetic'][] = $this->rewrite_library($library, $index);
     }
     if ($version->is_unreleased()) {
         $index = 0;
         foreach ($alphabetic as $library) {
             if ($library['boost-version']->is_unreleased() || $library['boost-version']->is_beta()) {
                 $params['unreleased_libs'][] = $this->rewrite_library($library, $index++);
             }
         }
     } else {
         $index = 0;
         foreach ($alphabetic as $library) {
             if ($library['boost-version']->major() == $version->major() && $library['boost-version']->minor() == $version->minor()) {
                 $params['unreleased_libs'][] = $this->rewrite_library($library, $index++);
             }
         }
     }
     $params['unreleased_lib_count'] = count($params['unreleased_libs']);
     // Better support for other branches?
     $template_dir = BOOST_REPOS_DIR . '/boost-' . ((string) $version == 'develop' ? 'develop' : 'master') . '/' . $page;
     echo BoostSimpleTemplate::render(file_get_contents($template_dir), $params);
 }
function main()
{
    $options = BoostSiteTools\CommandLineOptions::parse(SET_RELEASE_STATUS_USAGE);
    if (!count($options->positional)) {
        echo $options->usage_message();
        exit(1);
    }
    $version = BoostVersion::from($options->positional[0]);
    $releases = new BoostReleases(__DIR__ . '/../generated/state/release.txt');
    $releases->setReleaseStatus($version, 'released');
    $releases->save();
}
示例#4
0
 static function cmp_boost_version($a, $b)
 {
     if (empty($a['boost-version'])) {
         if (empty($b['boost-version'])) {
             return 0;
         }
         return 1;
     }
     if (empty($b['boost-version'])) {
         return -1;
     }
     return BoostVersion::from($a['boost-version'])->compare($b['boost-version']);
 }
示例#5
0
 public function __construct($lib)
 {
     assert(!isset($lib['update-version']));
     assert(isset($lib['key']));
     if (!empty($lib['boost-version'])) {
         $lib['boost-version'] = BoostVersion::from($lib['boost-version']);
     }
     // Preserve the current empty authors tags.
     if (!isset($lib['authors'])) {
         $lib['authors'] = '';
     }
     if (!isset($lib['std'])) {
         $lib['std'] = array();
     }
     foreach (array('proposal', 'tr1') as $std) {
         $tag = "std-{$std}";
         if (isset($lib[$tag])) {
             if ($lib[$tag]) {
                 $lib['std'][] = $std;
             } else {
                 $lib['std'] = array_diff($lib['std'], array($std));
             }
         } else {
             $lib[$tag] = in_array($std, $lib['std']);
         }
     }
     $lib['std'] = array_unique($lib['std']);
     // Normalize the data representation
     foreach ($lib as $key => &$value) {
         if (is_string($value)) {
             $value = trim(preg_replace('@\\s+@', ' ', $value));
         }
     }
     if (!empty($lib['category'])) {
         $lib['category'] = array_map('ucwords', $lib['category']);
         sort($lib['category']);
     }
     $this->details = $lib;
 }
function main()
{
    BoostSiteTools\CommandLineOptions::parse();
    $path = realpath(STATIC_DIR);
    if (!$path || !is_dir($path)) {
        echo "Unable to find documentation directory\n";
        exit(1);
    }
    $releases = new BoostReleases(__DIR__ . '/../generated/state/release.txt');
    foreach (new DirectoryIterator(STATIC_DIR) as $dir) {
        if ($dir->isDot()) {
            continue;
        }
        $name = $dir->getFilename();
        if ($name == 'develop' || $name == 'master') {
            // Store this somewhere?
        } else {
            if (preg_match('@^boost_[0-9_]+$@', $name)) {
                $releases->addDocumentation(BoostVersion::from($name), "/doc/libs/{$name}");
            }
        }
    }
    $releases->save();
}
示例#7
0
 /** Kind of hacky way to fill in details that probably shouldn't be
  *  stored here anyway. */
 public function fill_in_details_from_previous_version($previous = null)
 {
     if (empty($this->details['boost-version'])) {
         $this->details['boost-version'] = isset($previous->details['boost-version']) ? $previous->details['boost-version'] : BoostVersion::unreleased();
     }
 }
示例#8
0
 function categorized_libraries()
 {
     return $this->libs->get_categorized_for_version(BoostVersion::page(), $this->sort_value, array($this, 'filter'));
 }
示例#9
0
<?php

require_once __DIR__ . '/../boost_version.php';
$develop = BoostVersion::develop();
$master = BoostVersion::master();
$boost_1_55_0 = BoostVersion::release(1, 55, 0);
$boost_1_54_0 = BoostVersion::release(1, 54, 0);
$boost_1_56_0 = BoostVersion::release(1, 56, 0);
$boost_1_56_0_b1 = BoostVersion::release(1, 56, 0, 1);
$boost_1_56_0_b2 = BoostVersion::release(1, 56, 0, 2);
assert($develop->compare($master) > 0);
assert($master->compare($develop) < 0);
assert($develop->compare($boost_1_55_0) > 0);
assert($boost_1_55_0->compare($develop) < 0);
assert($boost_1_55_0->compare($boost_1_54_0) > 0);
assert($boost_1_54_0->compare($boost_1_55_0) < 0);
assert($boost_1_55_0->compare('boost_1_55_0') == 0);
assert($boost_1_55_0->compare('boost_1_54_0') > 0);
assert($boost_1_55_0->compare('boost_1_56_0') < 0);
assert($develop->dir() == 'develop');
assert($master->dir() == 'master');
assert($boost_1_55_0->dir() == 'boost_1_55_0');
assert((string) $boost_1_55_0 == '1.55.0');
assert($boost_1_56_0_b1->compare($boost_1_56_0_b1) == 0);
assert($boost_1_56_0_b1->compare($boost_1_56_0_b2) < 0);
assert($boost_1_56_0_b1->compare($boost_1_56_0) < 0);
assert($boost_1_56_0_b2->compare($boost_1_56_0_b1) > 0);
assert($boost_1_56_0_b2->compare($boost_1_56_0_b2) == 0);
assert($boost_1_56_0_b2->compare($boost_1_56_0) < 0);
assert($boost_1_56_0->compare($boost_1_56_0_b1) > 0);
assert($boost_1_56_0->compare($boost_1_56_0_b2) > 0);
示例#10
0
<?php

/*
  Copyright 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_config.php';
function html_encode($text)
{
    return htmlentities($text, ENT_COMPAT, 'UTF-8');
}
spl_autoload_register(function ($name) {
    if (!preg_match('@^[A-Za-z0-9\\\\_]*$@', $name)) {
        throw new \RuntimeException("Invalid autoload name: {$name}");
    }
    $file_path = __DIR__ . '/' . strtolower(preg_replace('@([a-z])([A-Z])@', '$1_$2', $name)) . '.php';
    if (is_file($file_path)) {
        require_once $file_path;
    }
});
BoostVersion::set_current(1, 59, 0);
示例#11
0
 static function cmp_boost_version($a, $b)
 {
     return BoostVersion::from($a['boost-version'])->compare($b['boost-version']);
 }
示例#12
0
/**
 *
 * @param string $location The location of the super project in the mirror.
 * @param BoostVersion|string $version The version to update from.
 * @throws RuntimeException
 */
function read_metadata_from_git($location, $version)
{
    global $quiet;
    $branch = BoostVersion::from($version)->git_ref();
    if (!$quiet) {
        echo "Updating from {$branch}\n";
    }
    return read_metadata_from_modules('', $location, $branch);
}
/**
 *
 * @param string $location The location of the super project in the mirror.
 * @param BoostVersion $version The version of the release.
 * @param \BoostLibraries $libs The existing libraries.
 * @throws RuntimeException
 */
function read_metadata_from_release($location, $version, $libs)
{
    // We don't have a list for modules, so have to work it out from the
    // existing library data.
    // If we're updating an old version, then use that as the basis,
    // For a new version, take the data from the master branch, as this
    // may contain new modules that aren't in a release yet.
    $equivalent_version = BoostVersion::$current->compare($version) >= 0 ? $version : BoostVersion::master();
    // Grab the modules from the metadata.
    $module_for_keys = array();
    foreach ($libs->get_for_version($equivalent_version) as $details) {
        $module_for_keys[$details['key']] = $details['module'];
    }
    // Scan release for metadata files.
    $module_paths = array();
    foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator("{$location}/libs", FilesystemIterator::CURRENT_AS_SELF | FilesystemIterator::UNIX_PATHS)) as $info) {
        if ($info->isDot() && $info->getFilename() == '.') {
            $path = dirname($info->getSubPathname());
            if (is_file("{$info->getPathname()}/libraries.json")) {
                $module_paths[] = "libs/" . dirname($path);
            }
        }
    }
    $updated_libs = array();
    foreach ($module_paths as $path) {
        $json_path = "{$location}/{$path}/meta/libraries.json";
        try {
            $libraries = BoostLibrary::read_libraries_json(file_get_contents($json_path));
            // Get the module for each library.
            foreach ($libraries as $lib) {
                if (!isset($module_for_keys[$lib->details['key']])) {
                    echo "No module for key: {$lib->details['key']}.\n";
                } else {
                    $lib->set_module($module_for_keys[$lib->details['key']], $path);
                }
            }
            $updated_libs = array_merge($updated_libs, $libraries);
        } catch (library_decode_exception $e) {
            echo "Error decoding metadata for module at {$json_path}:\n{$e->content()}\n";
        }
    }
    return $updated_libs;
}
 function display_from_archive($content_map = array())
 {
     extract($this->documenation_path_details());
     // Set default values
     $fix_dir = $this->get_param('fix_dir');
     $use_http_expire_date = $this->get_param('use_http_expire_date', false);
     $file = false;
     if ($fix_dir) {
         $fix_path = "{$fix_dir}/{$version_dir}/{$path}";
         if (is_file($fix_path) || is_dir($fix_path) && is_file("{$fix_path}/index.html")) {
             $file = $fix_path;
         }
     }
     if (!$file) {
         $file = $archive_dir . '/';
         $file = $file . $version_dir . '/' . $path;
     }
     // Only use a permanent redirect for releases (beta or full).
     $redirect_status_code = $version && $version->is_numbered_release() ? 301 : 302;
     // Calculate expiry date if requested.
     $expires = null;
     if ($use_http_expire_date) {
         if (!$version) {
             $expires = "+1 week";
         } else {
             $compare_version = BoostVersion::from($version)->compare(BoostVersion::current());
             $expires = $compare_version === -1 ? "+1 year" : ($compare_version === 0 ? "+1 week" : "+1 day");
         }
     }
     // Last modified date
     if (!is_readable($file)) {
         BoostWeb::error_404($file, 'Unable to find file.');
         return;
     }
     $last_modified = max(strtotime(BOOST_DOCS_MODIFIED_DATE), filemtime(dirname(__FILE__) . '/boost.php'), filemtime($file));
     // Check file exists.
     if (is_dir($file)) {
         if (substr($file, -1) != '/') {
             $redirect = BoostUrl::resolve(basename($file) . '/');
             header("Location: {$redirect}", TRUE, $redirect_status_code);
             return;
         }
         $found_file = NULL;
         if (is_readable("{$file}/index.html")) {
             $found_file = 'index.html';
         } else {
             if (is_readable("{$file}/index.htm")) {
                 $found_file = 'index.htm';
             }
         }
         if ($found_file) {
             $file = $file . $found_file;
             $path = $path . $found_file;
         } else {
             if (!BoostWeb::http_headers('text/html', $last_modified, $expires)) {
                 return;
             }
             $data = new BoostFilterData();
             $data->version = $version;
             $data->path = $path;
             $data->archive_dir = $archive_dir;
             $data->fix_dir = $fix_dir;
             $display_dir = new BoostDisplayDir($data);
             return $display_dir->display($file);
         }
     }
     // Choose filter to use
     $info_map = array_merge($content_map, array(array('', '@[.](txt|py|rst|jam|v2|bat|sh|xml|xsl|toyxml)$@i', 'text', 'text/plain'), array('', '@[.](qbk|quickbook)$@i', 'qbk', 'text/plain'), array('', '@[.](c|h|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('', '@[.]svg$@i', 'raw', 'image/svg+xml'), 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'), array('', '@(/|^)(Jamroot|Jamfile|ChangeLog|configure)$@i', 'text', 'text/plain'), array('', '@[.]dtd$@i', 'raw', 'application/xml-dtd'), array('', '@[.]json$@i', 'raw', 'application/json')));
     $preprocess = null;
     $extractor = null;
     $type = null;
     foreach ($info_map as $i) {
         if (preg_match($i[1], $path)) {
             if ($i[0]) {
                 $min_version = BoostVersion::from($i[0]);
                 if ($min_version->compare(BoostVersion::page()) > 0) {
                     // This is after the current version.
                     continue;
                 }
             }
             $extractor = $i[2];
             $type = $i[3];
             $preprocess = isset($i[4]) ? $i[4] : NULL;
             break;
         }
     }
     if (!$extractor) {
         if (strpos($_SERVER['HTTP_HOST'], 'www.boost.org') === false) {
             BoostWeb::error_404($file, 'No extractor found for filename.');
         } else {
             BoostWeb::error_404($file);
         }
         return;
     }
     // Handle ETags and Last-Modified HTTP headers.
     // Output raw files.
     if ($extractor == 'raw') {
         if (!BoostWeb::http_headers($type, $last_modified, $expires)) {
             return;
         }
         if ($_SERVER['REQUEST_METHOD'] != 'HEAD') {
             readfile($file);
         }
     } else {
         // Read file from hard drive
         $content = file_get_contents($file);
         // Check if the file contains a redirect.
         if ($type == 'text/html') {
             if ($redirect = detect_redirect($content)) {
                 BoostWeb::http_headers('text/html', null, "+1 day");
                 header("Location: {$redirect}", TRUE, $redirect_status_code);
                 if ($_SERVER['REQUEST_METHOD'] != 'HEAD') {
                     echo $content;
                 }
                 return;
             }
         }
         if (!BoostWeb::http_headers('text/html', $last_modified, $expires)) {
             return;
         }
         // Finally process the file and display it.
         if ($_SERVER['REQUEST_METHOD'] != 'HEAD') {
             if ($preprocess) {
                 $content = call_user_func($preprocess, $content);
             }
             $data = new BoostFilterData();
             $data->version = $version;
             $data->path = $path;
             $data->content = $content;
             $data->archive_dir = $archive_dir;
             $data->fix_dir = $fix_dir;
             echo_filtered($extractor, $data);
         }
     }
 }
示例#15
0
 static function set_current($major, $minor, $point)
 {
     if (self::$current != null) {
         die("Setting current version twice.");
     }
     self::$current = self::release($major, $minor, $point);
 }
示例#16
0
 function display_from_archive($content_map = array())
 {
     // Set default values
     $this->params = array_merge(array('pattern' => '@^[/]([^/]+)[/](.*)$@', 'vpath' => $_SERVER["PATH_INFO"], 'archive_subdir' => true, 'zipfile' => true, 'fix_dir' => false, 'archive_dir' => ARCHIVE_DIR, 'archive_file_prefix' => ARCHIVE_FILE_PREFIX, 'use_http_expire_date' => false, 'override_extractor' => null, 'title' => NULL, 'charset' => NULL, 'content' => NULL, 'error' => false), $this->params);
     $this->get_archive_location();
     // Only use a permanent redirect for releases (beta or full).
     $redirect_status_code = $this->params['version'] && $this->params['version']->is_numbered_release() ? 301 : 302;
     // Calculate expiry date if requested.
     $expires = null;
     if ($this->params['use_http_expire_date']) {
         if (!$this->params['version']) {
             $expires = "+1 week";
         } else {
             $compare_version = BoostVersion::from($this->params['version'])->compare(BoostVersion::current());
             $expires = $compare_version === -1 ? "+1 year" : ($compare_version === 0 ? "+1 week" : "+1 day");
         }
     }
     // Check file exists.
     if ($this->params['zipfile']) {
         $check_file = $this->params['archive'];
         if (!is_readable($check_file)) {
             error_page($this->params, 'Unable to find zipfile.');
             return;
         }
     } else {
         $check_file = $this->params['file'];
         if (is_dir($check_file)) {
             if (substr($check_file, -1) != '/') {
                 $redirect = resolve_url(basename($check_file) . '/');
                 header("Location: {$redirect}", TRUE, $redirect_status_code);
                 return;
             }
             $found_file = NULL;
             if (is_readable("{$check_file}/index.html")) {
                 $found_file = 'index.html';
             } else {
                 if (is_readable("{$check_file}/index.htm")) {
                     $found_file = 'index.htm';
                 }
             }
             if ($found_file) {
                 $this->params['file'] = $check_file = $check_file . $found_file;
                 $this->params['key'] = $this->params['key'] . $found_file;
             } else {
                 if (!http_headers('text/html', filemtime($check_file), $expires)) {
                     return;
                 }
                 $display_dir = new BoostDisplayDir($this->params);
                 return $display_dir->display($check_file);
             }
         } else {
             if (!is_readable($check_file)) {
                 error_page($this->params, 'Unable to find file.');
                 return;
             }
         }
     }
     // Choose filter to use
     $info_map = array_merge($content_map, array(array('', '@[.](txt|py|rst|jam|v2|bat|sh|xml|xsl|toyxml)$@i', 'text', 'text/plain'), array('', '@[.](qbk|quickbook)$@i', 'qbk', 'text/plain'), array('', '@[.](c|h|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('', '@[.]svg$@i', 'raw', 'image/svg+xml'), 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'), array('', '@(/|^)(Jamroot|Jamfile|ChangeLog|configure)$@i', 'text', 'text/plain'), array('', '@[.]dtd$@i', 'raw', 'application/xml-dtd')));
     $preprocess = null;
     $extractor = null;
     $type = null;
     foreach ($info_map as $i) {
         if (preg_match($i[1], $this->params['key'])) {
             if ($i[0]) {
                 $version = BoostVersion::from($i[0]);
                 if ($version->compare(BoostVersion::page()) > 0) {
                     // This is after the current version.
                     continue;
                 }
             }
             $extractor = $i[2];
             $type = $i[3];
             $preprocess = isset($i[4]) ? $i[4] : NULL;
             break;
         }
     }
     if ($this->params['override_extractor']) {
         $extractor = $this->params['override_extractor'];
     }
     if (!$extractor) {
         if (strpos($_SERVER['HTTP_HOST'], 'www.boost.org') === false) {
             error_page($this->params, "No extractor found for filename.");
         } else {
             error_page($this->params);
         }
         return;
     }
     // Handle ETags and Last-Modified HTTP headers.
     // Output raw files.
     if ($extractor == 'raw') {
         if (!http_headers($type, filemtime($check_file), $expires)) {
             return;
         }
         display_raw_file($this->params, $_SERVER['REQUEST_METHOD'], $type);
     } else {
         // Read file from hard drive or zipfile
         // Note: this sets $this->params['content'] with either the
         // content or an error message.
         if (!extract_file($this->params)) {
             error_page($this->params, $this->params['content']);
             return;
         }
         // Check if the file contains a redirect.
         if ($type == 'text/html') {
             if ($redirect = detect_redirect($this->params['content'])) {
                 http_headers('text/html', null, "+1 day");
                 header("Location: {$redirect}", TRUE, $redirect_status_code);
                 if ($_SERVER['REQUEST_METHOD'] != 'HEAD') {
                     echo $this->params['content'];
                 }
                 return;
             }
         }
         if (!http_headers('text/html', filemtime($check_file), $expires)) {
             return;
         }
         // Finally process the file and display it.
         if ($_SERVER['REQUEST_METHOD'] != 'HEAD') {
             if ($preprocess) {
                 $this->params['content'] = call_user_func($preprocess, $this->params['content']);
             }
             echo_filtered($extractor, $this->params);
         }
     }
 }
示例#17
0
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

<?php 
// Returns true if the library is part of the current release of boost.
function xmlentities($text)
{
    return str_replace(array('&', '<', '>', '"', "'"), array('&amp;', '&lt;', '&gt;', '&quot;', '&apos;'), $text);
}
function echo_sitemap_url($loc, $priority, $freq)
{
    $loc_xml = isset($_SERVER['HTTP_HOST']) ? xmlentities("http://{$_SERVER['HTTP_HOST']}/{$loc}") : xmlentities("http://www.boost.org/{$loc}");
    echo <<<EOL
<url>
<loc>{$loc_xml}</loc>
<priority>{$priority}</priority>
<changefreq>{$freq}</changefreq>
</url>

EOL;
}
// Library list
echo_sitemap_url("doc/libs/", '1.0', 'daily');
// Library 'home pages'
$libs = BoostLibraries::load();
// TODO: Include hidden libraries? Or not?
foreach ($libs->get_for_version(BoostVersion::current()) as $lib) {
    echo_sitemap_url("doc/libs/release/{$lib['documentation']}", '1.0', 'daily');
}
?>
</urlset>
示例#18
0
 function get_release_data($qbk_file, $section)
 {
     if ($section !== 'history' && $section !== 'downloads') {
         return null;
     }
     // TODO: This special case is a real pain to handle, maybe it
     //       shouldn't have release data? It doesn't make much
     //       sense as it is.
     $basename = pathinfo($qbk_file, PATHINFO_FILENAME);
     if ($basename == 'unversioned') {
         return array('release_status' => 'released', 'release_date' => new DateTime('Tue, 14 Dec 1999 12:00:00 GMT'));
     }
     $version = BoostVersion::from($basename);
     $base_version = $version->base_version();
     if (array_key_exists($base_version, $this->releases->release_data)) {
         $chosen_is_dev = true;
         $chosen_version = null;
         $release_data = null;
         foreach ($this->releases->release_data[$base_version] as $version2 => $data) {
             $version_object = BoostVersion::from($version2);
             $is_dev = array_key_exists('release_status', $data) && $data['release_status'] == 'dev';
             if (!$chosen_version || $chosen_is_dev && !$is_dev || $chosen_is_dev == $is_dev && $version_object->compare($chosen_version) > 0) {
                 $chosen_is_dev = $is_dev;
                 $chosen_version = $version_object;
                 $release_data = $data;
                 $release_data['version'] = $version_object;
             }
         }
         return $release_data ?: $dev_data;
     }
     // Assume old versions are released if there's no data.
     if ($version->compare('1.50.0') < 0) {
         return array('version' => $version);
     }
     // TODO: Maybe assume 'master' for new versions?
     return array();
 }
示例#19
0
<?php

require_once __DIR__ . '/../common/code/bootstrap.php';
if (isset($_GET['version'])) {
    try {
        $version = BoostVersion::from($_GET['version']);
    } catch (BoostVersion_Exception $e) {
        header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500);
        echo json_encode(array('error' => $e->getMessage()));
        exit(0);
    }
} else {
    $version = BoostVersion::current();
}
// TODO: This is a bit awkard, should probably have an alternative
//       to 'get_for_version' which returns a BoostLibraries instance
//       rather than an array.
// TODO: Include hidden libraries.
$version_libs = array_map(function ($lib) {
    return new BoostLibrary($lib);
}, BoostLibraries::load()->get_for_version($version));
header('Content-type: application/json');
echo BoostLibrary::get_libraries_json($version_libs);
echo $version_libs->to_json();
示例#20
0
<?php

/*
  Copyright 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_config.php';
function html_encode($text)
{
    return htmlentities($text, ENT_COMPAT, 'UTF-8');
}
spl_autoload_register(function ($name) {
    if (!preg_match('@^[A-Za-z0-9\\\\_]*$@', $name)) {
        throw new \RuntimeException("Invalid autoload name: {$name}");
    }
    $file_path = __DIR__ . '/' . strtolower(preg_replace('@([a-z])([A-Z])@', '$1_$2', $name)) . '.php';
    if (is_file($file_path)) {
        require_once $file_path;
    }
});
BoostVersion::set_current(1, 60, 0);
示例#21
0
 static function set_current($major, $minor, $point)
 {
     if (self::$current != null) {
         throw new BoostVersion_Exception("Setting current version twice.");
     }
     self::$current = self::release($major, $minor, $point);
 }
示例#22
0
 function loadReleaseInfo($release_details)
 {
     if (!preg_match('@
         \\A
         \\s*([^\\s]*)[ \\t]*\\n
         [ \\t]*\\n
         (.*)
         @xs', $release_details, $matches)) {
         throw new BoostException("Error parsing release details");
     }
     $download_page = $matches[1];
     $sha256sums = explode("\n", trim($matches[2]));
     // TODO: Better URL validation?
     if (substr($download_page, -1) != '/') {
         throw new BoostException("Release details needs to start with a directory URL");
     }
     $version = BoostVersion::from($download_page);
     $base_version = $version->base_version();
     $version_string = (string) $version;
     $downloads = array();
     foreach ($sha256sums as $sha256sum) {
         if (!preg_match('@^([0-9a-f]{64}) *([a-zA-Z0-9_.]*)$@', trim($sha256sum), $match)) {
             throw new BoostException("Invalid sha256sum: {$sha256sum}");
         }
         $sha256 = $match[1];
         $filename = $match[2];
         $extension = pathinfo($filename, PATHINFO_EXTENSION);
         $extensions = array('7z' => 'windows', 'zip' => 'windows', 'gz' => 'unix', 'bz2' => 'unix');
         if (!array_key_exists($extension, $extensions)) {
             throw new BoostException("Invalid extension: {$filename}");
         }
         $line_endings = $extensions[$extension];
         $downloads[$extension] = array('line_endings' => $line_endings, 'url' => "{$download_page}{$filename}", 'sha256' => $sha256);
     }
     // TODO: Should probably set documentation URL before loading in the
     //       release data, so the array keys should already exist?
     if (!array_key_exists($base_version, $this->release_data)) {
         $this->release_data[$base_version] = array();
     }
     if (!array_key_exists($version_string, $this->release_data[$base_version])) {
         $this->release_data[$base_version][$version_string] = array('release_status' => 'dev');
     }
     $this->release_data[$base_version][$version_string]['download_page'] = $download_page;
     $this->release_data[$base_version][$version_string]['downloads'] = $downloads;
 }
示例#23
0
 /**
  * Get the library details for a particular release.
  *
  * @param \BoostVersion $version
  * @param string $sort Optional field used to sort the libraries.
  * @param callable $filter Optional filter function.
  * @return array
  */
 function get_for_version($version, $sort = null, $filter = null)
 {
     $version = BoostVersion::from($version);
     $libs = array();
     if (!$filter) {
         $filter = $version->is_numbered_release() ? 'BoostLibraries::filter_released' : 'BoostLibraries::filter_all';
     }
     foreach ($this->db as $key => $versions) {
         $details = null;
         foreach ($versions as $lib) {
             if ($version->compare($lib->update_version) >= 0) {
                 $details = $lib->details;
             }
         }
         if ($details) {
             if ($filter && !call_user_func($filter, $details)) {
                 continue;
             }
             $libs[$key] = $details;
         }
     }
     $libs = array_values($libs);
     if ($sort) {
         uasort($libs, BoostUtility::sort_by_field($sort));
     }
     return $libs;
 }
示例#24
0
 function template_params($content)
 {
     $charset = $this->charset ?: 'us-ascii';
     $title = $this->title ?: 'Boost C++ Libraries';
     if (!empty($this->params['version'])) {
         $title = "{$this->title} - " . BoostVersion::from($this->params['version']);
     }
     $head = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset={$charset}\" />\n";
     if (!empty($this->params['noindex'])) {
         $head .= "<meta name=\"robots\" content=\"noindex\">\n";
     }
     $head .= "<title>{$title}</title>";
     return array('head' => $head, 'content' => $content);
 }