Compare commits
11 Commits
91e17be830
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
db87fdcca5
|
|||
|
e5c7d0c852
|
|||
|
d0e9d6913d
|
|||
|
c03ebbf853
|
|||
|
24a9683608
|
|||
|
c7d484fa9a
|
|||
|
74655cc762
|
|||
|
1bae00ea47
|
|||
|
182d0c0c86
|
|||
|
b459f5f4b1
|
|||
|
6c1b479bd5
|
@@ -1,2 +1,4 @@
|
|||||||
.git/
|
.git/
|
||||||
db-importer/
|
db-importer/
|
||||||
|
# poetry
|
||||||
|
poetry.lock
|
||||||
|
|||||||
@@ -28,11 +28,15 @@ def main():
|
|||||||
if obj_type not in collections:
|
if obj_type not in collections:
|
||||||
collections[obj_type] = []
|
collections[obj_type] = []
|
||||||
collections[obj_type].append(obj)
|
collections[obj_type].append(obj)
|
||||||
print("Inserting all data")
|
# print("Inserting all data")
|
||||||
mongo[DB][COLLECTION].insert_many(items)
|
# mongo[DB][COLLECTION].insert_many(items)
|
||||||
|
with mongo.start_session() as s:
|
||||||
|
s.start_transaction()
|
||||||
|
mongo.drop_database(DB)
|
||||||
for collection in collections:
|
for collection in collections:
|
||||||
print(f"Inserting collection: {collection}")
|
print(f"Inserting collection: {collection}")
|
||||||
mongo[DB][collection].insert_many(collections[collection])
|
mongo[DB][collection].insert_many(collections[collection])
|
||||||
|
s.commit_transaction()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
@@ -5,10 +5,12 @@ RUN python3 -m pip install poetry
|
|||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY db_explorer/ /app/
|
COPY db_explorer/pyproject.toml /app/
|
||||||
|
|
||||||
RUN poetry update
|
RUN poetry update
|
||||||
RUN poetry run pip install setuptools
|
RUN poetry run pip install setuptools
|
||||||
|
|
||||||
|
COPY db_explorer/ /app/
|
||||||
|
|
||||||
ENTRYPOINT [ "poetry", "run" ]
|
ENTRYPOINT [ "poetry", "run" ]
|
||||||
CMD [ "gunicorn", "-b=0.0.0.0:5000", "db_explorer:app" ]
|
CMD [ "gunicorn", "-b=0.0.0.0:5000", "db_explorer:app" ]
|
||||||
@@ -17,10 +17,10 @@ with open("./db_explorer/en.json") as 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\[(?P<ref>[^\]]+)\]\{(?P<value>[^\}]+)\}")
|
||||||
def compendium_return(m):
|
def compendium_return(m):
|
||||||
# TODO: Actually add links
|
# TODO: Actually add links
|
||||||
return f"<a>{m.group(2)}</a>"
|
return f"<a>{m.group('value')}</a>"
|
||||||
macro_re = re.compile(r"\[\[\/\S*?r(?:oll)?\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:
|
||||||
@@ -54,6 +54,7 @@ def list_actions():
|
|||||||
@app.route("/action/<name>")
|
@app.route("/action/<name>")
|
||||||
def show_action(name):
|
def show_action(name):
|
||||||
item = mongo.db.action.find_one_or_404({"name": name})
|
item = mongo.db.action.find_one_or_404({"name": name})
|
||||||
|
# Actions
|
||||||
if item["data"]["actions"]["value"] == None:
|
if item["data"]["actions"]["value"] == None:
|
||||||
if item["data"]["actionType"]["value"] == 'passive':
|
if item["data"]["actionType"]["value"] == 'passive':
|
||||||
item['_action_icon'] = None
|
item['_action_icon'] = None
|
||||||
@@ -67,7 +68,13 @@ def show_action(name):
|
|||||||
item['_action_icon'] = item["data"]["actions"]["value"]
|
item['_action_icon'] = item["data"]["actions"]["value"]
|
||||||
else:
|
else:
|
||||||
raise ValueError(f'Unknown action: {item["data"]["actionType"]["value"]} - {item["data"]["actions"]["value"]}')
|
raise ValueError(f'Unknown action: {item["data"]["actionType"]["value"]} - {item["data"]["actions"]["value"]}')
|
||||||
|
# Traits
|
||||||
|
_traits = item.get("data", {}).get("traits", {})
|
||||||
|
item["_all_traits"] = []
|
||||||
|
item["_all_traits"].append(_traits.get("rarity", {}).get("value", "unkown rarity"))
|
||||||
|
item["_all_traits"] += _traits.get("value", [])
|
||||||
|
item["_all_traits"] += _traits.get("custom").split(',')
|
||||||
|
item["_all_traits"] = list(filter(lambda x: x != '', item["_all_traits"]))
|
||||||
return render_template("action.html", action=item)
|
return render_template("action.html", action=item)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
body {
|
||||||
|
background: #efece9;
|
||||||
|
}
|
||||||
|
|
||||||
.action-icon {
|
.action-icon {
|
||||||
height: 26px;
|
height: 26px;
|
||||||
@@ -8,3 +11,20 @@
|
|||||||
text-align: right;
|
text-align: right;
|
||||||
font-size: 0.8em;
|
font-size: 0.8em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ul.traits {
|
||||||
|
padding-left: 0em;
|
||||||
|
}
|
||||||
|
|
||||||
|
li.trait {
|
||||||
|
display: inline;
|
||||||
|
font-size: 0.9em;
|
||||||
|
font-variant: small-caps;
|
||||||
|
color: #fefefe;
|
||||||
|
background-color: #5e0000;
|
||||||
|
border-color: #d8ce83;
|
||||||
|
border-style: solid;
|
||||||
|
border-width: 2px;
|
||||||
|
padding: 0.1em 0.25em;
|
||||||
|
margin: 0 0;
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
{% block head %}
|
{% block head %}
|
||||||
<title>{% block title %}PF2 DB{% endblock %}</title>
|
<title>{% block title %}PF2 DB{% endblock %}</title>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/base.css') }}"
|
<link rel="stylesheet" href="{{ url_for('static', filename='css/base.css') }}">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
{% block body %}
|
{% block body %}
|
||||||
|
|||||||
@@ -2,6 +2,11 @@
|
|||||||
{% block title %}{{action.name}} - PF2 DB{% endblock %}
|
{% block title %}{{action.name}} - PF2 DB{% endblock %}
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<h1>{{action["name"]}}{{c.actions[action["_action_icon"]]|safe}}</h1>
|
<h1>{{action["name"]}}{{c.actions[action["_action_icon"]]|safe}}</h1>
|
||||||
<p>{{action["data"]["description"]["value"]|filter_vtt|safe}}</p>
|
<ul class="traits">
|
||||||
|
{%- for trait in action["_all_traits"] -%}
|
||||||
|
<li class="trait">{{trait|capitalize}}</li>
|
||||||
|
{%- endfor -%}
|
||||||
|
</ul>
|
||||||
|
{{action["data"]["description"]["value"]|filter_vtt|safe}}
|
||||||
<p class="sourcebook">{{action["data"]["source"]["value"]}}</p>
|
<p class="sourcebook">{{action["data"]["source"]["value"]}}</p>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user