NEODB_SITE_INTRO and more documentation

This commit is contained in:
Your Name 2023-10-20 21:04:31 +00:00 committed by Henri Dickson
parent 8827ef9601
commit dc5e7fc377
6 changed files with 66 additions and 25 deletions

View file

@ -24,6 +24,7 @@ env = environ.FileAwareEnv(
NEODB_SITE_LOGO=(str, "/s/img/logo.svg"),
NEODB_SITE_ICON=(str, "/s/img/logo.svg"),
NEODB_USER_ICON=(str, "/s/img/avatar.svg"),
NEODB_SITE_INTRO=(str, ""),
# Links in site footer
NEODB_SITE_LINKS=(dict, {}),
# Invite only mode
@ -145,6 +146,7 @@ SITE_INFO = {
"site_logo": env("NEODB_SITE_LOGO"),
"site_icon": env("NEODB_SITE_ICON"),
"user_icon": env("NEODB_USER_ICON"),
"site_intro": env("NEODB_SITE_INTRO"),
"site_links": [{"title": k, "url": v} for k, v in env("NEODB_SITE_LINKS").items()],
}

View file

@ -9,23 +9,29 @@
{% load bleach_tags %}
<div class="grid__aside">
<section>
<article>
<h3>欢迎 🙋🏻‍♀️ 🙋🏻 🙋🏻‍♂️</h3>
<p>
<i class="fa-solid fa-puzzle-piece"></i> &nbsp; {{ site_name }}致力于提供一个涵盖书籍、影视、音乐、游戏、播客的自由开放互联的收藏评论空间。 你可以在这里记录你的收藏和想法,以及发现新的内容和朋友。
</p>
<p>
<i class="fa-solid fa-globe"></i> &nbsp; 登录{{ site_name }}的最佳方式通过联邦宇宙Fediverse有时也被称为长毛象一种分布式社交网络实例账号如果你还没有注册过可先<a href="https://joinmastodon.org/zh/servers" target="_blank">选择实例并注册</a>
</p>
<p>
<i class="fa-solid fa-envelope"></i> &nbsp; 如果还没准备好注册联邦宇宙也没问题,你可以在登录页面选择电子邮件注册,未来再连接到联邦宇宙。
</p>
<p>
<i class="fa-solid fa-circle-question"></i> &nbsp; 如果有任何问题或建议,欢迎通过<a href="https://mastodon.social/@neodb">联邦宇宙</a><a href="https://discord.gg/uprvcH8gqD">Discord</a>和我们联系。
</p>
<p>
<i class="fa-solid fa-door-open"></i> &nbsp; <a href="{% url 'users:login' %}">点击这里</a>登录。
</p>
</article>
{% if site_intro %}
<div hx-get="{{ site_intro }}" hx-trigger="load" hx-swap="outerHTML">
<i class="fa-solid fa-compact-disc fa-spin loading"></i>
</div>
{% else %}
<article>
<h3>欢迎 🙋🏻‍♀️ 🙋🏻 🙋🏻‍♂️</h3>
<p>
<i class="fa-solid fa-puzzle-piece"></i> &nbsp; {{ site_name }}致力于提供一个涵盖书籍、影视、音乐、游戏、播客的自由开放互联的收藏评论空间。 你可以在这里记录你的收藏和想法,以及发现新的内容和朋友。
</p>
<p>
<i class="fa-solid fa-globe"></i> &nbsp; 登录{{ site_name }}的最佳方式通过联邦宇宙Fediverse有时也被称为长毛象一种分布式社交网络实例账号如果你还没有注册过可先<a href="https://joinmastodon.org/zh/servers" target="_blank">选择实例并注册</a>
</p>
<p>
<i class="fa-solid fa-envelope"></i> &nbsp; 如果还没准备好注册联邦宇宙也没问题,你可以在登录页面选择电子邮件注册,未来再连接到联邦宇宙。
</p>
<p>
<i class="fa-solid fa-circle-question"></i> &nbsp; 如果有任何问题或建议,欢迎通过<a href="https://mastodon.social/@neodb">联邦宇宙</a><a href="https://discord.gg/uprvcH8gqD">Discord</a>和我们联系。
</p>
<p>
<i class="fa-solid fa-door-open"></i> &nbsp; <a href="{% url 'users:login' %}">点击这里</a>登录。
</p>
</article>
{% endif %}
</section>
</div>

View file

@ -19,6 +19,7 @@ x-shared:
NEODB_SECRET_KEY:
NEODB_SITE_NAME:
NEODB_SITE_DOMAIN:
NEODB_SITE_INTRO:
NEODB_SITE_LOGO:
NEODB_SITE_ICON:
NEODB_USER_ICON:

View file

@ -3,7 +3,7 @@ Development
Overview
--------
NeoDB is a Django project, and it runs side by side with a modified version of [Takahe](https://github.com/jointakahe/takahe) (a separate Django project, code in `neodb_takahe` as submodule). They communicate mainly thru database and task queue, the diagram in [Docker Installation](install-docker.md) demostrate a typical architecture. Currently the two are loosely coupled, so you may take either one offline without immediate impact on the other, which makes it very easy to conduct maintenance and troubleshooting separately. In the future, they may get combined but it's not decided and will not be decided very soon.
NeoDB is a Django project, and it runs side by side with a [modified version](https://github.com/neodb-social/neodb-takahe) of [Takahe](https://github.com/jointakahe/takahe) (a separate Django project, code in `neodb_takahe` as submodule). They communicate mainly thru database and task queue, the diagram in [Docker Installation](install-docker.md) demostrate a typical architecture. Currently the two are loosely coupled, so you may take either one offline without immediate impact on the other, which makes it very easy to conduct maintenance and troubleshooting separately. In the future, they may get combined but it's not decided and will not be decided very soon.
Before writing code
-------------------
@ -60,11 +60,16 @@ Preserving test database for alias 'default'...
Development in Docker
---------------------
To run local source code with `docker compose`, add `NEODB_DEBUG=True` in `.env`, and use `--profile dev` instead of `--profile production` in commands. The `dev` profile is different from `production`:
To run local source code with `docker compose`, add `NEODB_DEBUG=True` in `.env` or host environment, and use `--profile dev` instead of `--profile production` in commands, e.g.:
```
$ NEODB_DEBUG=True docker compose --profile dev up -d
```
The `dev` profile is different from `production`:
- code in `NEODB_SRC` (default: .) and `TAKAHE_SRC` (default: ./neodb-takahe) will be mounted and used in the container instead of code in the image
- `runserver` with autoreload will be used instead of `gunicorn` for both neodb and takahe web server
- /static/ and /s/ url are not map to pre-generated/collected static file path, `NEODB_DEBUG=True` will locate static files from source code
- /static/ and /s/ url are not map to pre-generated/collected static file path, `NEODB_DEBUG=True` is required locate static files from source code
- one `rqworker` container will be started, instead of two
- use `dev-shell` and `dev-root` to invoke shells, instead of `shell` and `root`
- there's no automatic `migration` container, but it can be triggered manually via `docker compose run dev-shell neodb-init`
@ -73,7 +78,7 @@ Note:
- Python virtual environments inside docker image, which are `/neodb-venv` and `/takahe-venv`, will be used by default. They can be changed to different locations with `TAKAHE_VENV` and `NEODB_VENV` if needed, usually in a case of development code using a package not in docker venv.
- Some packages inside python virtual environments are platform dependent, so mount venv built by macOS host into the Linux container will likely not work.
- Python servers are launched as `app` user, who has no write access to anywhere except /tmp and media path, that's by design.
- Database/redis used in the container cluster are not accessible outside, which is by design. Querying them can be done by either apt update/install client packages in `dev-root` or `root` container, or create `compose.override.yml` to uncomment `ports` section.
- Database/redis used in the container cluster are not accessible from host directly, which is by design. Querying them can be done by either apt update/install client packages in `dev-root` or `root` container, or create `compose.override.yml` to uncomment `ports` section.
To run local unit tests, use `docker compose run dev-shell neodb-manage test`

View file

@ -43,7 +43,7 @@ $ sudo usermod -aG docker neouser
```
## Get configuration files
- create a folder for configuration, eg ~/neodb/config
- create a folder for configuration, eg ~/mysite/config
- grab `compose.yml` and `neodb.env.example` from source code
- rename `neodb.env.example` to `.env`
@ -67,7 +67,13 @@ $ docker compose pull
$ docker compose --profile production up -d
```
In a minute or so, the site should be up at 127.0.0.1:8000 , you may check it with:
Starting up for the first time might take a few minutes, depending on download speed, use the following commands for status and logs:
```
$ docker compose ps
$ docker compose --profile production logs -f
```
In a few seconds, the site should be up at 127.0.0.1:8000 , you may check it with:
```
$ curl http://localhost:8000/nodeinfo/2.0/
```
@ -77,6 +83,8 @@ JSON response will be returned if the server is up and running:
{"version": "2.0", "software": {"name": "neodb", "version": "0.8-dev"}, "protocols": ["activitypub", "neodb"], "services": {"outbound": [], "inbound": []}, "usage": {"users": {"total": 1}, "localPosts": 0}, "openRegistrations": true, "metadata": {}}
```
## Make the site available publicly
Next step is to expose `127.0.0.1:8000` to external network as `https://yourdomain.tld` . There are many ways to do it, you may use nginx as a reverse proxy with a ssl cert, or configure a CDN provider to handle the SSL. There's no detailed instruction yet but contributions are welcomed.
@ -96,7 +104,7 @@ $ docker compose stop neodb-web neodb-worker neodb-worker-extra takahe-web takah
$ docker compose --profile production up -d
```
Otherwise restart the entire cluster:
Otherwise restart the entire cluster (including database/etc, hence slower):
```
$ docker compose down
$ docker compose --profile production up -d
@ -104,6 +112,24 @@ $ docker compose --profile production up -d
If there is `compose.override.yml` in the directory, make sure it's compatible with the updated `compose.yml`.
## Folders explained
a typical neodb folder after starting up should look like:
```
mysite
├── data # neodb data folder, location can be changed via NEODB_DATA in .env
│   ├── neodb-db # neodb database
│   ├── neodb-media # uid must be 1000 (app user in docker image), chmod if not so
│   ├── redis # neodb/takahe cache
│   ├── takahe-cache # uid must be 33 (www-data user in docker image), chmod if not so
│   ├── takahe-db # neodb database
│   ├── takahe-media # uid must be 1000 (app user in docker image), chmod if not so
│   ├── typesense # neodb search index
│   └── www-root # neodb web root for robots.txt, logo.png and etc
└── config
├── compose.yml # copied from neodb release
└── .env # your configuration, see neodb.env.example
```
## Troubleshooting
- `docker compose ps` to see if any service is down, (btw it's normal that `migration` is in `Exit 0` state)

View file

@ -10,6 +10,7 @@ NEODB_SITE_DOMAIN=example.site
# NEODB_SITE_DOMAIN=${CODESPACE_NAME}-8000.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}
# Change these too
NEODB_SITE_INTRO=/welcome.html
NEODB_SITE_LOGO=/logo.png
NEODB_SITE_ICON=/icon.png
NEODB_SITE_LINKS=@NiceDB=https://donotban.com/@testie,@NeoDB=https://mastodon.social/@neodb