git.shiar.nl
/
minimedit.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
f065f47
)
page: store placeholder values in $Page object
author
Mischa POSLAWSKY
<perl@shiar.org>
Thu, 3 Dec 2020 21:22:28 +0000
(22:22 +0100)
committer
Mischa POSLAWSKY
<perl@shiar.org>
Sat, 19 Dec 2020 02:01:43 +0000
(
03:01
+0100)
12 files changed:
article.inc.php
patch
|
blob
|
history
issue/index.php
patch
|
blob
|
history
login/index.php
patch
|
blob
|
history
login/post/index.php
patch
|
blob
|
history
mail/index.php
patch
|
blob
|
history
nieuws/index.php
patch
|
blob
|
history
page.inc.php
patch
|
blob
|
history
page.php
patch
|
blob
|
history
widget/login/commits.php
patch
|
blob
|
history
widget/login/list.php
patch
|
blob
|
history
widget/nieuws.php
patch
|
blob
|
history
widget/search.php
patch
|
blob
|
history
diff --git
a/article.inc.php
b/article.inc.php
index c63089843c5d89f3da48fbb165683a2cda47491b..cff69ffdec449dcd44fccd1299abc2a793aa1d3e 100644
(file)
--- a/
article.inc.php
+++ b/
article.inc.php
@@
-18,6
+18,7
@@
class ArchiveArticle
{
public $raw, $title, $body; # file contents
public $meta = []; # head metadata properties
{
public $raw, $title, $body; # file contents
public $meta = []; # head metadata properties
+ public $place = []; # template variables replaced in render()
function __construct($path)
{
function __construct($path)
{
@@
-184,10
+185,9
@@
class ArchiveArticle
$Page = clone $this;
$Page->handler = $Page->handler . $Page->path; // .= with explicit getter
$Page->path = '';
$Page = clone $this;
$Page->handler = $Page->handler . $Page->path; // .= with explicit getter
$Page->path = '';
- $Place = $GLOBALS['Place'];
foreach ($params as $param) {
if ($set = strpos($param, '=')) {
foreach ($params as $param) {
if ($set = strpos($param, '=')) {
- $Place[ substr($param, 0, $set) ] = substr($param, $set + 1);
+ $P
age->p
lace[ substr($param, 0, $set) ] = substr($param, $set + 1);
}
elseif (!empty($param)) {
$Page->path .= '/'.$param;
}
elseif (!empty($param)) {
$Page->path .= '/'.$param;
@@
-205,11
+205,11
@@
class ArchiveArticle
}
}
}
}
- function render(
$blocks = []
)
+ function render()
{
$doc = ob_get_clean();
{
$doc = ob_get_clean();
- if (!empty($
blocks
['warn'])) {
+ if (!empty($
this->place
['warn'])) {
$warn = '<p class="warn">[[warn]]</p>';
if ($offset = strpos($doc, '</h2>')) {
$doc = substr_replace($doc, "\n\n".$warn, $offset + 5, 0);
$warn = '<p class="warn">[[warn]]</p>';
if ($offset = strpos($doc, '</h2>')) {
$doc = substr_replace($doc, "\n\n".$warn, $offset + 5, 0);
@@
-226,9
+226,9
@@
class ArchiveArticle
return preg_replace_callback(
'{ \[\[ ([^] ]+) ([^]]*) \]\] }x',
return preg_replace_callback(
'{ \[\[ ([^] ]+) ([^]]*) \]\] }x',
- function ($sub)
use ($blocks)
{
+ function ($sub) {
list ($placeholder, $name, $params) = $sub;
list ($placeholder, $name, $params) = $sub;
- $html = $
blocks
[$name] ??
+ $html = $
this->place
[$name] ??
$this->widget($name, explode(' ', $params));
if (empty($html) or $html[0] != '<') {
$html = "<span>$html</span>";
$this->widget($name, explode(' ', $params));
if (empty($html) or $html[0] != '<') {
$html = "<span>$html</span>";
diff --git
a/issue/index.php
b/issue/index.php
index 181d5b73e6380fec368787929fe291dace82030b..8c58f415de331bb8e23f42e8a4759e8fcd7fb2b2 100644
(file)
--- a/
issue/index.php
+++ b/
issue/index.php
@@
-97,4
+97,4
@@
while ($row = $query->fetch()) {
print "</a></div></li>\n";
}
print "</ul>\n";
print "</a></div></li>\n";
}
print "</ul>\n";
-$Place['issuelist'] = ob_get_clean();
+$P
age->p
lace['issuelist'] = ob_get_clean();
diff --git
a/login/index.php
b/login/index.php
index 4ecee456f8d77f52dcdbb8c751521cfa875d3377..e1f0cae048e58a2753b6a61dbb20ea46b025a0cc 100644
(file)
--- a/
login/index.php
+++ b/
login/index.php
@@
-61,7
+61,7
@@
if (!$User or !$User->login) {
ob_start();
require_once 'login/form.inc.php';
$Page->raw = ob_get_clean();
ob_start();
require_once 'login/form.inc.php';
$Page->raw = ob_get_clean();
- $Place['warn'] = $message;
+ $P
age->p
lace['warn'] = $message;
return TRUE;
}
return TRUE;
}
diff --git
a/login/post/index.php
b/login/post/index.php
index f4c77591f988d3d03c6cb80fb1cd8082d2158de4..276848e8dfa4aeffd00d13ccbea2a60eb4affd88 100644
(file)
--- a/
login/post/index.php
+++ b/
login/post/index.php
@@
-19,16
+19,16
@@
else {
$user = $User;
}
$user = $User;
}
-$Place['login/name'] = $user->name ?: 'bewoner';
-$Place['user'] = $user->login;
+$P
age->p
lace['login/name'] = $user->name ?: 'bewoner';
+$P
age->p
lace['user'] = $user->login;
if ( $password = trim(@file_get_contents("{$user->dir}/.passwd")) ) {
if (substr($password, 0, 1) == '$') {
$password = NULL; // hashed
}
if ( $password = trim(@file_get_contents("{$user->dir}/.passwd")) ) {
if (substr($password, 0, 1) == '$') {
$password = NULL; // hashed
}
- $Place['pass'] = htmlspecialchars($password) ?: '<em>zelf ingesteld</em>';
+ $P
age->p
lace['pass'] = htmlspecialchars($password) ?: '<em>zelf ingesteld</em>';
}
else {
}
else {
- $Place['pass'] = '<em>onbekend</em>';
+ $P
age->p
lace['pass'] = '<em>onbekend</em>';
}
print '<aside class="nav"><a href="javascript:window.print()">Print</a></aside>'."\n";
}
print '<aside class="nav"><a href="javascript:window.print()">Print</a></aside>'."\n";
diff --git
a/mail/index.php
b/mail/index.php
index 67a076e157cf85614b9ea6cc0142dc279386bba0..37b1edc72491013887cf03133bd84487e5d096e7 100644
(file)
--- a/
mail/index.php
+++ b/
mail/index.php
@@
-45,8
+45,8
@@
if ($msgid) {
if (!$User->admin('user')) {
http_response_code(403);
if (!$User->admin('user')) {
http_response_code(403);
- $Place['warn'] = "Geen gebruikersrechten om e-mails in te zien.";
- $Place['maillist'] = '';
+ $P
age->p
lace['warn'] = "Geen gebruikersrechten om e-mails in te zien.";
+ $P
age->p
lace['maillist'] = '';
return TRUE;
}
return TRUE;
}
@@
-72,4
+72,4
@@
foreach (array_reverse($rows) as $filename) {
print "</a></li>\n";
}
print "</ul>\n";
print "</a></li>\n";
}
print "</ul>\n";
-$Place['maillist'] = ob_get_clean();
+$P
age->p
lace['maillist'] = ob_get_clean();
diff --git
a/nieuws/index.php
b/nieuws/index.php
index 0bb72f9142ff3363c26f0209edf6df697e74f3fd..f6e63a449c7b6377ff58559f56a09b0a5bf88f05 100644
(file)
--- a/
nieuws/index.php
+++ b/
nieuws/index.php
@@
-13,10
+13,10
@@
if ($page and !is_numeric($page)) {
$Page->title = $edit;
}
if ($Page->dateparts) {
$Page->title = $edit;
}
if ($Page->dateparts) {
- $Place[1] = ' <small class="date">'.$Page->date.'</small>';
+ $P
age->p
lace[1] = ' <small class="date">'.$Page->date.'</small>';
}
else {
}
else {
- $Place[1] = '';
+ $P
age->p
lace[1] = '';
}
print preg_replace('{(?<=<h2>)(.*?)(?=</h2>)}', ($edit ?: '\1').' [[1]]', $Page->raw);
if ($User->admin("edit {$Page->link}")) {
}
print preg_replace('{(?<=<h2>)(.*?)(?=</h2>)}', ($edit ?: '\1').' [[1]]', $Page->raw);
if ($User->admin("edit {$Page->link}")) {
diff --git
a/page.inc.php
b/page.inc.php
index 78cca99f070bcd61e1e4c06e0ed1972680fab489..afaa970868493fc3f509966f11576e47a3e3c64b 100644
(file)
--- a/
page.inc.php
+++ b/
page.inc.php
@@
-1,5
+1,5
@@
<?php
<?php
-$body = $Page->render(
@$Place
);
+$body = $Page->render();
include_once 'head.inc.php';
include_once 'head.inc.php';
@@
-30,7
+30,8
@@
if ($User and property_exists($User, 'login') and $User->login) {
}
print "</p></div>\n";
}
}
print "</p></div>\n";
}
-$nav = $menu->render(['login' => ob_get_clean()]);
+$menu->place['login'] = ob_get_clean();
+$nav = $menu->render();
$nav = preg_replace_callback('{<a href="([^"]+)">(.*?)</a>}', function ($m) {
$request = $_SERVER['REQUEST_URI'];
$nav = preg_replace_callback('{<a href="([^"]+)">(.*?)</a>}', function ($m) {
$request = $_SERVER['REQUEST_URI'];
diff --git
a/page.php
b/page.php
index 214f9d284804e89a7d4cb0949e177b22c9db775b..5eefadb5c8870e13ad8eeb045dce849f1ff258c3 100644
(file)
--- a/
page.php
+++ b/
page.php
@@
-25,7
+25,8
@@
function fail($error)
include_once 'page.inc.php';
ob_start();
require '500.inc.html';
include_once 'page.inc.php';
ob_start();
require '500.inc.html';
- print $Page->render(['debug' => htmlspecialchars($error)]);
+ $Page->place['debug'] = htmlspecialchars($error);
+ print $Page->render();
}
set_exception_handler('fail');
}
set_exception_handler('fail');
@@
-95,7
+96,7
@@
header(sprintf('Content-Security-Policy: %s', implode('; ', [
])));
ob_start(); # page body
])));
ob_start(); # page body
-$P
lace
= [
+$P
age->place +
= [
'user' => $User->login ?: '',
'url' => htmlspecialchars($_SERVER['REQUEST_URI']),
];
'user' => $User->login ?: '',
'url' => htmlspecialchars($_SERVER['REQUEST_URI']),
];
diff --git
a/widget/login/commits.php
b/widget/login/commits.php
index d892cb591e169945945eb8646904dd10a3bbeddb..72f897eee197cfce2bad6c5fbe549991e66251e2 100644
(file)
--- a/
widget/login/commits.php
+++ b/
widget/login/commits.php
@@
-4,7
+4,7
@@
if (!function_exists('popen')) {
return;
}
return;
}
-$pagesize = intval(@$Place['n'] ?: @$_GET['n']) ?: 20;
+$pagesize = intval(@$P
age->p
lace['n'] ?: @$_GET['n']) ?: 20;
$gitcmd = "git log -n $pagesize --pretty='%at\t%an\t%s'";
if ( $offset = intval(@$_GET['start']) ) {
$gitcmd = "git log -n $pagesize --pretty='%at\t%an\t%s'";
if ( $offset = intval(@$_GET['start']) ) {
diff --git
a/widget/login/list.php
b/widget/login/list.php
index 31d913044de23292e376502950621a09a789df64..94440dc88be215279cc72cee30c2db315380c3c8 100644
(file)
--- a/
widget/login/list.php
+++ b/
widget/login/list.php
@@
-8,8
+8,8
@@
foreach ($users as $col => $userdir) {
$users[$col] = new User($userdir);
}
$users[$col] = new User($userdir);
}
-if (isset($Place['order'])) {
- $ordercol = $Place['order'];
+if (isset($P
age->p
lace['order'])) {
+ $ordercol = $P
age->p
lace['order'];
$order = array_map(function ($row) use ($ordercol) {
return $row->$ordercol;
}, $users);
$order = array_map(function ($row) use ($ordercol) {
return $row->$ordercol;
}, $users);
@@
-23,12
+23,12
@@
if (isset($Place['order'])) {
}
}
}
}
-if (isset($Place['n'])) {
- array_splice($users, $Place['n']); # limit number of results
+if (isset($P
age->p
lace['n'])) {
+ array_splice($users, $P
age->p
lace['n']); # limit number of results
}
print '<ul';
}
print '<ul';
-if (@$Place['view'] == 'avatar') {
+if (@$P
age->p
lace['view'] == 'avatar') {
print ' class="gallery cat"';
}
elseif (count($users) > 5) {
print ' class="gallery cat"';
}
elseif (count($users) > 5) {
@@
-43,7
+43,7
@@
foreach ($users as $user) {
$name = sprintf('<a href="%s">%s</a>', $link, $name);
}
$name = sprintf('<a href="%s">%s</a>', $link, $name);
}
- switch (@$Place['view']) {
+ switch (@$P
age->p
lace['view']) {
case 'avatar':
if (!file_exists("{$user->dir}/avatar.jpg")) {
break;
case 'avatar':
if (!file_exists("{$user->dir}/avatar.jpg")) {
break;
diff --git
a/widget/nieuws.php
b/widget/nieuws.php
index 4f4fd454d1adada0fb8c081a892c27cdf2cba510..7185036121902fc2b4e946197282b9f28b583c06 100644
(file)
--- a/
widget/nieuws.php
+++ b/
widget/nieuws.php
@@
-55,7
+55,7
@@
function printtoc($input, $class = FALSE)
$articles = (ltrim($Page->path, '/') ?: 'nieuws');
if (strpos($articles, '/') === FALSE) {
$articles = (ltrim($Page->path, '/') ?: 'nieuws');
if (strpos($articles, '/') === FALSE) {
- if (@$Place['view'] === 'toc') {
+ if (@$P
age->p
lace['view'] === 'toc') {
print "<div>\n";
foreach (array_reverse(glob("$articles/2???")) as $page) {
$year = basename($page, '.html');
print "<div>\n";
foreach (array_reverse(glob("$articles/2???")) as $page) {
$year = basename($page, '.html');
@@
-68,10
+68,10
@@
if (strpos($articles, '/') === FALSE) {
$articles .= '/????';
}
$articles .= '/????';
}
-if (@$Place['view'] === 'toc') {
+if (@$P
age->p
lace['view'] === 'toc') {
printtoc($articles);
return;
}
ob_start();
printtoc($articles);
return;
}
ob_start();
-shownews($articles, @$Place['n'] ?: 5);
+shownews($articles, @$P
age->p
lace['n'] ?: 5);
print $Page->render();
print $Page->render();
diff --git
a/widget/search.php
b/widget/search.php
index ff091f795c83b5ff291eadee3eaa1f529e749423..6c5788eabc49598da412a43211831f0f72f05f20 100644
(file)
--- a/
widget/search.php
+++ b/
widget/search.php
@@
-1,11
+1,11
@@
<?php
<?php
-$limit = @$Place['limit'] ?: 10;
+$limit = @$P
age->p
lace['limit'] ?: 10;
$path = ' '.escapeshellarg('*.html');
$query = @$_REQUEST['q'] ?: $Page->path ?: $Page->handler;
if (!trim($query, '/')) return;
$path = ' '.escapeshellarg('*.html');
$query = @$_REQUEST['q'] ?: $Page->path ?: $Page->handler;
if (!trim($query, '/')) return;
-if (!empty($Place['suggest'])) {
+if (!empty($P
age->p
lace['suggest'])) {
$cmd = "git ls-files -- $path";
exec($cmd, $ls);
if (!$ls) {
$cmd = "git ls-files -- $path";
exec($cmd, $ls);
if (!$ls) {
@@
-28,7
+28,7
@@
else {
}
}
}
}
-if (isset($Place['verbose'])) {
+if (isset($P
age->p
lace['verbose'])) {
printf("<p>%s gevonden voor <q>%s</q>:</p>\n",
$results ? count($results).' resultaten' : 'Niets',
htmlspecialchars($query)
printf("<p>%s gevonden voor <q>%s</q>:</p>\n",
$results ? count($results).' resultaten' : 'Niets',
htmlspecialchars($query)