Initial import

This commit is contained in:
Thomas Sileo
2018-05-18 20:41:41 +02:00
commit 43e113e420
50 changed files with 4378 additions and 0 deletions

22
templates/about.html Normal file
View File

@@ -0,0 +1,22 @@
{% extends "layout.html" %}
{% import 'utils.html' as utils %}
{% block header %}
{% endblock %}
{% block content %}
<div style="width:90%;max-width: 720px;margin:40px auto;">
{% include "header.html" %}
<div class="h-card" style="display:flex">
<div style="flex:initial;width:200px;min-width:50px;">
<a class="u-url u-uid" href="{{ config.ID }}"><img class="u-photo" src="{{ me.icon.url }}" style="width:100%;max-width:200px;border-radius:5px;"></a>
</div>
<data class="p-name" value="{{ config.USERNAME }}">
<div style="flex:1;padding-left:30px;">
{{ text | safe }}
<div class="p-note" style="margin:20px 0;">{{ me.summary }}</div>
</div>
</div>
</div>
{% endblock %}

30
templates/admin.html Normal file
View File

@@ -0,0 +1,30 @@
{% extends "layout.html" %}
{% import 'utils.html' as utils %}
{% block content %}
<div id="container">
{% include "header.html" %}
<div id="admin">
<h3>Stats</h3>
<h4>DB</h4>
<ul>
<li>Inbox size: <strong>{{ inbox_size }}</strong></li>
<li>Outbox size: <strong>{{ outbox_size }}</strong></li>
<li>Object cache size: <strong>{{ object_cache_size }}</strong></li>
<li>Actor cache size: <strong>{{ actor_cache_size }}</strong></li>
</ul>
<h4>Collections</h4>
<ul>
<li>followers: <strong>{{ col_followers }}</strong></li>
<li>following: <strong>{{ col_following }}</strong></li>
<li>liked: <strong>{{col_liked }}</strong></li>
</ul>
<h4>Known Instances</h4>
<ul>
{% for instance in instances %}
<li><a href="{{ instance.instance }}">{{ instance.instance }}</a></li>
{% endfor %}
</ul>
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,15 @@
{% extends "layout.html" %}
{% import 'utils.html' as utils %}
{% block header %}
{% endblock %}
{% block content %}
<div id="container">
<h2>You're about to follow <strong>{{ profile}} </strong></h2>
<form method="POST" action="">
<input type="hidden" name="profile" value="{{ profile }}">
<input type="submit" value="follow">
</form>
</div>
{% endblock %}

16
templates/followers.html Normal file
View File

@@ -0,0 +1,16 @@
{% extends "layout.html" %}
{% import 'utils.html' as utils %}
{% block header %}
{% endblock %}
{% block content %}
<div id="container">
{% include "header.html" %}
<div id="followers">
{% for follower in followers_data %}
{{ utils.display_actor(follower) }}
{% endfor %}
</div>
</div>
{% endblock %}

16
templates/following.html Normal file
View File

@@ -0,0 +1,16 @@
{% extends "layout.html" %}
{% import 'utils.html' as utils %}
{% block header %}
{% endblock %}
{% block content %}
<div id="container">
{% include "header.html" %}
<div id="following">
{% for followed in following_data %}
{{ utils.display_actor(followed) }}
{% endfor %}
</div>
</div>
{% endblock %}

29
templates/header.html Normal file
View File

