0.3.0: initial commit + Dockerfile + rewrite

This commit is contained in:
Yusur 2025-06-13 03:01:32 +02:00
commit e679de5991
77 changed files with 4147 additions and 0 deletions

View file

@ -0,0 +1,35 @@
{% macro checked_if(cond) %}
{% if cond -%}
checked=""
{%- endif %}
{% endmacro %}
{% macro disabled_if(cond) %}
{% if cond -%}
disabled=""
{%- endif %}
{% endmacro %}
{% macro privacy_select(value = 0) %}
<ul>
<li><input type="radio" name="privacy" value="0" id="new__privacy_0" {{ checked_if(value == 0) }} /><label for="new__privacy_0" >Public <small class="faint">(everyone in your profile or public timeline)</small></label></li>
<li><input type="radio" name="privacy" value="1" id="new__privacy_1" {{ checked_if(value == 1) }} /><label for="new__privacy_1" >Unlisted <small class="faint">(everyone in your profile, hide from public timeline)</small></label></li>
<li><input type="radio" name="privacy" value="2" id="new__privacy_2" {{ checked_if(value == 2) }} /><label for="new__privacy_2" >Friends <small class="faint">(only people you follow each other)</small></label></li>
<li><input type="radio" name="privacy" value="3" id="new__privacy_3" {{ checked_if(value == 3) }} /><label for="new__privacy_3" >Only you <small class="faint">(nobody else)</small></label></li>
</ul>
{% endmacro %}
{% macro comment_area(url) %}
<form id="comment-area" class="boundaryless" action="{{ url }}" method="POST" enctype="multipart/form-data">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<input type="hidden" name="reply_to" value="" />
<div>
<textarea name="text" placeholder="Comment as {{ current_user.handle() }} ~"></textarea>
</div>
<div class="button-row-right">
<button type="reset">Cancel</button>
<button type="submit" class="primary">Publish</button>
</div>
</form>
{% endmacro %}

View file

@ -0,0 +1,19 @@
{% macro embed_post(p) %}
<div id="post-{{ p.id | to_b32l }}" class="post-frame" data-endpoint="{{ p.id | to_b32l }}">
<h3 class="message-title"><a href="{{ p.url() }}">{{ p.title }}</a></h3>
<div class="message-meta">Posted by <a href="{{ p.author.url() }}">@{{ p.author.username }}</a>
{% if p.parent_post %}
as a comment on <a href="{{ p.parent_post.url() }}">post “{{ p.parent_post.title }}”</a>
{% elif p.topic %}
on <a href="{{ p.topic.url() }}">+{{ p.topic.name }}</a>
{% else %}
on their user page
{% endif %}
- <time datetime="{{ p.created_at.isoformat('T') }}">{{ p.created_at.strftime('%B %-d, %Y at %H:%M') }}</time>
</div>
<div class="message-content">
{{ p.text_content | to_markdown }}
</div>
</div>
{% endmacro %}

View file

