Compare commits

..

10 commits

Author SHA1 Message Date
7ea505e27b adapt 2024-08-14 09:23:25 +09:00
mb
47e535b9e6 'README.md' updaten 2023-11-29 17:07:25 +01:00
mb
af123cd25d 'README.md' updaten 2023-11-29 17:06:48 +01:00
mb
ce60cf94bf 'README.md' updaten 2023-11-29 17:06:31 +01:00
mb
7ad6f9ca42 'Makefile' updaten 2023-11-29 17:01:38 +01:00
mb
1af89f1be3 'Makefile' updaten 2023-11-29 17:00:04 +01:00
mb
9353ae7210 'Makefile' updaten 2023-11-29 16:59:35 +01:00
mb
1f960a387f 'requirements.txt' updaten 2023-11-29 16:58:28 +01:00
mb
da5d22c6df 'README.md' updaten 2023-11-29 16:56:18 +01:00
mb
d269241505 'README.md' updaten 2023-11-29 16:56:00 +01:00
9 changed files with 47 additions and 16 deletions

2
.gitignore vendored
View file

@ -1 +1,3 @@
.env
.venv

1
.python-version Normal file
View file

@ -0,0 +1 @@
3.12.5

View file

@ -12,4 +12,5 @@ local:
@.venv/bin/python octomode.py
action:
@if [ ! -f ".venv/bin/gunicorn" ]; then .venv/bin/pip install gunicorn; fi
@SCRIPT_NAME=${OCTOMODE_APPLICATION_ROOT} .venv/bin/gunicorn -b localhost:${OCTOMODE_PORTNUMBER} --reload octomode:APP

View file

@ -53,18 +53,14 @@ This creates a virtual environment at `.venv` and installs all the dependencies
sudo apt install pandoc
```
Configure your webserver, to connect your application root (for example `octomode.domain.org` or `sub.domain.org/octomode/`) to the port on which the flask application is running (`localhost:5001` by default).
Configure your webserver, to connect your application root (for example `octomode.mydomainname.ext`) to the port on which the flask application is running (`localhost:5001` by default).
This is an example for nginx webservers:
```
# ----------------------------------------------------
# OCTOMODE
location /octomode/ {
proxy_pass http://localhost:5555;
}
location /octomode/ {
proxy_pass http://localhost:5555;
}
```
And finally, run the application.
@ -77,7 +73,21 @@ Open the application at port `5001`, for example: http://localhost:5001
## Install with URL prefix
If you want to install octomode with an URL prefix, like <https://mydomainname.ext/octomode/>, then you can use the gunicorn WSGI. If you have ran the `make setup` command already, then `gunicorn` is already installed. Configure your application root URL in your `.env` file. You can simply run *octomode* now with the following command to run it with `gunicorn` (and not the built-in Flask dev server): `make action`
If you want to install octomode with an URL prefix, like <https://mydomainname.ext/octomode/>, then you can use the gunicorn WSGI.
Configure your application root URL in your `.env` file to `/octomode`:
```
OCTOMODE_APPLICATION_ROOT=/octomode
```
After that, you can simply run:
```
make action
```
This will first check if you already install gunicorn in the `.venv` folder, and after that run *octomode* with `gunicorn` and not the built-in Flask dev server.
## Which browser to use?

Binary file not shown.

View file

@ -118,12 +118,12 @@ def main(name):
@APP.route('/<name>/pad/')
def pad(name):
url = f"{ APP.config['PAD_URL'] }/{ name }.md"
url = f"{ APP.config['PAD_URL'] }/p/{ name }.md"
return render_template('iframe.html', url=url, name=name.strip(), pad_url=APP.config['PAD_URL'])
@APP.route('/<name>/stylesheet/')
def stylesheet(name):
url = f"{ APP.config['PAD_URL'] }/{ name }.css"
url = f"{ APP.config['PAD_URL'] }/p/{ name }.css"
return render_template('iframe.html', url=url, name=name.strip(), pad_url=APP.config['PAD_URL'])
@APP.route('/<name>/html/')
@ -175,7 +175,16 @@ def preview(name):
lang = "en"
title = "No title"
return render_template('preview.html', name=name.strip(), pad_content=html, lang=lang, title=title)
# only here we need application root to make all the URLs work.....
if APP.config['APPLICATION_ROOT'] == '/':
app_root = ''
elif APP.config['APPLICATION_ROOT'].endswith('/'):
app_root = APP.config['APPLICATION_ROOT'][:-1]
else:
app_root = APP.config['APPLICATION_ROOT']
urn = f"{ app_root }/{ name }"
return render_template('preview.html', urn=urn, name=name.strip(), pad_content=html, lang=lang, title=title)
@APP.route('/<name>/pagedjs.html')
def pagedjs(name):
@ -186,7 +195,16 @@ def pagedjs(name):
lang = metadata['language'][0]
title = metadata['title'][0]
return render_template('pagedjs.html', name=name.strip(), pad_content=html, lang=lang, title=title)
# only here we need application root to make all the URLs work.....
if APP.config['APPLICATION_ROOT'] == '/':
app_root = ''
elif APP.config['APPLICATION_ROOT'].endswith('/'):
app_root = APP.config['APPLICATION_ROOT'][:-1]
else:
app_root = APP.config['APPLICATION_ROOT']
urn = f"{ app_root }/{ name }"
return render_template('pagedjs.html', urn=urn, name=name.strip(), pad_content=html, lang=lang, title=title)
# //////////////////

View file

@ -1,5 +1,4 @@
flask
gunicorn
pypandoc
markdown
python-dotenv

View file

@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="{{ url_for('static', filename='paged.polyfill.js') }}" type="text/javascript"></script>
<link href="{{ url_for('static', filename='pagedjs.css') }}" rel="stylesheet" type="text/css" media="screen">
<link href="/{{ name }}/stylesheet.css" rel="stylesheet" type="text/css" media="print">
<link href="{{ urn }}/stylesheet.css" rel="stylesheet" type="text/css" media="print">
<title>{{ title }}</title>
</head>
<body>

View file

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="/{{ name }}/stylesheet.css" rel="stylesheet" type="text/css" media="screen">
<link href="{{ urn }}/stylesheet.css" rel="stylesheet" type="text/css" media="screen">
<title>{{ title }}</title>
</head>
<body>