From 61bab81e593fa74b99b46ecd10a3db03ae2d69bb Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Sat, 7 Apr 2007 23:27:05 +0000 Subject: [PATCH] - RSSFromSVN now links to ViewVC entry - RSS feeds now are properly htmlspecialchar'ed when entered - Revision titles are now more descriptive git-svn-id: http://htmlpurifier.org/svnroot@953 48356398-32a2-884e-a903-53898d9a118a --- xhtml-compiler/TODO.txt | 3 --- xhtml-compiler/XHTMLCompiler.php | 2 +- .../XHTMLCompiler/DOMFilter/RSSFromSVN.php | 22 ++++++++++++++++++---- xhtml-compiler/XHTMLCompiler/RSSFeed.php | 6 +++--- xhtml-compiler/config.default.php | 4 ++++ 5 files changed, 26 insertions(+), 11 deletions(-) diff --git a/xhtml-compiler/TODO.txt b/xhtml-compiler/TODO.txt index 32a10c9..33e0879 100644 --- a/xhtml-compiler/TODO.txt +++ b/xhtml-compiler/TODO.txt @@ -8,9 +8,6 @@ DOMFilter - Embedded Math with LaTeX, see MediaWiki and texvc (difficult) DOMFilter_RSSFromSVN -- More description revision titles -- Links that actually go somewhere and properly keep track of visits -- Ability to look at past revisions (?, maybe source) - Incremental updates of cache TextFilter diff --git a/xhtml-compiler/XHTMLCompiler.php b/xhtml-compiler/XHTMLCompiler.php index 68caa9f..773fc0f 100644 --- a/xhtml-compiler/XHTMLCompiler.php +++ b/xhtml-compiler/XHTMLCompiler.php @@ -56,7 +56,7 @@ class XHTMLCompiler // PLUGIN/CONFIGURATION FUNCTIONALITY protected $configKeys = array('allowed_dirs', 'directory_index', - 'indexed_dirs', 'web_path', 'web_domain'); + 'indexed_dirs', 'web_path', 'web_domain', 'viewvc_url'); protected $config = array(); protected $filterManager; diff --git a/xhtml-compiler/XHTMLCompiler/DOMFilter/RSSFromSVN.php b/xhtml-compiler/XHTMLCompiler/DOMFilter/RSSFromSVN.php index ad0af65..807edb3 100644 --- a/xhtml-compiler/XHTMLCompiler/DOMFilter/RSSFromSVN.php +++ b/xhtml-compiler/XHTMLCompiler/DOMFilter/RSSFromSVN.php @@ -12,6 +12,9 @@ class XHTMLCompiler_DOMFilter_RSSFromSVN extends XHTMLCompiler_DOMFilter public function process(DOMDocument $dom, $page, $manager) { + $xc = XHTMLCompiler::getInstance(); + $viewvc_url = $xc->getConf('viewvc_url'); + // grab the document's links to RSS feeds // link must be marked with xc:rss-from-svn // only one allowed @@ -47,11 +50,22 @@ class XHTMLCompiler_DOMFilter_RSSFromSVN extends XHTMLCompiler_DOMFilter date_default_timezone_set('UTC'); foreach ($logs as $log) { + // link to ViewVC snapshot if possible + if ($viewvc_url) { + $item_link = $viewvc_url . '/' . $page->getSourcePath() . + '?revision=' . $log['rev'] . '&view=markup'; + } else { + $item_link = $page_link . '#svn_r' . $log['rev']; + } + // generate short message (first line) for title + $lines = explode("\n", wordwrap($log['msg'], 40)); + $short_msg = $lines[0]; + $rss->addItem( - $page_link, - 'Revision ' . $log['rev'], - gmdate('r', strtotime($log['date'])), - $log['msg'] + $item_link, + 'Revision ' . $log['rev'] . ': ' . htmlspecialchars($short_msg), + $d = gmdate('r', strtotime($log['date'])), + htmlspecialchars($log['msg']) ); } diff --git a/xhtml-compiler/XHTMLCompiler/RSSFeed.php b/xhtml-compiler/XHTMLCompiler/RSSFeed.php index 36525a2..34dbb74 100644 --- a/xhtml-compiler/XHTMLCompiler/RSSFeed.php +++ b/xhtml-compiler/XHTMLCompiler/RSSFeed.php @@ -61,10 +61,10 @@ class XHTMLCompiler_RSSFeed $body = preg_replace("/\s+/", ' ', $body); - $item->appendChild($this->doc->createElement('title', $title)); + if ($title) $item->appendChild($this->doc->createElement('title', htmlspecialchars($title))); $item->appendChild($this->doc->createElement('pubDate', $date)); - $item->appendChild($this->doc->createElement('description', $body)); - $item->appendChild($this->doc->createElement('link', $link)); + $item->appendChild($this->doc->createElement('description', htmlspecialchars($body))); + $item->appendChild($this->doc->createElement('link', htmlspecialchars($link))); } /** diff --git a/xhtml-compiler/config.default.php b/xhtml-compiler/config.default.php index dff5d25..6ccffce 100644 --- a/xhtml-compiler/config.default.php +++ b/xhtml-compiler/config.default.php @@ -44,4 +44,8 @@ $web_path = ''; // line unless you set it explicitly! $web_domain = $_SERVER['HTTP_HOST']; +// ** URL of ViewVC installation +// No trailing slash +$viewvc_url = false; + ?> \ No newline at end of file -- 2.11.4.GIT