1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-27 13:34:28 +00:00

Complete diarioview

This commit is contained in:
Steffo 2019-07-06 01:31:02 +03:00
parent 715cd686a3
commit ebafe494e8
7 changed files with 213 additions and 65 deletions

View file

@ -1,6 +1,6 @@
import os import os
from .web import create_app from royalnet.web import create_app
from .web.royalprints import * from royalnet.web.royalprints import *
class TestConfig: class TestConfig:
@ -8,7 +8,7 @@ class TestConfig:
TG_AK = os.environ["TG_AK"] TG_AK = os.environ["TG_AK"]
app = create_app(TestConfig, [rp_home, rp_wikiview, rp_tglogin, rp_docs, rp_wikiedit, rp_mcstatus]) app = create_app(TestConfig, [rp_home, rp_wikiview, rp_tglogin, rp_docs, rp_wikiedit, rp_mcstatus, rp_diarioview])
if __name__ == "__main__": if __name__ == "__main__":

View file

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

View file

@ -3,16 +3,19 @@
import flask as f import flask as f
import os import os
from ... import Royalprint from ... import Royalprint
from ....database.tables import Royal, WikiPage, WikiRevision from ....database.tables import Royal, Diario
tmpl_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates') tmpl_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates')
rp = Royalprint("diarioview", __name__, url_prefix="/diarioview", template_folder=tmpl_dir, rp = Royalprint("diarioview", __name__, url_prefix="/diarioview", template_folder=tmpl_dir,
required_tables={Royal, WikiPage, WikiRevision}) required_tables={Royal, Diario})
@rp.route("/", defaults={"page": 0}) @rp.route("/", defaults={"page": 1})
@rp.route("/<int:page>") @rp.route("/<int:page>")
def diarioview_index(page): def diarioview_index(page):
alchemy, alchemy_session = f.current_app.config["ALCHEMY"], f.current_app.config["ALCHEMY_SESSION"] alchemy, alchemy_session = f.current_app.config["ALCHEMY"], f.current_app.config["ALCHEMY_SESSION"]
return "TODO" if page < 1:
return "Page should be >1", 404
entries = alchemy_session.query(alchemy.Diario).order_by(alchemy.Diario.diario_id.desc()).offset((page - 1) * 1000).limit(1000).all()
return f.render_template("diarioview_page.html", page=page, entries=entries)

View file

@ -0,0 +1,40 @@
{% extends "base.html" %}
{% block title %}
Pagina {{ page }} - Diario RYG
{% endblock %}
{% block content %}
<div class="diarioview">
{% for entry in entries %}
<blockquote id="diario-{{ entry.diario_id }}" class="diario{% if entry.spoiler %} diario-spoiler{% endif %}">
<div class="diario-content">
{% if entry.media_url %}
<img class="diario-img" src="{{ entry.media_url }}" alt="Caricamento immagine fallito">
{% endif %}
{% if entry.text %}
"<span class="diario-text">{{ entry.text }}</span>"
{% endif %}
</div>
{% if entry.quoted %}
<div class="diario-quote">
{% if entry.quoted_account %}
<abbr title="{{ entry.quoted_account.username }}" class="diario-quoted">{{ entry.quoted }}</abbr>
{% else %}
<span class="diario-quoted">{{ entry.quoted }}</span>
{% endif %}
{% if entry.context %}
, <span class="diario-context">{{ entry.context }}</span>
{% endif %}
</div>
{% endif %}
{% if entry.creator %}
<div class="diario-created">Salvato da <span class="diario-creator">{{ entry.creator.username }}</span></div>
{% endif %}
<time class="diario-timestamp" datetime="{{ entry.timestamp.isoformat() }}">{{ entry.timestamp.strftime("%d %b %Y %H:%M:%S") }}</time>
<a class="diario-id no-icon" href="#diario-{{ entry.diario_id }}">#{{ entry.diario_id }}</a>
</blockquote>
{% endfor %}
</div>
{% endblock %}

View file

