зеркало из https://github.com/nextcloud/cookbook.git
Improving on #181
This commit is contained in:
Родитель
f94e58ae67
Коммит
2b6b3413c6
|
@ -76,7 +76,14 @@ class MainController extends Controller
|
|||
$recipes = $this->service->getAllRecipesInSearchIndex();
|
||||
|
||||
foreach ($recipes as $i => $recipe) {
|
||||
$recipes[$i]['image_url'] = $this->urlGenerator->linkToRoute('cookbook.recipe.image', ['id' => $recipe['recipe_id'], 'size' => 'thumb']);
|
||||
$recipes[$i]['image_url'] = $this->urlGenerator->linkToRoute(
|
||||
'cookbook.recipe.image',
|
||||
[
|
||||
'id' => $recipe['recipe_id'],
|
||||
'size' => 'thumb',
|
||||
't' => $this->service->getRecipeMTime($recipe['recipe_id'])
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$response = new TemplateResponse($this->appName, 'content/search', ['recipes' => $recipes]);
|
||||
|
@ -111,7 +118,14 @@ class MainController extends Controller
|
|||
$recipes = $this->service->findRecipesInSearchIndex($query);
|
||||
|
||||
foreach ($recipes as $i => $recipe) {
|
||||
$recipes[$i]['image_url'] = $this->urlGenerator->linkToRoute('cookbook.recipe.image', ['id' => $recipe['recipe_id'], 'size' => 'thumb']);
|
||||
$recipes[$i]['image_url'] = $this->urlGenerator->linkToRoute(
|
||||
'cookbook.recipe.image',
|
||||
[
|
||||
'id' => $recipe['recipe_id'],
|
||||
'size' => 'thumb',
|
||||
't' => $this->service->getRecipeMTime($recipe['recipe_id'])
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$response = new TemplateResponse($this->appName, 'content/search', ['query' => $query, 'recipes' => $recipes]);
|
||||
|
@ -135,7 +149,14 @@ class MainController extends Controller
|
|||
$recipes = $this->service->getRecipesByCategory($category);
|
||||
|
||||
foreach ($recipes as $i => $recipe) {
|
||||
$recipes[$i]['image_url'] = $this->urlGenerator->linkToRoute('cookbook.recipe.image', ['id' => $recipe['recipe_id'], 'size' => 'thumb']);
|
||||
$recipes[$i]['image_url'] = $this->urlGenerator->linkToRoute(
|
||||
'cookbook.recipe.image',
|
||||
[
|
||||
'id' => $recipe['recipe_id'],
|
||||
'size' => 'thumb',
|
||||
't' => $this->service->getRecipeMTime($recipe['recipe_id'])
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$response = new TemplateResponse($this->appName, 'content/search', ['tag' => $tag, 'recipes' => $recipes]);
|
||||
|
@ -155,7 +176,14 @@ class MainController extends Controller
|
|||
{
|
||||
try {
|
||||
$recipe = $this->service->getRecipeById($id);
|
||||
$recipe['imageURL'] = $this->urlGenerator->linkToRoute('cookbook.recipe.image', ['id' => $id, 'size' => 'full']);
|
||||
$recipe['image_url'] = $this->urlGenerator->linkToRoute(
|
||||
'cookbook.recipe.image',
|
||||
[
|
||||
'id' => $id,
|
||||
'size' => 'full',
|
||||
't' => $recipe['dateModified']
|
||||
]
|
||||
);
|
||||
$recipe['id'] = $id;
|
||||
$response = new TemplateResponse($this->appName, 'content/recipe', $recipe);
|
||||
$response->renderAs('blank');
|
||||
|
|
|
@ -52,6 +52,24 @@ class RecipeService
|
|||
|
||||
return $this->parseRecipeFile($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a recipe's modification time by its folder id.
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getRecipeMTime(int $id)
|
||||
{
|
||||
$file = $this->getRecipeFileByFolderId($id);
|
||||
|
||||
if (!$file) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $file->getMTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a recipe file by folder id
|
||||
|
@ -910,6 +928,8 @@ class RecipeService
|
|||
}
|
||||
|
||||
$json['id'] = $file->getParent()->getId();
|
||||
$json['dateCreated'] = $file->getCreationTime();
|
||||
$json['dateModified'] = $file->getMTime();
|
||||
|
||||
return $this->checkRecipe($json);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
<?php if(isset($_['image']) && $_['image']) { ?>
|
||||
<header class="collapsed">
|
||||
<img src="<?php echo $_['imageURL']; ?>&t=<?php echo time(); ?>">
|
||||
<img src="<?php echo $_['image_url']; ?>">
|
||||
</header>
|
||||
<?php } ?>
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<li>
|
||||
<a href="#recipes/<?php echo $recipe['recipe_id']; ?>">
|
||||
<?php if(isset($recipe['image_url']) && $recipe['image_url']) { ?>
|
||||
<img src="<?php echo $recipe['image_url']; ?>">
|
||||
<img src="<?php echo $recipe['image_url']; ?>">
|
||||
<?php } ?>
|
||||
<span>
|
||||
<?php echo $recipe['name']; ?>
|
||||
|
|
Загрузка…
Ссылка в новой задаче