'+page.title+'
'+page.contentRaw.substring(0, 50)+'
');
+ });
+ });
+}
+
// Set the page selected
function loadPage(pageKey) {
// Check the current key if the same as the page is editing
@@ -98,7 +123,7 @@ function loadPage(pageKey) {
content += "# "+page.title.trim()+"\n";
}
content += page.contentRaw;
- editorSetContent(content);
+ editorInitialize(content);
});
}
diff --git a/bl-kernel/admin/themes/grizzly/js/ajax.js b/bl-kernel/admin/themes/grizzly/js/ajax.js
index 2a10259a..41583b8c 100644
--- a/bl-kernel/admin/themes/grizzly/js/ajax.js
+++ b/bl-kernel/admin/themes/grizzly/js/ajax.js
@@ -21,29 +21,27 @@ class Ajax {
}
}
- createPage() {
+ async createPage() {
var url = this.apiURL+"pages";
- return fetch(url, {
- credentials: 'same-origin',
- method: "POST",
- body: JSON.stringify({
- token: this.token,
- authentication: this.authentication
- }),
- headers: new Headers({
- 'Content-Type': 'application/json'
- }),
- })
- .then(function(response) {
- return response.json();
- })
- .then(function(json) {
+ try {
+ const response = await fetch(url, {
+ credentials: 'same-origin',
+ method: "POST",
+ body: JSON.stringify({
+ token: this.token,
+ authentication: this.authentication
+ }),
+ headers: new Headers({
+ 'Content-Type': 'application/json'
+ }),
+ });
+ const json = await response.json();
return json.data.key;
- })
- .catch(err => {
+ }
+ catch (err) {
console.log(err);
- return false;
- });
+ return true;
+ }
}
updatePage(key, title, content, tags) {
@@ -104,4 +102,25 @@ class Ajax {
return false;
}
}
+
+ async getPagesUntagged() {
+ let parameters = {
+ token: this.token,
+ untagged: true,
+ published: true,
+ draft: true
+ }
+ let url = this.apiURL+"pages?"+$.param(parameters);
+ try {
+ const response = await fetch(url, {
+ method: "GET"
+ });
+ const json = await response.json();
+ return json.data;
+ }
+ catch (err) {
+ console.log(err);
+ return true;
+ }
+ }
}
\ No newline at end of file
diff --git a/bl-kernel/pages.class.php b/bl-kernel/pages.class.php
index 68c907cb..8dc935bf 100644
--- a/bl-kernel/pages.class.php
+++ b/bl-kernel/pages.class.php
@@ -474,19 +474,19 @@ class Pages extends dbJSON {
}
if ($static) {
- $list += $pages->getStaticDB();
+ $list += $this->getStaticDB();
}
if ($sticky) {
- $list += $pages->getStickyDB();
+ $list += $this->getStickyDB();
}
if ($draft) {
- $list += $pages->getDraftDB();
+ $list += $this->getDraftDB();
}
if ($scheduled) {
- $list += $pages->getScheduledDB();
+ $list += $this->getScheduledDB();
}
if ($numberOfItems==-1) {
diff --git a/bl-plugins/api/plugin.php b/bl-plugins/api/plugin.php
index bd5520bc..d08d36b9 100644
--- a/bl-plugins/api/plugin.php
+++ b/bl-plugins/api/plugin.php
@@ -296,11 +296,15 @@ class pluginAPI extends Plugin {
private function getPages($args)
{
global $pages;
- $published = $args['published'];
- $static = $args['static'];
- $draft = $args['draft'];
- $sticky = $args['sticky'];
- $scheduled = $args['scheduled'];
+
+ // Parameters and the default values
+ $published = (isset($args['published'])?$args['published']:true);
+ $static = (isset($args['static'])?$args['static']:false);
+ $draft = (isset($args['draft'])?$args['draft']:false);
+ $sticky = (isset($args['sticky'])?$args['sticky']:false);
+ $scheduled = (isset($args['scheduled'])?$args['scheduled']:false);
+ $untagged = (isset($args['untagged'])?$args['untagged']:false);
+
$numberOfItems = $this->getValue('numberOfItems');
$pageNumber = 1;
$list = $pages->getList($pageNumber, $numberOfItems, $published, $static, $sticky, $draft, $scheduled);
@@ -315,10 +319,12 @@ class pluginAPI extends Plugin {
try {
// Create the page object from the page key
$page = new Page($pageKey);
- if ($args['untagged'] && (empty($page->tags()))) {
- // Push the page to the data array for the response
- array_push($tmp['data'], $page->json($returnsArray=true));
- } else {
+ if ($untagged) {
+ if (empty($page->tags())) {
+ // Push the page to the data array for the response
+ array_push($tmp['data'], $page->json($returnsArray=true));
+ }
+ } else{
array_push($tmp['data'], $page->json($returnsArray=true));
}
} catch (Exception $e) {