Introduce /rules + minor style changes

This commit is contained in:
Yusur 2023-06-21 00:13:30 +02:00
parent a30d1c6fe0
commit ea0ccc0d0d
6 changed files with 117 additions and 30 deletions

5
.gitignore vendored
View file

@ -5,6 +5,10 @@ database/
site.conf
site-*.conf
run_8180.py
.env
alembic.ini
venv/
venv-*/
# automatically generated garbage
**/__pycache__/
@ -13,3 +17,4 @@ run_8180.py
**/.\#*
**/\#*\#
ig_api_settings/
node_modules/

View file

@ -8,7 +8,7 @@
+ Added `restrictions` field to `User`.
+ Pages now can have a Content Warning. It prevents them to show up in previews, and adds a
caution message when viewing them.
+ Added Terms and Privacy Policy.
+ Added Terms, Privacy Policy and Rules.
+ Changed user page URLs (contributions page) from `/u/user` to `/@user`.
+ `/manage/` is now a list of all managing options, including export/import and the brand new
`/manage/accounts`.

50
app.py
View file

@ -90,6 +90,17 @@ def _makelist(l):
else:
return []
def render_paginated_template(template_name, query_name, **kwargs):
query = kwargs.pop(query_name)
page = int(request.args.get('page', 1))
kwargs[query_name] = query.paginate(page)
return render_template(
template_name,
page_n = page,
total_count = query.count(),
min=min,
**kwargs
)
#### MARKDOWN EXTENSIONS ####
@ -588,8 +599,8 @@ def is_url_available(url):
forbidden_urls = [
'about', 'accounts', 'ajax', 'backlinks', 'calendar', 'circles', 'create',
'easter', 'edit', 'embed', 'group', 'help', 'history', 'init-config', 'kt',
'manage', 'media', 'p', 'privacy', 'protect', 'search', 'static', 'stats',
'tags', 'terms', 'u', 'upload', 'upload-info'
'manage', 'media', 'p', 'privacy', 'protect', 'rules', 'search', 'static',
'stats', 'tags', 'terms', 'u', 'upload', 'upload-info'
]
app = Flask(__name__)
@ -881,11 +892,9 @@ def embed_view(id):
html.escape(p.title), rev.html())
@app.route('/p/most_recent/')
@app.route('/p/most_recent/<int:page>/')
def view_most_recent(page=1):
def view_most_recent():
general_query = Page.select().order_by(Page.touched.desc())
return render_template('listrecent.jinja2', notes=general_query.paginate(page),
page_n=page, total_count=general_query.count(), min=min)
return render_paginated_template('listrecent.jinja2', 'notes', notes=general_query)
@app.route('/p/random/')
def view_random():
@ -941,13 +950,10 @@ def contributions(username):
except User.DoesNotExist:
abort(404)
contributions = user.contributions.order_by(PageRevision.pub_date.desc())
page = int(request.args.get('page', 1))
return render_template('contributions.jinja2',
"contributions",
u=user,
contributions=contributions.paginate(page),
page_n=page,
total_count=contributions.count(),
min=min
contributions=contributions,
)
def _advance_calendar(date, offset=0):
@ -976,10 +982,8 @@ def calendar_month(y, m):
(datetime.date(y, m, 1) <= Page.calendar) &
(Page.calendar < datetime.date(y+1 if m==12 else y, 1 if m==12 else m+1, 1))
).order_by(Page.calendar)
page = int(request.args.get('page', 1))
return render_template('month.jinja2', d=datetime.date(y, m, 1), notes=notes.paginate(page),
page_n=page, total_count=notes.count(), min=min, advance_calendar=_advance_calendar)
return render_paginated_template('month.jinja2', "notes", d=datetime.date(y, m, 1), notes=notes, advance_calendar=_advance_calendar)
@app.route('/history/revision/<int:revisionid>/')
def view_old(revisionid):
@ -1013,12 +1017,9 @@ def search():
return render_template('search.jinja2', pl_include_tags=True)
@app.route('/tags/<slug:tag>/')
@app.route('/tags/<slug:tag>/<int:page>/')
def listtag(tag, page=1):
def listtag(tag):
general_query = Page.select().join(PageTag, on=PageTag.page).where(PageTag.name == tag).order_by(Page.touched.desc())
page_query = general_query.paginate(page)
return render_template('listtag.jinja2', tagname=tag, tagged_notes=page_query,
page_n=page, total_count=general_query.count(), min=min)
return render_paginated_template('listtag.jinja2', "tagged_notes", tagname=tag, tagged_notes=general_query)
# symbolic route as of v0.5
@ -1298,12 +1299,7 @@ def manage_accounts():
pass
else:
flash('Operation not permitted!')
return render_template('manageaccounts.jinja2',
users=users.paginate(page),
page_n=page,
total_count=users.count(),
min=min
)
return render_paginated_template('manageaccounts.jinja2', 'users', users=users)
## terms / privacy ##
@ -1315,6 +1311,10 @@ def terms():
def privacy():
return render_template('privacy.jinja2')
@app.route('/rules/')
def rules():
return render_template('rules.jinja2')
#### EXTENSIONS ####
active_extensions = []