@ -0,0 +1,133 @@
{% from "macros/icon.html" import icon, callout with context %}
{% macro feed_post(p) %}
<div id="post-{{ p.id | to_b32l }}" class="post-frame" data-endpoint="{{ p.id | to_b32l }}">
<h3 class="message-title"><a href="{{ p.url() }}">{{ p.title }}</a></h3>
<div class="message-meta">Posted by <a href="{{ p.author.url() }}">@{{ p.author.username }}</a>
{% if p.topic %}
on <a href="{{ p.topic.url() }}">+{{ p.topic.name }}</a>
{% else %}
on their user page
{% endif %}
- <time datetime="{{ p.created_at.isoformat('T') }}">{{ p.created_at.strftime('%B %-d, %Y at %H:%M') }}</time>
</div>
<div class="message-stats">
{{ feed_upvote(p.id, p.upvotes(), p.upvoted_by(current_user)) }}
{{ comment_count(p.comments | count) }}
</div>
<div class="message-content shorten">
{{ p.text_content | to_markdown }}
</div>
</div>
{% endmacro %}
{% macro feed_upvote(postid, count, uservote=0) %}
<div class="upvote-button" data-endpoint="{{ postid|to_b32l }}">
{% if uservote > 0 %}
<a href="javascript:void 0" class="upvote-button-up active">
<i class="icon icon-upvote_fill"></i><span class="a11y">upvoted</span>
</a>
{% else %}
<a href="javascript:void 0" class="upvote-button-up">
<i class="icon icon-upvote"></i><span class="a11y">upvote</span>
</a>
{% endif %}
<strong class="upvote-count">{{ count }}</strong>
{% if uservote < 0 %}
<a href="javascript:void 0" class="upvote-button-down active">
<i class="icon icon-downvote_fill"></i><span class="a11y">downvoted</span>
</a>
{% else %}
<a href="javascript:void 0" class="upvote-button-down">
<i class="icon icon-downvote"></i><span class="a11y">downvote</span>
</a>
{% endif %}
</div>
{% endmacro %}
{% macro single_comment(comment) %}
<div class="comment-frame">
{% if comment.is_removed %}
{% call callout('delete') %}<i>Removed comment</i>{% endcall %}
{% else %}
<div class="message-meta">
{% if comment.author %}
<a href="{{ comment.author.url() }}">{{ comment.author.handle() }}</a>
{% else %}
<i>deleted account</i>
{% endif %}
{% if comment.author and comment.author == comment.parent_post.author %}
<span class="faint">(OP)</span>
{% endif %}
{# TODO add is_distinguished i.e. official comment #}
-
<time datetime="{{ comment.created_at.isoformat('T') }}">{{ comment.created_at.strftime('%B %-d, %Y at %H:%M') }}</time>
</div>
<div class="message-content">
{{ comment.text_content | to_markdown }}
</div>
<ul class="message-options inline">
{% if comment.author == current_user %}
{# TODO add comment edit link #}
{% else %}
<li><a href="{{ comment.report_url() }}">{{ icon('report') }} Report</a></li>
{% endif %}
{% if current_user.is_administrator and comment.report_count() %}
<li><a href="/admin/reports"><strong>{{ comment.report_count() }}</strong> reports</a></li>
{% endif %}
<li>ID #{{ comment.id|to_b32l }}</li>
</ul>
{% endif %}
</div>
{% endmacro %}
{% macro comment_count(c) %}
<div class="comment-count">
<a><i class="icon icon-comment"></i></a>
<strong>{{ c }}</strong>
<span class="a11y">comments</span>
</div>
{% endmacro %}
{% macro stop_scrolling(page_n = 1) %}
{% set choices1 = [
'STOP SCROLLING!',
'Scrolling is bad for your health',
'You scrolled enough for today',
'There is grass out there',
'Scrolling turns you into an extremist',
'Is your time really worth this little?',
'You learn nothing from social media'
] %}
{% set choices2 = [
'Nevermind',
'I understand the risks',
'I can\'t touch grass',
'Get me some more anyway!',
'I can\'t quit right now',
'A little more~'
] %}
{% set choice1 = choices1 | random %}
{% set choice2 = choices2 | random %}
<div class="centered">
<p><strong class="error">{{ choice1 }}</strong></p>
<p><small><a href="?page={{ page_n + 1 }}">{{ choice2 }}</a></small></p>
</div>
{% endmacro %}
{% macro no_more_scrolling(page_n = 1) %}
{% set choices1 = [
'Congratulations, you are a no lifer',
'Grass is still waiting out there',
'You could have done something more productive tho'
] %}
<li>
<p class="centered">You have reached the rock bottom
{%- if page_n > 10 or page_n + (range(10) | random) > 10 -%}
. {{ choices1 | random }}
{% endif %}
</p></li>
{% endmacro %}

View file

@ -0,0 +1,11 @@
{% macro icon(name, fill = False) %}
<i class="icon icon-{{ name }}{{ '_fill' if fill }}"></i>
{% endmacro %}
{% macro callout(useicon = "spoiler") %}
<div class="callout">
{{ icon(useicon) }}
{{ caller() }}
</div>
{% endmacro %}

View file

@ -0,0 +1,36 @@
{% macro nav_topic(topic) %}
<aside class="card">
<h3>About {{ topic.handle() }}</h3>
<ul>
<li><i class="icon icon-info" style="font-size:inherit"></i> {{ topic.description }}</li>
<li>
<strong>{{ topic.posts | count }}</strong> posts -
<strong>-</strong> subscribers
</li>
</ul>
</aside>
{% endmacro %}
{% macro nav_user(user) %}
<aside class="card">
<h3>About {{ user.handle() }}</h3>
<ul>
<li>{# user.biography #}</li>
</ul>
</aside>
{% endmacro %}
{% macro nav_top_communities(top_communities) %}
<aside class="card">
<h3>Top Communities</h3>
<ul>
{% for comm, pcnt, scnt in top_communities %}
<li><strong><a href="{{ comm.url() }}">{{ comm.handle() }}</a></strong> - <strong>{{ pcnt }}</strong> posts - <strong>{{ scnt }}</strong> subscribers</li>
{% endfor %}
{% if current_user and current_user.is_authenticated and current_user.can_create_community() %}
<li>Cant find your community? <a href="/createcommunity">Create a new one.</a></li>
{% endif %}
</ul>
</aside>
{% endmacro %}

View file

@ -0,0 +1,16 @@
{% macro title_tag(name, robots=True) %}
<title>
{%- if name -%}
{{ name }}; on {{ app_name }}
{%- else -%}
{{ app_name }}
{%- endif -%}
</title>
{% if robots %}
<meta name="robots" content="noai,noimageai" />
{% else %}
<meta name="robots" content="noindex,nofollow,noai,noimageai" />
{% endif %}
{% endmacro %}