diff --git a/pyproject.toml b/pyproject.toml index 81ce80e..a8b2177 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,7 @@ classifiers = [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", ] -dependencies = ["requests", "flask", "markdown2"] +dependencies = ["requests", "flask", "markdown2[all]"] [project.urls] "Homepage" = "https://git.private.coffee/kumi/gitcloak" diff --git a/src/gitcloak/app.py b/src/gitcloak/app.py index d12a7ca..0a85373 100644 --- a/src/gitcloak/app.py +++ b/src/gitcloak/app.py @@ -73,7 +73,13 @@ def get_raw(owner, repo, file_path): git = Git(repo_url) try: file_content = git.get_file_content(file_path) - return file_content + try: + file_content = file_content.decode("utf-8") + content_type = "text/plain" + except UnicodeDecodeError: + content_type = "application/octet-stream" + + return file_content, 200, {"Content-Type": content_type} except Exception as e: logger.error( f"Error getting file content for {file_path} in {owner}/{repo}: {e}" diff --git a/src/gitcloak/assets/css/style.css b/src/gitcloak/assets/css/style.css index c02ce96..5ec9c79 100644 --- a/src/gitcloak/assets/css/style.css +++ b/src/gitcloak/assets/css/style.css @@ -1,19 +1,18 @@ -html, body { +html, +body { margin: 0; padding: 0; height: 100%; } -body { - padding-top: 56px; /* Height of the navbar */ -} - -.directory a, .file a { +.directory a, +.file a { text-decoration: none; color: #0366d6; } -.directory a:hover, .file a:hover { +.directory a:hover, +.file a:hover { text-decoration: underline; } @@ -30,4 +29,18 @@ body { padding: 10px; border-radius: 4px; overflow: auto; +} + +.icon { + margin-right: 5px; +} + +.list-group-item { + display: flex; + align-items: center; +} + +.navbar-brand { + font-size: 1.5rem; + padding: 0 10px; } \ No newline at end of file diff --git a/src/gitcloak/assets/dist/icons/LICENSE b/src/gitcloak/assets/dist/icons/LICENSE new file mode 100644 index 0000000..e2eb0bd --- /dev/null +++ b/src/gitcloak/assets/dist/icons/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Phosphor Icons + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/src/gitcloak/assets/dist/icons/file.svg b/src/gitcloak/assets/dist/icons/file.svg new file mode 100644 index 0000000..85a7544 --- /dev/null +++ b/src/gitcloak/assets/dist/icons/file.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/gitcloak/assets/dist/icons/folder.svg b/src/gitcloak/assets/dist/icons/folder.svg new file mode 100644 index 0000000..88d66bf --- /dev/null +++ b/src/gitcloak/assets/dist/icons/folder.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/gitcloak/templates/base.html b/src/gitcloak/templates/base.html index 930c1b2..83d7676 100644 --- a/src/gitcloak/templates/base.html +++ b/src/gitcloak/templates/base.html @@ -4,12 +4,12 @@ {% block title %}GitCloak{% endblock %} - - + +
{% block content %}{% endblock %} diff --git a/src/gitcloak/templates/path.html b/src/gitcloak/templates/path.html index 6345a06..b54b60e 100644 --- a/src/gitcloak/templates/path.html +++ b/src/gitcloak/templates/path.html @@ -1,46 +1,49 @@ -{% extends 'base.html' %} {% block title %}{{ owner }}/{{ repo }} - {{ path }}{% -endblock %} {% block content %} +{% extends 'base.html' %} {% block title %}{{ owner }}/{{ repo }} - {{ path or +"/" }}{% endblock %} {% block content %}
-

{{ owner }}/{{ repo }} - {{ path }}

-
-

Directories

-
- {% for directory in directories %} - - {% endfor %} +

{{ owner }}/{{ repo }} - {{ path or "/" }}

+
+ {% if path %} +
+ Go up..
-
-
-

Files

-
- {% for file in files %} - - {% endfor %} + {% endif %} {% for entry in directories + files %} +
+ + {{ 'folder' if entry in
+          directories else 'file' }} {{ entry }} +
+ {% endfor %}
-
- {% if readme_content %} +
+ +{% if readme_content %} +
+

README.md

{{ readme_content|safe }}
- {% endif %}
-{% endblock %} +{% endif %} {% endblock %}