View file

@ -68,6 +68,7 @@ body{font-family:sans-serif;background-color:var(--bg-main); color: var(--fg-mai
.nl-new > a{margin-right:12px}
.nl-prev,.nl-next{text-align:center}
.nl-placeholder {font-style: italic; text-align: center;}
.nl-pagination {text-align: center; color: var(--fg-alt)}
input{border:0;border-bottom:3px solid var(--border);font:inherit;color:var(--fg-main);background-color:transparent}
input:focus{color:var(--fg-sharp);border-bottom-color:var(--border-sharp)}
input.error{border-bottom-color:var(--btn-error)}
@ -119,8 +120,11 @@ ul.inline > li:last-child::after {content: ""}
/* floating elements */
nav.toc{display:none}
@media only screen and (min-width:960px){
nav.toc{display:block;position:absolute; top: 0; right: 0; width: 320px;}
.inner-content {margin-right: 320px}
nav.toc{display:block;position:absolute; top: 0; right: 0; width: 240px;}
.inner-content {margin-right: 240px;}
}
@media only screen and (min-width:1200px){
.inner-content {margin-left: 240px}
}
.backontop{position:fixed;bottom:0;right:0}
@media print{

View file

@ -10,7 +10,7 @@
<ul>
{% for year in range(till_year, from_year-1, -1) %}
<li>
<strong>{{ year }} {% if year == now.year %}(current){% endif %}:</strong>
<strong>{% if year == now.year %}<mark>{% endif %}{{ year }}{% if year == now.year %}</mark>{% endif %}</strong>:
<ul class="inline">
{% for month in range(1, 13) %}
<li><a href="/calendar/{{year}}/{{month}}">{{ year }}.{{ month }}</a></li>

78
templates/rules.jinja2 Normal file
View file

@ -0,0 +1,78 @@
{% extends "base.jinja2" %}
{% block title %}Content Policy — {{ app_name }}{% endblock %}
{% block content %}
<h1 id="firstHeading">Content Policy</h1>
<div class="inner-content article-content">
{% filter markdown %}
These are the Rules of {{ app_name }}.
{{ app_name }} is a Free Speech environment. However, in order to ensure
the safety of our users as well as the longevity of the platform, there are a
few things you are not permitted to do with the platform.
By using {{ app_name }}, you agree to follow these rules.
Violations may lead to the suspension or terminaton of your {{ app_name }} account.
## 1. Intellectual Property
You may not upload to, embed within, or link out from {{ app_name }}:
1. Copyrighted material that you are not authorized to distribute
2. Anything not legal to publish within, or export from, intentionally
## 2. Digital Safety
You may not upload to, embed within, or link out from {{ app_name }}:
1. IP or token grabbers
2. Viruses or exploits
3. URL shorteners
4. Anything with the intent of breaking {{ app_name }}
## 3. User Safety
You may not use {{ app_name }} to do any of the following:
1. Threaten, intimidate, or harass other users
2. Impersonate other users, real life people, or {{ app_name }} staff
3. Solicit, collect, or publish personally identifiable information (PII), be it yours or the one
of another individual
4. Spam (the definition of “spam” is at {{ app_name }}s own discretion)
## 4. Sexual Content
You may not upload to, embed within, or link out from {{ app_name }}:
1. Sexual or sexually suggestive material not marked "NSFW"
2. Sexual or sexually suggestive material involving individuals under the age of 18, including fictitious content. Solicitation of such material is also prohibited.
3. Sexual or sexually suggestive material involving individuals who did not consent to its creation and distribution (commonly called "revenge pornography" or "involuntary pornography"). Solicitation of such material is also prohibited.
## 5. IRL Safety
You may not use {{ app_name }} to do any of the following:
1. Incite, plan, or execute unlawful or violent activity
2. Engage in fraud
## 6. Evil
While it would be nice to be able to entertain all viewpoints, certain ideologies are ontologically evil. We have a zero tolerance policy on advocacy, propaganda, recruitment, and any other forms of promotion of evil.
Evil ideologies prohibited from {{ app_name }} include, but are not limited to:
* Ethnic, racial, or sex-based supremecism
* Pedophile acceptance/normalization
* Terrorism
Discussion of these topics as they relate to current events or other subject matter is permitted; advocacy or promotion of them is not.
## 7. Additional Rules
Additional rules may be put in place by the {{ app_name }} administrator.
{% endfilter %}
</div>
{% endblock %}