Overview
Comment:More work on the rich text editor, but Trix sucks a lot :(
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | dev
Files: files | file ages | folders
SHA1: e1d70bedb99e90a4ef5c6d22e44c53b39704c9a4
User & Date: bohwaz on 2020-12-14 02:21:57
Other Links: branch diff | manifest | tags
Context
2020-12-14
23:42
Change of strategy: will do rich text editing later, first let's just migrate the wiki to web check-in: 246bb41500 user: bohwaz tags: dev
02:21
More work on the rich text editor, but Trix sucks a lot :( check-in: e1d70bedb9 user: bohwaz tags: dev
2020-12-13
18:21
List of pages and categories check-in: 76f8f4650a user: bohwaz tags: dev
Changes

Modified src/include/lib/Garradin/Entities/Files/File.php from [06d115add3] to [0da72de85a].

464
465
466
467
468
469
470





471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
		if (null !== $path) {
			readfile($path);
		}
		else {
			echo $content;
		}
	}






	public function render(): string
	{
		static $render_types = ['text/html', 'text/vnd.skriv', 'text/vnd.skriv.encrypted'];

		if (!in_array($this->type, $render_types)) {
			throw new \LogicException('Render can not be called on files of type: ' . $this->type);
		}

		$content = Files::callStorage('fetch', $this);

		if ($this->type == 'text/html') {
			return \Garradin\Files\Render\HTML::render($this, $content);
		}
		elseif ($this->type == 'text/vnd.skriv') {
			return \Garradin\Files\Render\Skriv::render($this, $content);
		}







>
>
>
>
>









|







464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
		if (null !== $path) {
			readfile($path);
		}
		else {
			echo $content;
		}
	}

	public function fetch()
	{
		return Files::callStorage('fetch', $this);
	}

	public function render(): string
	{
		static $render_types = ['text/html', 'text/vnd.skriv', 'text/vnd.skriv.encrypted'];

		if (!in_array($this->type, $render_types)) {
			throw new \LogicException('Render can not be called on files of type: ' . $this->type);
		}

		$content = $this->fetch();

		if ($this->type == 'text/html') {
			return \Garradin\Files\Render\HTML::render($this, $content);
		}
		elseif ($this->type == 'text/vnd.skriv') {
			return \Garradin\Files\Render\Skriv::render($this, $content);
		}

Modified src/include/lib/Garradin/Entities/Web/Page.php from [652702f2a8] to [a9d6f2dd6b].

1
2
3
4
5
6
7
8
9
10


11
12
13
14
15
16
17
<?php

namespace Garradin\Entities\Web;

use Garradin\Entity;
use Garradin\UserException;

use const Garradin\WWW_URL;

use KD2\DB\EntityManager as EM;



class Page extends Entity
{
	const TABLE = 'web_pages';

	protected $id;
	protected $parent_id;






|
<


>
>







1
2
3
4
5
6
7

8
9
10
11
12
13
14
15
16
17
18
<?php

namespace Garradin\Entities\Web;

use Garradin\Entity;
use Garradin\UserException;
use Garradin\Entities\Files\File;


use KD2\DB\EntityManager as EM;

use const Garradin\WWW_URL;

class Page extends Entity
{
	const TABLE = 'web_pages';

	protected $id;
	protected $parent_id;
45
46
47
48
49
50
51





52
53
54
55
56
57
58

		if ($this->type == self::TYPE_CATEGORY) {
			$url .= '/';
		}

		return $url;
	}






	public function file(): File
	{
		if (null === $this->_file) {
			$this->_file = EM::findOneById(File::class, $this->id);
		}








>
>
>
>
>







46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64

		if ($this->type == self::TYPE_CATEGORY) {
			$url .= '/';
		}

		return $url;
	}

	public function raw(): string
	{
		return $this->file()->fetch();
	}

	public function file(): File
	{
		if (null === $this->_file) {
			$this->_file = EM::findOneById(File::class, $this->id);
		}

Modified src/www/admin/web/edit.php from [8062efc532] to [4a4a219729].

18
19
20
21
22
23
24
25



26

$form->runIf('save', function ($page) {
    $page->importForm();
    $page->save();
}, $csrf_key, Utils::getSelfURI());

$tpl->assign(compact('page', 'csrf_key'));




$tpl->display('web/edit.tpl');








>
>
>

18
19
20
21
22
23
24
25
26
27
28
29

$form->runIf('save', function ($page) {
    $page->importForm();
    $page->save();
}, $csrf_key, Utils::getSelfURI());

$tpl->assign(compact('page', 'csrf_key'));

$tpl->assign('custom_css', ['styles/web-content.css', 'styles/web.css']);
//$tpl->assign('custom_js', ['trix.min.js']);

$tpl->display('web/edit.tpl');