remove examples

This commit is contained in:
lucaspalomodevelop 2022-10-27 19:19:23 +02:00
parent bfc35db211
commit 5cc73cb37b
27 changed files with 9441 additions and 225 deletions

2
.gitignore vendored
View File

@ -1,4 +1,6 @@
planning
.vscode
built
# Logs
logs
*.log

View File

@ -1,58 +0,0 @@
let express = require("express");
let app = express();
let jsste = require("../src");
const bodyParser = require("body-parser");
let path = require("path");
let fs = require("fs");
var decode = require("urldecode");
jsste.__config.set("templatePath", __dirname + "/templates");
jsste.__config.set("pagePath", __dirname + "/pages");
jsste.__config.set("assetsPath", "./assets");
jsste.__config.set("stylesheets", "./styles");
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
let folders = {
jsste: "pages",
css: "styles",
};
function getFolderFromFileEnding(filename) {
let regex_isAnDotfile = /\w+\.[a-z]*[A-Z]*/;
if (regex_isAnDotfile.test(filename)) {
let ending = filename.split(".").pop();
return folders[ending];
}
return folders.jsste;
}
function defaultUse(req, res, next) {
let regex_isAnDotfile = /\w+\.[a-z]*[A-Z]*/;
let filePath = path.join(
__dirname.toString(),
getFolderFromFileEnding(req.url).toString(),
req.url.toString()
);
if (regex_isAnDotfile.test(req.url) && !filePath.endsWith(".jsste")) {
res.sendFile(filePath);
} else if (fs.existsSync(filePath + ".jsste")) {
let content = jsste.renderFile(filePath + ".jsste");
res.send(content);
} else if (fs.lstatSync(filePath).isDirectory()) {
let content = jsste.renderFile(decode(path.join(filePath, "index.jsste")));
res.send(content);
} else next();
}
app.get("/assets/*", (req, res) => {
console.log(req.url);
console.log(__dirname);
res.sendFile(decode(path.join(__dirname, req.url)));
});
app.get("/*", defaultUse);
app.listen(8000, function () {
console.log("Example app listening on port http://127.0.0.1:8000 !");
});

View File

@ -1,3 +0,0 @@
{
"b":"hallo"
}

View File

@ -1,5 +0,0 @@
{
"_IMPORTS_":["data.jsste","lib/base.jsste"],
"a":"h1 - test",
"c":"p - test"
}

View File

@ -1,5 +0,0 @@
{
"_TEMPLATE_":"startpage"
}

View File

@ -1,6 +0,0 @@
{
"_STYLES_":["base"],
"js$Date": "return Date.now() + ' is the TimeStemp';",
"js$uxTime":"Date.Now();",
"js$TimeStemp":"const heute = new Date(); return heute"
}

View File

@ -1,5 +0,0 @@
{
"_IMPORTS_":["data2.jsste"],
"_TEMPLATE_":"page1",
"root":"root"
}

View File

@ -1,12 +0,0 @@
{
"_STYLES_":["base"],
"_TEMPLATE_":"page1",
"_TITLE_":"Page2.2",
"root":"root",
"a":"h1 - test",
"c":"p - test",
"b":"hallo",
"js$Date": "return Date.now() + ' is the TimeStemp';",
"pic$bild":"",
"//":"ich bin ein kommentar"
}

View File

@ -1,5 +0,0 @@
{
"_TEMPLATE_":"page3",
"Title":"Page3",
"_IMPORTS_":["lib/base.jsste","./mybase.jsste"]
}

View File

@ -1,3 +0,0 @@
{
"js$Date": "return Date.now();"
}

View File

@ -1,4 +0,0 @@
{
"a":"Ameise",
"_IMPORTS_":["./c.jsste","./b.jsste"]
}

View File

@ -1,4 +0,0 @@
{
"b":"braunbär",
"_IMPORTS_":["./d.jsste","./e.jsste"]
}

View File

@ -1,4 +0,0 @@
{
"c":"cobra",
"_IMPORTS_":["./f.jsste","./g.jsste"]
}

View File

@ -1,3 +0,0 @@
{
"d":"delfin"
}

View File

@ -1,3 +0,0 @@
{
"e":"esel"
}

View File

@ -1,3 +0,0 @@
{
"f":"fau"
}

View File

@ -1,3 +0,0 @@
{
"g":"giraffe"
}

View File

@ -1,4 +0,0 @@
{
"_TEMPLATE_": "example",
"_IMPORTS_":["./a.jsste","lib/base.jsste"]
}

View File

@ -1,3 +0,0 @@
* {
color: green;
}

View File

@ -1,36 +0,0 @@
<html>
<head>
<title>Template Example</title>
</head>
<body>
<ul>
<li>
<p>timestemp: <[js$Date]></p>
</li>
<li>
<p>path: <[_SELFPATH_]></p>
</li>
<li>
<p>a: <[a]></p>
</li>
<li>
<p>b: <[b]></p>
</li>
<li>
<p>c: <[c]></p>
</li>
<li>
<p>d: <[d]></p>
</li>
<li>
<p>e: <[e]></p>
</li>
<li>
<p>f: <[f]></p>
</li>
<li>
<p>g: <[g]></p>
</li>
</ul>
</body>
</html>

View File

@ -1,23 +0,0 @@
<!--example html-->
<!--<[:startpage:]>-->
<html>
<head>
<title>Template Example</title>
</head>
<body>
<h1><[a]></h1>
<p><[c]></p>
<p><[b]></p>
<p><[js$Date]></p>
<p><[js$TimeStemp]></p>
<p> root: <[root]></p>
<p><[Base_Date]></p>
<p>Kommentar: <[//]></p>
<script>
let c = "<[c]>";
console.log(c);
</script>
</body>
</html>

View File

@ -1,9 +0,0 @@
<html>
<head>
<title><[Title]></title>
</head>
<body>
<[js$Date]>
</body>
</html>

View File

@ -1,12 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
StartSeite
</body>
</html>

7249
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,8 @@
],
"scripts": {
"test": "mocha ./test/test.test.js",
"publish": "npm publish --access publish"
"publish": "npm publish --access publish",
"compile": "tsc"
},
"repository": {
"type": "git",
@ -31,7 +32,8 @@
},
"homepage": "https://github.com/lucaspalomodevelop/JSSTE#readme",
"dependencies": {
"typechecker": "^7.18.0"
"typechecker": "^7.18.0",
"yarn": "^1.22.19"
},
"engines": {
"node": ">= 0.10.0"
@ -40,7 +42,11 @@
"assert": "^2.0.0",
"chai": "^4.3.4",
"express": "^4.17.1",
"gulp": "^4.0.2",
"gulp-minify": "^3.1.0",
"gulp-typescript": "^6.0.0-alpha.1",
"mocha": "^8.4.0",
"typescript": "^4.5.4",
"urldecode": "^1.0.1"
}
}

View File

@ -14,6 +14,18 @@ config.getConfig = function () {
return configvar;
};
config.setConfig = function ({
templatePath,
pagePath,
assetsPath,
stylesheets,
}) {
configvar.templatePath = templatePath;
configvar.pagePath = pagePath;
configvar.assetsPath = assetsPath;
configvar.stylesheets = stylesheets;
};
config.set = function (key, value) {
configvar[key] = value;
};

2180
yarn.lock

File diff suppressed because it is too large Load Diff