Skip to content

Add application hiding #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,8 @@ The URL to an icon representing the app.

### `apps.<app-name>.url`
The URL at which the app is hosted, to which the user will be redirected when clicking it.

### `apps.<app-name>.hidden`
Set to `true` to mark an app as hidden and prevent it being shown to users.

If an app is fetched from authentik with `auth.fetch`, this will be set to `true` if the app's launch URL is `blank://blank`, as this is how authentik natively hides apps ([docs](https://docs.goauthentik.io/docs/add-secure-apps/applications/manage_apps#hide-applications)).
2 changes: 1 addition & 1 deletion src/blobdash/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import flask as f
from click import secho
from pydantic import ValidationError, BaseModel
from pydantic import ValidationError


from .settings import Settings
Expand Down
1 change: 1 addition & 0 deletions src/blobdash/applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Application:
url: Optional[str] = None
icon: Optional[str] = None
desc: Optional[str] = None
hidden: bool = False


class ApplicationProvider:
Expand Down
4 changes: 4 additions & 0 deletions src/blobdash/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ def get_applications(self, username: str) -> list[Application]:
url=app.launch_url,
icon=urllib.parse.urljoin(self.host, app.meta_icon),
desc=app.meta_description,
hidden=(
(parsed_url := urllib.parse.urlparse(app.launch_url)).scheme == "blank"
and parsed_url.netloc == "blank"
),
)
for app in list.results
}
Expand Down
1 change: 0 additions & 1 deletion src/blobdash/settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from typing import Tuple, Type, Optional, Literal
from abc import ABCMeta

from pydantic import BaseModel
from pydantic_extra_types import color
Expand Down
16 changes: 9 additions & 7 deletions src/blobdash/templates/index.html.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,15 @@
</dialog>
<main>
{% for app in apps.values() %}
<a href="{{ app.url }}">
<img src="{{ app.icon }}">
<h3>
{{ app.name }}
</h3>
<p>{{ app.desc }}</p>
</a>
{% if not app.hidden %}
<a href="{{ app.url }}">
<img src="{{ app.icon }}">
<h3>
{{ app.name }}
</h3>
<p>{{ app.desc }}</p>
</a>
{% endif %}
{% endfor %}
</main>
</body>
Expand Down
Loading