@@ -0,0 +1,29 @@
<div id="header">
<div class="h-card p-author">
<data class="u-photo" value="{{ config.ME.icon.url }}">
<a href="{{ config.ID }}" class="u-url u-uid no-hover title">
<span style="font-size:1.1em;">{{ config.NAME }}</span>
<span style="font-size:0.85em;" class="subtitle-username">@<span class="gold p-name">{{ config.USERNAME }}</span>@<span class="gold">{{ config.DOMAIN }}</span>
</span>
</a>
<data class="p-note" value="{{ config.ME.summary }}">
</div>
<div class="menu">
<ul>
<li><a href="/" {% if request.path == "/" %}class="selected"{% endif %}>/</a></li>
<li><a href="/followers"{% if request.path == "/followers" %} class="selected" {% endif %}>/followers</a></li>
<li><a href="/following"{% if request.path == "/following" %} class="selected" {% endif %}>/following</a></li>
<!-- <li><a href="/about"{% if request.path == "/about" %} class="selected" {% endif %}>/about</a></li>
-->
{% if logged_in %}
<li><a href="/stream"{% if request.path == "/stream" %} class="selected" {% endif %}>/stream</a></li>
<li><a href="/notifications"{% if request.path == "/notifications" %} class="selected" {% endif %}>/notifs</a></li>
<li><a href="/new"{% if request.path == "/new" %} class="selected" {% endif %}>/new</a></li>
<li><a href="/admin"{% if request.path == "/admin" %} class="selected" {% endif %}>/admin</a></li>
<li><a href="/logout">/logout</a></li>
{% else %}
<li><a href="/remote_follow"{% if request.path == "/remote_follow" %} class="selected" {% endif %}>/remote_follow</a></li>
{% endif %}
</ul>
</div>
</div>

45
templates/index.html Normal file
View File

@@ -0,0 +1,45 @@
{% extends "layout.html" %}
{% import 'utils.html' as utils %}
{% block header %}
<link rel="self" href="{{ config.ID }}/">
<link rel="hub" href="https://pubsubhubbub.superfeedr.com/">
<meta content="profile" property="og:type" />
<meta content="{{ config.ID }}" property="og:url" />
<meta content="{{ config.USERNAME }}" property="og:site_name" />
<meta content="{{ config.USERNAME }}" property="og:title" />
<meta content="{{ me.summary | html2plaintext }}" property="og:description" />
<meta content="{{ me.icon.url }}" property="og:image" />
<meta content="200" property="og:image:width" />
<meta content="200" property="og:image:height" />
<meta content="summary" property="twitter:card" />
<meta content="{{config.USERNAME}}@{{ config.DOMAIN}}" property="profile:username" />
{% endblock %}
{% block content %}
<div class="h-feed" id="container">
<data class="p-name" value="{{config.USERNAME}} notes">
{% include "header.html" %}
<div class="summary">
{{ config.SUMMARY | safe }}
</div>
<div id="notes">
{% for item in outbox_data %}
{% if item.type == 'Announce' %}
{% set boost_actor = item.activity.actor | get_actor %}
<p style="margin-left:65px;padding-bottom:5px;"><span class="bar-item"><a style="color:#808080;" href="{{ boost_actor.url }}">{{ boost_actor.name }}</a> boosted</span></p>
{% if item.ref %}
{{ utils.display_note(item.ref, ui=False) }}
{% endif %}
{% elif item.type == 'Create' %}
{{ utils.display_note(item) }}
{% endif %}
{% endfor %}
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,42 @@
{% extends "layout.html" %}
{% import 'utils.html' as utils %}
{% block header %}
{% endblock %}
{% block content %}
<div style="width:90%;max-width: 720px;margin:40px auto;">
{% if session.logged_in %}logged{% else%}not logged{%endif%}
<div style="display:flex">
{% if client.logo %}
<div style="flex:initial;width:100px;">
<img src="{{client.logo}}" style="max-width:100px;">
</div>
{% endif %}
<div style="flex:1;">
<div style="margin-top:20px">
<a style="font-size:1.2em;font-weight:600;text-decoration:none;color:#111;" href="{{ client.url }}">{{ client.name }}</a>
<p>wants you to login</p>
</div>
</div>
</div>
<form method="POST" action="{{ url_for('indieauth_flow') }}">
{% if scopes %}
<h3>Scopes</h3>
<ul>
{% for scope in scopes %}
<li><input type="checkbox" name="scopes" value="{{scope}}" id="scope-{{scope}}"><label for="scope-{{scope}}">{{ scope }}</label>
</li>
{% endfor %}
</ul>
{% endif %}
<input type="hidden" name="redirect_uri" value="{{ redirect_uri }}">
<input type="hidden" name="state" value="{{ state }}">
<input type="hidden" name="client_id" value="{{ client_id }}">
<input type="hidden" name="me" value="{{ me }}">
<input type="hidden" name="response_type" value="{{ response_type }}">
<input type="submit" value="login">
</form>
</div>
{% endblock %}

29
templates/layout.html Normal file
View File

@@ -0,0 +1,29 @@
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge"> <!---->
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>{{ config.USERNAME }}</title>
<link rel="stylesheet" href="https://unpkg.com/purecss@1.0.0/build/pure-min.css" integrity="sha384-nn4HPE8lTHyVtfCBi5yW9d20FjT8BJwUXyWZT9InLYax14RDjBj46LmSztkmNP9w" crossorigin="anonymous">
<link rel="stylesheet" href="/static/css/theme.css">
<link rel="authorization_endpoint" href="{{ config.ID }}/indieauth">
<link rel="token_endpoint" href="{{ config.ID }}/token">
<link rel="webmention" href="{{ config.ID }}/webmention">
<link rel="micropub" href="{{ config.ID }}/micropub">
<link rel="alternate" href="https://mastodon.social/users/tpub0" title="ActivityPub profile" type="application/activity+json">
<link rel="alternate" href="{{ config.ID }}/feed.json" type="application/json" title="JSON Feed">
<link rel="alternate" href="{{ config.ID }}/feed.rss" type="application/rss+xml" title="RSS">
<link rel="alternate" href="{{ config.ID }}/feed.atom" type="application/atom+xml" title="Atom 0.3">
</head>
<body>
<div class="base-container">
{% block content %}{% endblock %}
</div>
<div class="footer">
<div>
Powered by <a href="https://microblog.pub">microblog.pub</a> (<a href="https://github.com/tsileo/microblog.pub">source code</a>) and the <a href="https://activitypub.rocks/">ActivityPub</a> protocol
</div>
</div>
</body>
</html>

36
templates/login.html Normal file
View File

@@ -0,0 +1,36 @@
{% extends "layout.html" %}
{% import 'utils.html' as utils %}
{% block header %}
{% endblock %}
{% block content %}
<div id="container">
{% if session.logged_in %}logged{% else%}not logged{%endif%}
<form id="login-form" method="POST">
<input type="password" name="pass" placeholder="password">
{% if u2f_enabled %}
<input type="hidden" name="resp" id="sig-payload" value="">
<input type="submit" value="waiting for u2f" disabled>
{% else %}
<input type="submit" value="login">
{% endif %}
</form>
</div>
{% if u2f_enabled %}
<script>
var p = {{ payload | tojson }};
if (p) {
u2f.sign(p.appId, p.challenge, p.registeredKeys, function(resp) {
if (resp.errorCode) {
console.log(resp)
} else {
document.getElementById('sig-payload').value = JSON.stringify(resp)
document.getElementById('login-form').submit()
}
})
}
</script>
{% endif %}
{% endblock %}

17
templates/new.html Normal file
View File

@@ -0,0 +1,17 @@
{% extends "layout.html" %}
{% import 'utils.html' as utils %}
{% block content %}
<div id="container">
{% include "header.html" %}
<div id="new">
<form action="" method="POST">
{% if reply %}<input type="hidden" name="reply" value="{{reply}}">{% endif %}
<textarea name="content" rows="10" cols="50" autofocus="autofocus">{{ content }}</textarea>
<div style="margin-top:20px;">
<input type="submit" value="post">
</div>
</form>
</div>
</div>
{% endblock %}

23
templates/note.html Normal file
View File

@@ -0,0 +1,23 @@
{% extends "layout.html" %}
{% import 'utils.html' as utils %}
{% block header %}
<meta content="article" property="og:type" />
<meta content="{{ note.activity.object.url }}" property="og:url" />
<meta content="{{ config.USERNAME }}" property="og:site_name" />
<meta content="{{ config.USERNAME }}" property="og:title" />
<meta content="{{ note.activity.object.content | html2plaintext }}" property="og:description" />
<meta content="{{ me.icon.url }}" property="og:image" />
<meta content="200" property="og:image:width" />
<meta content="200" property="og:image:height" />
<meta content="summary" property="twitter:card" />
{% endblock %}
{% block content %}
<div id="container">
{% include "header.html" %}
{{ utils.display_note(note, perma=True) }}
{% for reply in replies %}
{{ utils.display_note(reply, perma=False) }}
{% endfor %}
</div>
{% endblock %}

View File

@@ -0,0 +1,16 @@
{% extends "layout.html" %}
{% import 'utils.html' as utils %}
{% block header %}
{% endblock %}
{% block content %}
<div id="container">
{% include "header.html" %}
<h2>You're about to follow me</h2>
<form method="POST" action="">
<input type="text" name="profile" placeholder="you@your-instance">
<input type="submit" value="Proceed to remote follow">
</form>
</div>
{% endblock %}

39
templates/stream.html Normal file
View File

@@ -0,0 +1,39 @@
{% extends "layout.html" %}
{% import 'utils.html' as utils %}
{% block content %}
<div class="h-feed" id="container">
{% include "header.html" %}
<div id="admin">
<div id="notes">
{% for item in inbox_data %}
{% if item.type == 'Create' %}
{{ utils.display_note(item, ui=True) }}
{% else %}
{% if item.type == 'Announce' %}
{% set boost_actor = item.activity.actor | get_actor %}
<p style="margin-left:70px;padding-bottom:5px;"><span class="bar-item"><a style="color:#808080;" href="{{ boost_actor.url }}">{{ boost_actor.name or boost_actor.preferredUsername }}</a> boosted</span></p>
{% if item.ref %}
{{ utils.display_note(item.ref, ui=True) }}
{% endif %}
{% endif %}
{% if item.type == 'Follow' %}
<p>{{ item.activity.actor }} followed you</p>
{% elif item.type == 'Accept' %}
<p>you followed {{ item.activity.actor }}</p>
{% elif item.type == 'Undo' %}
<p>{{ item.activity.actor }} unfollowed you</p>
{% else %}
{% endif %}
{% endif %}
{% endfor %}
</div>
</div>
</div>
{% endblock %}

30
templates/tags.html Normal file
View File

@@ -0,0 +1,30 @@
{% extends "layout.html" %}
{% import 'utils.html' as utils %}
{% block header %}
<link rel="self" href="{{ config.ID }}/">
<link rel="hub" href="https://pubsubhubbub.superfeedr.com/">
<meta content="profile" property="og:type" />
<meta content="{{ config.ID }}" property="og:url" />
<meta content="{{ config.USERNAME }}" property="og:site_name" />
<meta content="{{ config.USERNAME }}" property="og:title" />
<meta content="{{ me.summary | html2plaintext }}" property="og:description" />
<meta content="{{ me.icon.url }}" property="og:image" />
<meta content="200" property="og:image:width" />
<meta content="200" property="og:image:height" />
<meta content="summary" property="twitter:card" />
<meta content="{{config.USERNAME}}@{{ config.DOMAIN}}" property="profile:username" />
{% endblock %}
{% block content %}
<div class="h-feed" id="container">
<data class="p-name" value="#{{tag}}">
{% include "header.html" %}
<h2>#{{ tag }}</h2>
<div id="notes">
{% for item in outbox_data %}
{{ utils.display_note(item) }}
{% endfor %}
</div>
</div>
{% endblock %}

29
templates/u2f.html Normal file
View File

@@ -0,0 +1,29 @@
{% extends "layout.html" %}
{% import 'utils.html' as utils %}
{% block header %}
{% endblock %}
{% block content %}
<div style="width:90%;max-width: 720px;margin:40px auto;">
{% if session.logged_in %}logged{% else%}not logged{%endif%}
<form method="POST" id="register-form">
<input type="hidden" id="register-payload" name="resp" value="">
<input type="submit" value="login">
</form>
</div>
<script>
var p= {{ payload | tojson }};
//setTimeout(function() {
u2f.register(p.appId, p.registerRequests, p.registeredKeys, function(resp) {
if (resp.errorCode) {
console.log(resp)
} else {
document.getElementById('register-payload').value = JSON.stringify(resp)
document.getElementById('register-form').submit()
}
})
//}, 1000);
</script>
{% endblock %}

91
templates/utils.html Normal file
View File

