mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
No more internal communication via HTTP
This commit is contained in:
parent
efd4b89da1
commit
46d0874dfc
@ -631,6 +631,10 @@ def newrule():
|
|||||||
|
|
||||||
|
|
||||||
@dbserver.route("/issues")
|
@dbserver.route("/issues")
|
||||||
|
def issues_external(): #probably not even needed
|
||||||
|
return issues()
|
||||||
|
|
||||||
|
|
||||||
def issues():
|
def issues():
|
||||||
combined = []
|
combined = []
|
||||||
duplicates = []
|
duplicates = []
|
||||||
|
@ -133,7 +133,7 @@ def static_html(name):
|
|||||||
# If a python file exists, it provides the replacement dict for the html file
|
# If a python file exists, it provides the replacement dict for the html file
|
||||||
if os.path.exists("website/" + name + ".py"):
|
if os.path.exists("website/" + name + ".py"):
|
||||||
#txt_keys = SourceFileLoader(name,"website/" + name + ".py").load_module().replacedict(keys,DATABASE_PORT)
|
#txt_keys = SourceFileLoader(name,"website/" + name + ".py").load_module().replacedict(keys,DATABASE_PORT)
|
||||||
txt_keys,resources = SourceFileLoader(name,"website/" + name + ".py").load_module().instructions(keys,DATABASE_PORT)
|
txt_keys,resources = SourceFileLoader(name,"website/" + name + ".py").load_module().instructions(keys)
|
||||||
|
|
||||||
# add headers for server push
|
# add headers for server push
|
||||||
for resource in resources:
|
for resource in resources:
|
||||||
|
@ -2,7 +2,7 @@ import urllib
|
|||||||
import database
|
import database
|
||||||
|
|
||||||
|
|
||||||
def instructions(keys,dbport):
|
def instructions(keys):
|
||||||
from utilities import getArtistInfo
|
from utilities import getArtistInfo
|
||||||
from htmlgenerators import clean, artistLink, artistLinks, KeySplit
|
from htmlgenerators import clean, artistLink, artistLinks, KeySplit
|
||||||
from htmlmodules import module_pulse, module_trackcharts
|
from htmlmodules import module_pulse, module_trackcharts
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
import urllib
|
import urllib
|
||||||
import json
|
import database
|
||||||
from htmlgenerators import artistLink
|
from htmlgenerators import artistLink
|
||||||
|
|
||||||
def instructions(keys,dbport):
|
def instructions(keys):
|
||||||
|
|
||||||
response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/issues")
|
db_data = database.issues()
|
||||||
db_data = json.loads(response.read())
|
|
||||||
i = 0
|
i = 0
|
||||||
|
|
||||||
html = "<table class='list'>"
|
html = "<table class='list'>"
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import urllib
|
import urllib
|
||||||
import json
|
import database
|
||||||
|
|
||||||
|
|
||||||
def instructions(keys,dbport):
|
def instructions(keys):
|
||||||
from utilities import getArtistInfo, getTrackInfo
|
from utilities import getArtistInfo, getTrackInfo
|
||||||
from htmlgenerators import getTimeDesc, artistLink, artistLinks, trackLink, scrobblesLink, keysToUrl, getRangeDesc, KeySplit
|
from htmlgenerators import getTimeDesc, artistLink, artistLinks, trackLink, scrobblesLink, keysToUrl, getRangeDesc, KeySplit
|
||||||
from htmlmodules import module_pulse
|
from htmlmodules import module_pulse
|
||||||
@ -22,9 +22,8 @@ def instructions(keys,dbport):
|
|||||||
#limitkey["artist"], limitkey["associated"] = keys.get("artist"), (keys.get("associated")!=None)
|
#limitkey["artist"], limitkey["associated"] = keys.get("artist"), (keys.get("associated")!=None)
|
||||||
limitstring += "of " + artistLink(filterkeys.get("artist"))
|
limitstring += "of " + artistLink(filterkeys.get("artist"))
|
||||||
if filterkeys.get("associated"):
|
if filterkeys.get("associated"):
|
||||||
response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/artistinfo?artist=" + urllib.parse.quote(keys["artist"]))
|
data = database.artistInfo(filterkeys["artist"])
|
||||||
db_data = json.loads(response.read())
|
moreartists = data["associated"]
|
||||||
moreartists = db_data["associated"]
|
|
||||||
if moreartists != []:
|
if moreartists != []:
|
||||||
limitstring += " <span class='extra'>including " + artistLinks(moreartists) + "</span>"
|
limitstring += " <span class='extra'>including " + artistLinks(moreartists) + "</span>"
|
||||||
|
|
||||||
@ -34,9 +33,6 @@ def instructions(keys,dbport):
|
|||||||
imgurl = getTrackInfo(filterkeys.get("track")["artists"],filterkeys.get("track")["title"]).get("image")
|
imgurl = getTrackInfo(filterkeys.get("track")["artists"],filterkeys.get("track")["title"]).get("image")
|
||||||
elif filterkeys.get("artist") is not None:
|
elif filterkeys.get("artist") is not None:
|
||||||
imgurl = getArtistInfo(keys.get("artist")).get("image")
|
imgurl = getArtistInfo(keys.get("artist")).get("image")
|
||||||
#elif (len(scrobbles) != 0):
|
|
||||||
# imgurl = getTrackInfo(scrobbles[0]["artists"],scrobbles[0]["title"]).get("image")
|
|
||||||
# #imgurl = getArtistInfo(scrobbles[0]["artists"][0]).get("image")
|
|
||||||
else:
|
else:
|
||||||
imgurl = ""
|
imgurl = ""
|
||||||
|
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
import urllib
|
import urllib
|
||||||
import json
|
|
||||||
import database
|
import database
|
||||||
|
|
||||||
|
|
||||||
def instructions(keys,dbport):
|
def instructions(keys):
|
||||||
from utilities import getArtistInfo, getTrackInfo
|
from utilities import getArtistInfo, getTrackInfo
|
||||||
from htmlgenerators import artistLink, artistLinks, trackLink, KeySplit
|
from htmlgenerators import artistLink, artistLinks, trackLink, KeySplit
|
||||||
from htmlmodules import module_scrobblelist
|
from htmlmodules import module_scrobblelist
|
||||||
|
@ -5,7 +5,7 @@ import database
|
|||||||
from htmlmodules import module_scrobblelist, module_pulse
|
from htmlmodules import module_scrobblelist, module_pulse
|
||||||
|
|
||||||
|
|
||||||
def instructions(keys,dbport):
|
def instructions(keys):
|
||||||
from utilities import getArtistsInfo, getTracksInfo
|
from utilities import getArtistsInfo, getTracksInfo
|
||||||
from htmlgenerators import artistLink, artistLinks, trackLink, scrobblesArtistLink, scrobblesLink, keysToUrl, pickKeys, clean, getTimeDesc, getRangeDesc
|
from htmlgenerators import artistLink, artistLinks, trackLink, scrobblesArtistLink, scrobblesLink, keysToUrl, pickKeys, clean, getTimeDesc, getRangeDesc
|
||||||
|
|
||||||
|
@ -1,62 +1,23 @@
|
|||||||
import urllib
|
import urllib
|
||||||
import json
|
|
||||||
|
|
||||||
|
|
||||||
def instructions(keys,dbport):
|
def instructions(keys):
|
||||||
from utilities import getArtistInfo
|
from utilities import getArtistInfo
|
||||||
from htmlgenerators import KeySplit
|
from htmlgenerators import KeySplit
|
||||||
from htmlmodules import module_artistcharts
|
from htmlmodules import module_artistcharts
|
||||||
|
|
||||||
# clean(keys)
|
|
||||||
# timekeys = pickKeys(keys,"since","to","in")
|
|
||||||
# limitkeys = pickKeys(keys)
|
|
||||||
|
|
||||||
_, timekeys, _, amountkeys = KeySplit(keys)
|
_, timekeys, _, amountkeys = KeySplit(keys)
|
||||||
|
|
||||||
# get chart data
|
|
||||||
# response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/charts/artists?" + keysToUrl(timekeys,limitkeys))
|
|
||||||
# db_data = json.loads(response.read())
|
|
||||||
# charts = db_data["list"][:50]
|
|
||||||
# topartist = charts[0]["artist"]
|
|
||||||
|
|
||||||
# info = getArtistInfo(topartist)
|
|
||||||
# imgurl = info.get("image")
|
|
||||||
|
|
||||||
|
|
||||||
# get total amount of scrobbles
|
|
||||||
#response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/scrobbles?" + keysToUrl(timekeys,limitkeys))
|
|
||||||
#db_data = json.loads(response.read())
|
|
||||||
#scrobblelist = db_data["list"]
|
|
||||||
#scrobbles = len(scrobblelist)
|
|
||||||
|
|
||||||
|
|
||||||
html_charts, rep = module_artistcharts(**amountkeys,**timekeys)
|
html_charts, rep = module_artistcharts(**amountkeys,**timekeys)
|
||||||
|
|
||||||
if rep is not None:
|
if rep is not None:
|
||||||
imgurl = getArtistInfo(rep).get("image")
|
imgurl = getArtistInfo(rep).get("image")
|
||||||
else:
|
else:
|
||||||
imgurl = ""
|
imgurl = ""
|
||||||
|
|
||||||
pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else []
|
pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else []
|
||||||
|
|
||||||
# build list
|
|
||||||
# maxbar = charts[0]["scrobbles"]
|
|
||||||
#
|
|
||||||
# i = 1
|
|
||||||
# html = "<table class='list'>"
|
|
||||||
# for e in charts:
|
|
||||||
# html += "<tr>"
|
|
||||||
# html += "<td class='rank'>#" + str(i) + "</td>"
|
|
||||||
# html += "<td class='artist'>" + artistLink(e["artist"])
|
|
||||||
# if (e["counting"] != []):
|
|
||||||
# html += " <span class='extra'>incl. " + ", ".join([artistLink(a) for a in e["counting"]]) + "</span>"
|
|
||||||
# html += "</td>"
|
|
||||||
# html += "<td class='amount'>" + scrobblesArtistLink(e["artist"],timekeys,amount=e["scrobbles"],associated=True) + "</td>"
|
|
||||||
# html += "<td class='bar'>" + scrobblesArtistLink(e["artist"],timekeys,percent=e["scrobbles"]*100/maxbar,associated=True) + "</td>"
|
|
||||||
# html += "</tr>"
|
|
||||||
# i += 1
|
|
||||||
# html += "</table>"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
replace = {"KEY_TOPARTIST_IMAGEURL":imgurl,"KEY_ARTISTLIST":html_charts}
|
replace = {"KEY_TOPARTIST_IMAGEURL":imgurl,"KEY_ARTISTLIST":html_charts}
|
||||||
|
|
||||||
|
@ -1,43 +1,17 @@
|
|||||||
import urllib
|
import urllib
|
||||||
import json
|
|
||||||
|
|
||||||
|
|
||||||
def instructions(keys,dbport):
|
def instructions(keys):
|
||||||
from utilities import getArtistInfo, getTrackInfo
|
from utilities import getArtistInfo, getTrackInfo
|
||||||
from htmlgenerators import artistLink, KeySplit
|
from htmlgenerators import artistLink, KeySplit
|
||||||
from htmlmodules import module_trackcharts
|
from htmlmodules import module_trackcharts
|
||||||
|
|
||||||
# clean(keys)
|
|
||||||
# timekeys = pickKeys(keys,"since","to","in")
|
|
||||||
# limitkeys = pickKeys(keys,"artist")
|
|
||||||
|
|
||||||
filterkeys, timekeys, _, amountkeys = KeySplit(keys)
|
filterkeys, timekeys, _, amountkeys = KeySplit(keys)
|
||||||
|
|
||||||
|
|
||||||
limitstring = ""
|
limitstring = ""
|
||||||
|
|
||||||
if filterkeys.get("artist") is not None:
|
|
||||||
topartist = filterkeys.get("artist")
|
|
||||||
# #limitstring += "by " + ", ".join([artistLink(a) for a in keys.getall("artist")])
|
|
||||||
limitstring = "by " + artistLink(filterkeys.get("artist"))
|
|
||||||
# info = getArtistInfo(topartist)
|
|
||||||
# imgurl = info.get("image")
|
|
||||||
# else:
|
|
||||||
# #topartist = charts[0]["track"]["artists"][0] #for now
|
|
||||||
# info = getTrackInfo(charts[0]["track"]["artists"],charts[0]["track"]["title"])
|
|
||||||
# imgurl = info.get("image")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# get total amount of scrobbles
|
|
||||||
# response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/scrobbles?" + keysToUrl(timekeys,limitkeys))
|
|
||||||
# db_data = json.loads(response.read())
|
|
||||||
# scrobblelist = db_data["list"]
|
|
||||||
# scrobbles = len(scrobblelist)
|
|
||||||
|
|
||||||
|
|
||||||
html_charts, rep = module_trackcharts(**amountkeys,**timekeys,**filterkeys)
|
html_charts, rep = module_trackcharts(**amountkeys,**timekeys,**filterkeys)
|
||||||
|
|
||||||
|
|
||||||
@ -51,21 +25,7 @@ def instructions(keys,dbport):
|
|||||||
|
|
||||||
pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else []
|
pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else []
|
||||||
|
|
||||||
# build list
|
|
||||||
# maxbar = charts[0]["scrobbles"]
|
|
||||||
#
|
|
||||||
# i = 1
|
|
||||||
# html = "<table class='list'>"
|
|
||||||
# for e in charts:
|
|
||||||
# html += "<tr>"
|
|
||||||
# html += "<td class='rank'>#" + str(i) + "</td>"
|
|
||||||
# html += "<td class='artists'>" + artistLinks(e["track"]["artists"]) + "</td>"
|
|
||||||
# html += "<td class='title'>" + trackLink(e["track"]) + "</td>"
|
|
||||||
# html += "<td class='amount'>" + scrobblesTrackLink(e["track"],timekeys,amount=e["scrobbles"]) + "</td>"
|
|
||||||
# html += "<td class='bar'>" + scrobblesTrackLink(e["track"],timekeys,percent=e["scrobbles"]*100/maxbar) + "</td>"
|
|
||||||
# html += "</tr>"
|
|
||||||
# i += 1
|
|
||||||
# html += "</table>"
|
|
||||||
|
|
||||||
replace = {"KEY_TOPARTIST_IMAGEURL":imgurl,"KEY_TRACKLIST":html_charts,"KEY_LIMITS":limitstring}
|
replace = {"KEY_TOPARTIST_IMAGEURL":imgurl,"KEY_TRACKLIST":html_charts,"KEY_LIMITS":limitstring}
|
||||||
|
|
||||||
|
@ -2,9 +2,9 @@ import urllib
|
|||||||
import database
|
import database
|
||||||
|
|
||||||
|
|
||||||
def instructions(keys,dbport):
|
def instructions(keys):
|
||||||
from utilities import getArtistInfo, getTrackInfo
|
from utilities import getArtistInfo, getTrackInfo
|
||||||
from htmlgenerators import clean, artistLink, artistLinks, trackLink, scrobblesTrackLink, keysToUrl, pickKeys, getTimeDesc, getRangeDesc, scrobblesLink, KeySplit
|
from htmlgenerators import artistLinks, keysToUrl, KeySplit
|
||||||
from htmlmodules import module_scrobblelist, module_pulse
|
from htmlmodules import module_scrobblelist, module_pulse
|
||||||
|
|
||||||
|
|
||||||
@ -19,44 +19,9 @@ def instructions(keys,dbport):
|
|||||||
pos = "#" + str(data["position"])
|
pos = "#" + str(data["position"])
|
||||||
|
|
||||||
|
|
||||||
#response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/scrobbles?" + keysToUrl(limitkeys))
|
|
||||||
#db_data = json.loads(response.read())
|
|
||||||
#scrobbles = db_data["list"]
|
|
||||||
|
|
||||||
|
|
||||||
# build list
|
|
||||||
# html = "<table class='list'>"
|
|
||||||
# for s in scrobbles:
|
|
||||||
# html += "<tr>"
|
|
||||||
# html += "<td class='time'>" + getTimeDesc(s["time"]) + "</td>"
|
|
||||||
# html += "<td class='artists'>" + artistLinks(s["artists"]) + "</td>"
|
|
||||||
# html += "<td class='title'>" + trackLink({"artists":s["artists"],"title":s["title"]}) + "</td>"
|
|
||||||
# html += "</tr>"
|
|
||||||
# html += "</table>"
|
|
||||||
|
|
||||||
html_scrobbles, _, _ = module_scrobblelist(track=track,max_=100)
|
html_scrobbles, _, _ = module_scrobblelist(track=track,max_=100)
|
||||||
|
|
||||||
# pulse
|
|
||||||
# response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/pulse?step=year&trail=1&" + keysToUrl(limitkeys))
|
|
||||||
# db_data = json.loads(response.read())
|
|
||||||
# terms = db_data["list"]
|
|
||||||
|
|
||||||
# build list
|
|
||||||
# maxbar = max([t["scrobbles"] for t in terms])
|
|
||||||
|
|
||||||
# html_pulse = "<table class='list'>"
|
|
||||||
# for t in terms:
|
|
||||||
# fromstr = "/".join([str(e) for e in t["from"]])
|
|
||||||
# tostr = "/".join([str(e) for e in t["to"]])
|
|
||||||
# html_pulse += "<tr>"
|
|
||||||
# #html += "<td>" + fromstr + "</td>"
|
|
||||||
# #html += "<td>" + tostr + "</td>"
|
|
||||||
# html_pulse += "<td>" + getRangeDesc(t["from"],t["to"]) + "</td>"
|
|
||||||
# html_pulse += "<td class='amount'>" + scrobblesLink({"since":fromstr,"to":tostr},amount=t["scrobbles"],track=trackobject) + "</td>"
|
|
||||||
# html_pulse += "<td class='bar'>" + scrobblesLink({"since":fromstr,"to":tostr},percent=t["scrobbles"]*100/maxbar,track=trackobject) + "</td>"
|
|
||||||
# html_pulse += "</tr>"
|
|
||||||
# html_pulse += "</table>"
|
|
||||||
|
|
||||||
html_pulse = module_pulse(track=track,step="year",stepn=1,trail=1)
|
html_pulse = module_pulse(track=track,step="year",stepn=1,trail=1)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user