|
|
@@ -5,6 +5,7 @@ require_once __DIR__ . '/findMementos.php'; |
|
|
|
require_once __DIR__ . '/datetimeConversion.php'; |
|
|
|
|
|
|
|
use OCP\IRequest; |
|
|
|
use OCP\IURLGenerator; |
|
|
|
use OCP\IServerContainer; |
|
|
|
use OCP\AppFramework\Controller; |
|
|
|
use OCP\AppFramework\Http\RedirectResponse; |
|
|
@@ -14,15 +15,18 @@ use findMementos; |
|
|
|
|
|
|
|
class TimeGateController extends Controller { |
|
|
|
private $userFolder; |
|
|
|
private $URLGenerator; |
|
|
|
|
|
|
|
public function __construct( |
|
|
|
$AppName, |
|
|
|
IRequest $request, |
|
|
|
$UserId, |
|
|
|
IServerContainer $serverContainer |
|
|
|
IServerContainer $serverContainer, |
|
|
|
IURLGenerator $URLGenerator |
|
|
|
) { |
|
|
|
parent::__construct($AppName, $request); |
|
|
|
$this->userFolder = $serverContainer->getUserFolder($UserId); |
|
|
|
$this->URLGenerator = $URLGenerator; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@@ -65,7 +69,20 @@ class TimeGateController extends Controller { |
|
|
|
$response = new RedirectResponse($chosenMemento['mementoUrl']); |
|
|
|
$response->setStatus(302); |
|
|
|
$response->addHeader('Vary', 'accept-datetime'); |
|
|
|
$response->addHeader('Link', "<{$chosenMemento['originalUrl']}>; rel=\"original\""); |
|
|
|
|
|
|
|
// Add a link to the original and to the timemap. |
|
|
|
$originalLink = "<{$chosenMemento['originalUrl']}>;rel=\"original\""; |
|
|
|
// XXX hardcoding the route URL. |
|
|
|
$timeMapUrl = $this->URLGenerator->getAbsoluteUrl("/apps/memento/timemap/$url"); |
|
|
|
$firstDatetime = datetimeTimestampToString($matchingMementos[0]['datetime']); |
|
|
|
$lastMemento = $matchingMementos[count($matchingMementos)-1]; |
|
|
|
$lastDatetime = datetimeTimestampToString($lastMemento['datetime']); |
|
|
|
$timeMapLink = "<$timeMapUrl>" |
|
|
|
. ";rel=\"timemap\"" |
|
|
|
. ";type=\"application/link-format\"" |
|
|
|
. ";from=\"$firstDatetime\";until=\"$lastDatetime\""; |
|
|
|
$response->addHeader('Link', "$originalLink, $timeMapLink"); |
|
|
|
|
|
|
|
return $response; |
|
|
|
} |
|
|
|
} |
|
|
|