diff --git a/html/js/index.js b/html/js/index.js
index 3ddf713..280c55a 100644
--- a/html/js/index.js
+++ b/html/js/index.js
@@ -5,11 +5,9 @@ console.log(
// License: GPLv3 (if not noted otherwise) //
// ------------------------------------------ //`)
-// static theme for testing
-new themes( "light" )
-
// get newest 10 blog articles from api
-$.get("/posts?api&featured&len=10", json => {
+$.get("/posts?api&hot&len=10", json => {
+ displayshare()
if ( json.type != "s" )
return false
else {
diff --git a/html/js/posts.js b/html/js/posts.js
new file mode 100644
index 0000000..477d153
--- /dev/null
+++ b/html/js/posts.js
@@ -0,0 +1,7 @@
+// post displayer:
+$(document).ready(() => {
+console.log(1)
+ content = new entry(postDATA.title, postDATA.author, postDATA.desc, postDATA.href, postDATA.tags, postDATA.id, postDATA.create)
+ content.appendto(".content")
+ displayshare()
+})
diff --git a/html/js/share.js b/html/js/share.js
index d846f90..4f66d26 100644
--- a/html/js/share.js
+++ b/html/js/share.js
@@ -1,13 +1,15 @@
-$(document).ready(() => {
+// generate sharelink:
+let shareurl = encodeURI(this.location.toString().split("//")[1])
+
+function displayshare() {
sharemenu = new metaentry(undefined,"Share",".content",{"content":
`Don't know why you would, but here you can find me elsewhere on the Net:
(yea thats it)
oh yea the title of this box: go share my page:
-Email,
-WhatsApp,
-Twitter,
-Copy: `
+Email,
+WhatsApp,
+Twitter,
+Copy: `
})
-})
-
+}
diff --git a/html/js/themes.js b/html/js/themes.js
index 0277c10..c7d3236 100644
--- a/html/js/themes.js
+++ b/html/js/themes.js
@@ -15,4 +15,7 @@ class themes {
.html(css).appendTo("head")
})
}
-}
\ No newline at end of file
+}
+
+// static until cookie model implemented / user / idk preferences
+new themes("light")
diff --git a/html/posts/index.html b/html/posts/index.html
index 73a6807..7a8882a 100644
--- a/html/posts/index.html
+++ b/html/posts/index.html
@@ -1,16 +1,29 @@
-{
- "title":"My second Post",
- "author":"derzombiiie",
- "desc":"Lorem ipsum dolor sit.",
- "href":"#",
- "tags":[
- "testing",
- "$$$"
- ],
- "rating":{
- "+":10000,
- "-":-10
- }
- "create":1628198909950
- "id":1
-}
\ No newline at end of file
+
+
+
+
+
+
+
+ derzombiiie.com - home
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/log.txt b/log.txt
index 6d52c0b..258c09a 100644
--- a/log.txt
+++ b/log.txt
@@ -1 +1 @@
-2021/08/05 18:43:02 Micro started
+2021/08/06 15:48:27 Micro started
diff --git a/node/app.js b/node/app.js
index 8871444..ed94708 100644
--- a/node/app.js
+++ b/node/app.js
@@ -15,8 +15,6 @@ app.use("/static", express.static("html"))
// console commands:
con.registercmd( "stop", () => shutdown() )
-con.registercmd( "getpost", (arg) => console.log(postsDB.get(arg[0])) )
-con.registercmd( "getpostranking", (arg) => console.log(posts.ranking[arg[0]]))
con.registercmd( "appeval", (arg) => {try {console.log(eval(arg.join(" ")))} catch {console.log("Couldn't execute!")}})
con.registercmd( "post", (arg => {
@@ -83,17 +81,17 @@ posts.rank()
// posts:
app.get("/posts", (req, res) => {
if( typeof( req.query.api ) != "undefined" ) {
- res.type( "application/json" )
+ res.type( "application/json" )
if( ! ( req.query.len < 50 ) ) {
res.status( 400 )
res.end( JSON.stringify({"type":"err","text":"no len or to high specified"}) )
} else {
res.status( 200 )
- res.send(`{"type":"s","content":${JSON.stringify(posts.read(10, "featured"))}}`)
+ res.send(`{"type":"s","content":${JSON.stringify(posts.read(10, "hot"))}}`)
}
} else {
- res.status( 400 )
- res.end("Why you trying this?")
+ res.status( 200 )
+ filestuff.readFSr(req, res, "html/posts/index.html", "text/html", "////", JSON.stringify(postsDB.get(req.query.post)))
}
})
diff --git a/node/console.js b/node/console.js
index dd25b94..dcab5a4 100644
--- a/node/console.js
+++ b/node/console.js
@@ -22,6 +22,8 @@ module.exports.eval = ( cmd ) => {
split.shift()
let args = split
+ if (! comm ) return // if cmd empty dont do anything
+
if ( module.exports.registerdcmds[comm] ) {
module.exports.registerdcmds[comm](args, prefix)
} else {
@@ -50,4 +52,3 @@ this.registerdcmds["exit"] = () => {
this.registerdcmds["clear"] = () => {
console.log('\033[2J')
}
-
diff --git a/node/filestuff.js b/node/filestuff.js
index 4cb6e19..43904c4 100644
--- a/node/filestuff.js
+++ b/node/filestuff.js
@@ -15,10 +15,21 @@ module.exports.readFS = (req, res, file, type) => {
fs.readFile(file, "utf8", (err, data) => {
if (err) {
res.status(500)
- res.end("index not found!")
+ res.end("not found!")
} else {
res.type(type ? type : file)
res.end(data)
}
})
}
+module.exports.readFSr = (req, res, file, type, search, replace) => {
+ fs.readFile(file, "utf8", (err, data) => {
+ if (err) {
+ res.status(500)
+ res.end("not found!")
+ } else {
+ res.type(type ? type : file)
+ res.end(data.replace(search, replace))
+ }
+ })
+}
\ No newline at end of file
diff --git a/node/posts.js b/node/posts.js
index e5ab45b..359d393 100644
--- a/node/posts.js
+++ b/node/posts.js
@@ -4,7 +4,8 @@ this.init = (db) => {
}
this.ranking = { "hot":[-1], "new":[-1] }
-// generating "hot" articles etc. (should run 1 / 0:30h and at startup + on new article)
+
+// generating "hot" + "new" articles etc. (should run 1 / 0:30h and at startup + on new article)
this.rank = (c) => {
if (!c) {
// read * from db to work on
@@ -74,9 +75,24 @@ this.rank = (c) => {
this.read = (count, sort) => {
let ret = []
- for ( let i = 0 ; i < count ; i++ ) {
- if ( this.db.get( String(i) ) )
- ret.push( this.db.get( String( i ) ) )
+ debugger
+ switch (sort) {
+ case "hot":
+ this.ranking.hot.length
+ for ( let i = 0 ; i < count ; i++ ) {
+ if ( typeof( this.ranking.hot[i] ) == "number" ) {
+ ret.push( this.db.get( this.ranking.hot[i] ) )
+ }
+ }
+
+ break
+
+ default:
+ for ( let i = 0 ; i < count ; i++ ) {
+ if ( this.db.get( i ) )
+ ret.push( this.db.get( i ) )
+ }
+ break
}
return ret
}
\ No newline at end of file
diff --git a/storage/posts.json b/storage/posts.json
index b905cee..4e5dc1a 100644
--- a/storage/posts.json
+++ b/storage/posts.json
@@ -23,15 +23,32 @@
"tags": [
"testing",
"$$$"
- ],
- "dummy": {
- "1": 2
- },
- "rating": {
+ ],
+ "dummy": {
+ "1": 2
+ },
+ "rating": {
"+": 999,
- "-": 0
- },
- "create": 2,
- "id": 1
- }
+ "-": 0
+ },
+ "create": 2,
+ "id": 1
+ },
+ "2": {
+ "title": "Warum sind k.rum und was ist k.?",
+ "author": "olli",
+ "desc": "Warum nicht! hier text Lorem ipsum dolor sit!",
+ "href": "#",
+ "tags": [
+ "karotte",
+ "dumm",
+ "garten"
+ ],
+ "rating": {
+ "+": 395,
+ "-": 14
+ },
+ "create": 1628252855774,
+ "id": 2
+ }
}
\ No newline at end of file