1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

Add profile module

This commit is contained in:
Steffo 2019-07-06 18:49:56 +03:00
parent d2fa6dab58
commit a5c011ea7e
13 changed files with 166 additions and 15 deletions

View file

@ -8,7 +8,8 @@ class TestConfig:
TG_AK = os.environ["TG_AK"]
app = create_app(TestConfig, [rp_home, rp_wikiview, rp_tglogin, rp_docs, rp_wikiedit, rp_mcstatus, rp_diarioview])
app = create_app(TestConfig, [rp_home, rp_wikiview, rp_tglogin, rp_docs, rp_wikiedit, rp_mcstatus, rp_diarioview,
rp_profile])
if __name__ == "__main__":

View file

@ -7,5 +7,6 @@ from .docs import rp as rp_docs
from .wikiedit import rp as rp_wikiedit
from .mcstatus import rp as rp_mcstatus
from .diarioview import rp as rp_diarioview
from .profile import rp as rp_profile
__all__ = ["rp_home", "rp_wikiview", "rp_tglogin", "rp_docs", "rp_wikiedit", "rp_mcstatus", "rp_diarioview"]
__all__ = ["rp_home", "rp_wikiview", "rp_tglogin", "rp_docs", "rp_wikiedit", "rp_mcstatus", "rp_diarioview", "rp_profile"]

View file

@ -23,7 +23,7 @@
<div class="diario-quote">
{% if entry.quoted_account %}
<abbr title="{{ entry.quoted_account.username }}" class="diario-quoted">{{ entry.quoted }}</abbr>
<a href="{{ url_for("profile.profile_by_username", username=entry.quoted_account.username) }}" class="diario-quoted">{{ entry.quoted }}</a>
{% else %}
<span class="diario-quoted">{{ entry.quoted }}</span>
{% endif %}
@ -33,7 +33,7 @@
</div>
{% endif %}
{% if entry.creator %}
<div class="diario-created">Salvato da <span class="diario-creator">{{ entry.creator.username }}</span></div>
<div class="diario-created">Salvato da <a href="{{ url_for("profile.profile_by_username", username=entry.creator.username) }}" class="diario-creator">{{ entry.creator.username }}</a></div>
{% endif %}
<time class="diario-timestamp" datetime="{{ entry.timestamp.isoformat() }}">{{ entry.timestamp.strftime("%d %b %Y %H:%M:%S") }}</time>
<span class="diario-id">#{{ entry.diario_id }}</span>

View file

@ -10,7 +10,9 @@
<span class="left">Under construction</span>
</div>
<div class="bot">
Lentamente, su questo sito stanno apparendo nuove features. Come il <a href="{{ url_for("diarioview.diarioview_page", page=1) }}">diario</a>!
<p>
Lentamente, su questo sito stanno apparendo nuove features. Come il <a href="{{ url_for("diarioview.diarioview_page", page=1) }}">diario</a> e i <a href="{{ url_for("profile.profile_index") }}">profili</a>!
</p>
</div>
</div>
{% endblock %}

View file

@ -7,7 +7,7 @@
{% block content %}
<div class="doublebox">
<div class="top">
<span class="left">Minecraft Status</span>
<span class="left">Minecraft Server Status</span>
</div>
<div class="bot">
<div class="mcstatus-grid">

View file

@ -0,0 +1,29 @@
"""The profile page :py:class:`royalnet.web.Royalprint` for Royalnet members."""
import flask as f
import os
from ... import Royalprint
from ....database.tables import *
# Maybe some of these tables are optional...
tmpl_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates')
rp = Royalprint("profile", __name__, url_prefix="/profile", template_folder=tmpl_dir,
required_tables={Royal, ActiveKvGroup, Alias, Diario, Discord, Keygroup, Keyvalue, Telegram, WikiPage,
WikiRevision})
@rp.route("/")
def profile_index():
alchemy, alchemy_session = f.current_app.config["ALCHEMY"], f.current_app.config["ALCHEMY_SESSION"]
royals = alchemy_session.query(alchemy.Royal).order_by(alchemy.Royal.username).all()
return f.render_template("profile_index.html", royals=royals)
@rp.route("/<username>")
def profile_by_username(username):
alchemy, alchemy_session = f.current_app.config["ALCHEMY"], f.current_app.config["ALCHEMY_SESSION"]
royal = alchemy_session.query(alchemy.Royal).filter_by(username=username).one_or_none()
if royal is None:
return "No such user", 404
return f.render_template("profile_page.html", royal=royal)

View file

@ -0,0 +1,22 @@
{% extends "base.html" %}
{% block title %}
Indice RYGwiki
{% endblock %}
{% block content %}
<div class="doublebox">
<div class="top">
<span class="left">
Elenco Membri
</span>
</div>
<div class="bot">
<ul>
{% for royal in royals %}
<li><a href="{{ url_for("profile.profile_by_username", username=royal.username) }}">{{ royal.username }}</a></li>
{% endfor %}
</ul>
</div>
</div>
{% endblock %}

View file

