Browse Source

Update to use raw/u/{userId} paths

tags/v0.1.0
Gerben 6 years ago
parent
commit
4a9be92b8e
1 changed files with 7 additions and 7 deletions
  1. +7
    -7
      lib/Controller/findMementos.php

+ 7
- 7
lib/Controller/findMementos.php View File

@@ -24,7 +24,7 @@ trait MementoFinder {
// If logged in, and asking for one's own mementos, get private mementos too. // If logged in, and asking for one's own mementos, get private mementos too.
if ($this->loggedInUserId === $userId) { if ($this->loggedInUserId === $userId) {
$userFolder = $this->serverContainer->getUserFolder($this->loggedInUserId); $userFolder = $this->serverContainer->getUserFolder($this->loggedInUserId);
$moreMementos = findPrivateMementos($userFolder);
$moreMementos = findPrivateMementos($userFolder, $this->loggedInUserId);
$foundMementos = array_merge($foundMementos, $moreMementos); $foundMementos = array_merge($foundMementos, $moreMementos);
} }


@@ -48,7 +48,7 @@ trait MementoFinder {
// If logged in, get current user's private mementos too. // If logged in, get current user's private mementos too.
if ($this->loggedInUserId) { if ($this->loggedInUserId) {
$userFolder = $this->serverContainer->getUserFolder($this->loggedInUserId); $userFolder = $this->serverContainer->getUserFolder($this->loggedInUserId);
$moreMementos = findPrivateMementos($userFolder);
$moreMementos = findPrivateMementos($userFolder, $this->loggedInUserId);
$foundMementos = array_merge($foundMementos, $moreMementos); $foundMementos = array_merge($foundMementos, $moreMementos);
} }


@@ -56,16 +56,16 @@ trait MementoFinder {
} }
} }


function findPrivateMementos($folder) {
$urlForFile = function ($file) use ($folder) {
function findPrivateMementos($userFolder, $userId) {
$urlForFile = function ($file) use ($userFolder, $userId) {
$absoluteFilePath = $file->getPath(); $absoluteFilePath = $file->getPath();
$relativeFilePath = $folder->getRelativePath($absoluteFilePath);
$rawFileUrl = joinPaths("/apps/raw/files", $relativeFilePath); // XXX hardcoded dependency
$relativeFilePath = $userFolder->getRelativePath($absoluteFilePath);
$rawFileUrl = joinPaths("/apps/raw/u/$userId", $relativeFilePath); // XXX hardcoded dependency
return $rawFileUrl; return $rawFileUrl;
}; };


// Peek into each HTML file the user owns, and return those that are mementos. // Peek into each HTML file the user owns, and return those that are mementos.
$files = $folder->searchByMime('text/html');
$files = $userFolder->searchByMime('text/html');
$foundMementos = []; $foundMementos = [];
foreach ($files as $file) { foreach ($files as $file) {
$mementoInfo = extractMementoInfo($file); $mementoInfo = extractMementoInfo($file);


Loading…
Cancel
Save