mirror of
https://github.com/boostorg/website.git
synced 2026-01-23 18:12:16 +00:00
boost_archive.php: For mime types, the current list seems fine, and a full list doesn't seem feasable. boost_filter_text.php: For supporting other character sets, could possibly use mb_detect_encoding to guess the file's encoding, but it's not currently installed on the server, and I think guesses are probably no better than just assuming everything is UTF-8. The alternative would be some mechanism to specify a file's (path's?) encoding, but I'm sure that can be done if the need arises. boost_library.php: If it turns out that a better exception is needed, then it will be handled then, so I'm not concerned with that TODO note. boost_pages.php: Sourceforge is redirecting downloads to the right place, so I'll not bother with '/download' at the end. It's probably better if the download URLs have the right filename. boost_simple_template.php: I don't think the simple template class really needs to support tricky edge cases, so I'll just leave that alone. doc/libraries.php: I don't think anyone's desperate to see the library list for ancient versions. If they are, they can get the it in json format using: http://www.boost.org/doc/libraries.json.php?version=1.11.1 site-tools/git-prep-beta.sh: Coming back to this, I think the answer is no. A change on master is only really made when it has been pushed to remote, if it's only local then it might get rebased. This script doesn't actually get much use now that there are long standing unmerged changes in beta, but it used to work well for me. site-tools/update-doc-list.php: Other TODO note was to make the script a little more automatic when run against a local git tree, but I don't think that's a use case to support in general. The tree might not be fully synced, or might be checked out from a tag, which would be harder to check.
236 lines
7.2 KiB
PHP
236 lines
7.2 KiB
PHP
<?php
|
|
/*
|
|
Copyright 2006 Redshift Software, Inc.
|
|
Copyright 2014 Daniel James
|
|
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)
|
|
*/
|
|
|
|
/**
|
|
* The basic details about a single library.
|
|
*/
|
|
class BoostLibrary
|
|
{
|
|
var $details = null;
|
|
var $update_version = null; // Used by BoostLibraries.
|
|
|
|
/**
|
|
* Read a libraries json file, and return an array of BoostLibrary.
|
|
*/
|
|
static function read_libraries_json($json) {
|
|
$json = trim($json);
|
|
$libs = json_decode($json, true);
|
|
if (!is_array($libs)) {
|
|
throw new BoostLibraries_DecodeException("Error decoding json.", $json);
|
|
}
|
|
if ($json[0] == '{') {
|
|
$libs = array($libs);
|
|
}
|
|
return array_map(function($lib) {
|
|
return new BoostLibrary($lib);
|
|
}, $libs);
|
|
}
|
|
|
|
static function get_libraries_json($libs, $exclude = array()) {
|
|
$export = array_map(function($lib) use($exclude) {
|
|
return $lib->array_for_json($exclude);
|
|
}, $libs);
|
|
|
|
if (count($export) == 1) { $export = reset($export); }
|
|
|
|
// I'm not sure why php escapes slashes, but I don't want them so
|
|
// I'll just zap them. Maybe stop doing that in the future.
|
|
return str_replace('\\/', '/',
|
|
json_encode($export,
|
|
(defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0) |
|
|
(defined('JSON_UNESCAPED_UNICODE') ? JSON_UNESCAPED_UNICODE : 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'))) {
|
|
throw new BoostLibraries_exception("Invalid status: {$lib['status']}");
|
|
}
|
|
}
|
|
|
|
$this->details = $lib;
|
|
}
|
|
|
|
// This is basically the parent of the 'meta' directory.
|
|
public function set_library_path($library_path) {
|
|
assert(!isset($this->details['library_path']));
|
|
$library_path = trim($library_path, '/').'/';
|
|
$documentation_url =
|
|
isset($this->details['documentation']) ?
|
|
$this->details['documentation'] : '.';
|
|
$this->details['library_path'] = $library_path;
|
|
$this->details['documentation'] =
|
|
ltrim(BoostUrl::resolve($documentation_url, $library_path), '/');
|
|
}
|
|
|
|
public function array_for_json($exclude = array()) {
|
|
$details = $this->details;
|
|
|
|
if (empty($details['std'])) {
|
|
unset($details['std']);
|
|
}
|
|
unset($details['std-tr1']);
|
|
unset($details['std-proposal']);
|
|
|
|
$details = self::clean_for_output($details, $exclude);
|
|
|
|
foreach ($exclude as $field) {
|
|
if (isset($details[$field])) {
|
|
unset($details[$field]);
|
|
}
|
|
}
|
|
|
|
return $details;
|
|
}
|
|
|
|
/** 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();
|
|
}
|
|
}
|
|
|
|
public function equal_to($other) {
|
|
$details1 = $this->details;
|
|
$details2 = $other->details;
|
|
|
|
if (count(array_diff_key($details1, $details2))
|
|
|| count(array_diff_key($details2, $details1))) {
|
|
return false;
|
|
}
|
|
|
|
foreach($details1 as $key => $value) {
|
|
if (is_object($value)) {
|
|
if ($value->compare($details2[$key]) != 0) return false;
|
|
}
|
|
else {
|
|
if ($value != $details2[$key]) return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Convert authors and maintainers to strings.
|
|
* This is kind of rubbish, but I want authors and maintainers to be
|
|
* arrays in the repo metadata, but strings on the website. So call this
|
|
* when creating the website file.
|
|
*/
|
|
public function squash_name_arrays() {
|
|
if (isset($this->details['authors']))
|
|
{
|
|
$this->details['authors']
|
|
= $this->names_to_string($this->details['authors']);
|
|
}
|
|
|
|
if (isset($this->details['maintainers']))
|
|
{
|
|
$this->details['maintainers']
|
|
= $this->names_to_string($this->details['maintainers']);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param array|string $names
|
|
* @return string
|
|
*/
|
|
private function names_to_string($names) {
|
|
if (is_array($names)) {
|
|
$last_name = array_pop($names);
|
|
|
|
return $names ?
|
|
implode(', ', $names)." and {$last_name}" :
|
|
$last_name;
|
|
}
|
|
else {
|
|
return $names;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Prepare library details for output.
|
|
*
|
|
* Currently just reduces the version information.
|
|
*
|
|
* @param array $lib
|
|
* @return array Library details for output.
|
|
*/
|
|
static function clean_for_output($lib) {
|
|
//if (!isset($lib['update-version']) && !isset($lib['boost-version'])) {
|
|
// throw new RuntimeException("No version data for {$lib['name']}.");
|
|
//}
|
|
|
|
if (isset($lib['update-version'])) {
|
|
$lib['update-version'] = (string) $lib['update-version'];
|
|
}
|
|
|
|
if (isset($lib['boost-version'])) {
|
|
$lib['boost-version'] = (string) $lib['boost-version'];
|
|
}
|
|
|
|
if (isset($lib['boost-version']) && isset($lib['update-version']) &&
|
|
$lib['update-version'] == $lib['boost-version']) {
|
|
unset($lib['update-version']);
|
|
}
|
|
|
|
return $lib;
|
|
}
|
|
}
|