mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Rudimentary start page
This commit is contained in:
parent
4edc352bcc
commit
562c796a92
@ -410,8 +410,9 @@ def post_scrobble():
|
|||||||
|
|
||||||
createScrobble(artists,title,time)
|
createScrobble(artists,title,time)
|
||||||
|
|
||||||
if (time - lastsync) > 3600:
|
#if (time - lastsync) > 3600:
|
||||||
sync()
|
# sync()
|
||||||
|
sync() #let's just always sync, not like one filesystem access every three minutes is a problem and it avoids lost tracks when we lose power
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
from bottle import Bottle, route, get, post, error, run, template, static_file, request, response, FormsDict
|
from bottle import Bottle, route, get, post, error, run, template, static_file, request, response, FormsDict, redirect, template
|
||||||
from importlib.machinery import SourceFileLoader
|
from importlib.machinery import SourceFileLoader
|
||||||
from htmlgenerators import removeIdentical
|
from htmlgenerators import removeIdentical
|
||||||
from utilities import *
|
from utilities import *
|
||||||
@ -23,7 +23,7 @@ webserver = Bottle()
|
|||||||
@webserver.route("")
|
@webserver.route("")
|
||||||
@webserver.route("/")
|
@webserver.route("/")
|
||||||
def mainpage():
|
def mainpage():
|
||||||
return static_file("main.html",root="")
|
return static_html("start")
|
||||||
|
|
||||||
|
|
||||||
# this is the fallback option. If you run this service behind a reverse proxy, it is recommended to rewrite /db/ requests to the port of the db server
|
# this is the fallback option. If you run this service behind a reverse proxy, it is recommended to rewrite /db/ requests to the port of the db server
|
||||||
|
@ -16,6 +16,13 @@ a:hover {
|
|||||||
text-decoration:underline;
|
text-decoration:underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** TOP INFO TABLE
|
||||||
|
**
|
||||||
|
**
|
||||||
|
*/
|
||||||
|
|
||||||
table.top_info td.image {
|
table.top_info td.image {
|
||||||
padding:20px;
|
padding:20px;
|
||||||
@ -48,11 +55,19 @@ p.desc a {
|
|||||||
background-image:url("https://www.last.fm/static/images/lastfm_avatar_twitter.66cd2c48ce03.png");
|
background-image:url("https://www.last.fm/static/images/lastfm_avatar_twitter.66cd2c48ce03.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
table.top_info td.text .stats {
|
**
|
||||||
color:grey;
|
**
|
||||||
}
|
** SPECIAL TEXT BITS
|
||||||
|
**
|
||||||
|
**
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.stats {
|
.stats {
|
||||||
color:grey;
|
color:grey;
|
||||||
}
|
}
|
||||||
@ -69,6 +84,20 @@ a {
|
|||||||
cursor:pointer;
|
cursor:pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** LISTS
|
||||||
|
**
|
||||||
|
**
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
table.list {
|
table.list {
|
||||||
border-collapse:collapse;
|
border-collapse:collapse;
|
||||||
}
|
}
|
||||||
@ -177,3 +206,62 @@ td.button.important div {
|
|||||||
background-color:red;
|
background-color:red;
|
||||||
color:white;
|
color:white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** IMAGE TILES
|
||||||
|
**
|
||||||
|
**
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
table.tiles_top td {
|
||||||
|
padding:0px;
|
||||||
|
border:0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.tiles_top, table.tiles_sub {
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
table.tiles_top>tbody>tr>td {
|
||||||
|
height:300px;
|
||||||
|
width:300px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.tiles_sub {
|
||||||
|
height:100%;
|
||||||
|
width:100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
table.tiles_top td div {
|
||||||
|
background-size:cover;
|
||||||
|
background-position:center;
|
||||||
|
height:100%;
|
||||||
|
width:100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.tiles_2x2 td {
|
||||||
|
height:50%;
|
||||||
|
width:50%;
|
||||||
|
font-size:90%
|
||||||
|
}
|
||||||
|
table.tiles_3x3 td {
|
||||||
|
height:33.333%;
|
||||||
|
width:33.333%;
|
||||||
|
font-size:70%
|
||||||
|
}
|
||||||
|
52
website/start.html
Normal file
52
website/start.html
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<title>Maloja</title>
|
||||||
|
<link rel="stylesheet" href="maloja.css" />
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<h1>Top Artists</h1>
|
||||||
|
<table class="tiles_top">
|
||||||
|
<tr>
|
||||||
|
<td><div style="background-image:url('KEY_ARTISTIMAGE')"><span class="stats">KEY_POSITION</span> KEY_ARTISTLINK</div></td>
|
||||||
|
<td>
|
||||||
|
<table class="tiles_2x2 tiles_sub">
|
||||||
|
<tr>
|
||||||
|
<td><div style="background-image:url('KEY_ARTISTIMAGE')"><span class="stats">KEY_POSITION</span> KEY_ARTISTLINK</div></td>
|
||||||
|
<td><div style="background-image:url('KEY_ARTISTIMAGE')"><span class="stats">KEY_POSITION</span> KEY_ARTISTLINK</div></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><div style="background-image:url('KEY_ARTISTIMAGE')"><span class="stats">KEY_POSITION</span> KEY_ARTISTLINK</div></td>
|
||||||
|
<td><div style="background-image:url('KEY_ARTISTIMAGE')"><span class="stats">KEY_POSITION</span> KEY_ARTISTLINK</div></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<table class="tiles_3x3 tiles_sub">
|
||||||
|
<tr>
|
||||||
|
<td><div style="background-image:url('KEY_ARTISTIMAGE')"><span class="stats">KEY_POSITION</span> KEY_ARTISTLINK</div></td>
|
||||||
|
<td><div style="background-image:url('KEY_ARTISTIMAGE')"><span class="stats">KEY_POSITION</span> KEY_ARTISTLINK</div></td>
|
||||||
|
<td><div style="background-image:url('KEY_ARTISTIMAGE')"><span class="stats">KEY_POSITION</span> KEY_ARTISTLINK</div></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><div style="background-image:url('KEY_ARTISTIMAGE')"><span class="stats">KEY_POSITION</span> KEY_ARTISTLINK</div></td>
|
||||||
|
<td><div style="background-image:url('KEY_ARTISTIMAGE')"><span class="stats">KEY_POSITION</span> KEY_ARTISTLINK</div></td>
|
||||||
|
<td><div style="background-image:url('KEY_ARTISTIMAGE')"><span class="stats">KEY_POSITION</span> KEY_ARTISTLINK</div></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><div style="background-image:url('KEY_ARTISTIMAGE')"><span class="stats">KEY_POSITION</span> KEY_ARTISTLINK</div></td>
|
||||||
|
<td><div style="background-image:url('KEY_ARTISTIMAGE')"><span class="stats">KEY_POSITION</span> KEY_ARTISTLINK</div></td>
|
||||||
|
<td><div style="background-image:url('KEY_ARTISTIMAGE')"><span class="stats">KEY_POSITION</span> KEY_ARTISTLINK</div></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
34
website/start.py
Normal file
34
website/start.py
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import urllib
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
def replacedict(keys,dbport):
|
||||||
|
from utilities import getArtistInfo, getArtistsInfo
|
||||||
|
from htmlgenerators import artistLink, artistLinks, trackLink, scrobblesArtistLink, keysToUrl, pickKeys, clean
|
||||||
|
|
||||||
|
clean(keys)
|
||||||
|
timekeys = pickKeys(keys,"since","to","in")
|
||||||
|
limitkeys = pickKeys(keys)
|
||||||
|
|
||||||
|
# get chart data
|
||||||
|
response = urllib.request.urlopen("http://localhost:" + str(dbport) + "/charts/artists?" + keysToUrl(timekeys,limitkeys))
|
||||||
|
db_data = json.loads(response.read())
|
||||||
|
charts = db_data["list"][:50]
|
||||||
|
topartist = charts[0]["artist"]
|
||||||
|
|
||||||
|
chartslist = [c["artist"] for c in charts]
|
||||||
|
#chartslistimg = [getArtistInfo(a).get("image") for a in chartslist]
|
||||||
|
chartslistimg = [info.get("image") for info in getArtistsInfo(chartslist)]
|
||||||
|
chartslistlink = [artistLink(a) for a in chartslist]
|
||||||
|
|
||||||
|
|
||||||
|
# get total amount of scrobbles
|
||||||
|
response = urllib.request.urlopen("http://localhost:" + str(dbport) + "/scrobbles?" + keysToUrl(timekeys,limitkeys))
|
||||||
|
db_data = json.loads(response.read())
|
||||||
|
scrobblelist = db_data["list"]
|
||||||
|
scrobbles = len(scrobblelist)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return {"KEY_ARTISTIMAGE":chartslistimg,"KEY_ARTISTNAME":chartslist,"KEY_ARTISTLINK":chartslistlink,"KEY_POSITION":["#" + str(i) for i in range(1,50)]}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user