Stuff
parent
7c8a9c179f
commit
d4bc9920b9
|
@ -5,11 +5,9 @@ console.log(
|
||||||
// License: GPLv3 (if not noted otherwise) //
|
// License: GPLv3 (if not noted otherwise) //
|
||||||
// ------------------------------------------ //`)
|
// ------------------------------------------ //`)
|
||||||
|
|
||||||
// static theme for testing
|
|
||||||
new themes( "light" )
|
|
||||||
|
|
||||||
// get newest 10 blog articles from api
|
// 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" )
|
if ( json.type != "s" )
|
||||||
return false
|
return false
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -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()
|
||||||
|
})
|
|
@ -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":
|
sharemenu = new metaentry(undefined,"Share",".content",{"content":
|
||||||
`Don't know why you would, but here you can find me elsewhere on the Net:<br \\>
|
`Don't know why you would, but here you can find me elsewhere on the Net:<br \\>
|
||||||
<a href="https://github.com/derzombiiie"><img class="socialicon" src="/static//icon/github.png" \\></a>
|
<a href="https://github.com/derzombiiie"><img class="socialicon" src="/static//icon/github.png" \\></a>
|
||||||
<small>(yea thats it)</small><br \\><br \\>
|
<small>(yea thats it)</small><br \\><br \\>
|
||||||
oh yea the title of this box: go share my page:
|
oh yea the title of this box: go share my page:
|
||||||
<a class="share" href="mailto:?subject=DerZombiiies%20totally%20cool%20website!&body=Hi%2C%0AI%20just%20found%20this%20on%20the%20interwebz%3A%20derzombiiie.com">Email</a>,
|
<a class="share" href="mailto:?subject=DerZombiiies%20totally%20cool%20website!&body=Hi%2C%0AI%20just%20found%20this%20on%20the%20interwebz%3A%20${shareurl}">Email</a>,
|
||||||
<a class="share" href="whatsapp://send?text=Hi%2C%0AI%20just%20found%20this%20on%20the%20interwebz%3A%20derzombiiie.com">WhatsApp</a>,
|
<a class="share" href="whatsapp://send?text=Hi%2C%0AI%20just%20found%20this%20on%20the%20interwebz%3A%20${shareurl}">WhatsApp</a>,
|
||||||
<a class="share" href="https://twitter.com/intent/tweet?text==Check%20derzombiiies%20website!%0A%40%20derzombiiie.com">Twitter</a>,
|
<a class="share" href="https://twitter.com/intent/tweet?text==Check%20derzombiiies%20website!%0A%40%20${shareurl}">Twitter</a>,
|
||||||
Copy: <input value="derzombiiie.com" \\>`
|
Copy: <input value="${shareurl}" \\>`
|
||||||
})
|
})
|
||||||
})
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,4 +15,7 @@ class themes {
|
||||||
.html(css).appendTo("head")
|
.html(css).appendTo("head")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static until cookie model implemented / user / idk preferences
|
||||||
|
new themes("light")
|
||||||
|
|
|
@ -1,16 +1,29 @@
|
||||||
{
|
<!DOCTYPE html>
|
||||||
"title":"My second Post",
|
<html lang="en">
|
||||||
"author":"derzombiiie",
|
|
||||||
"desc":"Lorem ipsum dolor sit.",
|
<head>
|
||||||
"href":"#",
|
<meta charset="UTF-8">
|
||||||
"tags":[
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
"testing",
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
"$$$"
|
<title>derzombiiie.com - home</title>
|
||||||
],
|
<link rel="stylesheet" href="/static/style/fonts.css">
|
||||||
"rating":{
|
<link rel="stylesheet" href="/static/style/main.css">
|
||||||
"+":10000,
|
<script src="/static/js/jq.js"></script>
|
||||||
"-":-10
|
<script>
|
||||||
}
|
postDATA = //<!--POST-DATA-INJECT-->//
|
||||||
"create":1628198909950
|
</script>
|
||||||
"id":1
|
<script src="/static/js/themes.js"></script>
|
||||||
}
|
<script src="/static/js/menubar.js"></script>
|
||||||
|
<script src="/static/js/entry.js"></script>
|
||||||
|
<script src="/static/js/share.js"></script>
|
||||||
|
<script src="/static/js/posts.js"></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="menubox"></div>
|
||||||
|
|
||||||
|
<div class="content">
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
10
node/app.js
10
node/app.js
|
@ -15,8 +15,6 @@ app.use("/static", express.static("html"))
|
||||||
|
|
||||||
// console commands:
|
// console commands:
|
||||||
con.registercmd( "stop", () => shutdown() )
|
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( "appeval", (arg) => {try {console.log(eval(arg.join(" ")))} catch {console.log("Couldn't execute!")}})
|
||||||
|
|
||||||
con.registercmd( "post", (arg => {
|
con.registercmd( "post", (arg => {
|
||||||
|
@ -83,17 +81,17 @@ posts.rank()
|
||||||
// posts:
|
// posts:
|
||||||
app.get("/posts", (req, res) => {
|
app.get("/posts", (req, res) => {
|
||||||
if( typeof( req.query.api ) != "undefined" ) {
|
if( typeof( req.query.api ) != "undefined" ) {
|
||||||
res.type( "application/json" )
|
res.type( "application/json" )
|
||||||
if( ! ( req.query.len < 50 ) ) {
|
if( ! ( req.query.len < 50 ) ) {
|
||||||
res.status( 400 )
|
res.status( 400 )
|
||||||
res.end( JSON.stringify({"type":"err","text":"no len or to high specified"}) )
|
res.end( JSON.stringify({"type":"err","text":"no len or to high specified"}) )
|
||||||
} else {
|
} else {
|
||||||
res.status( 200 )
|
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 {
|
} else {
|
||||||
res.status( 400 )
|
res.status( 200 )
|
||||||
res.end("Why you trying this?")
|
filestuff.readFSr(req, res, "html/posts/index.html", "text/html", "//<!--POST-DATA-INJECT-->//", JSON.stringify(postsDB.get(req.query.post)))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,8 @@ module.exports.eval = ( cmd ) => {
|
||||||
split.shift()
|
split.shift()
|
||||||
let args = split
|
let args = split
|
||||||
|
|
||||||
|
if (! comm ) return // if cmd empty dont do anything
|
||||||
|
|
||||||
if ( module.exports.registerdcmds[comm] ) {
|
if ( module.exports.registerdcmds[comm] ) {
|
||||||
module.exports.registerdcmds[comm](args, prefix)
|
module.exports.registerdcmds[comm](args, prefix)
|
||||||
} else {
|
} else {
|
||||||
|
@ -50,4 +52,3 @@ this.registerdcmds["exit"] = () => {
|
||||||
this.registerdcmds["clear"] = () => {
|
this.registerdcmds["clear"] = () => {
|
||||||
console.log('\033[2J')
|
console.log('\033[2J')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,10 +15,21 @@ module.exports.readFS = (req, res, file, type) => {
|
||||||
fs.readFile(file, "utf8", (err, data) => {
|
fs.readFile(file, "utf8", (err, data) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
res.status(500)
|
res.status(500)
|
||||||
res.end("index not found!")
|
res.end("not found!")
|
||||||
} else {
|
} else {
|
||||||
res.type(type ? type : file)
|
res.type(type ? type : file)
|
||||||
res.end(data)
|
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))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
|
@ -4,7 +4,8 @@ this.init = (db) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.ranking = { "hot":[-1], "new":[-1] }
|
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) => {
|
this.rank = (c) => {
|
||||||
if (!c) {
|
if (!c) {
|
||||||
// read * from db to work on
|
// read * from db to work on
|
||||||
|
@ -74,9 +75,24 @@ this.rank = (c) => {
|
||||||
|
|
||||||
this.read = (count, sort) => {
|
this.read = (count, sort) => {
|
||||||
let ret = []
|
let ret = []
|
||||||
for ( let i = 0 ; i < count ; i++ ) {
|
debugger
|
||||||
if ( this.db.get( String(i) ) )
|
switch (sort) {
|
||||||
ret.push( this.db.get( String( i ) ) )
|
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
|
return ret
|
||||||
}
|
}
|
|
@ -23,15 +23,32 @@
|
||||||
"tags": [
|
"tags": [
|
||||||
"testing",
|
"testing",
|
||||||
"$$$"
|
"$$$"
|
||||||
],
|
],
|
||||||
"dummy": {
|
"dummy": {
|
||||||
"1": 2
|
"1": 2
|
||||||
},
|
},
|
||||||
"rating": {
|
"rating": {
|
||||||
"+": 999,
|
"+": 999,
|
||||||
"-": 0
|
"-": 0
|
||||||
},
|
},
|
||||||
"create": 2,
|
"create": 2,
|
||||||
"id": 1
|
"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
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue