public function newSiteForRequest(AphrontRequest $request) { if (!$this->isPhameActive()) { return null; } $whitelist = array('/phame/r/'); $path = $request->getPath(); if (!$this->isPathPrefixMatch($path, $whitelist)) { return null; } return new PhameBlogResourceSite(); }
public function newSiteForRequest(AphrontRequest $request) { $host = $request->getHost(); $uri = PhabricatorEnv::getEnvConfig('security.alternate-file-domain'); if (!strlen($uri)) { return null; } if ($this->isHostMatch($host, array($uri))) { return new PhabricatorResourceSite(); } // These are CDN routes, so we let them through even if the "Host" header // doesn't match anything we recognize. The $whitelist = array('/res/', '/file/data/', '/file/xform/'); $path = $request->getPath(); if ($this->isPathPrefixMatch($path, $whitelist)) { return new PhabricatorResourceSite(); } return null; }
public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $id = $request->getURIData('id'); $countdown = id(new PhabricatorCountdownQuery())->setViewer($viewer)->withIDs(array($id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne(); if (!$countdown) { return new Aphront404Response(); } if ($request->isFormPost()) { $countdown->delete(); return id(new AphrontRedirectResponse())->setURI('/countdown/'); } $inst = pht('Are you sure you want to delete the countdown %s?', $countdown->getTitle()); $dialog = new AphrontDialogView(); $dialog->setUser($request->getUser()); $dialog->setTitle(pht('Really delete this countdown?')); $dialog->appendChild(phutil_tag('p', array(), $inst)); $dialog->addSubmitButton(pht('Delete')); $dialog->addCancelButton('/countdown/'); $dialog->setSubmitURI($request->getPath()); return id(new AphrontDialogResponse())->setDialog($dialog); }
/** * NOTE: This is temporary glue; eventually, sites will return an entire * route map. */ public function getPathForRouting(AphrontRequest $request) { return $request->getPath(); }
/** * @task internal */ protected function renderContent(AphrontRequest $request) { $user = $request->getUser(); $matches = null; $path = $request->getPath(); // default to the blog-wide values $this->setTitle($this->getBlog()->getName()); $this->setDescription($this->getBlog()->getDescription()); $this->setOGType('website'); $this->setURIPath(''); if (preg_match('@^/post/(?P<name>.*)$@', $path, $matches)) { $post = id(new PhamePostQuery())->setViewer($user)->withBlogPHIDs(array($this->getBlog()->getPHID()))->withPhameTitles(array($matches['name']))->executeOne(); if ($post) { $description = $post->getMarkupText(PhamePost::MARKUP_FIELD_SUMMARY); $this->setTitle($post->getTitle()); $this->setDescription($description); $this->setOGType('article'); $this->setURIPath('post/' . $post->getPhameTitle()); $view = head($this->buildPostViews(array($post))); return $this->renderPostDetail($view); } } else { $pager = new AphrontCursorPagerView(); if (preg_match('@^/older/(?P<before>\\d+)/$@', $path, $matches)) { $pager->setAfterID($matches['before']); } else { if (preg_match('@^/newer/(?P<after>\\d)/$@', $path, $matches)) { $pager->setBeforeID($matches['after']); } else { if (preg_match('@^/$@', $path, $matches)) { // Just show the first page. } else { return null; } } } $pager->setPageSize($this->getPageSize()); $posts = id(new PhamePostQuery())->setViewer($user)->withBlogPHIDs(array($this->getBlog()->getPHID()))->executeWithCursorPager($pager); $this->pager = $pager; if ($posts) { $views = $this->buildPostViews($posts); return $this->renderPostList($views); } } return null; }
public function getPathForRouting(AphrontRequest $request) { $path = $request->getPath(); $id = $this->getBlog()->getID(); return "/phame/live/{$id}/{$path}"; }