0.1.1 - small fixes + installation instructions

This commit is contained in:
mystieneko 2024-08-28 12:20:25 +03:00
parent 046bcf740e
commit 07e35c9db5
10 changed files with 164 additions and 136 deletions

6
.env.example Normal file
View file

@ -0,0 +1,6 @@
DB_HOST = 127.0.0.1
DB_NAME = catask
DB_USER =
DB_PASS =
ADMIN_PASSWORD =
APP_SECRET =

View file

@ -1,2 +1,24 @@
# catask-server # CatAsk
## Installation
Clone this repository: `git clone https://git.gay/mst/catask.git`
### VPS-specific
Go into the cloned repository, create a virtual environment and activate it:
```python -m venv venv && . venv/bin/activate```
Install required packages:
```pip install -r requirements.txt```
### Shared hosting-specific
If your shared hosting provider supports [WSGI](https://w.wiki/_vTN2), [FastCGI](https://w.wiki/9EeQ), or something similar, use it (technically any CGI protocol could work)
## Post-installation
Create a MySQL/MariaDB database and connect MDFlare to it (in `.env` file)
Then init the database: `flask init-db`
If that doesn't work, try importing schema.sql into the created database manually
Rename `.env.example` to `.env`, configure all values there, and edit variable `fullBaseUrl` in `config.py` file
Then run it:
`flask run` or `gunicorn -w 4 app:app` (if you have gunicorn installed) or `python3 app.py`
If you want it to be accessible on a specific host address, specify a `--host` option (e.g. `--host 0.0.0.0`) to `flask run`
## Usage
Works on `127.0.0.1:5000` (`flask run` or `python app.py`) or `127.0.0.1:8000` (`gunicorn -w 4 app:app`), may work in a production environment

3
app.py
View file

@ -15,7 +15,8 @@ logged_in = False
load_dotenv() load_dotenv()
app = Flask(cfg.appName) app = Flask(cfg.appName)
app.config["SECRET_KEY"] = os.environ.get("APP_SECRET") print(os.environ.get("APP_SECRET"))
app.secret_key = os.environ.get("APP_SECRET")
# -- blueprints -- # -- blueprints --
api_bp = Blueprint('api', cfg.appName) api_bp = Blueprint('api', cfg.appName)

View file

@ -1,3 +1,3 @@
antiSpamFile = 'wordlist.txt' antiSpamFile = 'wordlist.txt'
blacklistFile = 'word_blacklist.txt' blacklistFile = 'word_blacklist.txt'
version = '0.1.0' version = '0.1.1'

View file

@ -1,3 +1,4 @@
flask flask
python-dotenv python-dotenv
mysql-connector-python==8.2.0 mysql-connector-python==8.2.0
humanize

View file

@ -1,5 +1,5 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% block title %}Admin Login{% endblock %}
{% block content %} {% block content %}
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">

View file

@ -40,11 +40,10 @@
{% endif %} {% endif %}
{% endwith %} {% endwith %}
{% block content %}{% endblock %} {% block content %}{% endblock %}
</div>
<script src="{{ url_for('static', filename='js/htmx.min.js') }}"></script> <script src="{{ url_for('static', filename='js/htmx.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/bootstrap.min.js') }}"></script> <script src="{{ url_for('static', filename='js/bootstrap.min.js') }}"></script>
{% block scripts %} {% block scripts %}{% endblock %}
{% endblock %}
</div>
<footer class="py-3 my-4"> <footer class="py-3 my-4">
<p class="text-center text-body-secondary">CatAsk v{{ version }}</p> <p class="text-center text-body-secondary">CatAsk v{{ version }}</p>
</footer> </footer>

View file

@ -10,7 +10,7 @@
<h5 class="card-title mt-0">{% if question.from_who %}{{ question.from_who }}{% else %}Anonymous{% endif %}</h5> <h5 class="card-title mt-0">{% if question.from_who %}{{ question.from_who }}{% else %}Anonymous{% endif %}</h5>
<h6 class="card-subtitle fw-light text-body-secondary">{{ formatRelativeTime(str(question.creation_date)) }}</h6> <h6 class="card-subtitle fw-light text-body-secondary">{{ formatRelativeTime(str(question.creation_date)) }}</h6>
</div> </div>
<p>{{ question.content }}</span> <p>{{ question.content }}</p>
<form hx-post="{{ url_for('api.addAnswer', question_id=question.id) }}" hx-target="#question-{{ question.id }}" hx-swap="none"> <form hx-post="{{ url_for('api.addAnswer', question_id=question.id) }}" hx-target="#question-{{ question.id }}" hx-swap="none">
<div class="form-group d-grid gap-2"> <div class="form-group d-grid gap-2">
<textarea class="form-control" required name="answer" id="answer-{{ question.id }}" placeholder="Write your answer..."></textarea> <textarea class="form-control" required name="answer" id="answer-{{ question.id }}" placeholder="Write your answer..."></textarea>

View file

@ -48,7 +48,6 @@
{% endblock %} {% endblock %}
{% block scripts %} {% block scripts %}
<script> <script>
console.log(navigator.clipboard);
function copy(questionId) { function copy(questionId) {
navigator.clipboard.writeText("{{ cfg.fullBaseUrl }}/q/" + questionId + "/") navigator.clipboard.writeText("{{ cfg.fullBaseUrl }}/q/" + questionId + "/")
} }