1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-24 03:54:20 +00:00

Finito il tabellone delle quest (closes #20)

This commit is contained in:
Steffo 2019-01-06 21:04:03 +01:00
parent 19e986664b
commit f6663a7227
7 changed files with 112 additions and 10 deletions

14
db.py
View file

@ -1036,6 +1036,20 @@ class ActivityReport(Base):
return f"<ActivityReport at {self.timestamp.isoformat()}>" 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 run as script, create all the tables in the db
if __name__ == "__main__": if __name__ == "__main__":
print("Creating new tables...") print("Creating new tables...")

View file

@ -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 { #debug-mode {
color: red; color: red;
font-weight: bold; font-weight: bold;

View file

@ -1,5 +1,4 @@
<div class="box"> <div class="box">
{% if next_events %}
<div class="upper-box"> <div class="upper-box">
Prossimi eventi Prossimi eventi
</div> </div>
@ -8,5 +7,4 @@
{% include "components/event.html" %} {% include "components/event.html" %}
{% endfor %} {% endfor %}
</div> </div>
{% endif %}
</div> </div>

View 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>

View file

@ -3,8 +3,12 @@
Tabellone delle quest Tabellone delle quest
</div> </div>
<div class="lower-box"> <div class="lower-box">
<div class="quest"> {% if quests %}
{% for quest in quests %}
</div> {% include "components/quest.html" %}
{% endfor %}
{% else %}
<i>Non ci sono quest al momento.</i>
{% endif %}
</div> </div>
</div> </div>

View file

@ -18,10 +18,14 @@
{% include "components/welcome.html" %} {% include "components/welcome.html" %}
{% endif %} {% endif %}
{% if g.logged_in %} {% if g.logged_in %}
{% if events %}
{% include "components/eventlist.html" %} {% include "components/eventlist.html" %}
{% include "components/diariooftheday.html" %} {% endif %}
{% endif %} {% endif %}
{% include "components/memberbox.html" %} {% include "components/memberbox.html" %}
{% if g.logged_in %}
{% include "components/wikibox.html" %}
{% endif %}
</div> </div>
<div class="right"> <div class="right">
{% if not g.logged_in %} {% if not g.logged_in %}
@ -29,11 +33,11 @@
{% endif %} {% endif %}
{% if g.logged_in %} {% if g.logged_in %}
{% include "components/questboard.html" %} {% include "components/questboard.html" %}
{% include "components/links.html" %}
{% endif %} {% endif %}
{% include "components/gamestatsbox.html" %} {% include "components/gamestatsbox.html" %}
{% if g.logged_in %} {% if g.logged_in %}
{% include "components/wikibox.html" %} {% include "components/links.html" %}
{% include "components/diariooftheday.html" %}
{% endif %} {% endif %}
</div> </div>
</div> </div>

View file

@ -29,6 +29,28 @@ telegram_bot = telegram.Bot(config["Telegram"]["bot_token"])
sentry = Sentry(app, dsn=config["Sentry"]["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("<", "&lt;"),
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&amp;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) @app.errorhandler(400)
def error_400(_=None): def error_400(_=None):
return render_template("400.html", g=fl_g) 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( next_events = db_session.query(db.Event).filter(db.Event.time > datetime.datetime.now()).order_by(
db.Event.time).all() db.Event.time).all()
halloween = db.Halloween.puzzle_status()[1] halloween = db.Halloween.puzzle_status()[1]
quests = db_session.query(db.Quest).all()
db_session.close() db_session.close()
return render_template("main.html", royals=royals, wiki_pages=wiki_pages, entry=random_diario, 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>") @app.route("/profile/<name>")