1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Expanded compare feature slightly

This commit is contained in:
Krateng 2019-06-18 13:24:20 +02:00
parent 8a80c265cd
commit a59381d0bf
2 changed files with 25 additions and 8 deletions

View File

@ -22,16 +22,18 @@
table tr td:first-child { table tr td:first-child {
text-align: left; text-align: left;
padding:20px; padding:10px;
width:33%;
} }
table tr td { table tr td {
text-align: center; text-align: center;
padding:20px; padding:10px;
} }
table tr td:last-child { table tr td:last-child {
text-align: right; text-align: right;
padding:20px; padding:10px;
width:33%;
} }
</style> </style>
</head> </head>
@ -41,8 +43,10 @@
<tr> <tr>
<td><h1>KEY_NAME_SELF</h1></td> <td><h1>KEY_NAME_SELF</h1></td>
<td> <td>
<div class="comparecircle"> <div class="comparecircle">
KEY_MATCH% KEY_MATCH%
</div> </div>
</td> </td>
<td><h1>KEY_NAME_OTHER</h1></td> <td><h1>KEY_NAME_OTHER</h1></td>
@ -50,12 +54,21 @@
</tr> </tr>
<tr> <tr>
<td></td> <td></td>
<td style="font-size:70%"> <td style="font-size:70%;color:grey;">
The size of the circle shows matching music taste. The size of the circle shows matching music taste.
The fuzziness of its border indicates differences in quantity. The fuzziness of its border indicates differences in quantity.
</td> </td>
<td></td> <td></td>
</tr> </tr>
<tr>
<td></td>
<td>
<span>Common Favorite</span>
<h2 style="margin:7px;">KEY_BESTARTIST_LINK</h2>
<img src="KEY_BESTARTIST_IMAGE" style="width:80px;" />
</td>
<td></td>
</tr>
</table> </table>

View File

@ -1,6 +1,9 @@
import urllib import urllib
import database import database
import json import json
from htmlgenerators import artistLink
from utilities import getArtistImage
def instructions(keys): def instructions(keys):
@ -27,9 +30,7 @@ def instructions(keys):
artists[a]["other"] -= common artists[a]["other"] -= common
artists[a]["common"] = common artists[a]["common"] = common
best = sorted((a for a in artists),key=lambda x: artists[x.lower()]["common"],reverse=True) best = sorted((artists[a]["name"] for a in artists),key=lambda x: artists[x.lower()]["common"],reverse=True)
result = { result = {
"unique_self":sum(artists[a]["self"] for a in artists if artists[a]["common"] == 0), "unique_self":sum(artists[a]["self"] for a in artists if artists[a]["common"] == 0),
@ -67,7 +68,8 @@ def instructions(keys):
pixel_fullmatch = fullmatch * 2.5 pixel_fullmatch = fullmatch * 2.5
pixel_partialmatch = (fullmatch+partialmatch) * 2.5 pixel_partialmatch = (fullmatch+partialmatch) * 2.5
matchcolor = format(int(min(1,match/50)*255),"x") * 2 + format(int(max(0,match/50-1)*255),"x") matchcolor = format(int(min(1,match/50)*255),"02x") * 2 + format(int(max(0,match/50-1)*255),"02x")
return { return {
"KEY_CIRCLE_CSS":",".join(css), "KEY_CIRCLE_CSS":",".join(css),
@ -77,4 +79,6 @@ def instructions(keys):
"KEY_PARTIALMATCH":str(int(pixel_partialmatch)), "KEY_PARTIALMATCH":str(int(pixel_partialmatch)),
"KEY_NAME_SELF":owninfo["name"], "KEY_NAME_SELF":owninfo["name"],
"KEY_NAME_OTHER":strangerinfo["name"], "KEY_NAME_OTHER":strangerinfo["name"],
"KEY_BESTARTIST_LINK":artistLink(best[0]),
"KEY_BESTARTIST_IMAGE":getArtistImage(best[0])
},[] },[]