Overview
Comment: | Fix attachements and page preview |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | dev |
Files: | files | file ages | folders |
SHA3-256: |
3b40c56acd8495b98a5a88c3c35e7a21 |
User & Date: | bohwaz on 2021-03-15 17:43:29 |
Other Links: | branch diff | manifest | tags |
Context
2021-03-15
| ||
19:38 | realpath doesn't work with non-existing files, make it a bit clever check-in: cfa99e898d user: bohwaz tags: dev | |
17:43 | Fix attachements and page preview check-in: 3b40c56acd user: bohwaz tags: dev | |
17:08 | Implement shared cache for Smartyer templates and common user templates check-in: 0b8f616ec9 user: bohwaz tags: dev | |
Changes
Modified src/include/lib/Garradin/Web/Render/Skriv.php from [3ea7a7d71c] to [678f6cab23].
︙ | ︙ | |||
33 34 35 36 37 38 39 | self::$skriv->registerExtension('image', [self::class, 'SkrivImage']); // Enregistrer d'autres extensions éventuellement Plugin::fireSignal('skriv.init', ['skriv' => self::$skriv]); } $skriv =& self::$skriv; | | | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | self::$skriv->registerExtension('image', [self::class, 'SkrivImage']); // Enregistrer d'autres extensions éventuellement Plugin::fireSignal('skriv.init', ['skriv' => self::$skriv]); } $skriv =& self::$skriv; self::$current_path = str_replace(File::CONTEXT_WEB . '/', '', $file->parent); $str = $content ?? $file->fetch(); $str = preg_replace_callback('/#file:\[([^\]\h]+)\]/', function ($match) { return WWW_URL . self::$current_path . '/' . $match[1]; }, $str); $str = self::$skriv->render($str); |
︙ | ︙ |
Modified src/templates/common/files/_preview.tpl from [d1cff317f1] to [958bb910be].
1 2 | {include file="admin/_head.tpl" title=$file.name custom_css=['/content.css']} | < | < < < | 1 2 3 4 5 | {include file="admin/_head.tpl" title=$file.name custom_css=['/content.css']} {$content|raw} {include file="admin/_foot.tpl"} |
Modified src/templates/web/_attach.tpl from [fcc9bc0c3e] to [d9dde30b66].
︙ | ︙ | |||
38 39 40 41 42 43 44 | </form> {if !empty($images)} <ul class="gallery"> {foreach from=$images item="file"} <li> <figure> | | > > | | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | </form> {if !empty($images)} <ul class="gallery"> {foreach from=$images item="file"} <li> <figure> <a href="{$file->url()}" data-name="{$file.name}" data-insert="image" data-thumb="{$file->thumb_url()}"><img src="{$file->thumb_url()}" alt="" title="{$file.name}" /></a> <form class="actions" method="post" action="{$self_url}"> {linkbutton shape="download" label="Télécharger" href=$file->url() target="_blank"} {linkbutton shape="plus" label="Insérer" href=$file->url() data-name=$file.name data-insert="image" data-thumb=$file->thumb_url()} {csrf_field key=$csrf_key} <input type="hidden" name="delete" value="{$file.name}" /> <noscript><input type="submit" value="Supprimer" /></noscript> </form> </figure> </li> {/foreach} </ul> {/if} {if !empty($files)} <table class="list"> <tbody> {foreach from=$files item="file"} <tr> <th>{$file.name}</th> <td>{$file.type}, {$file.size|size_in_bytes}</td> <td class="actions"> <form class="actions" method="post" action="{$self_url}"> {linkbutton shape="plus" label="Insérer" href=$file->url() data-name=$file.name data-insert="file"} {linkbutton shape="download" label="Télécharger" href=$file->url() target="_blank"} {csrf_field key=$csrf_key} <input type="hidden" name="delete" value="{$file.name}" /> <noscript><input type="submit" value="Supprimer" /></noscript> </form> </td> </tr> {/foreach} </tbody> </table> {/if} {include file="admin/_foot.tpl"} |
Modified src/www/admin/common/files/_preview.php from [5dcf0d903e] to [6864261fb7].
1 2 3 4 5 6 7 8 9 | <?php namespace Garradin; use Garradin\Files\Files; use Garradin\Web\Render\Skriv; require_once __DIR__ . '/../../_inc.php'; | > > | | | > > > > > > > > > > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | <?php namespace Garradin; use Garradin\Files\Files; use Garradin\Web\Render\Skriv; use Garradin\Web\Web; require_once __DIR__ . '/../../_inc.php'; if ($path = qg('p')) { $file = Files::get($path); if (!$file || !$file->checkReadAccess($session)) { throw new UserException('Vous n\'avez pas le droit de lire ce fichier.'); } } elseif ($web = qg('w')) { $page = Web::get($web); if (!$page || !$page->file() || !$page->file()->checkReadAccess($session)) { throw new UserException('Vous n\'avez pas le droit de lire ce fichier.'); } $file = $page->file(); } $content = Skriv::render($file, f('content')); $tpl->assign(compact('file', 'content')); $tpl->assign('custom_css', ['!web/css.php']); $tpl->display('common/files/_preview.tpl'); |
Modified src/www/admin/static/scripts/wiki_editor.js from [622ea92e5f] to [b9e13dc33e].
︙ | ︙ | |||
71 72 73 74 75 76 77 | openIFrame(''); let args = new URLSearchParams(window.location.search); var wiki_id = args.get('p'); var form = document.createElement('form'); form.appendChild(t.textarea.cloneNode(true)); form.firstChild.value = t.textarea.value; form.target = 'editorFrame'; | | | > | | | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | openIFrame(''); let args = new URLSearchParams(window.location.search); var wiki_id = args.get('p'); var form = document.createElement('form'); form.appendChild(t.textarea.cloneNode(true)); form.firstChild.value = t.textarea.value; form.target = 'editorFrame'; form.action = g.admin_url + 'common/files/_preview.php?_dialog&w=' + wiki_id; form.style.display = 'none'; form.method = 'post'; document.body.appendChild(form); form.submit(); return true; }; var openSyntaxHelp = function () { openIFrame(g.admin_url + 'web/_syntaxe.html'); return true; }; var openFileInsert = function () { let args = new URLSearchParams(window.location.search); var wiki_id = args.get('p'); g.openFrameDialog(g.admin_url + 'web/_attach.php?_dialog&p=' + wiki_id); return true; }; window.te_insertFile = function (file) { var tag = '<<file|'+file+'>>'; t.insertAtPosition(t.getSelection().start, tag); g.closeDialog(); }; window.te_insertImage = function (file, position, caption) |
︙ | ︙ |
Modified src/www/admin/static/scripts/wiki_fichiers.js from [b7a3614019] to [1bc10af361].
︙ | ︙ | |||
48 49 50 51 52 53 54 | if (file.image) { insertImageHelper(file, true); } else { | | < < | < < < < < < | | | > | | | | | < | 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | if (file.image) { insertImageHelper(file, true); } else { window.parent.te_insertFile(file.name); } return true; } document.querySelectorAll('a[data-insert]').forEach((a) => { a.onclick = function (e) { insertHelper({ name: this.dataset.name, image: this.dataset.insert == 'image', thumb: this.dataset.thumb }); return false; }; }); var a = document.createElement('button'); a.className = 'icn-btn'; a.innerText = 'Supprimer'; a.dataset.icon = '✘'; a.type = 'button'; a.onclick = function() { if (confirm('Supprimer ce fichier ?')) this.parentNode.submit(); }; |
︙ | ︙ |
Modified src/www/admin/static/styles/01-layout.css from [91d3f8d7aa] to [00233b0391].
︙ | ︙ | |||
39 40 41 42 43 44 45 | margin-left: 180px; margin-bottom: 0.4em; } .header .menu { position: fixed; overflow: auto; | | | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | margin-left: 180px; margin-bottom: 0.4em; } .header .menu { position: fixed; overflow: auto; z-index: 1000; width: 170px; top: 0; bottom: 0; padding-top: 100px; background: rgb(var(--gMainColor)) var(--gBgImage) no-repeat 0px 0px; } |
︙ | ︙ |
Modified src/www/admin/web/_attach.php from [a91ba927e5] to [8ef09cfb3d].
︙ | ︙ | |||
8 9 10 11 12 13 14 | use Garradin\Entities\Files\File; use Garradin\Files\Files; require_once __DIR__ . '/_inc.php'; $session->requireAccess($session::SECTION_WEB, $session::ACCESS_WRITE); | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | use Garradin\Entities\Files\File; use Garradin\Files\Files; require_once __DIR__ . '/_inc.php'; $session->requireAccess($session::SECTION_WEB, $session::ACCESS_WRITE); $page = Web::get(qg('p') ?: ''); if (!$page) { throw new UserException('Page inconnue'); } $csrf_key = 'attach_' . $page->id(); |
︙ | ︙ | |||
32 33 34 35 36 37 38 | $form->runIf(f('upload') || f('uploadHelper_mode'), function () use ($page) { if (f('uploadHelper_status') > 0) { throw new UserException('Un seul fichier peut être envoyé en même temps.'); } | | | 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | $form->runIf(f('upload') || f('uploadHelper_mode'), function () use ($page) { if (f('uploadHelper_status') > 0) { throw new UserException('Un seul fichier peut être envoyé en même temps.'); } $new_file = File::upload(dirname($page->file_path), 'file'); if (f('uploadHelper_status') !== null) { $uri = Utils::getSelfURI() . '&sent'; echo json_encode([ 'redirect' => $uri, 'callback' => 'insertHelper', |
︙ | ︙ |