@ -0,0 +1,66 @@
{% extends "base.html" %}
{% block title %}
{{ royal.username }} - Profilo RYG
{% endblock %}
{% block content %}
<div class="profile">
<h1>
{{ royal.username }}
</h1>
<div class="doublebox profile-links">
<div class="top">
<span class="left">Account collegati</span>
</div>
<div class="bot">
<ul class="links-list">
<li><span class="links-item links-linked">royalnet:{{ royal.username }}</span></li>
{% for telegram in royal.telegram %}
{% if telegram.username %}
<li><a class="links-item links-linked" href="https://t.me/{{ telegram.username }}">telegram:{{ telegram.mention() }}</a></li>
{% else %}
<li><span class="links-item links-linked">telegram:{{ telegram.mention() }}</span></li>
{% endif %}
{% else %}
<li><span class="links-item links-missing">Telegram non collegato</span></li>
{% endfor %}
{% for discord in royal.discord %}
<li><span class="links-item links-linked">discord:{{ discord.full_username() }}</span></li>
{% else %}
<li><span class="links-item links-missing">Discord non collegato</span></li>
{% endfor %}
</ul>
</div>
</div>
<div class="doublebox profile-stats">
<div class="top">
<span class="left">Statistiche</span>
</div>
<div class="bot">
<ul class="stats-list">
<li><span class="stats-info">Righe del diario create</span>: <span class="stats-value">{{ royal.diario_created|length }}</span></li>
<li><span class="stats-info">Righe del diario in cui è menzionato</span>: <span class="stats-value">{{ royal.diario_quoted|length }}</span></li>
<li><span class="stats-info">Modifiche alla wiki</span>: <span class="stats-value">{{ royal.wiki_contributions|length }}</span>
{% if royal.active_kv_group %}
<li><span class="stats-info">Kvgroup attivo</span>: <span class="stats-value">{{ royal.active_kv_group[0].group_name }}</span></li>
{% else %}
<li><span class="stats-info">Kvgroup attivo</span>: <span class="stats-value faded">Nessuno</span></li>
{% endif %}
</ul>
</div>
</div>
<div class="doublebox profile-aliases">
<div class="top">
<span class="left">Alias</span>
</div>
<div class="bot">
<ul class="alias-list">
{% for alias in royal.aliases %}
<li>{{ alias.alias|capitalize }}</li>
{% endfor %}
</ul>
</div>
</div>
</div>
{% endblock %}

View file

@ -13,7 +13,7 @@
<div class="doublebox">
<div class="top">
<span class="left">
Wiki Editor
Editor Wiki
</span>
</div>
<div class="bot">

View file

@ -8,7 +8,7 @@
<div class="doublebox">
<div class="top">
<span class="left">
Wiki Index
Pagine Wiki
</span>
</div>
<div class="bot">

View file

@ -642,14 +642,14 @@ button[disabled=""] {
}
.diario {
display: grid;
grid-template-columns: auto auto 8%;
grid-template-columns: auto auto 40px;
}
.diario .diario-content {
grid-row: 1;
grid-column-start: 1;
grid-column-end: 4;
}
.diario .diario-content .diario-img {
.diario .diario-content .diario-img img {
color: red;
margin-top: 2px;
margin-bottom: 2px;
@ -701,4 +701,12 @@ button[disabled=""] {
.diario.diario-spoiler:hover {
color: #ff7d7d;
}
/*# sourceMappingURL=ryg.css.map */
.profile .profile-links .links-linked {
font-family: "Consolas", "Source Code Pro", monospace;
}
.profile .profile-links .links-missing {
color: #ff7d7d;
}
.profile .profile-stats .stats-value {
font-weight: bold;
}

View file

@ -786,14 +786,14 @@ table {
.diario {
display: grid;
grid-template-columns: auto auto 8%;
grid-template-columns: auto auto 40px;
.diario-content {
grid-row: 1;
grid-column-start: 1;
grid-column-end: 4;
.diario-img {
.diario-img img {
color: red;
margin-top: 2px;
margin-bottom: 2px;
@ -855,3 +855,24 @@ table {
}
}
}
.profile {
.profile-links {
.links-linked {
font-family: @monospace-fonts;
}
.links-missing {
color: @pastel-red;
}
}
.profile-stats {
.stats-value {
font-weight: bold;
}
}
}

View file

@ -28,6 +28,7 @@
<span class="nav-modules">
<a class="no-icon" href="{{ url_for("wikiview.wikiview_index") }}">Wiki</a>
<a class="no-icon" href="{{ url_for("diarioview.diarioview_page", page=1) }}">Diario</a>
<a class="no-icon" href="{{ url_for("profile.profile_index") }}">Membri</a>
</span>
</div>
<div class="nav-center">
@ -35,14 +36,14 @@
<div class="nav-right">
<span>
{% if session["royal"] %}
<span class="nav-login">
<a href="{{ url_for("profile.profile_by_username", username=session["royal"]["username"]) }}" class="no-icon nav-profile">
<span class="nav-accountname">{{ session["royal"]["username"] }}</span>
{% if session["royal"]["avatar"] %}
<img class="nav-image" alt="" src="{{ session["royal"]["avatar"] }}">
{% else %}
<img class="nav-image" alt="" src="{{ url_for("static", filename="generic.png") }}">
{% endif %}
</span>
</a>
{% else %}
<span class="nav-login">
<a class="no-icon" href="{{ url_for("tglogin.tglogin_index") }}">