aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/class/modelpage.php18
-rw-r--r--app/class/page.php2
-rw-r--r--app/fn/fn.php3
-rw-r--r--composer.lock2
-rw-r--r--package-lock.json12
-rw-r--r--package.json2
-rw-r--r--src/edit.js60
-rw-r--r--webpack.config.js8
8 files changed, 73 insertions, 34 deletions
diff --git a/app/class/modelpage.php b/app/class/modelpage.php
index a47ebdb..68ccf23 100644
--- a/app/class/modelpage.php
+++ b/app/class/modelpage.php
@@ -12,7 +12,7 @@ class Modelpage extends Modeldb
parent::__construct();
$this->storeinit(Config::pagetable());
if(!$this->dircheck(Model::HTML_RENDER_DIR)) {
- throw new Exception("Media error : Cant create /rendernew folder");
+ throw new Exception("Media error : Cant create /render folder");
}
}
@@ -32,7 +32,14 @@ class Modelpage extends Modeldb
}
- public function getlisterid(array $idlist = [])
+ /**
+ * Scan database for specific pages IDs and return array of Pages objects
+ *
+ * @param array $idlist list of ID strings
+ *
+ * @return array of Page objects
+ */
+ public function getlisterid(array $idlist = []) : array
{
$pagedatalist = $this->repo->query()
->where('__id', 'IN', $idlist)
@@ -45,6 +52,11 @@ class Modelpage extends Modeldb
return $pagelist;
}
+ /**
+ * Store new page in the database
+ *
+ * @param Page $page object
+ */
public function add(Page $page)
{
@@ -194,6 +206,7 @@ class Modelpage extends Modeldb
* @param array $pagelist List of Page
* @param array $tagchecked list of tags
* @param string $tagcompare string, can be 'OR' or 'AND', set the tag filter method
+ *
* @return array $array
*/
@@ -280,6 +293,7 @@ class Modelpage extends Modeldb
/**
* @param array $taglist list of tags
* @param array $pagelist list of Page
+ *
* @return array list of tags each containing list of id
*/
diff --git a/app/class/page.php b/app/class/page.php
index 299e448..a55e7cb 100644
--- a/app/class/page.php
+++ b/app/class/page.php
@@ -480,7 +480,7 @@ class Page
{
if (is_string($tag)) {
- if (strlen($tag) < self::LEN and is_string($tag)) {
+ if (strlen($tag) < self::LEN) {
$tag = strip_tags(trim(strtolower($tag)));
$tag = str_replace('*', '', $tag);
$tag = str_replace(' ', '', $tag);
diff --git a/app/fn/fn.php b/app/fn/fn.php
index f5068fa..9c011ef 100644
--- a/app/fn/fn.php
+++ b/app/fn/fn.php
@@ -85,8 +85,7 @@ function idclean(string $input)
function getversion()
{
if(file_exists('VERSION')) {
- $composer = file_get_contents('VERSION');
- $version = $composer['version'];
+ $version = file_get_contents('VERSION');
} else {
$version = 'unknown';
}
diff --git a/composer.lock b/composer.lock
index 1b7f620..7aa580a 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
- "content-hash": "f9644fc739f56d4f7a89c3050f0771d4",
+ "content-hash": "0af1268a5134477e3b6be211b055ec59",
"packages": [
{
"name": "altorouter/altorouter",
diff --git a/package-lock.json b/package-lock.json
index 221b5b6..7dbe19c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -4335,6 +4335,18 @@
"integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=",
"dev": true
},
+ "prettier": {
+ "version": "1.18.2",
+ "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.18.2.tgz",
+ "integrity": "sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw==",
+ "dev": true
+ },
+ "prettier-webpack-plugin": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/prettier-webpack-plugin/-/prettier-webpack-plugin-1.2.0.tgz",
+ "integrity": "sha512-icoIPxDpOo/q7SUCHSW152dCr83z7QS/6s2V3phweKu1bfJcXSObVAq/Z8OeSX7ykuXrcV2UpZbfljRI2rIOMg==",
+ "dev": true
+ },
"process": {
"version": "0.11.10",
"resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
diff --git a/package.json b/package.json
index 445afb1..ad88d1d 100644
--- a/package.json
+++ b/package.json
@@ -8,6 +8,8 @@
"devDependencies": {
"@release-it/bumper": "^1.0.5",
"css-loader": "^3.2.0",
+ "prettier": "^1.18.2",
+ "prettier-webpack-plugin": "^1.2.0",
"release-it": "^12.4.3",
"style-loader": "^1.0.0",
"webpack": "^4.41.2",
diff --git a/src/edit.js b/src/edit.js
index eaf2d1e..6c2f328 100644
--- a/src/edit.js
+++ b/src/edit.js
@@ -1,15 +1,14 @@
-import CodeMirror from "codemirror";
-import "codemirror/lib/codemirror.css";
-import "codemirror/mode/markdown/markdown";
-import "codemirror/mode/css/css"
-import "codemirror/mode/htmlmixed/htmlmixed"
-import "codemirror/mode/javascript/javascript"
-import "codemirror/addon/search/search";
-import "codemirror/addon/search/searchcursor";
-import "codemirror/addon/search/jump-to-line";
-import "codemirror/addon/dialog/dialog";
-import "codemirror/addon/dialog/dialog.css";
-
+import CodeMirror from 'codemirror';
+import 'codemirror/lib/codemirror.css';
+import 'codemirror/mode/markdown/markdown';
+import 'codemirror/mode/css/css';
+import 'codemirror/mode/htmlmixed/htmlmixed';
+import 'codemirror/mode/javascript/javascript';
+import 'codemirror/addon/search/search';
+import 'codemirror/addon/search/searchcursor';
+import 'codemirror/addon/search/jump-to-line';
+import 'codemirror/addon/dialog/dialog';
+import 'codemirror/addon/dialog/dialog.css';
let form;
let editors = [];
@@ -23,58 +22,58 @@ window.onload = () => {
input.oninput = changeHandler;
}
- form.addEventListener("submit", function (event) {
+ form.addEventListener('submit', function(event) {
event.preventDefault();
submitHandler(this);
});
- delete CodeMirror.keyMap['default']["Ctrl-D"];
+ delete CodeMirror.keyMap['default']['Ctrl-D'];
editors = [
CodeMirror.fromTextArea(document.getElementById('editmain'), {
mode: 'markdown',
lineNumbers: true,
lineWrapping: true,
- extraKeys: {"Alt-F": "findPersistent"}
+ extraKeys: { 'Alt-F': 'findPersistent' },
}),
CodeMirror.fromTextArea(document.getElementById('editcss'), {
mode: 'css',
lineNumbers: true,
- extraKeys: {"Alt-F": "findPersistent"}
+ extraKeys: { 'Alt-F': 'findPersistent' },
}),
CodeMirror.fromTextArea(document.getElementById('editheader'), {
mode: 'markdown',
lineNumbers: true,
lineWrapping: true,
- extraKeys: {"Alt-F": "findPersistent"}
+ extraKeys: { 'Alt-F': 'findPersistent' },
}),
CodeMirror.fromTextArea(document.getElementById('editnav'), {
mode: 'markdown',
lineNumbers: true,
lineWrapping: true,
- extraKeys: {"Alt-F": "findPersistent"}
+ extraKeys: { 'Alt-F': 'findPersistent' },
}),
CodeMirror.fromTextArea(document.getElementById('editaside'), {
mode: 'markdown',
lineNumbers: true,
lineWrapping: true,
- extraKeys: {"Alt-F": "findPersistent"}
+ extraKeys: { 'Alt-F': 'findPersistent' },
}),
CodeMirror.fromTextArea(document.getElementById('editfooter'), {
mode: 'markdown',
lineNumbers: true,
lineWrapping: true,
- extraKeys: {"Alt-F": "findPersistent"}
+ extraKeys: { 'Alt-F': 'findPersistent' },
}),
CodeMirror.fromTextArea(document.getElementById('editbody'), {
mode: 'htmlmixed',
lineNumbers: true,
- extraKeys: {"Alt-F": "findPersistent"}
+ extraKeys: { 'Alt-F': 'findPersistent' },
}),
CodeMirror.fromTextArea(document.getElementById('editjavascript'), {
mode: 'javascript',
lineNumbers: true,
- extraKeys: {"Alt-F": "findPersistent"}
+ extraKeys: { 'Alt-F': 'findPersistent' },
}),
];
for (const editor of editors) {
@@ -82,7 +81,7 @@ window.onload = () => {
}
const fontSizeInput = document.getElementById('editfontsize');
- fontSizeInput.addEventListener('change', fontSizeChangeHandler)
+ fontSizeInput.addEventListener('change', fontSizeChangeHandler);
fontSizeInput.dispatchEvent(new Event('change'));
window.onkeydown = keyboardHandler;
@@ -103,7 +102,9 @@ function keyboardHandler(e) {
break;
// ctrl + d
case 'd':
- const url = document.getElementById('update').getAttribute('href');
+ const url = document
+ .getElementById('update')
+ .getAttribute('href');
window.open(url);
break;
default:
@@ -120,7 +121,10 @@ function keyboardHandler(e) {
* @param {InputEvent} e
*/
function changeHandler(e) {
- if(e.target.classList.contains("toggle")||e.target.classList.contains("checkboxtab")) {
+ if (
+ e.target.classList.contains('toggle') ||
+ e.target.classList.contains('checkboxtab')
+ ) {
return;
}
unsavedChanges = true;
@@ -130,7 +134,7 @@ function changeHandler(e) {
* Manage CodeMirror editor change event
* @param {CodeMirror.EditorFromTextArea} cm the CodeMirror instance
*/
-function cmChangeHandler(cm){
+function cmChangeHandler(cm) {
let textArea = cm.getTextArea();
textArea.value = cm.getValue();
textArea.dispatchEvent(inputEvent);
@@ -152,11 +156,11 @@ function submitHandler(form) {
var xhr = new XMLHttpRequest();
var fd = new FormData(form);
- xhr.addEventListener("load", function(event) {
+ xhr.addEventListener('load', function(event) {
unsavedChanges = false;
// Add "last update" timestamp here
});
- xhr.addEventListener("error", function(event) {
+ xhr.addEventListener('error', function(event) {
alert('Error while trying to update.');
});
xhr.open(form.method, form.action);
diff --git a/webpack.config.js b/webpack.config.js
index 734b3cd..c0286df 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -1,4 +1,5 @@
const path = require('path');
+const PrettierPlugin = require('prettier-webpack-plugin');
module.exports = (env) => {
return {
@@ -27,5 +28,12 @@ module.exports = (env) => {
},
],
},
+ plugins: [
+ new PrettierPlugin({
+ tabWidth: 4,
+ trailingComma: 'es5',
+ singleQuote: true,
+ })
+ ],
}
};