This commit is contained in:
Dooho Yi 2024-08-14 09:23:25 +09:00
parent 47e535b9e6
commit 7ea505e27b
6 changed files with 27 additions and 6 deletions

2
.gitignore vendored
View file

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

1
.python-version Normal file
View file

@ -0,0 +1 @@
3.12.5

Binary file not shown.

View file

@ -118,12 +118,12 @@ def main(name):
@APP.route('/<name>/pad/') @APP.route('/<name>/pad/')
def pad(name): 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']) return render_template('iframe.html', url=url, name=name.strip(), pad_url=APP.config['PAD_URL'])
@APP.route('/<name>/stylesheet/') @APP.route('/<name>/stylesheet/')
def stylesheet(name): 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']) return render_template('iframe.html', url=url, name=name.strip(), pad_url=APP.config['PAD_URL'])
@APP.route('/<name>/html/') @APP.route('/<name>/html/')
@ -175,7 +175,16 @@ def preview(name):
lang = "en" lang = "en"
title = "No title" 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') @APP.route('/<name>/pagedjs.html')
def pagedjs(name): def pagedjs(name):
@ -186,7 +195,16 @@ def pagedjs(name):
lang = metadata['language'][0] lang = metadata['language'][0]
title = metadata['title'][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

@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="{{ url_for('static', filename='paged.polyfill.js') }}" type="text/javascript"></script> <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="{{ 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> <title>{{ title }}</title>
</head> </head>
<body> <body>

View file

@ -3,7 +3,7 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <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> <title>{{ title }}</title>
</head> </head>
<body> <body>