Ejemplo n.º 1
0
 public function processRequest()
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $books = id(new DivinerBookQuery())->setViewer($viewer)->execute();
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb(pht('Books'));
     $search_icon = id(new PHUIIconView())->setIconFont('fa-search');
     $query_button = id(new PHUIButtonView())->setTag('a')->setHref($this->getApplicationURI('query/'))->setText(pht('Advanced Search'))->setIcon($search_icon);
     $header = id(new PHUIHeaderView())->setHeader(pht('Documentation Books'))->addActionLink($query_button);
     $document = new PHUIDocumentView();
     $document->setHeader($header);
     $document->setFontKit(PHUIDocumentView::FONT_SOURCE_SANS);
     $document->addClass('diviner-view');
     if ($books) {
         $books = msort($books, 'getTitle');
         $list = array();
         foreach ($books as $book) {
             $item = id(new DivinerBookItemView())->setTitle($book->getTitle())->setHref('/book/' . $book->getName() . '/')->setSubtitle($book->getPreface());
             $list[] = $item;
         }
         $list = id(new PHUIBoxView())->addPadding(PHUI::PADDING_LARGE_LEFT)->addPadding(PHUI::PADDING_LARGE_RIGHT)->addPadding(PHUI::PADDING_SMALL_TOP)->addPadding(PHUI::PADDING_SMALL_BOTTOM)->appendChild($list);
         $document->appendChild($list);
     } else {
         $text = pht("(NOTE) **Looking for Phabricator documentation?** If you're looking " . "for help and information about Phabricator, you can " . "[[ https://secure.phabricator.com/diviner/ | browse the public " . "Phabricator documentation ]] on the live site.\n\n" . "Diviner is the documentation generator used to build the Phabricator " . "documentation.\n\n" . "You haven't generated any Diviner documentation books yet, so " . "there's nothing to show here. If you'd like to generate your own " . "local copy of the Phabricator documentation and have it appear " . "here, run this command:\n\n" . "  phabricator/ \$ ./bin/diviner generate\n\n" . "Right now, Diviner isn't very useful for generating documentation " . "for projects other than Phabricator. If you're interested in using " . "it in your own projects, leave feedback for us on " . "[[ https://secure.phabricator.com/T4558 | T4558 ]].");
         $text = PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setContent($text), 'default', $viewer);
         $document->appendChild($text);
     }
     return $this->buildApplicationPage(array($crumbs, $document), array('title' => pht('Documentation Books'), 'fonts' => true));
 }
Ejemplo n.º 2
0
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $book_name = $request->getURIData('book');
     $book = id(new DivinerBookQuery())->setViewer($viewer)->withNames(array($book_name))->needRepositories(true)->executeOne();
     if (!$book) {
         return new Aphront404Response();
     }
     $actions = $this->buildActionView($viewer, $book);
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->setBorder(true);
     $crumbs->addTextCrumb($book->getShortTitle(), '/book/' . $book->getName() . '/');
     $action_button = id(new PHUIButtonView())->setTag('a')->setText(pht('Actions'))->setHref('#')->setIconFont('fa-bars')->addClass('phui-mobile-menu')->setDropdownMenu($actions);
     $header = id(new PHUIHeaderView())->setHeader($book->getTitle())->setUser($viewer)->setPolicyObject($book)->setEpoch($book->getDateModified())->addActionLink($action_button);
     // TODO: This could probably look better.
     if ($book->getRepositoryPHID()) {
         $header->addTag(id(new PHUITagView())->setType(PHUITagView::TYPE_STATE)->setBackgroundColor(PHUITagView::COLOR_BLUE)->setName($book->getRepository()->getMonogram()));
     }
     $document = new PHUIDocumentView();
     $document->setHeader($header);
     $document->addClass('diviner-view');
     $document->setFontKit(PHUIDocumentView::FONT_SOURCE_SANS);
     $atoms = id(new DivinerAtomQuery())->setViewer($viewer)->withBookPHIDs(array($book->getPHID()))->withGhosts(false)->withIsDocumentable(true)->execute();
     $atoms = msort($atoms, 'getSortKey');
     $group_spec = $book->getConfig('groups');
     if (!is_array($group_spec)) {
         $group_spec = array();
     }
     $groups = mgroup($atoms, 'getGroupName');
     $groups = array_select_keys($groups, array_keys($group_spec)) + $groups;
     if (isset($groups[''])) {
         $no_group = $groups[''];
         unset($groups['']);
         $groups[''] = $no_group;
     }
     $out = array();
     foreach ($groups as $group => $atoms) {
         $group_name = $book->getGroupName($group);
         if (!strlen($group_name)) {
             $group_name = pht('Free Radicals');
         }
         $section = id(new DivinerSectionView())->setHeader($group_name);
         $section->addContent($this->renderAtomList($atoms));
         $out[] = $section;
     }
     $preface = $book->getPreface();
     $preface_view = null;
     if (strlen($preface)) {
         $preface_view = PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setContent($preface), 'default', $viewer);
     }
     $document->appendChild($preface_view);
     $document->appendChild($out);
     return $this->buildApplicationPage(array($crumbs, $document), array('title' => $book->getTitle()));
 }
