Skip to content

Commit

Permalink
Fix version display
Browse files Browse the repository at this point in the history
  • Loading branch information
oeway committed Feb 13, 2021
1 parent cb51be4 commit 6f5e711
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 31 deletions.
14 changes: 3 additions & 11 deletions imjoy_elfinder/elfinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,8 +839,7 @@ def __upload_large_file(self) -> None:
break

with open(
record_path,
"r+" if os.path.exists(record_path) else "w+",
record_path, "r+" if os.path.exists(record_path) else "w+",
) as fil:
fil.seek(chunk_index)
fil.write("X")
Expand Down Expand Up @@ -1937,9 +1936,7 @@ def _path2url(self, path: str) -> str:
cur_dir = path
length = len(self._options["root"])
url = multi_urljoin(
self._options["base_url"],
self._options["files_url"],
cur_dir[length:],
self._options["base_url"], self._options["files_url"], cur_dir[length:],
)
url = self._check_utf8(url).replace(os.sep, "/")
url = quote(url, safe="/")
Expand Down Expand Up @@ -2393,10 +2390,5 @@ def make_hash(to_hash: str) -> str:
def multi_urljoin(*parts: str) -> str:
"""Join multiple url parts into a valid url."""
if parts[0].startswith("http"):
return str(
urljoin(
parts[0],
"/".join(part.strip("/") for part in parts[1:]),
)
)
return str(urljoin(parts[0], "/".join(part.strip("/") for part in parts[1:]),))
return "/" + "/".join(part.strip("/") for part in parts if part)
5 changes: 3 additions & 2 deletions imjoy_elfinder/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from fastapi.responses import FileResponse
from fastapi.responses import PlainTextResponse, JSONResponse

from . import elfinder
from . import elfinder, __version__
from .api_const import API_NAME, API_TARGETS, API_DIRS, API_UPLOAD, API_UPLOAD_PATH
from .util import get_all, get_one
from .settings import get_settings
Expand Down Expand Up @@ -108,5 +108,6 @@ async def connector(request: Request):
@router.get("/filebrowser", response_class=HTMLResponse)
async def index(request: Request):
return templates.TemplateResponse(
"elfinder/filebrowser.jinja2", {"request": request}
"elfinder/filebrowser.jinja2",
{"request": request, "IMJOY_ELFINDER_VERSION": __version__},
)
20 changes: 2 additions & 18 deletions tests/test_elfinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,24 +238,8 @@ def test_run(
None,
{"file": "txt_file_parent", "mode": 0o100},
), # With no init and no read access to target
(
"Invalid parameters",
None,
[],
None,
None,
None,
None,
),
(
"File not found",
None,
[],
None,
"missing",
None,
None,
),
("Invalid parameters", None, [], None, None, None, None,),
("File not found", None, [], None, "missing", None, None,),
],
indirect=["access"],
)
Expand Down

0 comments on commit 6f5e711

Please # to comment.