Skip to content

Commit

Permalink
Use elfinder-client for static assets (#89)
Browse files Browse the repository at this point in the history
* Use elfinder client

* Add blank line

* change order

* bump version

* Fix linter

* Sort list
  • Loading branch information
oeway committed Apr 19, 2020
1 parent 8d6b2f3 commit 38ed852
Show file tree
Hide file tree
Showing 196 changed files with 208 additions and 70,688 deletions.
2 changes: 1 addition & 1 deletion imjoy_elfinder/VERSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "0.1.46"
"version": "0.1.47"
}
12 changes: 9 additions & 3 deletions imjoy_elfinder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@
by Alexandr Rakov 08-03-2012
"""
from pyramid.config import Configurator
from elfinder_client import get_base_dir

IMJOY_ELFINDER_CONNECTOR = "imjoy_elfinder_connector"
IMJOY_ELFINDER_FILEBROWSER = "imjoy_elfinder_filebrowser"


def includeme(config: Configurator) -> None:
"""Include frontend."""
config.include(".routes")
config.include(".assets")
"""Include routes and assets."""
# routes
config.add_route(IMJOY_ELFINDER_FILEBROWSER, "/")
config.add_route(IMJOY_ELFINDER_CONNECTOR, "/connector/")
config.scan(".views")
# assets
config.include("pyramid_jinja2")
config.add_jinja2_search_path("imjoy_elfinder:templates")
config.add_static_view(name="static", path=get_base_dir())
10 changes: 2 additions & 8 deletions imjoy_elfinder/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,13 @@
from pyramid.response import Response
from pyramid.router import Router

from imjoy_elfinder import IMJOY_ELFINDER_FILEBROWSER


def build_app(opt: argparse.Namespace, settings: Dict[str, Optional[str]]) -> Router:
"""Build the app."""
config = Configurator(settings=settings)
config.include("imjoy_elfinder")

# serve the folder content as static files under /static
config.add_static_view(settings["files_url"], settings["root_dir"])

# serve the file browser under /
config.add_route(IMJOY_ELFINDER_FILEBROWSER, "/")
# serve the folder content with a route path defined with `files_url`
config.add_static_view(name=settings["files_url"], path=settings["root_dir"])

def add_cors_headers_response_callback(event: Any) -> None:
def cors_headers(request: Request, response: Response) -> None:
Expand Down
17 changes: 0 additions & 17 deletions imjoy_elfinder/assets.py

This file was deleted.

2 changes: 1 addition & 1 deletion imjoy_elfinder/elfinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -2106,7 +2106,7 @@ def _check_utf8(self, name: Union[str, bytes]) -> str:

def _check_name(name: str) -> bool:
"""Check for valid file/dir name."""
if secure_filename(name) != name.replace(' ', '_'): # type: ignore
if secure_filename(name) != name.replace(" ", "_"): # type: ignore
return False
return True

Expand Down
17 changes: 0 additions & 17 deletions imjoy_elfinder/routes.py

This file was deleted.

0 comments on commit 38ed852

Please sign in to comment.