Skip to content

Commit

Permalink
Revert AJAX System for Now
Browse files Browse the repository at this point in the history
  • Loading branch information
taufik-nurrohman committed Feb 20, 2020
1 parent bf4cdeb commit dc58ea9
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 35 deletions.
17 changes: 12 additions & 5 deletions panel/engine/f.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,17 +314,24 @@ function Page($in, $key) {
];
\_\lot\x\panel\h\c($out[2], $in, $tags);
$path = $in['path'] ?? $key;
$title = !empty($in['time']) ? \strtr($in['time'], '-', '/') : null;
$image = isset($in['image']) ? (\is_callable($in['image']) ? \call_user_func($in['image'], $path) : $in['image']) : null;
$out[1] .= '<div' . (isset($image) && false === $image ? ' hidden' : "") . '>' . (!empty($image) ? '<img alt="" height="72" src="' . $image . '" width="72">' : '<span class="img" style="background: #' . \substr(\md5(\strtr($path, [
foreach (['title', 'description', 'image'] as $k) {
if (isset($in[$k])) {
// Delay `page.*` hook execution with closure(s)
if (\is_callable($in[$k])) {
$in[$k] = \call_user_func($in[$k], $path);
}
}
}
$date = isset($in['time']) ? \strtr($in['time'], '-', '/') : null;
$out[1] .= '<div' . (isset($in['image']) && false === $in['image'] ? ' hidden' : "") . '>' . (!empty($in['image']) ? '<img alt="" height="72" src="' . $in['image'] . '" width="72">' : '<span class="img" style="background: #' . \substr(\md5(\strtr($path, [
\ROOT => "",
\DS => '/'
])), 0, 6) . ';"></span>') . '</div>';
$out[1] .= '<div><h3>' . \_\lot\x\panel\Link([
'link' => $in['link'] ?? null,
'title' => $in['title'] ?? $title,
'title' => $in['title'] ?? $date,
'url' => $in['url'] ?? null
], $key) . '</h3>' . \_\lot\x\panel\h\description($in, $title) . '</div>';
], $key) . '</h3>' . \_\lot\x\panel\h\description($in, $date) . '</div>';
$out[1] .= '<div>' . \_\lot\x\panel\Tasks\Link([
0 => 'p',
'lot' => $in['tasks'] ?? []
Expand Down
4 changes: 2 additions & 2 deletions panel/engine/f/h.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function description($in, $or = null) {
}
$out = [
0 => 'p',
1 => \w('<span>' . \i(...("" !== $description ? (array) $description : (array) $or)) . '</span>', ['a', 'b', 'code', 'del', 'em', 'i', 'ins', 'span', 'strong', 'sub', 'sup']),
1 => \w('<span>' . \i(...("" !== $description ? (array) $description : (array) $or)) . '</span>', ['a', 'abbr', 'b', 'code', 'del', 'em', 'i', 'ins', 'span', 'strong', 'sub', 'sup']),
2 => []
];
unset($in['tags']);
Expand Down Expand Up @@ -148,7 +148,7 @@ function title($in, $i = -1, $or = null) {
];
$icon = \_\lot\x\panel\h\icon($in['icon'] ?? [null, null]);
if (null !== $title && false !== $title) {
$title = \w('<span>' . \i(...((array) $title)) . '</span>', ['a', 'b', 'code', 'del', 'em', 'i', 'ins', 'span', 'strong', 'sub', 'sup']);
$title = \w('<span>' . \i(...((array) $title)) . '</span>', ['a', 'abbr', 'b', 'code', 'del', 'em', 'i', 'ins', 'span', 'strong', 'sub', 'sup']);
}
$out[1] = $icon[0] . $title . $icon[1];
unset($in['tags']);
Expand Down
3 changes: 2 additions & 1 deletion panel/engine/r/asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
}
Asset::set($f . 'js' . DS . 'panel' . $dot . 'js', 20);
Asset::set($f . 'js' . DS . 'panel' . DS . 'alert' . $dot . 'js', 20.1);
Asset::set($f . 'js' . DS . 'panel' . DS . 'fetch' . $dot . 'js', 20.1);
// TODO:
// Asset::set($f . 'js' . DS . 'panel' . DS . 'fetch' . $dot . 'js', 20.1);
Asset::set($f . 'js' . DS . 'panel' . DS . 'menu' . $dot . 'js', 20.1);
Asset::set($f . 'js' . DS . 'panel' . DS . 'tab' . $dot . 'js', 20.1);
Asset::set($f . 'js' . DS . 'panel' . DS . 'field' . DS . 'query' . $dot . 'js', 20.2);
Expand Down
2 changes: 1 addition & 1 deletion panel/engine/r/layout/panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta content="width=device-width" name="viewport">
<meta content="noindex" name="robots">
<title data-loading-text="<?= i('Loading'); ?>&#x2026;"><?= w($t->reverse); ?></title>
<title data-is-loading="<?= i('Loading'); ?>&#x2026;"><?= w($t->reverse); ?></title>
<link href="<?= $url; ?>/favicon.ico" rel="shortcut icon">
</head>
<body spellcheck="false">
Expand Down
17 changes: 10 additions & 7 deletions panel/engine/r/state/files/comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,18 @@
$create = is_dir($folder = Path::F($k)) && q(g($folder, 'archive,draft,page')) > 0;
$pages[$k] = [
'path' => $k,
'title' => _\lot\x\panel\h\w($page->author),
'description' => _\lot\x\panel\h\w(To::excerpt($page->content)),
'title' => function($path) use($page) {
return S . _\lot\x\panel\h\w($page->author) . S;
},
'description' => function($path) use($page) {
return S . _\lot\x\panel\h\w($page->content) . S;
},
'image' => function($path) use($page) {
return $page->avatar(72);
},
'author' => $page['author'],
'type' => 'Page',
'link' => 'draft' === ($x = $page->x) ? null : $page->url,
'image' => function($path) {
// Load avatar asynchronously for best performance
return (new Comment($path))->avatar(72);
},
'time' => $page->time . "",
'tags' => [
'is:' . $x,
Expand Down Expand Up @@ -83,4 +86,4 @@
$lot['desk']['lot']['form']['lot'][0]['lot']['tasks']['lot']['page']['hidden'] = true;
$lot['desk']['lot']['form']['lot'][0]['lot']['tasks']['lot']['data']['hidden'] = true;

return $lot;
return $lot;
8 changes: 4 additions & 4 deletions panel/engine/r/state/files/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
foreach ($lot['desk']['lot']['form']['lot'][1]['lot']['tabs']['lot']['pages']['lot']['pages']['lot'] as $k => &$v) {
$page = new User($k);
$v['link'] = 'draft' !== $page->x ? $page->url : null;
$v['title'] = $page . "";
$v['description'] = $page->user;
$v['image'] = function($path) {
$v['title'] = S . $page . S;
$v['description'] = S . $page->user . S;
$v['image'] = function($path) use($page) {
// Load avatar asynchronously for best performance
return (new User($path))->avatar(72);
return $page->avatar(72);
};
// Disable page children feature
$v['tasks']['enter']['hidden'] = true;
Expand Down
21 changes: 15 additions & 6 deletions panel/engine/r/state/pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
if (is_dir($folder = LOT . strtr($_['path'], '/', DS))) {
$before = $url . $_['/'] . '::';
foreach ($search($folder, 'archive,draft,page', 0) as $k => $v) {
if (false !== strpos(',.archive,.draft,.page,', basename($k))) {
continue; // Skip placeholder page(s)
}
$after = '::' . strtr($k, [
LOT => "",
DS => '/'
Expand All @@ -22,15 +25,21 @@
$create = $add && q(g($folder, 'archive,draft,page')) > 0;
$pages[$k] = [
'path' => $k,
'title' => S . _\lot\x\panel\h\w($page->title) . S,
'description' => S . _\lot\x\panel\h\w($page->description) . S,
'title' => function($path) use($page) {
// Load title asynchronously for best performance
return S . _\lot\x\panel\h\w($page->title) . S;
},
'description' => function($path) use($page) {
// Load description asynchronously for best performance
return S . _\lot\x\panel\h\w($page->description) . S;
},
'image' => function($path) use($page) {
// Load image asynchronously for best performance
return $page->image(72, 72, 50);
},
'author' => $page['author'],
'type' => 'Page',
'link' => 'draft' === ($x = $page->x) ? null : $page->url,
'image' => function($path) {
// Load image asynchronously for best performance
return (new Page($path))->image(72, 72, 50);
},
'time' => $page->time . "",
'tags' => [
'is:' . $x,
Expand Down
2 changes: 1 addition & 1 deletion panel/engine/r/task/g.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ function page($_, $lot) {
}
$page[$k] = $v;
}
$lot['file']['content'] = \To::page($page);
$lot['file']['content'] = $_POST['file']['content'] = \To::page($page);
$lot['file']['name'] = $name . '.' . $x;
$_f = $_['f']; // Get old file name
$_ = file($_, $lot); // Move to `file`
Expand Down
2 changes: 1 addition & 1 deletion panel/engine/r/task/s.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ function page($_, $lot) {
}
$page[$k] = $v;
}
$lot['file']['content'] = \To::page($page);
$lot['file']['content'] = $_POST['file']['content'] = \To::page($page);
$lot['file']['name'] = $name . '.' . $x;
$_ = file($_, $lot); // Move to `file`
if (empty($_['alert']['error'])) {
Expand Down
4 changes: 2 additions & 2 deletions panel/lot/asset/css/panel.css
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ svg[display='none'] {
overflow: hidden;
text-overflow: ellipsis;
}
.lot\:file h3 a.not\:active:not(:focus):not(:hover), .lot\:page h3 a.not\:active:not(:focus):not(:hover) {
.lot\:file h3 a.not\:active, .lot\:page h3 a.not\:active {
opacity: 1;
}
.lot\:file h3 .title, .lot\:page h3 .title {
Expand Down Expand Up @@ -960,7 +960,7 @@ svg[display='none'] {
width: 12px;
top: 7px;
}
.lot\:file .not\:active:not(:focus):not(:hover), .lot\:page .not\:active:not(:focus):not(:hover) {
.lot\:file .not\:active, .lot\:page .not\:active {
opacity: 0.5;
}
.lot\:file.count\:0, .lot\:page.count\:0 {
Expand Down
2 changes: 1 addition & 1 deletion panel/lot/asset/css/panel.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion panel/lot/asset/js/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

_.on('let', function() {
var title = doc.querySelector('title');
title = title.getAttribute('data-loading-text');
title = title.getAttribute('data-is-loading');
title && (doc.title = title);
});

Expand Down
2 changes: 1 addition & 1 deletion panel/lot/asset/js/panel/fetch.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions panel/lot/asset/scss/panel/lot.scss
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
overflow: hidden;
text-overflow: ellipsis;
a {
&.not\:active:not(:focus):not(:hover) {
&.not\:active {
opacity: 1;
}
}
Expand Down Expand Up @@ -206,7 +206,7 @@
top: 7px;
}
}
.not\:active:not(:focus):not(:hover) {
.not\:active {
opacity: .5;
}
&.count\:0 {
Expand Down
1 change: 1 addition & 0 deletions panel/lot/layout/asset/scss/construction.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ $color-secondary: #888;
$color-title: #66a;

$color-button: $color-back;

$color-back-button: $color-link;
$color-back-button-focus: $color-link-focus;
$color-back-button-active: $color-link-active;
Expand Down

0 comments on commit dc58ea9

Please sign in to comment.