Skip to content

Commit

Permalink
Dirbrowser use relative paths to support reverse proxies
Browse files Browse the repository at this point in the history
Close #268
  • Loading branch information
mar10 committed Oct 21, 2022
1 parent 41b38ee commit b96f07f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 4.0.3 / Unreleased

- #246 Add dir_browser/htdocs folder setup.cfg (for install with `pip install .`)
- #268 Use relative paths to support reverse proxies

## 4.0.2 / 2022-08-01

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[![StackOverflow: WsgiDAV](https://img.shields.io/badge/StackOverflow-WsgiDAV-blue.svg)](https://stackoverflow.com/questions/tagged/WsgiDAV)


[![Open in Visual Studio Code](https://img.shields.io/badge/--007ACC?logo=visual%20studio%20code&logoColor=ffffff) Open in Visual Studio Code (experimental)](https://open.vscode.dev/mar10/wsgidav)
[![Edit online in vscode.dev](https://img.shields.io/badge/--007ACC?logo=visual%20studio%20code&logoColor=ffffff) Open in Visual Studio Code (experimental)](https://open.vscode.dev/mar10/wsgidav)

<!-- [![Open in Visual Studio Code](https://open.vscode.dev/badges/open-in-vscode.svg)](https://open.vscode.dev/mar10/wsgidav) -->

Expand Down
Binary file not shown.
14 changes: 7 additions & 7 deletions wsgidav/dir_browser/_dir_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from wsgidav import __version__, util
from wsgidav.dav_error import HTTP_MEDIATYPE_NOT_SUPPORTED, HTTP_OK, DAVError
from wsgidav.mw.base_mw import BaseMiddleware
from wsgidav.util import safe_re_encode
from wsgidav.util import get_uri_name, safe_re_encode

__docformat__ = "reStructuredText"

Expand Down Expand Up @@ -182,9 +182,7 @@ def _get_context(self, environ, dav_res):
if trailer:
trailer = trailer.replace(
"${version}",
"<a href='https://github.com/mar10/wsgidav/'>WsgiDAV/{}</a>".format(
__version__
),
f"<a href='https://github.com/mar10/wsgidav/'>WsgiDAV/{__version__}</a>",
)
trailer = trailer.replace("${time}", util.get_rfc1123_time())

Expand All @@ -202,6 +200,8 @@ def _get_context(self, environ, dav_res):
for res in childList:
di = res.get_display_info()
href = res.get_href()
# #268 Use relative paths to support reverse proxies:
rel_href = get_uri_name(href)
ofe_prefix = None
tr_classes = []
a_classes = []
Expand All @@ -214,11 +214,11 @@ def _get_context(self, environ, dav_res):
ms_office_type = MS_OFFICE_EXT_TO_TYPE_MAP.get(ext)
if ms_office_type:
if ms_sharepoint_support:
ofe_prefix = "ms-{}:ofe|u|".format(ms_office_type)
ofe_prefix = f"ms-{ms_office_type}:ofe|u|"
a_classes.append("msoffice")
if libre_office_support:
add_link_html.append(
f"<a class='edit2' title='Edit with Libre Office' href='vnd.libreoffice.command:ofv|u|{href}'>Edit</a>"
f"<a class='edit2' title='Edit with Libre Office' href='vnd.libreoffice.command:ofv|u|{rel_href}'>Edit</a>"
)
# ofe_prefix_2 = "vnd.libreoffice.command:ofv|u|"
# a_classes.append("msoffice")
Expand All @@ -232,7 +232,7 @@ def _get_context(self, environ, dav_res):
a_classes.append("msoffice")

entry = {
"href": href,
"href": rel_href,
"ofe_prefix": ofe_prefix,
"a_class": " ".join(a_classes),
"add_link_html": "".join(add_link_html),
Expand Down
2 changes: 1 addition & 1 deletion wsgidav/dir_browser/htdocs/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ <h1>
{%- if parent_url %}
<tr class="directory">
<td>
<a href="{{ parent_url }}">..</a>
<a href="..">..</a>
</td>
<td>Directory</td>
<td>-</td>
Expand Down

0 comments on commit b96f07f

Please sign in to comment.