diff --git a/src/lib/views/system/PanaceaTemplateView.php b/src/lib/views/system/PanaceaTemplateView.php index 269fdaa..283a423 100644 --- a/src/lib/views/system/PanaceaTemplateView.php +++ b/src/lib/views/system/PanaceaTemplateView.php @@ -82,8 +82,10 @@ } } - return ViewMetaData::generate()->addMeta('revised', date('c', $revised)) - ->addCss($this->cssPath . '/global.css'); + $data = ViewMetaData::generate()->addMeta('revised', date('c', $revised)) + ->addCss($this->cssPath . '/global.css'); + + return parent::getMetaData()->merge($data); } /** diff --git a/src/lib/views/wiki/WikiRevisionHistoryView.php b/src/lib/views/wiki/WikiRevisionHistoryView.php index 5a5273f..627c830 100644 --- a/src/lib/views/wiki/WikiRevisionHistoryView.php +++ b/src/lib/views/wiki/WikiRevisionHistoryView.php @@ -47,14 +47,18 @@ public function __construct(Collection $revisions, $pageName, $priority = 0) { parent::__construct($priority); - if ($revisions->type !== 'WikiHistory') { - throw new InvalidTypeException(1, 'Collection with type "WikiHistory"', $revisions); + if ($revisions->type !== 'Registry') { + throw new InvalidTypeException(1, 'Collection with type "Registry"', $revisions); } $this->revisions = $revisions; $this->pageName = $pageName; } + public function getMetaData() { + return ViewMetaData::generate()->addJavaScript($this->jsPath . '/wiki.js'); + } + /** * Renders the view * @@ -69,31 +73,37 @@ Date Message Author - Diff + Diff revisions as $revision => $history) { + foreach ($this->revisions as $revision => $revisionData) { $affectedBytes = 'n/a'; if ($previous !== null) { $link = $this->wikiPath . '/' . $this->pageName; $link .= '?diff[' . $previous->revision . ',' . $revision .']'; - $affectedBytes = strlen($history->wikitext) - strlen($previous->wikitext); - $affectedBytes = (($affectedBytes >= 0) ? '+' : '') . $affectedBytes; - $affectedBytes = '' . $affectedBytes . ' bytes'; + $affectedBytes = strlen($revisionData->wikitext) - strlen($previous->wikitext); + $percentage = round(100 * $affectedBytes / strlen($revisionData->wikitext), 2); + $prefix = ($affectedBytes === 0) ? '±' : (($affectedBytes > 0) ? '+' : ''); + $suffix = (abs($affectedBytes) === 1) ? ' byte' : ' bytes'; + $affectedBytes = $prefix . $affectedBytes . $suffix . ' (' . $prefix . $percentage . '%)'; + + $affectedBytes = '' . $affectedBytes . ''; } - $previous = $history; + $previous = $revisionData; ?> - revision; ?> - created; ?> - message; ?> - created_user_id; ?> + revision; ?> + created; ?> + message; ?> + user_name; ?> + + + + + +