mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
Finito il tabellone delle quest (closes #20)
This commit is contained in:
parent
19e986664b
commit
f6663a7227
7 changed files with 112 additions and 10 deletions
14
db.py
14
db.py
|
@ -1036,6 +1036,20 @@ class ActivityReport(Base):
|
|||
return f"<ActivityReport at {self.timestamp.isoformat()}>"
|
||||
|
||||
|
||||
class Quest(Base):
|
||||
__tablename__ = "quests"
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
|
||||
title = Column(String)
|
||||
description = Column(Text)
|
||||
reward = Column(Integer)
|
||||
expiration_date = Column(DateTime)
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Quest {self.id}: {self.title}>"
|
||||
|
||||
|
||||
# If run as script, create all the tables in the db
|
||||
if __name__ == "__main__":
|
||||
print("Creating new tables...")
|
||||
|
|
|
@ -974,6 +974,51 @@ ul {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
.quest {
|
||||
padding: 8px;
|
||||
color: @accent-color;
|
||||
font-family: "Verdana", sans-serif;
|
||||
background-image: url("/static/plank.jpg");
|
||||
display: grid;
|
||||
grid-template-columns: auto 64px;
|
||||
grid-row-gap: 2px;
|
||||
margin-bottom: 1px;
|
||||
margin-top: 1px;
|
||||
|
||||
.title {
|
||||
grid-row: 1;
|
||||
grid-column: 1;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.description {
|
||||
grid-row: 2;
|
||||
grid-column: 1;
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.reward {
|
||||
grid-row-start: 1;
|
||||
grid-row-end: 3;
|
||||
grid-column: 2;
|
||||
text-align: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
.number {
|
||||
font-size: xx-large;
|
||||
}
|
||||
|
||||
.subtext {
|
||||
font-size: smaller;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#debug-mode {
|
||||
color: red;
|
||||
font-weight: bold;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<div class="box">
|
||||
{% if next_events %}
|
||||
<div class="upper-box">
|
||||
Prossimi eventi
|
||||
</div>
|
||||
|
@ -8,5 +7,4 @@
|
|||
{% include "components/event.html" %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
14
templates/components/quest.html
Normal file
14
templates/components/quest.html
Normal file
|
@ -0,0 +1,14 @@
|
|||
<div class="quest">
|
||||
<div class="title">
|
||||
{{ quest.title }}
|
||||
</div>
|
||||
<div class="description">
|
||||
{{ quest.description | markdown }}
|
||||
</div>
|
||||
<div class="reward">
|
||||
{% if quest.reward %}
|
||||
<div class="number">{{ quest.reward }}</div>
|
||||
<div class="subtext">fioryg{% if quest.reward != 1 %}i{% endif %}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
|
@ -3,8 +3,12 @@
|
|||
Tabellone delle quest
|
||||
</div>
|
||||
<div class="lower-box">
|
||||
<div class="quest">
|
||||
|
||||
</div>
|
||||
{% if quests %}
|
||||
{% for quest in quests %}
|
||||
{% include "components/quest.html" %}
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<i>Non ci sono quest al momento.</i>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
|
@ -18,10 +18,14 @@
|
|||
{% include "components/welcome.html" %}
|
||||
{% endif %}
|
||||
{% if g.logged_in %}
|
||||
{% if events %}
|
||||
{% include "components/eventlist.html" %}
|
||||
{% include "components/diariooftheday.html" %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% include "components/memberbox.html" %}
|
||||
{% if g.logged_in %}
|
||||
{% include "components/wikibox.html" %}
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="right">
|
||||
{% if not g.logged_in %}
|
||||
|
@ -29,11 +33,11 @@
|
|||
{% endif %}
|
||||
{% if g.logged_in %}
|
||||
{% include "components/questboard.html" %}
|
||||
{% include "components/links.html" %}
|
||||
{% endif %}
|
||||
{% include "components/gamestatsbox.html" %}
|
||||
{% if g.logged_in %}
|
||||
{% include "components/wikibox.html" %}
|
||||
{% include "components/links.html" %}
|
||||
{% include "components/diariooftheday.html" %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
|
25
webserver.py
25
webserver.py
|
@ -29,6 +29,28 @@ telegram_bot = telegram.Bot(config["Telegram"]["bot_token"])
|
|||
sentry = Sentry(app, dsn=config["Sentry"]["token"])
|
||||
|
||||
|
||||
@app.template_filter()
|
||||
def markdown(text):
|
||||
"""Convert a string to markdown."""
|
||||
converted_md = markdown2.markdown(text.replace("<", "<"),
|
||||
extras=["spoiler", "tables", "smarty-pants", "fenced-code-blocks"])
|
||||
converted_md = re.sub(r"{https?://(?:www\.)?(?:youtube\.com/watch\?.*?&?v=|youtu.be/)([0-9A-Za-z-]+).*?}",
|
||||
r'<div class="youtube-embed">'
|
||||
r' <iframe src="https://www.youtube-nocookie.com/embed/\1?rel=0&showinfo=0"'
|
||||
r' frameborder="0"'
|
||||
r' allow="autoplay; encrypted-media"'
|
||||
r' allowfullscreen'
|
||||
r' width="640px"'
|
||||
r' height="320px">'
|
||||
r' </iframe>'
|
||||
r'</div>', converted_md)
|
||||
converted_md = re.sub(r"{https?://clyp.it/([a-z0-9]+)}",
|
||||
r'<div class="clyp-embed">'
|
||||
r' <iframe width="100%" height="160" src="https://clyp.it/\1/widget" frameborder="0">'
|
||||
r' </iframe>'
|
||||
r'</div>', converted_md)
|
||||
return Markup(converted_md)
|
||||
|
||||
@app.errorhandler(400)
|
||||
def error_400(_=None):
|
||||
return render_template("400.html", g=fl_g)
|
||||
|
@ -68,9 +90,10 @@ def page_main():
|
|||
next_events = db_session.query(db.Event).filter(db.Event.time > datetime.datetime.now()).order_by(
|
||||
db.Event.time).all()
|
||||
halloween = db.Halloween.puzzle_status()[1]
|
||||
quests = db_session.query(db.Quest).all()
|
||||
db_session.close()
|
||||
return render_template("main.html", royals=royals, wiki_pages=wiki_pages, entry=random_diario,
|
||||
events=next_events, g=fl_g, escape=escape, halloween=enumerate(halloween))
|
||||
events=next_events, g=fl_g, escape=escape, quests=quests, halloween=enumerate(halloween))
|
||||
|
||||
|
||||
@app.route("/profile/<name>")
|
||||
|
|
Loading…
Reference in a new issue