-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.php
More file actions
executable file
·116 lines (101 loc) · 3.38 KB
/
Copy pathplugin.php
File metadata and controls
executable file
·116 lines (101 loc) · 3.38 KB
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
35
36
37
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
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
110
111
112
113
114
115
116
<?php
/**
* ReadLater (LocalStorage)
*
* Bludit plugin that provides a local browser-based read-later list.
*/
class pluginMmReadLater extends Plugin
{
// Storage key versionieren, damit du später migrationsfähig bleibst
private $storageKey = 'bludit-readlater-v1';
public function init()
{
// Custom Hook für das Theme: Theme::plugins('readLaterIcon')
$this->customHooks = array('readLaterIcon');
}
/**
* CSS in <head>
*/
public function siteHead()
{
return '<link rel="stylesheet" href="' . $this->htmlPath() . 'css/readlater.css">' . PHP_EOL;
}
/**
* Custom hook: Icon/Trigger für dein Theme (Header neben Social Icons)
* Verwendung im Theme: Theme::plugins('readLaterIcon')
*/
public function readLaterIcon()
{
// SVG Bookmark (inline, ohne externe Assets)
$svg = '<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">'
. '<path d="M7 3h10a2 2 0 0 1 2 2v16l-7-4-7 4V5a2 2 0 0 1 2-2z" stroke="currentColor" stroke-width="2" stroke-linejoin="round"/>'
. '</svg>';
// Badge wird via JS aktualisiert
$html = '<a class="rl-trigger nav-link" href="#" data-rl-open aria-label="Read later">'
. $svg
. '<span class="d-inline d-sm-none">Später lesen</span>'
. '<span class="rl-badge" data-rl-badge hidden>0</span>'
. '</a>';
return $html;
}
/**
* Optional: Button innerhalb einer Page (setzt voraus, dass dein Theme Theme::plugins('pageBegin') nutzt)
*/
public function pageBegin()
{
return '';
}
/**
* Overlay-Markup und Frontend-Assets am Ende vom <body>
*/
public function siteBodyEnd()
{
global $WHERE_AM_I, $page;
// Current page context (sofern verfügbar) als JS-Objekt bereitstellen
$current = array(
'where' => (string)$WHERE_AM_I,
'url' => '',
'slug' => '',
'title' => ''
);
if ($WHERE_AM_I === 'page' && !empty($page)) {
$current['url'] = $page->permalink();
$current['slug'] = $page->slug();
$current['title'] = $page->title();
}
$currentJson = json_encode($current, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$scriptUrl = $this->htmlPath() . 'js/readlater.js';
$html = <<<HTML
<div class="rl-overlay" id="rlOverlay" aria-hidden="true">
<div class="rl-sheet" role="dialog" aria-modal="true" aria-label="Read later">
<div class="rl-sheet__header">
<div>
<span class="rl-sheet__title">Später lesen</span>
<span class="rl-sheet__count" data-rl-count>(0)</span>
</div>
<div class="rl-sheet__actions">
<button class="rl-btn rl-btn--danger" type="button" data-rl-clear>Liste leeren</button>
<button class="rl-btn rl-btn--icon" type="button" data-rl-close aria-label="Close">X</button>
</div>
</div>
<div class="rl-sheet__body">
<div class="rl-empty" data-rl-empty hidden>Nichts gespeichert.</div>
<ul class="rl-list" data-rl-list></ul>
<label class="rl-pref">
<input type="checkbox" data-rl-auto-remove />
Einträge beim Öffnen aus der Liste entfernen?
</label>
</div>
</div>
</div>
<script>
window.__bluditReadLaterConfig = {
storageKey: "{$this->storageKey}",
current: $currentJson
};
</script>
<script src="$scriptUrl"></script>
HTML;
return $html;
}
}