diff --git a/src/__celerity_resource_map__.php b/src/__celerity_resource_map__.php index b638d1d94e..e1e52ed079 100644 --- a/src/__celerity_resource_map__.php +++ b/src/__celerity_resource_map__.php @@ -27,7 +27,7 @@ celerity_register_resource_map(array( ), 'aphront-dark-console-css' => array( - 'uri' => '/res/a7d1dbf1/rsrc/css/aphront/dark-console.css', + 'uri' => '/res/1a9f84bb/rsrc/css/aphront/dark-console.css', 'type' => 'css', 'requires' => array( @@ -1137,7 +1137,7 @@ celerity_register_resource_map(array( ), 'phriction-document-css' => array( - 'uri' => '/res/b682cd2e/rsrc/css/application/phriction/phriction-document-css.css', + 'uri' => '/res/e764414a/rsrc/css/application/phriction/phriction-document-css.css', 'type' => 'css', 'requires' => array( diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 716a6a0051..b9c0057a34 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -585,6 +585,7 @@ phutil_register_library_map(array( 'PhrictionDocument' => 'applications/phriction/storage/document', 'PhrictionDocumentController' => 'applications/phriction/controller/document', 'PhrictionEditController' => 'applications/phriction/controller/edit', + 'PhrictionHistoryController' => 'applications/phriction/controller/history', ), 'function' => array( @@ -1080,6 +1081,7 @@ phutil_register_library_map(array( 'PhrictionDocument' => 'PhrictionDAO', 'PhrictionDocumentController' => 'PhrictionController', 'PhrictionEditController' => 'PhrictionController', + 'PhrictionHistoryController' => 'PhrictionController', ), 'requires_interface' => array( diff --git a/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php b/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php index 383c0ee92f..5acf39191b 100644 --- a/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php +++ b/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php @@ -347,6 +347,9 @@ class AphrontDefaultApplicationConfiguration '/w/(?P.+/)$' => 'PhrictionDocumentController', '/phriction/' => array( + 'history(?P/)$' => 'PhrictionHistoryController', + 'history/(?P.+/)$' => 'PhrictionHistoryController', + 'edit/(?:(?P\d+)/)?$' => 'PhrictionEditController', ), ); diff --git a/src/applications/phriction/controller/base/PhrictionController.php b/src/applications/phriction/controller/base/PhrictionController.php index ec509e0a7a..7a88e71080 100644 --- a/src/applications/phriction/controller/base/PhrictionController.php +++ b/src/applications/phriction/controller/base/PhrictionController.php @@ -27,6 +27,24 @@ abstract class PhrictionController extends PhabricatorController { $page->setTitle(idx($data, 'title')); $page->setGlyph("\xE2\x9A\xA1"); + $tabs = array(); + if (!empty($data['document'])) { + $tabs['document'] = array( + 'name' => 'Document', + 'href' => $data['document'], + ); + } + if (!empty($data['history'])) { + $tabs['history'] = array( + 'name' => 'History', + 'href' => $data['history'], + ); + } + + if (!empty($tabs)) { + $page->setTabs($tabs, idx($data, 'tab')); + } + $page->appendChild($view); $response = new AphrontWebpageResponse(); diff --git a/src/applications/phriction/controller/document/PhrictionDocumentController.php b/src/applications/phriction/controller/document/PhrictionDocumentController.php index f9110a5424..59ea1c2008 100644 --- a/src/applications/phriction/controller/document/PhrictionDocumentController.php +++ b/src/applications/phriction/controller/document/PhrictionDocumentController.php @@ -73,7 +73,8 @@ class PhrictionDocumentController return $this->buildStandardPageResponse( $page, array( - 'title' => 'Phriction - '.$page_title, + 'title' => 'Phriction - '.$page_title, + 'history' => PhrictionDocument::getSlugURI($slug, 'history'), )); } diff --git a/src/applications/phriction/controller/history/PhrictionHistoryController.php b/src/applications/phriction/controller/history/PhrictionHistoryController.php new file mode 100644 index 0000000000..0e1c42c140 --- /dev/null +++ b/src/applications/phriction/controller/history/PhrictionHistoryController.php @@ -0,0 +1,103 @@ +slug = $data['slug']; + } + + public function processRequest() { + + $request = $this->getRequest(); + $user = $request->getUser(); + + $document = id(new PhrictionDocument())->loadOneWhere( + 'slug = %s', + PhrictionDocument::normalizeSlug($this->slug)); + + if (!$document) { + return new Aphront404Response(); + } + + $pager = new AphrontPagerView(); + $pager->setOffset($request->getInt('page')); + $pager->setURI($request->getRequestURI(), 'page'); + + $history = id(new PhrictionContent())->loadAllWhere( + 'documentID = %d ORDER BY version DESC LIMIT %d, %d', + $document->getID(), + $pager->getOffset(), + $pager->getPageSize() + 1); + $history = $pager->sliceResults($history); + + $author_phids = mpull($history, 'getAuthorPHID'); + $handles = id(new PhabricatorObjectHandleData($author_phids)) + ->loadHandles(); + + $rows = array(); + foreach ($history as $content) { + + $uri = PhrictionDocument::getSlugURI($document->getSlug()); + + $rows[] = array( + phabricator_date($content->getDateCreated(), $user), + phabricator_time($content->getDateCreated(), $user), + (int)$content->getVersion(), + $handles[$content->getAuthorPHID()]->renderLink(), + ); + } + + $table = new AphrontTableView($rows); + $table->setHeaders( + array( + 'Date', + 'Time', + 'Version', + 'Author', + )); + $table->setColumnClasses( + array( + '', + 'right', + '', + 'wide', + )); + + $panel = new AphrontPanelView(); + $panel->setHeader('Document History'); + $panel->appendChild($table); + $panel->appendChild($pager); + + $slug = $document->getSlug(); + + return $this->buildStandardPageResponse( + $panel, + array( + 'title' => 'Document History', + 'history' => PhrictionDocument::getSlugURI($slug, 'history'), + 'document' => PhrictionDocument::getSlugURI($slug), + 'tab' => 'history', + )); + + } + +} diff --git a/src/applications/phriction/controller/history/__init__.php b/src/applications/phriction/controller/history/__init__.php new file mode 100644 index 0000000000..d02b018a49 --- /dev/null +++ b/src/applications/phriction/controller/history/__init__.php @@ -0,0 +1,22 @@ + '/w/', + 'history' => '/phriction/history/', + ); + + if (empty($types[$type])) { + throw new Exception("Unknown URI type '{$type}'!"); + } + + $prefix = $types[$type]; + if ($slug == '/') { - return '/w/'; + return $prefix; } else { - return '/w/'.$slug; + return $prefix.$slug; } } + public static function normalizeSlug($slug) { // TODO: We need to deal with unicode at some point, this is just a very