Compare commits
10 commits
985e0be1ce
...
7ea505e27b
| Author | SHA1 | Date | |
|---|---|---|---|
| 7ea505e27b | |||
|
|
47e535b9e6 | ||
|
|
af123cd25d | ||
|
|
ce60cf94bf | ||
|
|
7ad6f9ca42 | ||
|
|
1af89f1be3 | ||
|
|
9353ae7210 | ||
|
|
1f960a387f | ||
|
|
da5d22c6df | ||
|
|
d269241505 |
9 changed files with 47 additions and 16 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -1 +1,3 @@
|
|||
.env
|
||||
.venv
|
||||
|
||||
|
|
|
|||
1
.python-version
Normal file
1
.python-version
Normal file
|
|
@ -0,0 +1 @@
|
|||
3.12.5
|
||||
1
Makefile
1
Makefile
|
|
@ -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
|
||||
|
|
|
|||
22
README.md
22
README.md
|
|
@ -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;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
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?
|
||||
|
||||
|
|
|
|||
BIN
__pycache__/octomode.cpython-312.pyc
Normal file
BIN
__pycache__/octomode.cpython-312.pyc
Normal file
Binary file not shown.
26
octomode.py
26
octomode.py
|
|
@ -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)
|
||||
|
||||
# //////////////////
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
flask
|
||||
gunicorn
|
||||
pypandoc
|
||||
markdown
|
||||
python-dotenv
|
||||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Reference in a new issue