Ejemplo n.º 3
0
 public function processRequest()
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $book = id(new DivinerBookQuery())->setViewer($viewer)->withNames(array($this->bookName))->executeOne();
     if (!$book) {
         return new Aphront404Response();
     }
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb($book->getShortTitle(), '/book/' . $book->getName() . '/');
     $header = id(new PHUIHeaderView())->setHeader($book->getTitle())->setUser($viewer)->setPolicyObject($book);
     $document = new PHUIDocumentView();
     $document->setHeader($header);
     $document->addClass('diviner-view');
     $document->setFontKit(PHUIDocumentView::FONT_SOURCE_SANS);
     $properties = $this->buildPropertyList($book);
     $atoms = id(new DivinerAtomQuery())->setViewer($viewer)->withBookPHIDs(array($book->getPHID()))->execute();
     $atoms = msort($atoms, 'getSortKey');
     $group_spec = $book->getConfig('groups');
     if (!is_array($group_spec)) {
         $group_spec = array();
     }
     $groups = mgroup($atoms, 'getGroupName');
     $groups = array_select_keys($groups, array_keys($group_spec)) + $groups;
     if (isset($groups[''])) {
         $no_group = $groups[''];
         unset($groups['']);
         $groups[''] = $no_group;
     }
     $out = array();
     foreach ($groups as $group => $atoms) {
         $group_name = $book->getGroupName($group);
         if (!strlen($group_name)) {
             $group_name = pht('Free Radicals');
         }
         $section = id(new DivinerSectionView())->setHeader($group_name);
         $section->addContent($this->renderAtomList($atoms));
         $out[] = $section;
     }
     $preface = $book->getPreface();
     $preface_view = null;
     if (strlen($preface)) {
         $preface_view = PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setContent($preface), 'default', $viewer);
     }
     $document->appendChild($properties);
     $document->appendChild($preface_view);
     $document->appendChild($out);
     return $this->buildApplicationPage(array($crumbs, $document), array('title' => $book->getTitle()));
 }
 public function renderExample()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $action = id(new PHUIListItemView())->setName(pht('Actions'))->setType(PHUIListItemView::TYPE_LABEL);
     $action1 = id(new PHUIListItemView())->setName(pht('Edit Document'))->setHref('#')->setIcon('fa-edit')->setType(PHUIListItemView::TYPE_LINK);
     $action2 = id(new PHUIListItemView())->setName(pht('Move Document'))->setHref('#')->setIcon('fa-arrows')->setType(PHUIListItemView::TYPE_LINK);
     $action3 = id(new PHUIListItemView())->setName(pht('Delete Document'))->setHref('#')->setIcon('fa-times')->setType(PHUIListItemView::TYPE_LINK);
     $action4 = id(new PHUIListItemView())->setName(pht('View History'))->setHref('#')->setIcon('fa-list')->setType(PHUIListItemView::TYPE_LINK);
     $action5 = id(new PHUIListItemView())->setName(pht('Subscribe'))->setHref('#')->setIcon('fa-plus-circle')->setType(PHUIListItemView::TYPE_LINK);
     $divider = id(new PHUIListItemView())->setType(PHUIListItemView::TYPE_DIVIDER);
     $header = id(new PHUIHeaderView())->setHeader(pht('Installation'));
     $label1 = id(new PHUIListItemView())->setName(pht('Getting Started'))->setType(PHUIListItemView::TYPE_LABEL);
     $label2 = id(new PHUIListItemView())->setName(pht('Documentation'))->setType(PHUIListItemView::TYPE_LABEL);
     $item1 = id(new PHUIListItemView())->setName(pht('Installation'))->setHref('#')->setType(PHUIListItemView::TYPE_LINK);
     $item2 = id(new PHUIListItemView())->setName(pht('Webserver Config'))->setHref('#')->setType(PHUIListItemView::TYPE_LINK);
     $item3 = id(new PHUIListItemView())->setName(pht('Adding Users'))->setHref('#')->setType(PHUIListItemView::TYPE_LINK);
     $item4 = id(new PHUIListItemView())->setName(pht('Debugging'))->setHref('#')->setType(PHUIListItemView::TYPE_LINK);
     $sidenav = id(new PHUIListView())->setType(PHUIListView::SIDENAV_LIST)->addMenuItem($action)->addMenuItem($action1)->addMenuItem($action2)->addMenuItem($action3)->addMenuItem($action4)->addMenuItem($action5)->addMenuItem($divider)->addMenuItem($label1)->addMenuItem($item1)->addMenuItem($item2)->addMenuItem($item3)->addMenuItem($item4)->addMenuItem($label2)->addMenuItem($item2)->addMenuItem($item3)->addMenuItem($item4)->addMenuItem($item1);
     $home = id(new PHUIListItemView())->setIcon('fa-home')->setHref('#')->setType(PHUIListItemView::TYPE_ICON);
     $item1 = id(new PHUIListItemView())->setName(pht('Installation'))->setHref('#')->setSelected(true)->setType(PHUIListItemView::TYPE_LINK);
     $item2 = id(new PHUIListItemView())->setName(pht('Webserver Config'))->setHref('#')->setType(PHUIListItemView::TYPE_LINK);
     $item3 = id(new PHUIListItemView())->setName(pht('Adding Users'))->setHref('#')->setType(PHUIListItemView::TYPE_LINK);
     $item4 = id(new PHUIListItemView())->setName(pht('Debugging'))->setHref('#')->setType(PHUIListItemView::TYPE_LINK);
     $topnav = id(new PHUIListView())->setType(PHUIListView::NAVBAR_LIST)->addMenuItem($home)->addMenuItem($item1)->addMenuItem($item2)->addMenuItem($item3)->addMenuItem($item4);
     $document = hsprintf('<p class="pl">Lorem ipsum dolor sit amet, consectetur adipisicing, ' . 'sed do eiusmod tempor incididunt ut labore et dolore magna ' . 'aliqua. Ut enim ad minim veniam, quis nostrud exercitation ' . 'ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis ' . 'aute irure dolor in reprehenderit in voluptate velit esse cillum ' . 'dolore eu fugiat nulla pariatur. Excepteur sint occaecat ' . 'cupidatat non proident, sunt in culpa qui officia deserunt ' . 'mollit anim id est laborum.</p>' . '<p class="plr pll plb">Lorem ipsum dolor sit amet, consectetur, ' . 'sed do eiusmod tempor incididunt ut labore et dolore magna ' . 'aliqua. Ut enim ad minim veniam, quis nostrud exercitation ' . 'ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis ' . 'aute irure dolor in reprehenderit in voluptate velit esse cillum ' . 'dolore eu fugiat nulla pariatur. Excepteur sint occaecat ' . 'cupidatat non proident, sunt in culpa qui officia deserunt ' . 'mollit anim id est laborum.</p>' . '<p class="plr pll plb">Lorem ipsum dolor sit amet, consectetur, ' . 'sed do eiusmod tempor incididunt ut labore et dolore magna ' . 'aliqua. Ut enim ad minim veniam, quis nostrud exercitation ' . 'ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis ' . 'aute irure dolor in reprehenderit in voluptate velit esse cillum ' . 'dolore eu fugiat nulla pariatur. Excepteur sint occaecat ' . 'cupidatat non proident, sunt in culpa qui officia deserunt ' . 'mollit anim id est laborum.</p>' . '<p class="plr pll plb">Lorem ipsum dolor sit amet, consectetur, ' . 'sed do eiusmod tempor incididunt ut labore et dolore magna ' . 'aliqua. Ut enim ad minim veniam, quis nostrud exercitation ' . 'ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis ' . 'aute irure dolor in reprehenderit in voluptate velit esse cillum ' . 'dolore eu fugiat nulla pariatur. Excepteur sint occaecat ' . 'cupidatat non proident, sunt in culpa qui officia deserunt ' . 'mollit anim id est laborum.</p>' . '<p class="plr pll plb">Lorem ipsum dolor sit amet, consectetur, ' . 'sed do eiusmod tempor incididunt ut labore et dolore magna ' . 'aliqua. Ut enim ad minim veniam, quis nostrud exercitation ' . 'ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis ' . 'aute irure dolor in reprehenderit in voluptate velit esse cillum ' . 'dolore eu fugiat nulla pariatur. Excepteur sint occaecat ' . 'cupidatat non proident, sunt in culpa qui officia deserunt ' . 'mollit anim id est laborum.</p>' . '<p class="plr pll plb">Lorem ipsum dolor sit amet, consectetur, ' . 'sed do eiusmod tempor incididunt ut labore et dolore magna ' . 'aliqua. Ut enim ad minim veniam, quis nostrud exercitation ' . 'ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis ' . 'aute irure dolor in reprehenderit in voluptate velit esse cillum ' . 'dolore eu fugiat nulla pariatur. Excepteur sint occaecat ' . 'cupidatat non proident, sunt in culpa qui officia deserunt ' . 'mollit anim id est laborum.</p>');
     $content = new PHUIDocumentView();
     $content->setBook(pht('Book or Project Name'), pht('Article'));
     $content->setHeader($header);
     $content->setFluid(true);
     $content->setTopNav($topnav);
     $content->setSidenav($sidenav);
     $content->appendChild($document);
     return $content;
 }