Server-side less compilation

This commit is contained in:
Krateng 2019-10-11 05:17:15 +02:00
parent f4a3fff848
commit 2170350315
7 changed files with 70 additions and 10 deletions

1
.gitignore vendored
View File

@ -10,6 +10,7 @@ nohup.out
*.tsv
*.rulestate
*.log
*.css
# currently not using
/screenshot*.png

View File

@ -4,3 +4,4 @@ doreah>=1.0
nimrodel>=0.4.9
setproctitle>=1.1.10
wand>=0.5.4
lesscpy>=0.13

View File

@ -31,6 +31,16 @@ HOST = settings.get_settings("HOST")
webserver = Bottle()
import lesscpy
css = ""
for f in os.listdir("website/less"):
css += lesscpy.compile("website/less/" + f)
os.makedirs("website/css",exist_ok=True)
with open("website/css/style.css","w") as f:
f.write(css)
@webserver.route("")
@webserver.route("/")
def mainpage():
@ -128,7 +138,7 @@ def static(name):
@webserver.route("/<name>")
def static_html(name):
linkheaders = ["</css/maloja.css>; rel=preload; as=style"]
linkheaders = ["</css/style.css>; rel=preload; as=style"]
keys = remove_identical(FormsDict.decode(request.query))
with open("website/" + name + ".html") as htmlfile:

View File

@ -1,8 +1,9 @@
<meta name="description" content='Maloja is a self-hosted music scrobble server.' />
<link rel="stylesheet/less" href="/less/maloja.less" />
<!--<link rel="stylesheet/less" href="/less/maloja.less" />
<link rel="stylesheet/less" href="/less/grisons.less" />
<!--
<link rel="stylesheet" href="/css/maloja.css" />
<link rel="stylesheet" href="/css/grisons.css" /> -->
<script src="//cdnjs.cloudflare.com/ajax/libs/less.js/3.9.0/less.min.js" ></script>
<link rel="stylesheet" href="/css/grisons.css" />
<script src="//cdnjs.cloudflare.com/ajax/libs/less.js/3.9.0/less.min.js" ></script> -->
<link rel="stylesheet" href="/css/style.css" />
<script src="/javascript/search.js" async></script>

View File

@ -4,7 +4,7 @@
@BASE_COLOR: #333337;
@BASE_COLOR_DARK: rgba(10,10,10,1);
@BASE_COLOR_DARK: #0a0a0a;
@BASE_COLOR_LIGHT: #444447;
@TEXT_COLOR: beige;
@ -23,7 +23,9 @@
@BUTTON_FOCUS_FG_COLOR: @BASE_COLOR;
@import url('https://fonts.googleapis.com/css?family=Ubuntu');
//@import url('https://fonts.googleapis.com/css?family=Ubuntu');
body {
background-color: @BASE_COLOR;
color: @TEXT_COLOR;

View File

@ -0,0 +1,45 @@
/* cyrillic-ext */
@font-face {
font-family: 'Ubuntu';
font-style: normal;
font-weight: 400;
src: local('Ubuntu Regular'), local('Ubuntu-Regular'), url(https://fonts.gstatic.com/s/ubuntu/v14/4iCs6KVjbNBYlgoKcg72j00.woff2) format('woff2');
}
/* cyrillic */
@font-face {
font-family: 'Ubuntu';
font-style: normal;
font-weight: 400;
src: local('Ubuntu Regular'), local('Ubuntu-Regular'), url(https://fonts.gstatic.com/s/ubuntu/v14/4iCs6KVjbNBYlgoKew72j00.woff2) format('woff2');
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* greek-ext */
@font-face {
font-family: 'Ubuntu';
font-style: normal;
font-weight: 400;
src: local('Ubuntu Regular'), local('Ubuntu-Regular'), url(https://fonts.gstatic.com/s/ubuntu/v14/4iCs6KVjbNBYlgoKcw72j00.woff2) format('woff2');
unicode-range: U+1F00-1FFF;
}
/* greek */
@font-face {
font-family: 'Ubuntu';
font-style: normal;
font-weight: 400;
src: local('Ubuntu Regular'), local('Ubuntu-Regular'), url(https://fonts.gstatic.com/s/ubuntu/v14/4iCs6KVjbNBYlgoKfA72j00.woff2) format('woff2');
unicode-range: U+0370-03FF;
}
/* latin-ext */
@font-face {
font-family: 'Ubuntu';
font-style: normal;
font-weight: 400;
src: local('Ubuntu Regular'), local('Ubuntu-Regular'), url(https://fonts.gstatic.com/s/ubuntu/v14/4iCs6KVjbNBYlgoKcQ72j00.woff2) format('woff2');
}
/* latin */
@font-face {
font-family: 'Ubuntu';
font-style: normal;
font-weight: 400;
src: local('Ubuntu Regular'), local('Ubuntu-Regular'), url(https://fonts.gstatic.com/s/ubuntu/v14/4iCs6KVjbNBYlgoKfw72.woff2) format('woff2');
}

View File

@ -1,4 +1,4 @@
@import "grisons";
@import "website/less/grisons";
body {
padding:15px;
@ -61,7 +61,7 @@ div.footer {
position:fixed;
height:20px;
/**width:100%;**/
background-color:fadeout(@BASE_COLOR_DARK,10%);
background-color:@BASE_COLOR_DARK;
bottom:0px;
left:0px;
right:0px;
@ -170,7 +170,7 @@ div.searchresults table.searchresults_tracks td span:nth-child(1) {
position:fixed;
/*height:30px;*/
/**width:100%;**/
background-color:fadeout(@BASE_COLOR_DARK,10%);
background-color:@BASE_COLOR_DARK;
bottom:0px;
left:0px;
right:0px;