Stuff
parent
7c8a9c179f
commit
d4bc9920b9
|
@ -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 {
|
||||
|
|
|
@ -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":
|
||||
`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>
|
||||
<small>(yea thats it)</small><br \\><br \\>
|
||||
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="whatsapp://send?text=Hi%2C%0AI%20just%20found%20this%20on%20the%20interwebz%3A%20derzombiiie.com">WhatsApp</a>,
|
||||
<a class="share" href="https://twitter.com/intent/tweet?text==Check%20derzombiiies%20website!%0A%40%20derzombiiie.com">Twitter</a>,
|
||||
Copy: <input value="derzombiiie.com" \\>`
|
||||
<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%20${shareurl}">WhatsApp</a>,
|
||||
<a class="share" href="https://twitter.com/intent/tweet?text==Check%20derzombiiies%20website!%0A%40%20${shareurl}">Twitter</a>,
|
||||
Copy: <input value="${shareurl}" \\>`
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
|
|
|
@ -15,4 +15,7 @@ class themes {
|
|||
.html(css).appendTo("head")
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// static until cookie model implemented / user / idk preferences
|
||||
new themes("light")
|
||||
|
|
|
@ -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
|
||||
}
|
||||
<!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>derzombiiie.com - home</title>
|
||||
<link rel="stylesheet" href="/static/style/fonts.css">
|
||||
<link rel="stylesheet" href="/static/style/main.css">
|
||||
<script src="/static/js/jq.js"></script>
|
||||
<script>
|
||||
postDATA = //<!--POST-DATA-INJECT-->//
|
||||
</script>
|
||||
<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:
|
||||
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", "//<!--POST-DATA-INJECT-->//", JSON.stringify(postsDB.get(req.query.post)))
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
@ -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')
|
||||
}
|
||||
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
})
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue