Skip to content

Commit

Permalink
First Stable AJAX System
Browse files Browse the repository at this point in the history
  • Loading branch information
taufik-nurrohman committed Feb 22, 2020
1 parent dc58ea9 commit 38f8db2
Show file tree
Hide file tree
Showing 19 changed files with 84 additions and 58 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Release Notes

### 2.2.0

- **TODO:** AJAX system that allows other JavaScript extensions to listen to the AJAX loading and loaded events.
- Added generic JavaScript hook system for external extensions that can be used to enhance the core control panel features.
- Added AJAX system that allows other JavaScript extensions to listen to the AJAX loading and loaded events.
- Fixed bug where users could not save the file content properly due to the automatic string evaluation by the `e` function.

### 2.1.6
Expand Down
4 changes: 2 additions & 2 deletions panel/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ Use it for free, pay if you get paid. If you make a commercial product with this

You have the right to determine the price of your project without any interference from me. You may be able to discuss this additional cost with your clients, honestly, without the need to keep anything confidential. I want everything to be transparent so that no one feels aggrieved.

I started this project as a way to get people to leave social media which tends to shape the habit of spamming. I miss the existence of bloggers in the past who like to display photos, poems and short stories, with various effects of animated cursors and snow falling on their blogs that really makes me dizzy. They might all have gone extinct. It was a beautiful past. But lately social media has dominated society because of the ease and speed provided, for free.
I started this project as a way to get people to leave social media which tends to shape the habit of spamming. I miss the existence of bloggers in the past who like to display photos, poems and short stories, with various effects of animated cursors and snow falling on their blogs that really makes me dizzy. They might all have gone extinct. It was a beautiful past.

Note: If you are from Indonesia and are having problems with the current rupiah exchange rate against the dollar, you are allowed to consider 15 USD as 150,000 IDR.

Thank you.
Thank you 💕️

