Esempio n. 1
0
    function generate_rss_item($qbk_file, $page)
    {
        assert($page->loaded);
        $rss_xml = new DOMDocument();
        $rss_xml->loadXML(<<<EOL
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:boostbook="urn:boost.org:boostbook">
</rss>
EOL
);
        $page_link = "http://www.boost.org/{$page->location}";
        $item = $rss_xml->createElement('item');
        $node = new DOMDocument();
        $node->loadXML('<title>' . $this->encode_for_rss($page->title_xml) . '</title>');
        $item->appendChild($rss_xml->importNode($node->documentElement, true));
        $node = new DOMDocument();
        $node->loadXML('<link>' . $this->encode_for_rss($page_link) . '</link>');
        $item->appendChild($rss_xml->importNode($node->documentElement, true));
        $node = new DOMDocument();
        $node->loadXML('<guid>' . $this->encode_for_rss($page_link) . '</guid>');
        $item->appendChild($rss_xml->importNode($node->documentElement, true));
        # TODO: Convert date format?
        $node = $rss_xml->createElement('pubDate');
        $node->appendChild($rss_xml->createTextNode($page->pub_date));
        $item->appendChild($node);
        $node = $rss_xml->createElement('description');
        # Placing the description in a root element to make it well formed xml->
        $description = new DOMDocument();
        $description->loadXML('<x>' . $this->encode_for_rss($page->description_xml) . '</x>');
        BoostSiteTools::base_links($description, $page_link);
        foreach ($description->firstChild->childNodes as $child) {
            $node->appendChild($rss_xml->createTextNode($description->saveXML($child)));
        }
        $item->appendChild($node);
        return array('item' => $item, 'quickbook' => $qbk_file, 'last_modified' => $page->last_modified);
    }
Esempio n. 2
0
#!/usr/bin/env php
<?php 
# Copyright 2007 Rene Rivera
# Copyright 2011, 2015 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)
$usage = <<<EOL
Usage: {}

Update the html pages and rss feeds for new or updated quickbook files.
EOL;
require_once __DIR__ . '/../common/code/bootstrap.php';
BoostSiteTools\CommandLineOptions::parse($usage);
$site_tools = new BoostSiteTools(__DIR__ . '/..');
$site_tools->update_quickbook();
Esempio n. 3
0
 function load_boostbook_data($values, $refresh = false)
 {
     $this->title_xml = BoostSiteTools::trim_lines($values['title_xhtml']);
     $this->purpose_xml = BoostSiteTools::trim_lines($values['purpose_xhtml']);
     $this->notice_xml = BoostSiteTools::trim_lines($values['notice_xhtml']);
     $this->notice_url = $values['notice_url'];
     $this->pub_date = $values['pub_date'];
     $this->id = $values['id'];
     if (!$this->id) {
         $this->id = strtolower(preg_replace('@[\\W]@', '_', $this->title_xml));
     }
 }
Esempio n. 4
0
 function generate_rss_item($qbk_file, $page)
 {
     assert(!!$page->description_xml);
     $xml = '';
     $page_link = "http://www.boost.org/{$page->location}";
     $xml .= '<item>';
     $xml .= '<title>' . $this->encode_for_rss($page->title_xml) . '</title>';
     $xml .= '<link>' . $this->encode_for_rss($page_link) . '</link>';
     $xml .= '<guid>' . $this->encode_for_rss($page_link) . '</guid>';
     // Q: Maybe use $page->last_modified when there's no pub_date.
     $pub_date = null;
     if ($page->release_data && array_key_exists('release_date', $page->release_data)) {
         $pub_date = $page->release_data['release_date'];
     } else {
         $pub_date = $page->pub_date;
     }
     if ($pub_date) {
         $xml .= '<pubDate>' . $this->encode_for_rss($pub_date->format(DATE_RSS)) . '</pubDate>';
     }
     # Placing the description in a root element to make it well formed xml->
     $description = BoostSiteTools::base_links($page->description_xml, $page_link);
     $xml .= '<description>' . $this->encode_for_rss($description) . '</description>';
     $xml .= '</item>';
     // Q: Should this be using the page last_modified, or when the RSS
     //    feed item was last modified?
     return array('item' => $xml, 'quickbook' => $qbk_file, 'last_modified' => $page->last_modified);
 }
Esempio n. 5
0
#!/usr/bin/env php
<?php 
# Copyright 2007 Rene Rivera
# Copyright 2011, 2015 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)
$usage = <<<EOL
Usage: {}

Reconvert all the quickbook files and regenerate the html pages. Does
not update the rss feeds or add new pages. Useful for when quickbook,
the scripts or the templates have been updated.
EOL;
require_once __DIR__ . '/../common/code/bootstrap.php';
BoostSiteTools\CommandLineOptions::parse($usage);
$site_tools = new BoostSiteTools(__DIR__ . '/..');
$site_tools->update_quickbook(true);
Esempio n. 6
0
 function load($values, $refresh = false)
 {
     assert($this->dir_location || $refresh);
     assert(!$this->loaded);
     $this->title_xml = BoostSiteTools::fragment_to_string($values['title_fragment']);
     $this->purpose_xml = BoostSiteTools::fragment_to_string($values['purpose_fragment']);
     $this->notice_xml = BoostSiteTools::fragment_to_string($values['notice_fragment']);
     $this->notice_url = $values['notice_url'];
     $this->pub_date = $values['pub_date'];
     $this->last_modified = $values['last_modified'];
     $this->download_item = $values['download_item'];
     $this->download_basename = $values['download_basename'];
     $this->documentation = $values['documentation'];
     $this->final_documentation = $values['final_documentation'];
     $this->id = $values['id'];
     if (!$this->id) {
         $this->id = strtolower(preg_replace('@[\\W]@', '_', $this->title_xml));
     }
     if ($this->dir_location) {
         $this->location = $this->dir_location . $this->id . '.html';
         $this->dir_location = null;
         $this->page_state = null;
     }
     $this->release_status = $values['status_item'];
     $this->loaded = true;
     $this->initialise();
     if (empty($this->flags['released']) && $this->documentation) {
         $doc_prefix = rtrim($this->documentation, '/');
         BoostSiteTools::transform_links($values['description_fragment'], function ($x) use($doc_prefix) {
             return preg_match('@^/(?:libs/|doc/html/)@', $x) ? $doc_prefix . $x : $x;
         });
     }
     if ($this->final_documentation) {
         $link_pattern = '@^' . rtrim($this->final_documentation, '/') . '/@';
         $replace = "{$doc_prefix}/";
         BoostSiteTools::transform_links($values['description_fragment'], function ($x) use($link_pattern, $replace) {
             return preg_replace($link_pattern, $replace, $x);
         });
     }
     $this->description_xml = BoostSiteTools::fragment_to_string($values['description_fragment']);
 }