Page MenuHomec4science

PhabricatorSitemapsController.php
No OneTemporary

File Metadata

Created
Sun, Nov 24, 03:53

PhabricatorSitemapsController.php

<?php
final class PhabricatorSitemapsController extends PhabricatorController {
public function shouldRequireLogin() {
return false;
}
public function handleRequest(AphrontRequest $request) {
$user = $request->getViewer();
$out = array();
// headers
$out[] = '<?xml version="1.0" encoding="UTF-8"?>';
$out[] = '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
// Static pages
$today = date("Y-m-d");
$out[] = $this->url('/', $today, 'daily', '1.0');
$out[] = $this->url('/diffusion/', $today, 'daily', '0.9');
$out[] = $this->url('/phriction/', $today, 'daily', '0.9');
$out[] = $this->url('/project/', $today, 'daily', '0.9');
$out[] = $this->url('/audit/', $today, 'weekly', '0.5');
$out[] = $this->url('/differential/', $today, 'weekly', '0.5');
$out[] = $this->url('/maniphest/', $today, 'weekly', '0.5');
$out[] = $this->url('/paste/', $today, 'weekly', '0.5');
$out[] = $this->url('/feed/', $today, 'weekly', '0.4');
$out[] = $this->url('/file/', $today, 'weekly', '0.4');
$out[] = $this->url('/calendar/', $today, 'monthly', '0.1');
$out[] = $this->url('/conpherence/', $today, 'monthly', '0.1');
//$out[] = $this->url('/dashboard/', $today, 'monthly', '0.1');
$out[] = $this->url('/people/', $today, 'monthly', '0.1');
$out[] = $this->url('/phurl/', $today, 'monthly', '0.1');
$out[] = $this->url('/badges/', $today, 'monthly', '0.1');
$out[] = $this->url('/countdown/', $today, 'monthly', '0.1');
$out[] = $this->url('/diviner/', $today, 'monthly', '0.1');
$out[] = $this->url('/flag/', $today, 'monthly', '0.1');
$out[] = $this->url('/harbormaster/', $today, 'monthly', '0.1');
//$out[] = $this->url('/herald/', $today, 'monthly', '0.1');
$out[] = $this->url('/legalpad/', $today, 'monthly', '0.1');
$out[] = $this->url('/macro/', $today, 'monthly', '0.1');
//$out[] = $this->url('/passphrase/', $today, 'monthly', '0.1');
$out[] = $this->url('/applications/', $today, 'yearly', '0.0');
$out[] = $this->url('/auth/', $today, 'never', '0.0');
$out[] = $this->url('/config/', $today, 'never', '0.0');
$out[] = $this->url('/daemon/', $today, 'never', '0.0');
$out[] = $this->url('/mail/', $today, 'never', '0.0');
//$out[] = $this->url('/conduit/', $today, 'never', '0.0');
// Repositories
$repo = id(new PhabricatorRepositoryQuery())
->setViewer($user)
->withStatus(PhabricatorRepositoryQuery::STATUS_OPEN)
->execute();
foreach($repo as $r) {
$out[] = $this->url(
$r->getURI(),
date('c', $r->getDateModified()),
'weekly', '0.8'
);
$out[] = $this->url(
'/diffusion/' . $r->getId() . '/manage/',
$today,
'never', '0.0'
);
}
// Projects
$project = id(new PhabricatorProjectQuery())
->setViewer($user)
->execute();
foreach($project as $p) {
$out[] = $this->url(
$p->getURI(),
date('c', $p->getDateModified()),
'weekly', '0.8'
);
$out[] = $this->url(
'/project/manage/' . $p->getId() . '/',
$today,
'never', '0.0'
);
}
// Wiki
$wiki = id(new PhrictionDocumentQuery())
->setViewer($user)
->needContent(true)
->withStatuses(array(PhrictionDocumentStatus::STATUS_EXISTS))
->execute();
foreach($wiki as $w) {
$out[] = $this->url(
$w->getSlugURI($w->getSlug()),
date('c', $w->getContent()->getDateModified()),
'weekly', '0.8'
);
}
// Files
$files = id(new PhabricatorFileQuery())
->setViewer($user)
->showOnlyExplicitUploads(true)
->execute();
foreach($files as $f){
if($f->getTTL()) continue; // Ignore temporary files
$out[] = $this->url(
$f->getURI(),
date('c', $f->getDateCreated()),
'weekly', '0.4'
);
$out[] = $this->url(
'/file/transforms/' . $f->getId() . '/',
$today,
'never', '0.0'
);
}
// Footer
$out[] = '</urlset>';
$content = implode("\n", $out)."\n";
return id(new AphrontFileResponse())
->setContent($content)
->setMimeType('text/xml')
->setCacheDurationInSeconds(phutil_units('10 minutes in seconds'))
->setCanCDN(true);
}
private function url($loc, $mod, $freq, $priority) {
$uri = PhabricatorEnv::getURI($loc);
return
"<url>"
. " <loc>${uri}</loc>"
. " <lastmod>${mod}</lastmod>"
. " <changefreq>${freq}</changefreq>"
. " <priority>${priority}</priority>"
. "</url>";
}
}

Event Timeline