diff --git a/maloja/database.py b/maloja/database.py index 608da89..c3dec71 100644 --- a/maloja/database.py +++ b/maloja/database.py @@ -829,6 +829,53 @@ def issues(): return {"duplicates":duplicates,"combined":combined,"newartists":newartists,"inconsistent":inconsistent} +def get_predefined_rulesets(): + validchars = "-_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" + + rulesets = [] + + for f in os.listdir(datadir("rules/predefined")): + if f.endswith(".tsv"): + + rawf = f.replace(".tsv","") + valid = True + for char in rawf: + if char not in validchars: + valid = False + break # don't even show up invalid filenames + + if not valid: continue + if not "_" in rawf: continue + + try: + with open(datadir("rules/predefined",f)) as tsvfile: + line1 = tsvfile.readline() + line2 = tsvfile.readline() + + if "# NAME: " in line1: + name = line1.replace("# NAME: ","") + else: name = rawf.split("_")[1] + if "# DESC: " in line2: + desc = line2.replace("# DESC: ","") + else: desc = "" + + author = rawf.split("_")[0] + except: + continue + + ruleset = {"file":rawf} + rulesets.append(ruleset) + if os.path.exists(datadir("rules",f)): + ruleset["active"] = True + else: + ruleset["active"] = False + + ruleset["name"] = name + ruleset["author"] = author + ruleset["desc"] = desc + + return rulesets + @dbserver.post("importrules") def import_rulemodule(**keys): apikey = keys.pop("key",None) diff --git a/maloja/web/jinja/setup.jinja b/maloja/web/jinja/setup.jinja new file mode 100644 index 0000000..5fd88fe --- /dev/null +++ b/maloja/web/jinja/setup.jinja @@ -0,0 +1,140 @@ +{% extends "base.jinja" %} +{% block title %}Maloja - Setup{% endblock %} + +{% block scripts %} + + + +{% endblock %} + +{% set rulesets = dbp.get_predefined_rulesets() %} + +{% block content %} + + +
+ + | +
+ Maloja+ + Welcome to your own Maloja server! + |
+
artist | Artist String |
title | Title String |
key | API Key |
seconds | Duration of Scrobble - optional and currently not used |
+ | Module | +Author | +Description | +|
---|---|---|---|---|
Remove: | + {% else %} +Add: | + {% endif %} +{{ rs.name }} | +{{ rs.author }} | +{{ rs.desc }} | +
- - | -
- Maloja- - Welcome to your own Maloja server! - |
-
artist | Artist String |
title | Title String |
key | API Key |
seconds | Duration of Scrobble - optional and currently not used |
Module | Author | Description | ||
---|---|---|---|---|
Remove: | " - else: - html += "Add: | " - html += "" + name + " | " - html += "" + author + " | " - html += "" + desc + " | " - - html += "