@lexho111/plainblog 0.5.28 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Article.js +73 -4
- package/Blog.js +341 -140
- package/Formatter.js +2 -11
- package/README.md +1 -1
- package/{blog → blog_test_empty.db} +0 -0
- package/blog_test_load.db +0 -0
- package/build-scripts.js +54 -0
- package/coverage/clover.xml +1043 -0
- package/coverage/coverage-final.json +20 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +161 -0
- package/coverage/lcov-report/package/Article.js.html +406 -0
- package/coverage/lcov-report/package/Blog.js.html +2635 -0
- package/coverage/lcov-report/package/Formatter.js.html +379 -0
- package/coverage/lcov-report/package/build-scripts.js.html +247 -0
- package/coverage/lcov-report/package/build-styles.js.html +367 -0
- package/coverage/lcov-report/package/index.html +191 -0
- package/coverage/lcov-report/package/model/APIModel.js.html +190 -0
- package/coverage/lcov-report/package/model/ArrayList.js.html +382 -0
- package/coverage/lcov-report/package/model/ArrayListHashMap.js.html +379 -0
- package/coverage/lcov-report/package/model/BinarySearchTree.js.html +856 -0
- package/coverage/lcov-report/package/model/BinarySearchTreeHashMap.js.html +346 -0
- package/coverage/lcov-report/package/model/DataModel.js.html +307 -0
- package/coverage/lcov-report/package/model/DatabaseModel.js.html +232 -0
- package/coverage/lcov-report/package/model/FileAdapter.js.html +394 -0
- package/coverage/lcov-report/package/model/FileList.js.html +244 -0
- package/coverage/lcov-report/package/model/FileModel.js.html +358 -0
- package/coverage/lcov-report/package/model/SequelizeAdapter.js.html +538 -0
- package/coverage/lcov-report/package/model/SqliteAdapter.js.html +247 -0
- package/coverage/lcov-report/package/model/datastructures/ArrayList.js.html +439 -0
- package/coverage/lcov-report/package/model/datastructures/ArrayListHashMap.js.html +196 -0
- package/coverage/lcov-report/package/model/datastructures/BinarySearchTree.js.html +913 -0
- package/coverage/lcov-report/package/model/datastructures/BinarySearchTreeHashMap.js.html +346 -0
- package/coverage/lcov-report/package/model/datastructures/FileList.js.html +244 -0
- package/coverage/lcov-report/package/model/datastructures/index.html +176 -0
- package/coverage/lcov-report/package/model/index.html +206 -0
- package/coverage/lcov-report/package/utilities.js.html +511 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +210 -0
- package/coverage/lcov.info +2063 -0
- package/index.js +25 -1
- package/model/DataModel.js +79 -0
- package/model/DatabaseModel.js +20 -8
- package/model/FileAdapter.js +43 -4
- package/model/FileModel.js +47 -9
- package/model/SequelizeAdapter.js +11 -3
- package/model/datastructures/ArrayList.js +118 -0
- package/model/datastructures/ArrayListHashMap.js +37 -0
- package/model/datastructures/ArrayListHashMap.js.bk +90 -0
- package/model/datastructures/BinarySearchTree.js +276 -0
- package/model/datastructures/BinarySearchTreeHashMap.js +89 -0
- package/model/datastructures/BinarySearchTreeTest.js +16 -0
- package/model/datastructures/FileList.js +53 -0
- package/package.json +10 -2
- package/public/fetchData.js +0 -0
- package/public/scripts.min.js +2 -1
- package/public/styles.min.css +2 -1
- package/src/fetchData.js +150 -30
- package/src/styles.css +29 -0
- package/utilities.js +142 -0
package/Formatter.js
CHANGED
|
@@ -40,6 +40,7 @@ export function formatHTML(data) {
|
|
|
40
40
|
return `${header(data.title)}
|
|
41
41
|
<body>
|
|
42
42
|
<nav>
|
|
43
|
+
<input type="text" id="search" placeholder="Search..." style="float:right; margin: 5px;">
|
|
43
44
|
${data.login}
|
|
44
45
|
</nav>
|
|
45
46
|
<div id="header">
|
|
@@ -49,17 +50,7 @@ export function formatHTML(data) {
|
|
|
49
50
|
<div id="wrapper">
|
|
50
51
|
${form}
|
|
51
52
|
<section id="articles" class="grid">
|
|
52
|
-
${data.articles
|
|
53
|
-
.map((article) => {
|
|
54
|
-
let html = article.toHTML();
|
|
55
|
-
if (article.id != null)
|
|
56
|
-
html = html.replace(
|
|
57
|
-
"<article",
|
|
58
|
-
`<article data-id="${article.id}" `
|
|
59
|
-
);
|
|
60
|
-
return html;
|
|
61
|
-
})
|
|
62
|
-
.join("")}
|
|
53
|
+
${data.articles.map((article) => article.toHTML(data.loggedin)).join("")}
|
|
63
54
|
</section>
|
|
64
55
|
</div>
|
|
65
56
|
<script src="scripts.min.js">
|
package/README.md
CHANGED
|
Binary file
|
|
Binary file
|
package/build-scripts.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compiles JS scripts from file content objects.
|
|
3
|
+
* @param {Array<{path: string, content: string}>} fileData - An array of objects containing file paths and content.
|
|
4
|
+
* @returns {Promise<string>} The compiled and minified JS.
|
|
5
|
+
*/
|
|
6
|
+
export async function compileScripts(fileData) {
|
|
7
|
+
let combinedJs = "";
|
|
8
|
+
try {
|
|
9
|
+
if (fileData) {
|
|
10
|
+
// concat
|
|
11
|
+
for (const file of fileData) {
|
|
12
|
+
combinedJs += file.content + "\n;\n";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (combinedJs) {
|
|
17
|
+
return await runBabelAndUglify(combinedJs);
|
|
18
|
+
}
|
|
19
|
+
return "";
|
|
20
|
+
} catch (error) {
|
|
21
|
+
if (error.message !== "Missing optional dependencies") {
|
|
22
|
+
console.error("Build scripts failed:", error);
|
|
23
|
+
}
|
|
24
|
+
return combinedJs;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async function runBabelAndUglify(js) {
|
|
29
|
+
let babel, uglify;
|
|
30
|
+
try {
|
|
31
|
+
babel = await import("@babel/core");
|
|
32
|
+
uglify = await import("uglify-js");
|
|
33
|
+
await import("@babel/preset-env");
|
|
34
|
+
} catch (error) {
|
|
35
|
+
console.error("Build scripts failed. Missing dependencies.");
|
|
36
|
+
console.error("Please run: npm install");
|
|
37
|
+
throw new Error("Missing optional dependencies");
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const babelResult = await babel.transformAsync(js, {
|
|
41
|
+
presets: [["@babel/preset-env", { targets: "defaults", debug: false }]],
|
|
42
|
+
sourceType: "script",
|
|
43
|
+
configFile: false,
|
|
44
|
+
babelrc: false,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
if (!babelResult || !babelResult.code) return js;
|
|
48
|
+
|
|
49
|
+
// Handle potential CJS default export wrapping
|
|
50
|
+
const minify = uglify.minify || (uglify.default && uglify.default.minify);
|
|
51
|
+
const uglifyResult = minify(babelResult.code);
|
|
52
|
+
if (uglifyResult.error) throw uglifyResult.error;
|
|
53
|
+
return uglifyResult.code;
|
|
54
|
+
}
|