did some stuff
idk all of it though lol + made search function disablable + disableing of it disables "search" command / "/search" handler (NOT posts.search() func) + fixed enubar styling in firefox + added "FE!" force exit commend to console.js + made "exit" cmd behave like "stop" - some other stuff i forgot cuz i got distracted --- this is done ~90% safe about that, lolmaster
parent
71be53cd5e
commit
1e96a62fc9
|
@ -1 +1 @@
|
|||
passhash: zbTuKuppzGqDMxu+ltwsqpopnSEynvsDNvwCqC4YOag=
|
||||
passhash: JAvlGPq9JyTdtvBO6x2llnRI1+gxwIyPqCKAn3THIKk=
|
||||
|
|
|
@ -24,7 +24,7 @@ cl: true # enable / disable interactive-ish shell
|
|||
# content config:
|
||||
site_name: "blog.derzombiiie.com"
|
||||
|
||||
search_enable: true # enable / disable search WIP
|
||||
search_enable: true # enable / disable search
|
||||
|
||||
commenting_enabled: true # enable / disable ability to comment bellow articles
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ function post() {
|
|||
|
||||
if( prompt( "To proceed posting please type: " + check ) != check ) {
|
||||
alert( "wrong!" )
|
||||
return
|
||||
//return
|
||||
}
|
||||
|
||||
// push post
|
||||
|
|
|
@ -31,7 +31,11 @@ class entry {
|
|||
// create taglist
|
||||
let tags = ""
|
||||
for ( let i = 0 ; i < this.tags.length ; i++ ) {
|
||||
tags += `<span class="tag"><a href="/search?tag=${this.tags[i]}">${this.tags[i]}</a></span>`
|
||||
let encoded = this.tags[i].replace(/[\u00A0-\u9999<>\&]/g, function(i) {
|
||||
return '&#'+i.charCodeAt(0)+';';
|
||||
});
|
||||
|
||||
tags += `<span class="tag tag-content-${encoded}"><a href="/search?tag=${this.tags[i]}">${this.tags[i]}</a></span>`
|
||||
}
|
||||
|
||||
let element = document.createElement("DIV");
|
||||
|
|
|
@ -11,8 +11,8 @@ $.get(`/posts?api&${conf.index_post_sort}&len=10&page=${index}`, json => {
|
|||
if ( json.type != "s" )
|
||||
return alert( json.text )
|
||||
else {
|
||||
rawelements = json
|
||||
elements = []
|
||||
console.log(json)
|
||||
for( let i = 0 ; i < json.content.length ; i++ ) {
|
||||
let elem = new entry(json.content[i].title, json.content[i].author, json.content[i].desc, json.content[i].href, json.content[i].tags, json.content[i].id, json.content[i].rating)
|
||||
elements.push(elem)
|
||||
|
|
|
@ -4,10 +4,12 @@ $(document).ready(() => {
|
|||
// generate shorted description:
|
||||
let desc = ""
|
||||
let d = searchDATA.sd[i].desc.split(" ")
|
||||
let a = "..."
|
||||
for( let i = 0 ; i < 10 ; i ++ ) {
|
||||
desc += d[i] ? d[i] + " " : ""
|
||||
a = d[i] ? a : ""
|
||||
}
|
||||
desc += "..."
|
||||
desc += a
|
||||
|
||||
results.push( new entry( searchDATA.sd[i].title, searchDATA.sd[i].author, desc, "", searchDATA.sd[i].tags, searchDATA.sd[i].id, searchDATA.sd[i].rating ) )
|
||||
results[results.length-1].appendto(".content")
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
<!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 src="/config.js"></script>
|
||||
<script>
|
||||
const searchDATA = ""//<!--SEARCH-DATA-INJECT-->//
|
||||
</script>
|
||||
<script src="/static/js/themes.js"></script>
|
||||
<script src="/static/js/menubar.js"></script>
|
||||
<script src="/static/js/footer.js"></script>
|
||||
<script src="/static/js/entry.js"></script>
|
||||
<script src="/static/js/share.js"></script>
|
||||
<script src="/static/js/search.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="menubox"></div>
|
||||
|
||||
<div class="content">
|
||||
<div class="entrybox">
|
||||
<div class="entry metaentry">
|
||||
<div class="title">search</div>
|
||||
<div class="subtitle search"></div>
|
||||
<hr class="seperator">
|
||||
<div class="preview">
|
||||
search is disabled at the moment<br>
|
||||
sorry!
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="footer"></div>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -60,6 +60,22 @@ body, html {
|
|||
.menubox > .menubar > .spacer {
|
||||
width: 0.5em;
|
||||
}
|
||||
@-moz-document url-prefix() {
|
||||
.menubox > .menubar > *:not(.spacer) {
|
||||
padding: 0.05em;
|
||||
padding-top: 0.1px;
|
||||
margin-top: 0px;
|
||||
top: 0px;
|
||||
}
|
||||
.menubox > .menubar > .input > input {
|
||||
height: 1.2em;
|
||||
top: -1em;
|
||||
}
|
||||
.menubox > .menubar > .input > img {
|
||||
height: 1.2em;
|
||||
top: -0.05em;
|
||||
}
|
||||
}
|
||||
|
||||
/* content */
|
||||
.content {
|
||||
|
|
99
logs/log.log
99
logs/log.log
|
@ -1655,3 +1655,102 @@ err, crashed!"
|
|||
1629715792558 | Reading comments from post "2", with length: undefined
|
||||
1629715809795 | Reading post 2
|
||||
1629715810285 | Reading comments from post "2", with length: undefined
|
||||
--- SEPERATOR ---
|
||||
1629716194735 | Dumping config:
|
||||
1629716194741 | {"debug":false,"logging":1337,"logfile":"logs/log.log","ipget_endpoint_set":"//derzombiiie.com/getip.php?settoken=${TOKEN}","ipget_endpoint_get":"//derzombiiie.com/getip.php?token=${TOKEN}","cl":true,"site_name":"blog.derzombiiie.com","search_enable":true,"commenting_enabled":true,"post_ranking_auto":43200,"index_post_sort":"new","comment_sync_on_write":false,"comment_auto_sync":360}
|
||||
1629719516642 | Reading posts sorted by "new" with a length of 10
|
||||
--- SEPERATOR ---
|
||||
1629719529909 | Dumping config:
|
||||
1629719529915 | {"debug":false,"logging":1337,"logfile":"logs/log.log","ipget_endpoint_set":"//derzombiiie.com/getip.php?settoken=${TOKEN}","ipget_endpoint_get":"//derzombiiie.com/getip.php?token=${TOKEN}","cl":true,"site_name":"blog.derzombiiie.com","search_enable":true,"commenting_enabled":true,"post_ranking_auto":43200,"index_post_sort":"new","comment_sync_on_write":false,"comment_auto_sync":360}
|
||||
1629719532203 | Reading posts sorted by "new" with a length of 10
|
||||
--- SEPERATOR ---
|
||||
--- SEPERATOR ---
|
||||
1629719694625 | Dumping config:
|
||||
1629719694630 | {"debug":false,"logging":1337,"logfile":"logs/log.log","ipget_endpoint_set":"//derzombiiie.com/getip.php?settoken=${TOKEN}","ipget_endpoint_get":"//derzombiiie.com/getip.php?token=${TOKEN}","cl":true,"site_name":"blog.derzombiiie.com","search_enable":true,"commenting_enabled":true,"post_ranking_auto":43200,"index_post_sort":"new","comment_sync_on_write":false,"comment_auto_sync":360}
|
||||
1629719737266 | Reading posts sorted by "new" with a length of 10
|
||||
--- SEPERATOR ---
|
||||
--- SEPERATOR ---
|
||||
1629719999994 | Dumping config:
|
||||
1629720000000 | {"debug":false,"logging":1337,"logfile":"logs/log.log","ipget_endpoint_set":"//derzombiiie.com/getip.php?settoken=${TOKEN}","ipget_endpoint_get":"//derzombiiie.com/getip.php?token=${TOKEN}","cl":true,"site_name":"blog.derzombiiie.com","search_enable":true,"commenting_enabled":true,"post_ranking_auto":43200,"index_post_sort":"new","comment_sync_on_write":false,"comment_auto_sync":360}
|
||||
1629720057137 | Trying to set post "undefined", as name "me try 2 other creator"
|
||||
1629720057138 | Contents: {"author":"Author","content":"# Your post (NO HEADLINE HERE)","create":1629720057137,"desc":"This is a post about *","id":-1,"rating":{"+":0,"-":0},"tags":["tag1","othertag1","$$$$"],"title":"me try 2 other creator"}
|
||||
1629720067537 | Trying to set post "undefined", as name "me try 2 other creator"
|
||||
--- SEPERATOR ---
|
||||
1629720154609 | Dumping config:
|
||||
1629720154615 | {"debug":false,"logging":1337,"logfile":"logs/log.log","ipget_endpoint_set":"//derzombiiie.com/getip.php?settoken=${TOKEN}","ipget_endpoint_get":"//derzombiiie.com/getip.php?token=${TOKEN}","cl":true,"site_name":"blog.derzombiiie.com","search_enable":true,"commenting_enabled":true,"post_ranking_auto":43200,"index_post_sort":"new","comment_sync_on_write":false,"comment_auto_sync":360}
|
||||
1629720164614 | Reading posts sorted by "new" with a length of 10
|
||||
1629720217216 | Reading posts sorted by "new" with a length of 10
|
||||
1629720339874 | Reading posts sorted by "new" with a length of 10
|
||||
--- SEPERATOR ---
|
||||
1629720429702 | Dumping config:
|
||||
1629720429708 | {"debug":false,"logging":1337,"logfile":"logs/log.log","ipget_endpoint_set":"//derzombiiie.com/getip.php?settoken=${TOKEN}","ipget_endpoint_get":"//derzombiiie.com/getip.php?token=${TOKEN}","cl":true,"site_name":"blog.derzombiiie.com","search_enable":true,"commenting_enabled":true,"post_ranking_auto":43200,"index_post_sort":"new","comment_sync_on_write":false,"comment_auto_sync":360}
|
||||
1629720431298 | Reading posts sorted by "new" with a length of 10
|
||||
--- SEPERATOR ---
|
||||
1629720500917 | Dumping config:
|
||||
1629720500922 | {"debug":false,"logging":1337,"logfile":"logs/log.log","ipget_endpoint_set":"//derzombiiie.com/getip.php?settoken=${TOKEN}","ipget_endpoint_get":"//derzombiiie.com/getip.php?token=${TOKEN}","cl":true,"site_name":"blog.derzombiiie.com","search_enable":true,"commenting_enabled":true,"post_ranking_auto":43200,"index_post_sort":"new","comment_sync_on_write":false,"comment_auto_sync":360}
|
||||
1629720502303 | Reading posts sorted by "new" with a length of 10
|
||||
--- SEPERATOR ---
|
||||
--- SEPERATOR ---
|
||||
--- SEPERATOR ---
|
||||
1629721158710 | Dumping config:
|
||||
1629721158716 | {"debug":false,"logging":1337,"logfile":"logs/log.log","ipget_endpoint_set":"//derzombiiie.com/getip.php?settoken=${TOKEN}","ipget_endpoint_get":"//derzombiiie.com/getip.php?token=${TOKEN}","cl":true,"site_name":"blog.derzombiiie.com","search_enable":true,"commenting_enabled":true,"post_ranking_auto":43200,"index_post_sort":"new","comment_sync_on_write":false,"comment_auto_sync":360}
|
||||
1629721251036 | Reading posts sorted by "new" with a length of 10
|
||||
1629721254624 | Reading posts sorted by "new" with a length of 10
|
||||
1629721910423 | Reading posts sorted by "new" with a length of 10
|
||||
1629724829613 | Reading posts sorted by "new" with a length of 10
|
||||
1629727628418 | Trying to set post "undefined", as name "0das hier ist einz title"
|
||||
1629727628419 | Contents: {"author":"author","content":"# Your post (NO HEADLINE HERE)\nyou post ","create":1629727628418,"desc":"desc","id":-1,"rating":{"+":0,"-":0},"tags":["tag0","othertag","$$$"],"title":"0das hier ist einz title"}
|
||||
1629727632131 | Trying to set post "preview", as name "1das hier ist einz title"
|
||||
1629727632132 | Contents: {"author":"author","content":"# Your post (NO HEADLINE HERE)\nyou post ","create":1629727632131,"desc":"desc","id":-1,"rating":{"+":0,"-":0},"tags":["tag0","othertag","$$$"],"title":"1das hier ist einz title"}
|
||||
1629727635585 | Trying to set post "preview", as name "1das hier ist einz title"
|
||||
1629727635587 | Contents: {"author":"author","content":"# Your post (NO HEADLINE HERE)\nyou post ","create":1629727635585,"desc":"desc","id":-1,"rating":{"+":0,"-":0},"tags":["tag0","othertag","$$$"],"title":"1das hier ist einz title"}
|
||||
1629727638519 | Trying to set post "preview", as name "2das hier ist einz title"
|
||||
1629727638520 | Contents: {"author":"author","content":"# Your post (NO HEADLINE HERE)\nyou post ","create":1629727638519,"desc":"desc","id":-1,"rating":{"+":0,"-":0},"tags":["tag0","othertag","$$$"],"title":"2das hier ist einz title"}
|
||||
1629727642467 | Trying to set post "undefined", as name "2das hier ist einz title"
|
||||
1629727642468 | Contents: {"author":"author","content":"# Your post (NO HEADLINE HERE)\nyou post ","create":1629727642467,"desc":"desc","id":-1,"rating":{"+":0,"-":0},"tags":["tag0","othertag","$$$"],"title":"2das hier ist einz title"}
|
||||
1629727647823 | Trying to set post "undefined", as name "3das hier ist einz title"
|
||||
1629727647825 | Contents: {"author":"author","content":"# Your post (NO HEADLINE HERE)\nyou post ","create":1629727647823,"desc":"desc","id":-1,"rating":{"+":0,"-":0},"tags":["tag0","othertag","$$$"],"title":"3das hier ist einz title"}
|
||||
1629727650534 | Trying to set post "preview", as name "4das hier ist einz title"
|
||||
1629727650536 | Contents: {"author":"author","content":"# Your post (NO HEADLINE HERE)\nyou post ","create":1629727650534,"desc":"desc","id":-1,"rating":{"+":0,"-":0},"tags":["tag0","othertag","$$$"],"title":"4das hier ist einz title"}
|
||||
1629727652358 | Trying to set post "undefined", as name "4das hier ist einz title"
|
||||
1629727652360 | Contents: {"author":"author","content":"# Your post (NO HEADLINE HERE)\nyou post ","create":1629727652358,"desc":"desc","id":-1,"rating":{"+":0,"-":0},"tags":["tag0","othertag","$$$"],"title":"4das hier ist einz title"}
|
||||
1629727676048 | Trying to set post "undefined", as name "5das hier ist einz title"
|
||||
1629727676049 | Contents: {"author":"author","content":"# Your post (NO HEADLINE HERE)\nyou post ","create":1629727676048,"desc":"desc","id":-1,"rating":{"+":0,"-":0},"tags":["tag0","othertag","$$$"],"title":"5das hier ist einz title"}
|
||||
1629727681549 | Trying to set post "undefined", as name "6das hier ist einz title"
|
||||
1629727681550 | Contents: {"author":"author","content":"# Your post (NO HEADLINE HERE)\nyou post ","create":1629727681549,"desc":"desc","id":-1,"rating":{"+":0,"-":0},"tags":["tag0","othertag","$$$"],"title":"6das hier ist einz title"}
|
||||
1629727686171 | Trying to set post "undefined", as name "7das hier ist einz title"
|
||||
1629727686172 | Contents: {"author":"author","content":"# Your post (NO HEADLINE HERE)\nyou post ","create":1629727686171,"desc":"desc","id":-1,"rating":{"+":0,"-":0},"tags":["tag0","othertag","$$$"],"title":"7das hier ist einz title"}
|
||||
1629727689858 | Trying to set post "preview", as name "8das hier ist einz title"
|
||||
1629727689859 | Contents: {"author":"author","content":"# Your post (NO HEADLINE HERE)\nyou post ","create":1629727689858,"desc":"desc","id":-1,"rating":{"+":0,"-":0},"tags":["tag0","othertag","$$$"],"title":"8das hier ist einz title"}
|
||||
1629727692876 | Trying to set post "undefined", as name "8das hier ist einz title"
|
||||
1629727692877 | Contents: {"author":"author","content":"# Your post (NO HEADLINE HERE)\nyou post ","create":1629727692876,"desc":"desc","id":-1,"rating":{"+":0,"-":0},"tags":["tag0","othertag","$$$"],"title":"8das hier ist einz title"}
|
||||
1629727698662 | Trying to set post "undefined", as name "9das hier ist einz title"
|
||||
1629727698663 | Contents: {"author":"author","content":"# Your post (NO HEADLINE HERE)\nyou post ","create":1629727698662,"desc":"desc","id":-1,"rating":{"+":0,"-":0},"tags":["tag0","othertag","$$$"],"title":"9das hier ist einz title"}
|
||||
1629727706950 | Trying to set post "undefined", as name "10das hier ist einz title"
|
||||
1629727706951 | Contents: {"author":"author","content":"# Your post (NO HEADLINE HERE)\nyou post ","create":1629727706950,"desc":"desc","id":-1,"rating":{"+":0,"-":0},"tags":["tag0","othertag","$$$"],"title":"10das hier ist einz title"}
|
||||
1629727717296 | Trying to set post "undefined", as name "11das hier ist einz title"
|
||||
1629727717297 | Contents: {"author":"author","content":"# Your post (NO HEADLINE HERE)\nyou post ","create":1629727717296,"desc":"desc","id":-1,"rating":{"+":0,"-":0},"tags":["tag0","othertag","$$$"],"title":"11das hier ist einz title"}
|
||||
1629727721726 | Trying to set post "undefined", as name "12das hier ist einz title"
|
||||
1629727721727 | Contents: {"author":"author","content":"# Your post (NO HEADLINE HERE)\nyou post ","create":1629727721726,"desc":"desc","id":-1,"rating":{"+":0,"-":0},"tags":["tag0","othertag","$$$"],"title":"12das hier ist einz title"}
|
||||
1629727812617 | Reading posts sorted by "new" with a length of 10
|
||||
1629727825196 | Reading posts sorted by "new" with a length of 10
|
||||
1629727925705 | Reading posts sorted by "new" with a length of 10
|
||||
1629728008009 | Reading posts sorted by "new" with a length of 10
|
||||
1629728104861 | searching stuff by tags "$$$" and sorting "undefined"
|
||||
--- SEPERATOR ---
|
||||
--- SEPERATOR ---
|
||||
--- SEPERATOR ---
|
||||
--- SEPERATOR ---
|
||||
--- SEPERATOR ---
|
||||
1629731380955 | Dumping config:
|
||||
1629731380961 | {"debug":false,"logging":1337,"logfile":"logs/log.log","ipget_endpoint_set":"//derzombiiie.com/getip.php?settoken=${TOKEN}","ipget_endpoint_get":"//derzombiiie.com/getip.php?token=${TOKEN}","cl":true,"site_name":"blog.derzombiiie.com","search_enable":false,"commenting_enabled":true,"post_ranking_auto":43200,"index_post_sort":"new","comment_sync_on_write":false,"comment_auto_sync":360}
|
||||
1629731615844 | Reading posts sorted by "new" with a length of 10
|
||||
1629731622684 | Reading posts sorted by "new" with a length of 10
|
||||
--- SEPERATOR ---
|
||||
1629733161895 | Dumping config:
|
||||
1629733161901 | {"debug":false,"logging":1337,"logfile":"logs/log.log","ipget_endpoint_set":"//derzombiiie.com/getip.php?settoken=${TOKEN}","ipget_endpoint_get":"//derzombiiie.com/getip.php?token=${TOKEN}","cl":true,"site_name":"blog.derzombiiie.com","search_enable":true,"commenting_enabled":true,"post_ranking_auto":43200,"index_post_sort":"new","comment_sync_on_write":false,"comment_auto_sync":360}
|
||||
1629733172114 | Reading posts sorted by "new" with a length of 10
|
||||
1629733207204 | Reading posts sorted by "new" with a length of 10
|
||||
1629734004107 | Reading posts sorted by "new" with a length of 10
|
||||
--- SEPERATOR ---
|
||||
--- SEPERATOR ---
|
||||
|
|
38
node/app.js
38
node/app.js
|
@ -164,6 +164,13 @@ con.registercmd( "post", (arg => {
|
|||
console.log("DONE!")
|
||||
break
|
||||
|
||||
case "index":
|
||||
console.log("indexing...")
|
||||
t = posts.index()
|
||||
if (t) console.log(t)
|
||||
console.log("DONE!")
|
||||
break
|
||||
|
||||
default:
|
||||
console.log("Sub-command not found or not supplied!")
|
||||
|
||||
|
@ -171,7 +178,7 @@ con.registercmd( "post", (arg => {
|
|||
case "?":
|
||||
case "h":
|
||||
case "help":
|
||||
console.log("Availible cmds: get, ranking, rank, sync")
|
||||
console.log("Availible cmds: get, ranking, rank, sync, index")
|
||||
break
|
||||
}
|
||||
}))
|
||||
|
@ -324,6 +331,7 @@ app.all("/comments", (req, res) => { // + rating
|
|||
})
|
||||
|
||||
// search stuff:
|
||||
if ( conf.search_enable ) {
|
||||
con.registercmd("search", (arg) => {
|
||||
if ( !arg[0] || !arg[1] ) return console.log( "No search parameters specified!\nusage: \"search <sort> <param1> <param2>...\"" )
|
||||
let sort = arg[0]
|
||||
|
@ -331,12 +339,23 @@ con.registercmd("search", (arg) => {
|
|||
console.log( posts.search( arg, sort ) )
|
||||
})
|
||||
app.get("/search", (req, res) => {
|
||||
let tags = req.query.tag.split(" ")
|
||||
let tags = req.query.tag ? req.query.tag.split(" ") : []
|
||||
let author = req.query.author ? req.query.author.split(" ") : []
|
||||
let sort = req.query.sort ? req.query.sort : undefined
|
||||
|
||||
if ( tags.length == 0 && author.length == 0 ) {
|
||||
res.status( 400 )
|
||||
if ( req.query.api != undefined ) {
|
||||
res.type("application/json")
|
||||
res.end( JSON.stringify( {"type":"err","text":"NO SEARCH PARAMS"} ) )
|
||||
} else {
|
||||
res.end("No search params")
|
||||
}
|
||||
}
|
||||
|
||||
if ( req.query.api == undefined ) {
|
||||
let r = {}
|
||||
r.sd = posts.search( tags, sort, true )
|
||||
r.sd = posts.search( tags, author, sort, true )
|
||||
r.arg = tags
|
||||
|
||||
filestuff.readFSr(req, res, "html/search/index.html", "text/html", `""//<!--SEARCH-DATA-INJECT-->//`, JSON.stringify( r ) )
|
||||
|
@ -346,22 +365,19 @@ app.get("/search", (req, res) => {
|
|||
|
||||
// actual api
|
||||
res.type("application/json")
|
||||
if ( req.query.tag == undefined ) {
|
||||
res.status( 400 )
|
||||
res.end( JSON.stringify({"type":"err", "text":"No tag provided"}) )
|
||||
return
|
||||
}
|
||||
console.log(req.query)
|
||||
|
||||
// check is post info is needed:
|
||||
let p = req.query.pi != undefined
|
||||
|
||||
// construct response
|
||||
let r = {"type":"s","text":"success!"}
|
||||
r.content = posts.search( tags, sort, p )
|
||||
r.content = posts.search( tags, author, sort, p )
|
||||
|
||||
res.end( JSON.stringify( r ) )
|
||||
})
|
||||
} else {
|
||||
app.get("/search", (req, res) => filestuff.readFS(req,res,"html/search/disabled.html","text/html"))
|
||||
}
|
||||
|
||||
// debug stuff:
|
||||
if( conf.debug )
|
||||
|
@ -392,6 +408,6 @@ app.get("/admin", (req, res) => filestuff.readFS(req, res, "html/admin/index.htm
|
|||
app.post("/admin/post", (req, res) => admin.post(req, res))
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`Server listening on http://localhost:${port}`)
|
||||
console.log(`Server listening on http://0.0.0.0:${port}`)
|
||||
if(conf.cl) con.init()
|
||||
})
|
||||
|
|
|
@ -24,7 +24,7 @@ module.exports.eval = ( cmd ) => {
|
|||
|
||||
if (! comm ) return // if cmd empty dont do anything
|
||||
|
||||
if ( comm = "FE!") {
|
||||
if ( comm === "FE!") {
|
||||
process.exit(1) // FORCE EXIT "crash" programm
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
const fs = require("fs")
|
||||
|
||||
module.exports.handler = (req, res, folder) => {
|
||||
|
|
|
@ -110,7 +110,7 @@ this.push = (post) => {
|
|||
|
||||
let len = this.db.get("len")
|
||||
this.db.set(len, {
|
||||
"autor": post.author,
|
||||
"author": post.author,
|
||||
"content": post.content,
|
||||
"create": post.create,
|
||||
"desc": post.desc,
|
||||
|
@ -153,7 +153,6 @@ this.rate = ( post, rating, ip ) => {
|
|||
let ipi = this.ipcheck( post, ip )
|
||||
let p = this.db.get( post )
|
||||
|
||||
console.log(`ip: ${ip}; ipi:${JSON.stringify(ipi)}`)
|
||||
if ( ip ) {
|
||||
if ( ipi == "+" ) {
|
||||
p.rating["+"]--
|
||||
|
@ -170,39 +169,45 @@ this.rate = ( post, rating, ip ) => {
|
|||
return {"type":"s", "text":"success!", "content": p.rating}
|
||||
}
|
||||
|
||||
// does the indexing for search by tags
|
||||
// does the indexing for search by tags / author
|
||||
this.index = () => {
|
||||
let len = this.len
|
||||
this.tags = []
|
||||
this.author = []
|
||||
|
||||
for ( let i = 0 ; i < len ; i++ ) {
|
||||
this.tags[i] = this.db.get( i ).tags.sort()
|
||||
}
|
||||
for ( let i = 0 ; i < len ; i++ ) {
|
||||
this.author[i] = this.db.get( i ).author
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
this.search = ( tags, sort, pinfo ) => {
|
||||
this.search = ( tags, author, sort, pinfo ) => {
|
||||
// search goes through all articles and counts the amount of matching tags; then it uses sort to sort stuff though the this.ranking[sort]
|
||||
let len = this.len
|
||||
let rnk = []
|
||||
let len = this.len
|
||||
let rnk = [] // rank based on tags
|
||||
|
||||
console.log( len )
|
||||
// rnk[postID] = amount of matching tags
|
||||
for ( let l = 0 ; l < len ; l++ ) {
|
||||
for ( let i = 0 ; i < tags.length ; i++ ) {
|
||||
if ( this.tags[l].includes( tags[i] ) ) {
|
||||
console.log(rnk)
|
||||
if ( !rnk[l] ) {
|
||||
rnk[l] = 0
|
||||
if ( ( author.includes( this.author[l] ) || author.length == 0 || author == false ) && tags.length > 0 ) {
|
||||
for ( let i = 0 ; i < tags.length ; i++ ) {
|
||||
if ( this.tags[l].includes( tags[i] ) ) {
|
||||
if ( !rnk[l] ) {
|
||||
rnk[l] = 0
|
||||
}
|
||||
rnk[l]++
|
||||
}
|
||||
rnk[l]++
|
||||
}
|
||||
}
|
||||
if ( author.includes( this.author[l] ) && ( tags.length == 0 || this.tags == false ) ) {
|
||||
rnk[l] = 1
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
console.log(rnk)
|
||||
|
||||
let rem = true
|
||||
let sorted = []
|
||||
let pos = -1;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
"id": 0
|
||||
},
|
||||
"1": {
|
||||
"autor": "deinz mudda",
|
||||
"author": "deinz mudda",
|
||||
"content": "\thier könnte ihre werbung stehen",
|
||||
"create": 1629562159432,
|
||||
"desc": "hier nicht",
|
||||
|
@ -36,7 +36,7 @@
|
|||
"title": "testing for tagz"
|
||||
},
|
||||
"2": {
|
||||
"autor": "deinz mudda",
|
||||
"author": "deinz mudda",
|
||||
"content": "\thier könnte ihre werbung stehen",
|
||||
"create": 1629562186156,
|
||||
"desc": "hier nicht",
|
||||
|
@ -52,5 +52,260 @@
|
|||
],
|
||||
"title": "testing for tagz1"
|
||||
},
|
||||
"len": 3
|
||||
"3": {
|
||||
"author": "Author",
|
||||
"content": "# Your post (NO HEADLINE HERE)",
|
||||
"create": 1629720057137,
|
||||
"desc": "This is a post about *",
|
||||
"id": 3,
|
||||
"rating": {
|
||||
"+": 0,
|
||||
"-": 0
|
||||
},
|
||||
"tags": [
|
||||
"$$$$",
|
||||
"othertag1",
|
||||
"tag1"
|
||||
],
|
||||
"title": "me try 2 other creator"
|
||||
},
|
||||
"4": {
|
||||
"author": "Author",
|
||||
"content": "# Your post (NO HEADLINE HERE)",
|
||||
"create": 1629720067537,
|
||||
"desc": "This is a post about *",
|
||||
"id": 4,
|
||||
"rating": {
|
||||
"+": 0,
|
||||
"-": 0
|
||||
},
|
||||
"tags": [
|
||||
"$$$$",
|
||||
"othertag1",
|
||||
"tag1"
|
||||
],
|
||||
"title": "me try 2 other creator"
|
||||
},
|
||||
"5": {
|
||||
"author": "author",
|
||||
"content": "# Your post (NO HEADLINE HERE)\nyou post ",
|
||||
"create": 1629727628418,
|
||||
"desc": "desc",
|
||||
"id": 5,
|
||||
"rating": {
|
||||
"+": 0,
|
||||
"-": 0
|
||||
},
|
||||
"tags": [
|
||||
"$$$",
|
||||
"othertag",
|
||||
"tag0"
|
||||
],
|
||||
"title": "0das hier ist einz title"
|
||||
},
|
||||
"6": {
|
||||
"author": "author",
|
||||
"content": "# Your post (NO HEADLINE HERE)\nyou post ",
|
||||
"create": 1629727642467,
|
||||
"desc": "desc",
|
||||
"id": 6,
|
||||
"rating": {
|
||||
"+": 0,
|
||||
"-": 0
|
||||
},
|
||||
"tags": [
|
||||
"$$$",
|
||||
"othertag",
|
||||
"tag0"
|
||||
],
|
||||
"title": "2das hier ist einz title"
|
||||
},
|
||||
"7": {
|
||||
"author": "author",
|
||||
"content": "# Your post (NO HEADLINE HERE)\nyou post ",
|
||||
"create": 1629727647823,
|
||||
"desc": "desc",
|
||||
"id": 7,
|
||||
"rating": {
|
||||
"+": 0,
|
||||
"-": 0
|
||||
},
|
||||
"tags": [
|
||||
"$$$",
|
||||
"othertag",
|
||||
"tag0"
|
||||
],
|
||||
"title": "3das hier ist einz title"
|
||||
},
|
||||
"8": {
|
||||
"author": "author",
|
||||
"content": "# Your post (NO HEADLINE HERE)\nyou post ",
|
||||
"create": 1629727652358,
|
||||
"desc": "desc",
|
||||
"id": 8,
|
||||
"rating": {
|
||||
"+": 0,
|
||||
"-": 0
|
||||
},
|
||||
"tags": [
|
||||
"$$$",
|
||||
"othertag",
|
||||
"tag0"
|
||||
],
|
||||
"title": "4das hier ist einz title"
|
||||
},
|
||||
"9": {
|
||||
"author": "author",
|
||||
"content": "# Your post (NO HEADLINE HERE)\nyou post ",
|
||||
"create": 1629727676048,
|
||||
"desc": "desc",
|
||||
"id": 9,
|
||||
"rating": {
|
||||
"+": 0,
|
||||
"-": 0
|
||||
},
|
||||
"tags": [
|
||||
"$$$",
|
||||
"othertag",
|
||||
"tag0"
|
||||
],
|
||||
"title": "5das hier ist einz title"
|
||||
},
|
||||
"10": {
|
||||
"author": "author",
|
||||
"content": "# Your post (NO HEADLINE HERE)\nyou post ",
|
||||
"create": 1629727681549,
|
||||
"desc": "desc",
|
||||
"id": 10,
|
||||
"rating": {
|
||||
"+": 0,
|
||||
"-": 0
|
||||
},
|
||||
"tags": [
|
||||
"$$$",
|
||||
"othertag",
|
||||
"tag0"
|
||||
],
|
||||
"title": "6das hier ist einz title"
|
||||
},
|
||||
"11": {
|
||||
"author": "author",
|
||||
"content": "# Your post (NO HEADLINE HERE)\nyou post ",
|
||||
"create": 1629727686171,
|
||||
"desc": "desc",
|
||||
"id": 11,
|
||||
"rating": {
|
||||
"+": 0,
|
||||
"-": 0
|
||||
},
|
||||
"tags": [
|
||||
"$$$",
|
||||
"othertag",
|
||||
"tag0"
|
||||
],
|
||||
"title": "7das hier ist einz title"
|
||||
},
|
||||
"12": {
|
||||
"author": "author",
|
||||
"content": "# Your post (NO HEADLINE HERE)\nyou post ",
|
||||
"create": 1629727692876,
|
||||
"desc": "desc",
|
||||
"id": 12,
|
||||
"rating": {
|
||||
"+": 0,
|
||||
"-": 0
|
||||
},
|
||||
"tags": [
|
||||
"$$$",
|
||||
"othertag",
|
||||
"tag0"
|
||||
],
|
||||
"title": "8das hier ist einz title"
|
||||
},
|
||||
"13": {
|
||||
"author": "author",
|
||||
"content": "# Your post (NO HEADLINE HERE)\nyou post ",
|
||||
"create": 1629727698662,
|
||||
"desc": "desc",
|
||||
"id": 13,
|
||||
"rating": {
|
||||
"+": 0,
|
||||
"-": 0
|
||||
},
|
||||
"tags": [
|
||||
"$$$",
|
||||
"othertag",
|
||||
"tag0"
|
||||
],
|
||||
"title": "9das hier ist einz title"
|
||||
},
|
||||
"14": {
|
||||
"author": "author",
|
||||
"content": "# Your post (NO HEADLINE HERE)\nyou post ",
|
||||
"create": 1629727706950,
|
||||
"desc": "desc",
|
||||
"id": 14,
|
||||
"rating": {
|
||||
"+": 0,
|
||||
"-": 0
|
||||
},
|
||||
"tags": [
|
||||
"$$$",
|
||||
"othertag",
|
||||
"tag0"
|
||||
],
|
||||
"title": "10das hier ist einz title"
|
||||
},
|
||||
"15": {
|
||||
"author": "author",
|
||||
"content": "# Your post (NO HEADLINE HERE)\nyou post ",
|
||||
"create": 1629727717296,
|
||||
"desc": "desc",
|
||||
"id": 15,
|
||||
"rating": {
|
||||
"+": 0,
|
||||
"-": 0
|
||||
},
|
||||
"tags": [
|
||||
"$$$",
|
||||
"othertag",
|
||||
"tag0"
|
||||
],
|
||||
"title": "11das hier ist einz title"
|
||||
},
|
||||
"16": {
|
||||
"author": "author",
|
||||
"content": "# Your post (NO HEADLINE HERE)\nyou post ",
|
||||
"create": 1629727721726,
|
||||
"desc": "desc",
|
||||
"id": 16,
|
||||
"rating": {
|
||||
"+": 0,
|
||||
"-": 0
|
||||
},
|
||||
"tags": [
|
||||
"$$$",
|
||||
"othertag",
|
||||
"tag0"
|
||||
],
|
||||
"title": "12das hier ist einz title"
|
||||
},
|
||||
"len": 17,
|
||||
"preview": {
|
||||
"author": "author",
|
||||
"content": "# Your post (NO HEADLINE HERE)\nyou post ",
|
||||
"create": 1629727689858,
|
||||
"desc": "desc",
|
||||
"id": -1,
|
||||
"rating": {
|
||||
"+": 0,
|
||||
"-": 0
|
||||
},
|
||||
"tags": [
|
||||
"tag0",
|
||||
"othertag",
|
||||
"$$$"
|
||||
],
|
||||
"title": "8das hier ist einz title"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue