9
ENVVARS.md
Normal file
9
ENVVARS.md
Normal file
@@ -0,0 +1,9 @@
|
||||
| var | default |
|
||||
|----------------------------------|-------------------------|
|
||||
| POUSSETACHES_AUTH_KEY | |
|
||||
| FLASK_DEBUG | 0 |
|
||||
| MICROBLOGPUB_DEBUG | "false" |
|
||||
| MICROBLOGPUB_INTERNAL_HOST | "http://localhost:5000" |
|
||||
| MICROBLOGPUB_MONGODB_HOST | "localhost:27017" |
|
||||
| MICROBLOGPUB_POUSSETACHES_HOST | "http://localhost:7991" |
|
||||
| MICROBLOGPUB_WIZARD_PROJECT_NAME | "microblogpub" |
|
@@ -57,7 +57,7 @@ HEADERS = [
|
||||
|
||||
|
||||
with open(os.path.join(KEY_DIR, "me.yml")) as f:
|
||||
conf = yaml.load(f)
|
||||
conf = yaml.safe_load(f)
|
||||
|
||||
USERNAME = conf["username"]
|
||||
NAME = conf["name"]
|
||||
|
@@ -327,9 +327,10 @@ def post_to_outbox(activity: ap.BaseActivity) -> str:
|
||||
activity._data["object"]["id"] = urljoin(
|
||||
BASE_URL, url_for("outbox_activity", item_id=obj_id)
|
||||
)
|
||||
activity._data["object"]["url"] = urljoin(
|
||||
BASE_URL, url_for("note_by_id", note_id=obj_id)
|
||||
)
|
||||
if "url" not in activity._data["object"]:
|
||||
activity._data["object"]["url"] = urljoin(
|
||||
BASE_URL, url_for("note_by_id", note_id=obj_id)
|
||||
)
|
||||
activity.reset_object_cache()
|
||||
|
||||
save(Box.OUTBOX, activity)
|
||||
|
8
run_dev.sh
Executable file
8
run_dev.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
DEV_POUSSETACHES_AUTH_KEY="1234567890"
|
||||
MICROBLOGPUB_INTERNAL_HOST="http://host.docker.internal:5005"
|
||||
|
||||
|
||||
env POUSSETACHES_AUTH_KEY=${DEV_POUSSETACHES_AUTH_KEY} docker-compose -f docker-compose-dev.yml up -d
|
||||
FLASK_DEBUG=1 MICROBLOGPUB_DEBUG=1 FLASK_APP=app.py POUSSETACHES_AUTH_KEY=${DEV_POUSSETACHES_AUTH_KEY} MICROBLOGPUB_INTERNAL_HOST=${MICROBLOGPUB_INTERNAL_HOST} flask run -p 5005 --with-threads
|
||||
docker-compose down
|
@@ -1,14 +1,14 @@
|
||||
{% extends "layout.html" %}
|
||||
{% import 'utils.html' as utils %}
|
||||
{% block title %}{{ config.NAME }}: "{{ note.activity.object.content | html2plaintext | trim | truncate(50) }}"{% endblock %}
|
||||
{% block title %}{{ config.NAME }}{{ note.activity.object | get_text | html2plaintext | trim | truncate(50) }}"{% endblock %}
|
||||
{% block header %}
|
||||
<meta name="description" content="{{ note.activity.object.content | html2plaintext | trim | truncate(50) }}">
|
||||
<meta name="description" content="{{ note.activity.object | get_text | html2plaintext | trim | truncate(50) }}">
|
||||
|
||||
<meta content="article" property="og:type" />
|
||||
<meta content="{{ note.activity.object.url }}" property="og:url" />
|
||||
<meta content="{{ config.USERNAME }} microblog" property="og:site_name" />
|
||||
<meta content="{{ config.USERNAME }}" property="og:title" />
|
||||
<meta content="{{ note.activity.object.content | html2plaintext | trim | truncate(50) }}" property="og:description" />
|
||||
<meta content="{{ note.activity.object | get_text | html2plaintext | trim | truncate(50) }}" 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" />
|
||||
|
@@ -198,7 +198,7 @@
|
||||
|
||||
|
||||
{% else %}
|
||||
{{ obj.content | update_inline_imgs | clean | replace_custom_emojis(obj) | code_highlight | safe }}
|
||||
{{ obj | get_text | update_inline_imgs | clean | replace_custom_emojis(obj) | code_highlight | safe }}
|
||||
{% endif %}
|
||||
|
||||
{% if obj | has_place %}
|
||||
|
@@ -215,7 +215,7 @@ def format_timeago(val):
|
||||
@filters.app_template_filter()
|
||||
def url_or_id(d):
|
||||
if isinstance(d, dict):
|
||||
if "url" in d:
|
||||
if "url" in d and isinstance(d["url"], str):
|
||||
return d["url"]
|
||||
else:
|
||||
return d["id"]
|
||||
@@ -367,7 +367,7 @@ def update_inline_imgs(content):
|
||||
def get_video_url(url):
|
||||
if isinstance(url, list):
|
||||
for link in url:
|
||||
if link.get("mimeType", "").startswith("video/"):
|
||||
if link.get("mediaType", "").startswith("video/"):
|
||||
return _get_file_url(link.get("href"), None, Kind.ATTACHMENT)
|
||||
else:
|
||||
return _get_file_url(url, None, Kind.ATTACHMENT)
|
||||
@@ -403,6 +403,14 @@ def get_video_link(data):
|
||||
return data
|
||||
return None
|
||||
|
||||
@filters.app_template_filter()
|
||||
def get_text(data):
|
||||
"""return first in 'content', 'name' or ''"""
|
||||
for _t in ("content", "name"):
|
||||
if _t in data:
|
||||
return data[_t]
|
||||
return ""
|
||||
|
||||
|
||||
@filters.app_template_filter()
|
||||
def has_type(doc, _types):
|
||||
|
Reference in New Issue
Block a user