heartranked

git clone https://git.tarina.org/heartranked
Log | Files | Refs

commit ad448c566ac2609e640c84b2eca858b40fa6b27d
parent 479cf2f7ff2bf2b5e452995bb6741bf52e115c5e
Author: rbckman <rob@tarina.org>
Date:   Tue,  4 Aug 2026 18:27:38 +0300

all your base are belong to us

Diffstat:
Mhtml/editor.html | 6+++---
Mhtml/heartranked.html | 221+++++++++++++++++++++++++++++++++++++++++--------------------------------------
Mserver.py | 49++++++++++++++++++++++---------------------------
3 files changed, 139 insertions(+), 137 deletions(-)

diff --git a/html/editor.html b/html/editor.html @@ -269,15 +269,15 @@ function uploadSingleFile(file, progressBar, statusEl) { $if soundlink: <a href="https://robinbackman.com/editor?edit=$soundlink"><code>https://robinbackman.com/editor?edit=$soundlink</code></a></br> <div id="status"></div> -<a id='back' href='/heartranked'>go back</a> +<a id='back' href='/'>go back</a> $if logged: or <a id='publish' href='/editor?publish=yes'>publish</a> or <a id='new' href='/editor?new=yes'>new</a> <small>logged in as $user $if combine: - this is a <a href="/heartranked?show=$combine">combined post</a> + this is a <a href="/?show=$combine">combined post</a> $if remix: - this is a <a href="/heartranked?show=$remix">remix post</a></small> + this is a <a href="/?show=$remix">remix post</a></small> </div> <div style="text-align: left; width: 455px;" id="rendered"> </div> diff --git a/html/heartranked.html b/html/heartranked.html @@ -23,7 +23,7 @@ $unique UNICORNS 🦄 PEACE! ☮️ <div id="mod"> $if rights=='mod' or rights=='admin': $#displayname = db.query("SELECT displayname FROM rymdadmin WHERE name='"+namn+"';")[0] - $ displayname=loadjson('r/users/'+session.user) + $ displayname=loadjson('r/users/'+namn) hey <b><a href="/tuning">$displayname['displayname']</a></b>, <a href="/invites">invite</a> or <a href="/editor?new=yes">write</a> <br> $else: @@ -74,120 +74,127 @@ $else: <small>🌍 <a href="/?feedbase=time">time</a> ❤️ <a href="/?feedbase=heart">heart</a> ⚭ <a href="/?feedbase=combo">combo</a> for <a href="/?timebase=today">day</a> <a href="/?timebase=week">week</a> <a href="/?timebase=month">month</a> <a href="/?timebase=year">year</a> <a href="/?timebase=all">all</a></small> <br> $ goodies=getfeed() - $for g in goodies: - <div class="post" id="$g['soundname']"> - <br> - <br> - <div class="heartpost"> - $:markdown.markdown(loadtext('p/posts/'+g['postid']+'/intro')) - </div> - <div class="postmenu"> - <small><small>$formattime(g['timeadded'])</small></small> - <small>by $g['creator']</small> - $:userimage(g['creator']) - <br> - $getcombines(g['postid']) - $if g['combine']: - $if postexist(g['combine']): + $if goodies != []: + $for g in goodies: + <div class="post" id="$g['soundname']"> + <br> + <br> + <div class="heartpost"> + $:markdown.markdown(loadtext('p/posts/'+g['postid']+'/intro')) + </div> + <div class="postmenu"> + <small><small>$formattime(g['timeadded'])</small></small> + <small>by $g['creator']</small> + $:userimage(g['creator']) + <br> + $getcombines(g['postid']) + $if g['combine']: + $if postexist(g['combine']): + $#combined = db.select('published', where="postid='"+g['combine']+"'")[0] + $ combined=loadjson('p/posts/'+g['combine']+'/meta') + <small>combo with <a href="/?show=$combined['postid']">$combined['soundname']</a></small><br> + $if g['remix']: + $if postexist(g['remix']): + $#remixed = db.select('published', where="postid='"+g['remix']+"'") + $ remixed=loadjson('p/posts/'+g['remix']+'/meta') + <small>remixed <a href="/?show=$remixed['postid']">$remixed['soundname']</a></small><br> + $if loadtext('p/posts/'+g['postid']+'/post') != '': + $if len(loadtext('p/posts/'+g['postid']+'/post')) > 255: + <a href="/?show=$g['postid']">read plenty more</a> + $else: + <a href="/?show=$g['postid']">read more</a> + $else: + $if namn: + <a href="/editor?combine=$g['postid']">combo</a> + or <a href="/?show=$g['postid']">more</a> + $else: + <a href="/?show=$g['postid']">combo</a> + or <div class="megalike" id="megalike$g['postid']" onclick="like('$g['postid']')">$getlikes(g['postid'],namn)</div> + <br> + </div> + </div> + $else: + $:markdown.markdown('#welcome to HEART RANKED!') + $else: + $#goodies = db.select('published', where="postid='"+show+"'") + $#goodies=loadjson('p/posts/'+show+'/meta') + $ goodies=getfeed() + if goodies != []: + $for g in goodies: + <a href="/#$g['soundname']">back</a> + $if namn == g['creator']: + or <a href="/?edit=$g['postid']">edit</a> + $if namn: + or <a href="/editor?remix=$g['postid']">remix</a> + or <a href="/editor?combine=$g['postid']">combo</a> + $if namn == g['creator']: + or <small><a href="/?remove=$g['postid']">remove</a></small> + <div class="post" id="$g['soundname']"> + <br> + <div class="heartpost"> + $:markdown.markdown(loadtext('p/posts/'+g['postid']+'/intro')) + $:markdown.markdown(loadtext('p/posts/'+g['postid']+'/post')) + </div> + <div class="postmenu"> + <small>by $g['creator'] $formattime(g['timeadded'])</small><br> + $getcombines(g['postid']) + $if g['combine']: $#combined = db.select('published', where="postid='"+g['combine']+"'")[0] $ combined=loadjson('p/posts/'+g['combine']+'/meta') <small>combo with <a href="/?show=$combined['postid']">$combined['soundname']</a></small><br> - $if g['remix']: - $if postexist(g['remix']): - $#remixed = db.select('published', where="postid='"+g['remix']+"'") + $if g['remix']: + $#remixed = db.select('published', where="postid='"+g['remix']+"'")[0] $ remixed=loadjson('p/posts/'+g['remix']+'/meta') <small>remixed <a href="/?show=$remixed['postid']">$remixed['soundname']</a></small><br> - $if (loadtext('p/posts/'+g['postid']+'/post') != '': - $if len(loadtext('p/posts/'+g['postid']+'/post')) > 255: - <a href="/?show=$g['postid']">read plenty more</a> - $else: - <a href="/?show=$g['postid']">read more</a> - $else: + or <a href="/#$g['soundname']">back</a> + $if namn == g['creator']: + or <a href="/?edit=$g['postid']">edit</a> $if namn: - <a href="/editor?combine=$g['postid']">combo</a> - or <a href="/?show=$g['postid']">more</a> - $else: - <a href="/?show=$g['postid']">combo</a> - or <div class="megalike" id="megalike$g['postid']" onclick="like('$g['postid']')">$getlikes(g['postid'],namn)</div> - <br> - </div> - </div> - $else: - $#goodies = db.select('published', where="postid='"+show+"'") - $ goodies=loadjson('p/posts/'+show+'/meta') - $for g in goodies: - <a href="/#$g['soundname']">back</a> - $if namn == g['creator']: - or <a href="/?edit=$g['postid']">edit</a> - $if namn: - or <a href="/editor?remix=$g['postid']">remix</a> - or <a href="/editor?combine=$g['postid']">combo</a> - $if namn == g['creator']: - or <small><a href="/?remove=$g['postid']">remove</a></small> - <div class="post" id="$g['soundname']"> + or <a href="/editor?remix=$g['postid']">remix</a> + or <a href="/editor?combine=$g['postid']">combo</a> + <div class="megalike" id="megalike$g['postid']" onclick="like('$g['postid']')">$getlikes(g['postid'],namn)</div> + <br> + </div> + </div> <br> - <div class="heartpost"> - $:markdown.markdown(loadtext('p/posts/'+g['postid']+'/intro')) - $:markdown.markdown(loadtext('p/posts/'+g['postid']+'/post')) - </div> - <div class="postmenu"> - <small>by $g['creator'] $formattime(g['timeadded'])</small><br> - $getcombines(g['postid']) - $if g['combine']: - $#combined = db.select('published', where="postid='"+g['combine']+"'")[0] - $ combined=loadjson('p/posts/'+g['combine']+'/meta') - <small>combo with <a href="/?show=$combined['postid']">$combined['soundname']</a></small><br> - $if g['remix']: - $#remixed = db.select('published', where="postid='"+g['remix']+"'")[0] - $ remixed=loadjson('p/posts/'+g['remix']+'/meta') - <small>remixed <a href="/?show=$remixed['postid']">$remixed['soundname']</a></small><br> - and <a href="/#$g['soundname']">back</a> - $if namn == g['creator']: - or <a href="/?edit=$g['postid']">edit</a> - $if namn: - or <a href="/editor?remix=$g['postid']">remix</a> - or <a href="/editor?combine=$g['postid']">combo</a> - <div class="megalike" id="megalike$g['postid']" onclick="like('$g['postid']')">$getlikes(g['postid'],namn)</div> <br> - </div> - </div> - <br> - <br> - $ comboposts=getcombofeed(show) - $ choose_feed = False - $for c in comboposts: - $if c['soundname'] and choose_feed == False: - $#<small><a href="/?show=$g['postid']&feedbase=timebased">timebased 🌍</a> <a href="/?show=$g['postid']&feedbase=heart1day">heartbased ❤️ day</a> <a href="/?show=$g['postid']&feedbase=heart1week">week</a> <a href="/?show=$g['postid']&feedbase=heart1month">month</a> <a href="/?show=$g['postid']&feedbase=heart1year">year</a> <a href="/?show=$g['postid']&feedbase=alltime">alltime</a></small> - <small>🌍 <a href="/?show=$g['postid']&feedbase=time">time</a> ❤️ <a href="/?show=$g['postid']&feedbase=heart">heart</a> ⚭ <a href="/?show=$g['postid']&feedbase=combo">combo</a> for <a href="/?show=$g['postid']&feedbase=today">day</a> <a href="/?show=$g['postid']&timebase=week">week</a> <a href="/?show=$g['postid']&timebase=month">month</a> <a href="/?show=$g['postid']&timebase=year">year</a> <a href="/?show=$g['postid']&timebase=all">all</a></small> - $ choose_feed = True - <div class="post" id="$c['soundname']"> - <br> - <br> - <div class="heartpost"> - $:markdown.markdown(loadtext('p/posts/'+c['postid']+'/intro')) - $:markdown.markdown(loadtext('p/posts/'+c['postid']+'/post')) - </div> - <div class="postmenu"> - <small>by $c['creator'] $formattime(c['timeadded'])</small><br> - $getcombines(c['postid']) - $if c['combine']: - $#combined = db.select('published', where="postid='"+c['combine']+"'")[0] - $ combined=loadjson('p/posts/'+c['combine']+'/meta') - <small>combo with <a href="/?show=$combined['postid']">$combined['soundname']</a></small><br> - $if c['remix']: - $#remixed = db.select('published', where="postid='"+c['remix']+"'")[0] - $ remixed=loadjson('p/posts/'+c['remix']+'/meta') - <small>remixed <a href="/?show=$remixed['postid']">$remixed['soundname']</a></small><br> - <a href="/?show=$c['postid']">more</a> - or <a href="/#$c['soundname']">back</a> - $if namn == c['creator']: - or <a href="/?edit=$c['postid']">edit</a> - $if namn: - or <a href="/editor?combine=$c['postid']">combo</a> - <div class="megalike" id="megalike$c['postid']" onclick="like('$c['postid']')">$getlikes(c['postid'],namn)</div> - <br> - </div> - </div> + $ comboposts=getcombofeed(show) + $ choose_feed = False + $for c in comboposts: + $if c['soundname'] and choose_feed == False: + $#<small><a href="/?show=$g['postid']&feedbase=timebased">timebased 🌍</a> <a href="/?show=$g['postid']&feedbase=heart1day">heartbased ❤️ day</a> <a href="/?show=$g['postid']&feedbase=heart1week">week</a> <a href="/?show=$g['postid']&feedbase=heart1month">month</a> <a href="/?show=$g['postid']&feedbase=heart1year">year</a> <a href="/?show=$g['postid']&feedbase=alltime">alltime</a></small> + <small>🌍 <a href="/?show=$g['postid']&feedbase=time">time</a> ❤️ <a href="/?show=$g['postid']&feedbase=heart">heart</a> ⚭ <a href="/?show=$g['postid']&feedbase=combo">combo</a> for <a href="/?show=$g['postid']&feedbase=today">day</a> <a href="/?show=$g['postid']&timebase=week">week</a> <a href="/?show=$g['postid']&timebase=month">month</a> <a href="/?show=$g['postid']&timebase=year">year</a> <a href="/?show=$g['postid']&timebase=all">all</a></small> + $ choose_feed = True + <div class="post" id="$c['soundname']"> + <br> + <br> + <div class="heartpost"> + $:markdown.markdown(loadtext('p/posts/'+c['postid']+'/intro')) + $:markdown.markdown(loadtext('p/posts/'+c['postid']+'/post')) + </div> + <div class="postmenu"> + <small>by $c['creator'] $formattime(c['timeadded'])</small><br> + $getcombines(c['postid']) + $if c['combine']: + $#combined = db.select('published', where="postid='"+c['combine']+"'")[0] + $ combined=loadjson('p/posts/'+c['combine']+'/meta') + <small>combo with <a href="/?show=$combined['postid']">$combined['soundname']</a></small><br> + $if c['remix']: + $#remixed = db.select('published', where="postid='"+c['remix']+"'")[0] + $ remixed=loadjson('p/posts/'+c['remix']+'/meta') + <small>remixed <a href="/?show=$remixed['postid']">$remixed['soundname']</a></small><br> + <a href="/?show=$c['postid']">more</a> + or <a href="/#$c['soundname']">back</a> + $if namn == c['creator']: + or <a href="/?edit=$c['postid']">edit</a> + $if namn: + or <a href="/editor?combine=$c['postid']">combo</a> + <div class="megalike" id="megalike$c['postid']" onclick="like('$c['postid']')">$getlikes(c['postid'],namn)</div> + <br> + </div> + </div> + else: + print('de nada') <br> <br> diff --git a/server.py b/server.py @@ -145,7 +145,7 @@ def adduser(name, password, mail): adminlevel=3 else: adminlevel=5 - savedict={'name':name, 'originalname':originalname, 'password':password_hashed,'mail':mail,'adminlevel':adminlevel} + savedict={'name':name, 'displayname':originalname, 'password':password_hashed,'mail':mail,'adminlevel':adminlevel} savejson('r/users/'+name, savedict) #savetext('r/user/'+name,password_hashed) print("new user added") @@ -894,12 +894,14 @@ def getfeed(): feedbase=session.feedbase if feedbase == '': feedbase = 'time' - now = formattime(datetime.datetime.now()) + if timebase == '': + timebase = 'week' + now = datetime.datetime.now() + goodies=[] #HEARTS #SAVE HEARTRANKING EVERY MINUTE CHECK BOTH USER LIKES AND POST LIKES IF IT CHECKS OUT GOOD IT NOT WRITE ERROR AT LEAST (A BACKEND PROGRAM, RUNS EVERY MINUTE AND COUNTS LIKES AND WRITES THE HEARTRANKING FOR TODAY. HEARTRANKING STAYES SAVED FOREVER IN FOLDERS BY DAYS. IT IS A FOLDER WITH NUMBERS. starting with 0000000000000001 pointing to postid. simple. effective. #backend program will also sync posts and likes to trustees if feedbase == "heart" and timebase == "today": - now = formattime(datetime.datetime.now()) one_day_before = now - datetime.timedelta(days=1) now = now.strftime('%Y-%m-%d %H:%M:%S') one_day_before=one_day_before.strftime('%Y-%m-%d %H:%M:%S') @@ -910,13 +912,12 @@ def getfeed(): goodies=[] for p in posts: #check modtime here day - lastupdate = os.path.getmtime(basedir+'r/heartrank/'+p) + lastupdate = os.path.getmtime(basedir+'p/posts/'+p+'/meta') if lastupdate > one_day_before: l=loadjson('p/posts/'+p) goodies.append(l) print(goodies) elif feedbase == "heart" and timebase == "week": - now = formattime(datetime.datetime.now()) one_day_before = now - datetime.timedelta(weeks=1) now = now.strftime('%Y-%m-%d %H:%M:%S') one_day_before=one_day_before.strftime('%Y-%m-%d %H:%M:%S') @@ -925,13 +926,12 @@ def getfeed(): goodies=[] for p in posts: #check modtime here day - lastupdate = os.path.getmtime(basedir+'r/heartrank/'+p) + lastupdate = os.path.getmtime(basedir+'p/posts/'+p+'/meta') if lastupdate > one_day_before: l=loadjson('p/posts/'+p) goodies.append(l) print(goodies) elif feedbase == "heart" and timebase == "month": - now = formattime(datetime.datetime.now()) one_day_before = now - datetime.timedelta(weeks=4) now = now.strftime('%Y-%m-%d %H:%M:%S') one_day_before=one_day_before.strftime('%Y-%m-%d %H:%M:%S') @@ -940,13 +940,12 @@ def getfeed(): goodies=[] for p in posts: #check modtime here day - lastupdate = os.path.getmtime(basedir+'r/heartrank/'+p) + lastupdate = os.path.getmtime(basedir+'p/posts/'+p+'/meta') if lastupdate > one_day_before: l=loadjson('p/posts/'+p) goodies.append(l) print(goodies) elif feedbase == "heart" and timebase == "year": - now = formattime(datetime.datetime.now()) one_day_before = now - datetime.timedelta(weeks=54) now = now.strftime('%Y-%m-%d %H:%M:%S') one_day_before=one_day_before.strftime('%Y-%m-%d %H:%M:%S') @@ -955,7 +954,7 @@ def getfeed(): goodies=[] for p in posts: #check modtime here day - lastupdate = os.path.getmtime(basedir+'r/heartrank/'+p) + lastupdate = os.path.getmtime(basedir+'p/posts/'+p+'/meta') if lastupdate > one_day_before: l=loadjson('p/posts/'+p) goodies.append(l) @@ -977,13 +976,12 @@ def getfeed(): posts = get_files_by_modtime('p/posts/',newest_first=True) for p in posts: #check modtime here day - lastupdate = os.path.getmtime('p/posts/'+p) + lastupdate = os.path.getmtime(basedir+'p/posts/'+p+'/meta') if lastupdate > one_day_before: l=loadjson('p/posts/'+p) goodies.append(l) print(goodies) elif feedbase == "time" and timebase == "week": - now = formattime(datetime.datetime.now()) one_day_before = now - datetime.timedelta(weeks=1) now = now.strftime('%Y-%m-%d %H:%M:%S') one_day_before=one_day_before.strftime('%Y-%m-%d %H:%M:%S') @@ -991,12 +989,12 @@ def getfeed(): posts = get_files_by_modtime('p/posts/',newest_first=True) for p in posts: #check modtime here day - lastupdate = os.path.getmtime('p/posts/'+p) + lastupdate = os.path.getmtime(basedir+'p/posts/'+p+'/meta') if lastupdate > one_day_before: l=loadjson('p/posts/'+p) goodies.append(l) + print(goodies) elif feedbase == "time" and timebase == "month": - now = formattime(datetime.datetime.now()) one_day_before = now - datetime.timedelta(weeks=4) now = now.strftime('%Y-%m-%d %H:%M:%S') one_day_before=one_day_before.strftime('%Y-%m-%d %H:%M:%S') @@ -1004,12 +1002,11 @@ def getfeed(): posts = get_files_by_modtime('p/posts/',newest_first=True) for p in posts: #check modtime here day - lastupdate = os.path.getmtime('p/posts/'+p) + lastupdate = os.path.getmtime(basedir+'p/posts/'+p+'/meta') if lastupdate > one_day_before: l=loadjson('p/posts/'+p) goodies.append(l) elif feedbase == "time" and timebase == "year": - now = formattime(datetime.datetime.now()) one_day_before = now - datetime.timedelta(weeks=54) now = now.strftime('%Y-%m-%d %H:%M:%S') one_day_before=one_day_before.strftime('%Y-%m-%d %H:%M:%S') @@ -1017,13 +1014,13 @@ def getfeed(): posts = get_files_by_modtime('p/posts/',newest_first=True) for p in posts: #check modtime here day - lastupdate = os.path.getmtime('p/posts/'+p) + lastupdate = os.path.getmtime(basedir+'p/posts/'+p+'/meta') if lastupdate > one_day_before: l=loadjson('p/posts/'+p) goodies.append(l) elif feedbase == "time" and timebase == "" or feedbase == "time" and timebase == "all": #goodies = db.query("SELECT * FROM published ORDER BY ID DESC LIMIT 1000;") - posts = get_files_by_modtime('/p/posts/',newest_first=True) + posts = get_files_by_modtime('p/posts/',newest_first=True) for p in posts: l=loadjson('p/posts/'+p) goodies.append(l) @@ -1037,13 +1034,12 @@ def getfeed(): goodies=[] for p in posts: #check modtime here day - lastupdate = os.path.getmtime(basedir+'r/comborank/'+p) + lastupdate = os.path.getmtime(basedir+'p/posts/'+p+'/meta') if lastupdate > one_day_before: l=loadjson('p/posts/'+p) goodies.append(l) print(goodies) elif feedbase == "combo" and timebase == "week": - now = formattime(datetime.datetime.now()) one_day_before = now - datetime.timedelta(weeks=1) now = now.strftime('%Y-%m-%d %H:%M:%S') one_day_before=one_day_before.strftime('%Y-%m-%d %H:%M:%S') @@ -1052,12 +1048,11 @@ def getfeed(): goodies=[] for p in posts: #check modtime here day - lastupdate = os.path.getmtime(basedir+'r/comborank/'+p) + lastupdate = os.path.getmtime(basedir+'p/posts/'+p+'/meta') if lastupdate > one_day_before: l=loadjson('p/posts/'+p) goodies.append(l) elif feedbase == "combo" and timebase == "month": - now = formattime(datetime.datetime.now()) one_day_before = now - datetime.timedelta(weeks=4) now = now.strftime('%Y-%m-%d %H:%M:%S') one_day_before=one_day_before.strftime('%Y-%m-%d %H:%M:%S') @@ -1066,12 +1061,11 @@ def getfeed(): goodies=[] for p in posts: #check modtime here day - lastupdate = os.path.getmtime(basedir+'r/comborank/'+p) + lastupdate = os.path.getmtime(basedir+'p/posts/'+p+'/meta') if lastupdate > one_day_before: l=loadjson('p/posts/'+p) goodies.append(l) elif feedbase == "combo" and timebase == "year": - now = formattime(datetime.datetime.now()) one_day_before = now - datetime.timedelta(weeks=54) now = now.strftime('%Y-%m-%d %H:%M:%S') one_day_before=one_day_before.strftime('%Y-%m-%d %H:%M:%S') @@ -1080,7 +1074,7 @@ def getfeed(): goodies=[] for p in posts: #check modtime here day - lastupdate = os.path.getmtime(basedir+'r/comborank/'+p) + lastupdate = os.path.getmtime(basedir+'p/posts/'+p+'/meta') if lastupdate > one_day_before: l=loadjson('p/posts/'+p) goodies.append(l) @@ -1092,7 +1086,8 @@ def getfeed(): l=loadjson('p/posts/'+p) goodies.append(l) elif feedbase == "Idontevenknow": - goodies = db.query("SELECT * FROM published ORDER BY combines DESC LIMIT 1000;") + #goodies = db.query("SELECT * FROM published ORDER BY combines DESC LIMIT 1000;") + print('write your own custom feed here') else: #goodies = db.query("SELECT * FROM published ORDER BY ID DESC LIMIT 1000;") posts = os.listdir('p/posts/') @@ -1121,7 +1116,7 @@ def getcombofeed(show): comboposts.append(l) else: #comboposts = db.query("SELECT * FROM published WHERE combine='"+show+"' ORDER BY ID DESC LIMIT 1000;") - posts = get_files_by_modtime(basedir+'p/posts/',newest_first=True) + posts = get_files_by_modtime('p/posts/',newest_first=True) comboposts=[] for p in posts: l=loadjson('p/posts/'+p)