@ -127,16 +127,33 @@ h6 {
margin-bottom: 0; margin-bottom: 0;
font-weight: normal; font-weight: normal;
} }
pre {
color: lightgray;
border: 1px solid rgba(160, 204, 255, 0.1);
background-color: rgba(160, 204, 255, 0.1);
padding: 2px 4px 2px 8px;
margin: 8px;
}
code { code {
font-family: "Consolas", "Source Code Pro", monospace; font-family: "Consolas", "Source Code Pro", monospace;
} }
blockquote { blockquote {
color: #a0ccff; color: #7dff7d;
border-left: 3px solid #a0ccff; border-left: 3px solid #7dff7d;
background-color: rgba(160, 204, 255, 0.1); background-color: rgba(125, 255, 125, 0.1);
padding: 2px 4px 2px 8px; padding: 2px 4px 2px 8px;
margin: 8px; margin: 8px;
} }
blockquote.spoiler {
color: transparent;
background-color: rgba(255, 125, 125, 0.1);
border: 1px solid rgba(255, 125, 125, 0.1);
border-radius: 2px;
padding: 4px;
}
blockquote.spoiler:hover {
color: #ff7d7d;
}
textarea { textarea {
background-color: rgba(160, 204, 255, 0.1); background-color: rgba(160, 204, 255, 0.1);
color: #a0ccff; color: #a0ccff;
@ -202,9 +219,6 @@ select option {
background-color: #293c61; background-color: #293c61;
color: #a0ccff; color: #a0ccff;
} }
pre {
margin: 0;
}
img { img {
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
@ -605,7 +619,6 @@ button[disabled=""] {
justify-self: end; justify-self: end;
grid-row: 2; grid-row: 2;
} }
.wikiview-doublebox .bot { .wikiview-doublebox .bot {
background-color: transparent; background-color: transparent;
border-top: 0; border-top: 0;
@ -627,26 +640,60 @@ button[disabled=""] {
margin-top: revert; margin-top: revert;
margin-bottom: revert; margin-bottom: revert;
} }
.wikiview-doublebox .bot blockquote { .diario {
color: #7dff7d; display: grid;
border-left: 3px solid #7dff7d; grid-template-columns: auto auto 8%;
background-color: rgba(125, 255, 125, 0.1);
} }
.wikiview-doublebox .bot blockquote.spoiler { .diario .diario-content {
grid-row: 1;
grid-column-start: 1;
grid-column-end: 4;
margin-top: 2px;
margin-bottom: 2px;
}
.diario .diario-content .diario-img {
color: red;
}
.diario .diario-quote {
grid-row: 2;
grid-column-start: 1;
grid-column-end: 4;
font-size: small;
margin-top: 2px;
margin-bottom: 2px;
}
.diario .diario-quote .diario-context {
font-style: italic;
}
.diario .diario-timestamp {
grid-row: 3;
grid-column: 1;
font-size: x-small;
margin-top: 2px;
margin-bottom: 2px;
}
.diario .diario-created {
grid-row: 3;
grid-column: 2;
justify-self: end;
font-size: x-small;
margin-top: 2px;
margin-bottom: 2px;
}
.diario .diario-id {
grid-row: 3;
grid-column: 3;
justify-self: end;
font-size: x-small;
margin-top: 2px;
margin-bottom: 2px;
}
.diario.diario-spoiler {
color: transparent; color: transparent;
background-color: rgba(255, 125, 125, 0.1); background-color: rgba(255, 125, 125, 0.1);
border: 1px solid rgba(255, 125, 125, 0.1); border-left: 3px solid #ff7d7d;
border-radius: 2px;
padding: 4px;
} }
.wikiview-doublebox .bot blockquote.spoiler:hover { .diario.diario-spoiler:hover {
color: #ff7d7d; color: #ff7d7d;
} }
.wikiview-doublebox .bot pre {
color: lightgray;
border: 1px solid rgba(160, 204, 255, 0.1);
background-color: rgba(160, 204, 255, 0.1);
padding: 2px 4px 2px 8px;
margin: 8px;
}
/*# sourceMappingURL=ryg.css.map */ /*# sourceMappingURL=ryg.css.map */

File diff suppressed because one or more lines are too long

View file

@ -172,16 +172,37 @@ h1, h2, h3, h4, h5, h6 {
font-weight: normal; font-weight: normal;
} }
pre {
color: lightgray;
border: 1px solid @fg-ten;
background-color: @fg-ten;
padding: 2px 4px 2px 8px;
margin: 8px;
}
code { code {
font-family: @monospace-fonts; font-family: @monospace-fonts;
} }
blockquote { blockquote {
color: @fg; color: @pastel-lime;
border-left: 3px solid @fg; border-left: 3px solid @pastel-lime;
background-color: @fg-ten; background-color: fade(@pastel-lime, 10%);
padding: 2px 4px 2px 8px; padding: 2px 4px 2px 8px;
margin: 8px; margin: 8px;
&.spoiler {
color: transparent;
background-color: fade(@pastel-red, 10%);
border: 1px solid fade(@pastel-red, 10%);
border-radius: 2px;
padding: 4px;
&:hover {
color: @pastel-red;
}
}
} }
textarea { textarea {
@ -248,10 +269,6 @@ select {
} }
} }
pre {
margin: 0;
}
img { img {
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
@ -764,31 +781,71 @@ table {
margin-top: revert; margin-top: revert;
margin-bottom: revert; margin-bottom: revert;
} }
}
}
blockquote { .diario {
color: @pastel-lime; display: grid;
border-left: 3px solid @pastel-lime; grid-template-columns: auto auto 8%;
background-color: fade(@pastel-lime, 10%);
&.spoiler { .diario-content {
grid-row: 1;
grid-column-start: 1;
grid-column-end: 4;
margin-top: 2px;
margin-bottom: 2px;
.diario-img {
color: red;
}
}
.diario-quote {
grid-row: 2;
grid-column-start: 1;
grid-column-end: 4;
font-size: small;
margin-top: 2px;
margin-bottom: 2px;
.diario-context {
font-style: italic;
}
}
.diario-timestamp {
grid-row: 3;
grid-column: 1;
font-size: x-small;
margin-top: 2px;
margin-bottom: 2px;
}
.diario-created {
grid-row: 3;
grid-column: 2;
justify-self: end;
font-size: x-small;
margin-top: 2px;
margin-bottom: 2px;
}
.diario-id {
grid-row: 3;
grid-column: 3;
justify-self: end;
font-size: x-small;
margin-top: 2px;
margin-bottom: 2px;
}
&.diario-spoiler {
color: transparent; color: transparent;
background-color: fade(@pastel-red, 10%); background-color: fade(@pastel-red, 10%);
border: 1px solid fade(@pastel-red, 10%); border-left: 3px solid @pastel-red;
border-radius: 2px;
padding: 4px;
&:hover { &:hover {
color: @pastel-red; color: @pastel-red;
} }
} }
}
pre {
color: lightgray;
border: 1px solid @fg-ten;
background-color: @fg-ten;
padding: 2px 4px 2px 8px;
margin: 8px;
}
}
} }