Пример #1
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);
 }
Пример #2
0
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();
}
Пример #3
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']);
 }
Пример #4
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'] = '';
     }
     // Setup the standard flags.
     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']);
     }
     // Check the status.
     if (isset($lib['status'])) {
         $lib['status'] = strtolower($lib['status']);
         if (!in_array($lib['status'], array('hidden', 'unreleased', 'deprecated'))) {
             // TODO: Better exception?
             throw new BoostLibraries_exception("Invalid status: {$lib['status']}");
         }
     }
     $this->details = $lib;
 }
Пример #5
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)
{
    $branch = BoostVersion::from($version)->git_ref();
    echo "Updating from {$branch}\n";
    $super_project = new BoostSuperProject($location, $branch);
    $modules = $super_project->get_modules();
    $modules_by_path = array();
    foreach ($modules as $name => $details) {
        $modules_by_path[$details['path']] = $name;
    }
    foreach ($super_project->run_git("ls-tree {$branch} " . implode(' ', array_keys($modules_by_path))) as $line_number => $line) {
        if (!$line) {
            continue;
        }
        if (preg_match("@^160000 commit ([a-zA-Z0-9]+)\t(.*)\$@", $line, $matches)) {
            $modules[$modules_by_path[$matches[2]]]['hash'] = $matches[1];
        } else {
            throw new RuntimeException("Unmatched submodule line: {$line}");
        }
    }
    $updated_libs = array();
    foreach ($modules as $name => $module) {
        $module_location = "{$location}/{$module['url']}";
        $module_command = "cd '{$module_location}' && git";
        foreach (BoostSuperProject::run_process("{$module_command} ls-tree {$module['hash']} " . "meta/libraries.xml meta/libraries.json") as $entry) {
            try {
                $entry = trim($entry);
                if (preg_match("@^100644 blob ([a-zA-Z0-9]+)\t(.*)\$@", $entry, $matches)) {
                    $hash = $matches[1];
                    $filename = $matches[2];
                    $text = implode("\n", BoostSuperProject::run_process("{$module_command} show {$hash}"));
                    $updated_libs = array_merge($updated_libs, load_from_text($text, $filename, $name, $module['path']));
                }
            } catch (library_decode_exception $e) {
                echo "Error decoding metadata for module {$name}:\n{$e->content()}\n";
            }
        }
    }
    return $updated_libs;
}
Пример #6
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;
 }
Пример #7
0
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();
}
Пример #8
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);
         }
     }
 }
Пример #9
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);
}
Пример #10
0
 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);
         }
     }
 }
Пример #11
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();
 }
Пример #12
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();
Пример #13
0
 static function cmp_boost_version($a, $b)
 {
     return BoostVersion::from($a['boost-version'])->compare($b['boost-version']);
 }
Пример #14
0
 /**
  * Compare this verison with another. Ignores the beta field
  * (i.e. 1.50.0 beta1 == 1.50.0 beta).
  * @return int, -1 if less than the other version, 0 if the
  * same, +1 if more
  */
 function compare($x)
 {
     $x = BoostVersion::from($x);
     // Full releases come after betas.
     $beta = $this->beta === false ? 9999 : $this->beta;
     $x_beta = $x->beta === false ? 9999 : $x->beta;
     return $this->version < $x->version ? -1 : ($this->version > $x->version ? 1 : 0) ?: ($beta < $x_beta ? -1 : ($beta > $x_beta ? 1 : 0));
 }
Пример #15
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;
 }
Пример #16
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;
 }
Пример #17
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);
 }