Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix image regex viewer #105

Merged
merged 2 commits into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## Version 0.5.0
* contributors: @imfx77

---

Expand Down Expand Up @@ -34,6 +35,7 @@ Actions like changing the parent shouldn't trigger new editions to avoid unneces
* Improved this very `ChangeLog`, transforming it into MD.

### Bug fixes:
* Fixed file viewer
* Fixed routes for all controller actions in use.
They used to be copy pasted and were useless as they were all the same.
Minimalistic possible and sensible notation is proposed.
Expand Down
6 changes: 4 additions & 2 deletions Controller/WikiFileViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,13 @@ public function thumbnail()
{
$file = $this->wikiFileModel->getById($this->request->getIntegerParam('file_id'));
$filename = $this->wikiFileModel->getThumbnailPath($file['path']);

$etag = md5($filename);

$this->response->withCache(5 * 86400, $file['etag']);
$this->response->withCache(5 * 86400, $etag);
$this->response->withContentType('image/png');

if ($this->request->getHeader('If-None-Match') === '"'.$file['etag'].'"') {
if ($this->request->getHeader('If-None-Match') === '"'.$etag.'"') {
$this->response->status(304);
} else {
$this->response->send();
Expand Down
3 changes: 1 addition & 2 deletions Template/wiki_file/images.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
<?= $this->app->component('image-slideshow', array(
'images' => $images,
'image' => $file,
'regex_file_id' => 'FILE_ID',
'regex_etag' => 'ETAG',
'regex' => 'FILE_ID',
'url' => array(
'image' => $this->url->to('WikiFileViewController', 'image', array('plugin' => 'wiki', 'file_id' => 'FILE_ID')),
'thumbnail' => $this->url->to('WikiFileViewController', 'thumbnail', array('plugin' => 'wiki', 'file_id' => 'FILE_ID')),
Expand Down
Loading