@@ -0,0 +1,91 @@
{% macro display_actor(follower) -%}
<a class="actor-box" href="{{follower.url}}">
<div class="pure-g">
<div class="pure-u-1-5">
{% if not follower.icon %}
<img class="actor-icon" src="/static/nopic.png">
{% else %}
<img class="actor-icon" src="{{ follower.icon.url }}">{% endif %}
</div>
<div class="pure-u-4-5">
<h3>{{ follower.name or follower.preferredUsername }}</h3>
<small>@{{ follower.preferredUsername }}@{{ follower.url | domain }}</small>
<div>{{ follower.summary | safe }}</div>
</div>
</div>
</a>
{%- endmacro %}
{% macro display_note(item, perma=False, ui=False) -%}
{% set actor = item.activity.object.attributedTo | get_actor %}
<div class="note h-entry" id="activity-{{ item['_id'].__str__() }}">
<div class="h-card p-author">
<a class="u-url u-uid no-hover" href="{{ actor.url }}"><img class="u-photo" src="{% if not actor.icon %}/static/nopic.png{% else %}{{ actor.icon.url }}{% endif %}">
</a>
<data class="p-name" value="{{ actor.name or actor.preferredUsername }}">
</div>
<div class="note-wrapper">
<a href="{{ actor.url }}" style="margin:0;text-decoration:none;" class="no-hover"><strong>{{ actor.name or actor.preferredUsername }}</strong> <span class="l">@{{ actor.preferredUsername }}@{{ actor.url | domain }}</span></a>
{% if not perma %}
<span style="float:right">
<a rel="noopener" class="u-url u-uid note-permalink l" href="{{ item.activity.object.url }}">
<time class="dt-published" title="{{ item.activity.object.published }}" datetime="{{ item.activity.object.published }}">{{ item.activity.object.published | format_timeago }}</time></a>
</span>
{% endif %}
{% if item.activity.object.summary %}<p class="p-summary">{{ item.activity.object.summary }}</p>{% endif %}
<div class="note-container{% if perma %} perma{%endif%} p-name e-content">
{{ item.activity.object.content | safe }}
</div>
{% if item.activity.object.attachment %}
<div style="padding:20px 0;">
{% if item.activity.object.attachment | not_only_imgs %}
<h3 class="l">Attachment</h3>
<ul>
{% endif %}
{% for a in item.activity.object.attachment %}
{% if a.url | is_img %}
<img src="{{a.url}}" class="img-attachment">
{% else %}
<li><a href="{{a.url}}" class="l">{% if a.filename %}{{ a.filename }}{% else %}{{ a.url }}{% endif %}</a></li>
{% endif %}
{% endfor %}
{% if item.activity.object.attachment | not_only_imgs %}
</ul>
{% endif %}
</div>
{% endif %}
<div class="bottom-bar">
{% if perma %}<span class="perma-item">{{ item.activity.object.published | format_time }}</span> {% endif %}
<a class ="bar-item" href="{{ item.activity.object.url }}">permalink</a>
{% if item.meta.count_reply %}<a class ="bar-item" href="{{ item.activity.object.url }}">{{ item.meta.count_reply }} replies</a>{% endif %}
{% if item.meta.count_boost %}<a class ="bar-item" href="{{ item.activity.object.url }}">{{ item.meta.count_boost }} boosts</a>{% endif %}
{% if item.meta.count_like %}<a class ="bar-item" href="{{ item.activity.object.url }}">{{ item.meta.count_like }} likes</a>{% endif %}
{% if ui %}
{% set aid = item.activity.object.id | quote_plus %}
<a class="bar-item" href="/new?reply={{ aid }}">reply</a>
{% set redir = request.path + "#activity-" + item['_id'].__str__() %}
{% if item.meta.boosted %}
<a class="bar-item" href="/ui/undo?id={{ item.meta.boosted | quote_plus }}&redirect={{redir | quote_plus }}">unboost</a>
{% else %}
<a class="bar-item" href="/ui/boost?id={{ aid }}&redirect={{ redir | quote_plus }}">boost</a>
{% endif %}
{% if item.meta.liked %}
<a class="bar-item" href="/ui/undo?id={{ item.meta.liked | quote_plus }}&redirect={{ redir | quote_plus }}">unlike</a>
{% else %}
<a class="bar-item" href="/ui/like?id={{ aid }}&redirect={{ redir | quote_plus }}">like</a>
{% endif %}
{% endif %}
</div>
</div>
</div>
{%- endmacro %}