Compare commits
4 Commits
28f3d7e6cb
...
ec6a94f18e
Author | SHA1 | Date | |
---|---|---|---|
|
ec6a94f18e | ||
|
3982850dd3 | ||
|
9641173758 | ||
|
41a32accfd |
@ -1,4 +1,5 @@
|
|||||||
|
|
||||||
|
import json
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
@ -10,16 +11,32 @@ app = Flask(__name__)
|
|||||||
app.config["MONGO_URI"] = os.environ["MONGO_URI"]
|
app.config["MONGO_URI"] = os.environ["MONGO_URI"]
|
||||||
mongo = PyMongo(app)
|
mongo = PyMongo(app)
|
||||||
|
|
||||||
|
LOCALIZATION_JSON = {}
|
||||||
|
with open("./db_explorer/en.json") as f:
|
||||||
|
LOCALIZATION_JSON = json.load(f)
|
||||||
|
|
||||||
@app.template_filter('filter_vtt')
|
@app.template_filter('filter_vtt')
|
||||||
def filter_vtt(text):
|
def filter_vtt(text):
|
||||||
compendium_re = re.compile(r"@Compendium\[([^\]]+)\]\{([^\}]+)\}")
|
compendium_re = re.compile(r"@Compendium\[([^\]]+)\]\{([^\}]+)\}")
|
||||||
def compendium_return(m):
|
def compendium_return(m):
|
||||||
|
# TODO: Actually add links
|
||||||
return f"<a>{m.group(2)}</a>"
|
return f"<a>{m.group(2)}</a>"
|
||||||
macro_re = re.compile(r"\[\[\/\S?r\s(?:(?P<sdice>[^\{\] ]+)[^\{\]]*|(?:\{(?P<ldice>[^\}]+)\}\[[^\]]+\])?)\]\](?:\{(?P<alt>[^\}]+)\})?")
|
macro_re = re.compile(r"\[\[\/\S+?r(?:oll)?\s(?:(?P<sdice>[^\{\] ]+)[^\{\]]*|(?:\{(?P<ldice>[^\}]+)\}\[[^\]]+\])?)\]\](?:\{(?P<alt>[^\}]+)\})?")
|
||||||
def macro_return(m):
|
def macro_return(m):
|
||||||
if m.group('alt') is not None:
|
if m.group('alt') is not None:
|
||||||
return m.group('alt')
|
return m.group('alt')
|
||||||
return m.group('sdice')
|
return m.group('sdice')
|
||||||
|
localize_re = re.compile(r"@Localize\[([^\]]+)\]")
|
||||||
|
def localize_return(m):
|
||||||
|
path = m.group(1)
|
||||||
|
output = LOCALIZATION_JSON
|
||||||
|
for chunk in path.split('.'):
|
||||||
|
output = output.get(chunk, {})
|
||||||
|
if type(output) != str:
|
||||||
|
output = f"[LOCALIZATION LOOKUP ERROR - {m.group(0)}]"
|
||||||
|
return output
|
||||||
|
# Template
|
||||||
|
text = localize_re.sub(localize_return, text) # Has to be run before Compendium and Macro replacement
|
||||||
text = compendium_re.sub(compendium_return, text)
|
text = compendium_re.sub(compendium_return, text)
|
||||||
text = macro_re.sub(macro_return, text)
|
text = macro_re.sub(macro_return, text)
|
||||||
return text
|
return text
|
||||||
|
4563
db_explorer/db_explorer/en.json
Normal file
4563
db_explorer/db_explorer/en.json
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user