<https://mecha-cms.com/support>
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', 'abbr', 'b', 'code', 'del', 'em', 'i', 'ins', 'span', 'strong', 'sub', 'sup']),
1 => \w('<span>' . \i(...\array_values("" !== $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', 'abbr', 'b', 'code', 'del', 'em', 'i', 'ins', 'span', 'strong', 'sub', 'sup']);
$title = \w('<span>' . \i(...\array_values((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
35 changes: 17 additions & 18 deletions panel/engine/r/asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,29 @@
Hook::set('get', function() use($_) {
Asset::let(); // Again: remove all asset(s)
$f = __DIR__ . DS . '..' . DS . '..' . DS . 'lot' . DS . 'asset' . DS;
$dot = defined('DEBUG') && DEBUG ? '.' : '.min.';
$z = defined('DEBUG') && DEBUG ? '.' : '.min.';
if (null !== State::get('x.scss')) {
Asset::set($f . 'scss' . DS . 'panel.scss', 20);
} else {
Asset::set($f . 'css' . DS . 'panel' . $dot . 'css', 20);
Asset::set($f . 'css' . DS . 'panel' . $z . 'css', 20);
}
Asset::set($f . 'js' . DS . 'panel' . $dot . 'js', 20);
Asset::set($f . 'js' . DS . 'panel' . DS . 'alert' . $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);
Asset::set($f . 'js' . DS . 'panel' . DS . 'field' . DS . 'source' . $dot . 'js', 20.2);
extract($GLOBALS);
$js = $_;
if (isset($js['f'])) {
$js['f'] = To::URL($js['f']);
Asset::set($f . 'js' . DS . 'panel' . $z . 'js', 20);
Asset::set($f . 'js' . DS . 'panel' . DS . 'alert' . $z . 'js', 20.1);
Asset::set($f . 'js' . DS . 'panel' . DS . 'fetch' . $z . 'js', 20.1);
Asset::set($f . 'js' . DS . 'panel' . DS . 'menu' . $z . 'js', 20.1);
Asset::set($f . 'js' . DS . 'panel' . DS . 'tab' . $z . 'js', 20.1);
Asset::set($f . 'js' . DS . 'panel' . DS . 'field' . DS . 'query' . $z . 'js', 20.2);
Asset::set($f . 'js' . DS . 'panel' . DS . 'field' . DS . 'source' . $z . 'js', 20.2);
extract($GLOBALS, EXTR_SKIP);
$data = $_;
if (isset($data['f'])) {
$data['f'] = To::URL($data['f']);
}
if (isset($js['ff'])) {
$js['ff'] = To::URL($js['ff']);
if (isset($data['ff'])) {
$data['ff'] = To::URL($data['ff']);
}
// Remove sensitive data
unset($js['lot'], $js['user']);
Asset::script('window._=Object.assign(window._||{},' . json_encode($js) . ');', 0);
unset($data['lot'], $data['user']);
Asset::script('window._=Object.assign(window._||{},' . json_encode($data) . ');', 0);
require __DIR__ . DS . 'layout.php';
}, 20);
6 changes: 3 additions & 3 deletions panel/engine/r/state/files/comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@
$create = is_dir($folder = Path::F($k)) && q(g($folder, 'archive,draft,page')) > 0;
$pages[$k] = [
'path' => $k,
'title' => function($path) use($page) {
'title' => function() use($page) {
return S . _\lot\x\panel\h\w($page->author) . S;
},
'description' => function($path) use($page) {
'description' => function() use($page) {
return S . _\lot\x\panel\h\w($page->content) . S;
},
'image' => function($path) use($page) {
'image' => function() use($page) {
return $page->avatar(72);
},
'author' => $page['author'],
Expand Down
2 changes: 1 addition & 1 deletion panel/engine/r/state/files/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
$v['link'] = 'draft' !== $page->x ? $page->url : null;
$v['title'] = S . $page . S;
$v['description'] = S . $page->user . S;
$v['image'] = function($path) use($page) {
$v['image'] = function() use($page) {
// Load avatar asynchronously for best performance
return $page->avatar(72);
};
Expand Down
17 changes: 10 additions & 7 deletions panel/engine/r/state/files/x.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
$index = $index = $_['f'] . DS . 'index.php';
$lot['desk']['lot']['form']['lot'][1]['lot']['tabs']['lot']['files']['lot']['files']['lot'][$index]['tasks']['l']['active'] = false;
unset($lot['desk']['lot']['form']['lot'][1]['lot']['tabs']['lot']['files']['lot']['files']['lot'][$index]['tasks']['l']['url']);

}
if (2 === $i) {
$GLOBALS['_']['lot']['bar']['lot'][0]['lot']['folder']['hidden'] = true;
Expand Down Expand Up @@ -112,13 +112,16 @@
$page = new Page($k);
$pages[$k] = [
'path' => $k,
'title' => _\lot\x\panel\h\w($page->title),
'description' => _\lot\x\panel\h\w($page->description),
'title' => function() use($page) {
return S . _\lot\x\panel\h\w($page->title) . S;
},
'description' => function() use($page) {
return S . _\lot\x\panel\h\w($page->description) . S;
},
'type' => 'Page',
'url' => $before . 'g' . $after . '/1' . $url->query('&', ['tab' => ['info']]),
'image' => function($path) {
// Load image asynchronously for the best performance
return (new Page($path))->image(72, 72, 50);
'image' => function() use($page) {
return $page->image(72, 72, 50);
},
'time' => $page->time . "",
'tasks' => [
Expand Down Expand Up @@ -157,4 +160,4 @@
$lot['desk']['lot']['form']['lot'][0]['lot']['tasks']['lot']['blob']['icon'] = 'M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z';
$lot['desk']['lot']['form']['lot'][0]['lot']['tasks']['lot']['blob']['url'] = $url . $_['/'] . '::s::' . $_['path'] . $url->query('&', ['layout' => 'blob.x', 'tab' => false]) . $url->hash;

return $lot;
return $lot;
4 changes: 2 additions & 2 deletions panel/engine/r/state/page.page.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
return $_;
}
// Delete `kind.data` file if `data[kind]` field is empty
if (empty($lot['data']['kind'])) {
unlink(Path::F($_['f']) . DS . 'kind.data');
if (empty($lot['data']['kind']) && $f = Path::F($_['f']) . DS . 'kind.data') {
unlink($f);
return $_;
}
if (!is_dir($d = LOT . DS . 'tag')) {
Expand Down
6 changes: 3 additions & 3 deletions panel/engine/r/state/pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
$create = $add && q(g($folder, 'archive,draft,page')) > 0;
$pages[$k] = [
'path' => $k,
'title' => function($path) use($page) {
'title' => function() use($page) {
// Load title asynchronously for best performance
return S . _\lot\x\panel\h\w($page->title) . S;
},
'description' => function($path) use($page) {
'description' => function() use($page) {
// Load description asynchronously for best performance
return S . _\lot\x\panel\h\w($page->description) . S;
},
'image' => function($path) use($page) {
'image' => function() use($page) {
// Load image asynchronously for best performance
return $page->image(72, 72, 50);
},
Expand Down
8 changes: 4 additions & 4 deletions panel/lot/asset/js/panel.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(function(win, doc, _) {

var hooks = {};
let hooks = {};

function isSet(x) {
return 'undefined' !== typeof x;
Expand All @@ -22,7 +22,7 @@
}
if (isSet(hooks[name])) {
if (isSet(fn)) {
for (var i = 0, j = hooks[name].length; i < j; ++i) {
for (let i = 0, j = hooks[name].length; i < j; ++i) {
if (fn === hooks[name][i]) {
hooks[name].splice(i, 1);
}
Expand All @@ -38,7 +38,7 @@
if (!isSet(hooks[name])) {
return _;
}
for (var i = 0, j = hooks[name].length; i < j; ++i) {
for (let i = 0, j = hooks[name].length; i < j; ++i) {
hooks[name][i].apply(_, lot);
}
return _;
Expand All @@ -59,7 +59,7 @@
});

_.on('let', function() {
var title = doc.querySelector('title');
let title = doc.querySelector('title');
title = title.getAttribute('data-is-loading');
title && (doc.title = title);
});
Expand Down
2 changes: 1 addition & 1 deletion panel/lot/asset/js/panel.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions panel/lot/asset/js/panel/alert.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
(function(win, doc, _) {
var timer;
let timer;
function onChange() {
var bell = doc.querySelector('.js\\:alert');
let bell = doc.querySelector('.js\\:alert');
if (bell) {
var a = bell.querySelector('a'),
let a = bell.querySelector('a'),
svg = a.querySelector('use'),
icon = svg.getAttribute('href'),
url = a.href;
Expand Down
2 changes: 1 addition & 1 deletion panel/lot/asset/js/panel/alert.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 24 additions & 1 deletion panel/lot/asset/js/panel/fetch.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions panel/lot/asset/js/panel/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
doHide(0, e);
}
function onClickShow(e) {
var t = this,
let t = this,
menu = t.nextElementSibling;
doHide(menu, e);
setTimeout(function() {
Expand All @@ -25,11 +25,11 @@
}
function onChange() {
doc.removeEventListener('click', onClickHide);
var dropdowns = doc.querySelectorAll('.has\\:menu');
let dropdowns = doc.querySelectorAll('.has\\:menu');
if (dropdowns.length) {
doc.addEventListener('click', onClickHide, false);
dropdowns.forEach(function($) {
var menu = $.querySelector('.lot\\:menu');
let menu = $.querySelector('.lot\\:menu');
if (menu) {
menu.previousElementSibling.addEventListener('click', onClickShow, false);
}
Expand Down
2 changes: 1 addition & 1 deletion panel/lot/asset/js/panel/menu.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions panel/lot/asset/js/panel/tab.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
(function(win, doc, _) {
function onChange() {
var tabs = doc.querySelectorAll('.lot\\:tab'),
let tabs = doc.querySelectorAll('.lot\\:tab'),
replaceState = 'replaceState' in win.history,
setAction = function($) {
var href = $.href;
let href = $.href;
while ($ && $.nodeName.toLowerCase() !== 'form') {
$ = $.parentNode;
}
$ && $.nodeName.toLowerCase() === 'form' && ($.action = href);
};
if (tabs.length) {
tabs.forEach(function($) {
var panes = [].slice.call($.children),
let panes = [].slice.call($.children),
buttons = panes.shift().querySelectorAll('a');
function onClick(e) {
if (!this.parentNode.classList.contains('has:link')) {
Expand Down
Loading

0 comments on commit 38f8db2

Please sign in to comment.