Skip to content
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

Support favicon customization #520

Merged
merged 7 commits into from
Mar 14, 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
4 changes: 4 additions & 0 deletions docs/changelog/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

* Add Support for favicon customization by [@omarmoo5](https://github.com/omarmoo5) in [#520](https://github.com/jowilf/starlette-admin/pull/520)

## [0.13.2] - 2023-02-04

### Fixed
Expand Down
4 changes: 4 additions & 0 deletions starlette_admin/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def __init__(
middlewares: Optional[Sequence[Middleware]] = None,
debug: bool = False,
i18n_config: Optional[I18nConfig] = None,
favicon_url: Optional[str] = None,
):
"""
Parameters:
Expand All @@ -67,12 +68,14 @@ def __init__(
auth_provider: Authentication Provider
middlewares: Starlette middlewares
i18n_config: i18n configuration
favicon_url: URL of favicon.
"""
self.title = title
self.base_url = base_url
self.route_name = route_name
self.logo_url = logo_url
self.login_logo_url = login_logo_url
self.favicon_url = favicon_url
self.templates_dir = templates_dir
self.statics_dir = statics_dir
self.auth_provider = auth_provider
Expand Down Expand Up @@ -201,6 +204,7 @@ def _setup_templates(self) -> None:
templates.env.globals["__name__"] = self.route_name
templates.env.globals["logo_url"] = self.logo_url
templates.env.globals["login_logo_url"] = self.login_logo_url
templates.env.globals["favicon_url"] = self.favicon_url
templates.env.globals["custom_render_js"] = lambda r: self.custom_render_js(r)
templates.env.globals["get_locale"] = get_locale
templates.env.globals["get_locale_display_name"] = get_locale_display_name
Expand Down
2 changes: 2 additions & 0 deletions starlette_admin/contrib/odmantic/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def __init__(
middlewares: Optional[Sequence[Middleware]] = None,
debug: bool = False,
i18n_config: Optional[I18nConfig] = None,
favicon_url: Optional[str] = None,
) -> None:
super().__init__(
title=title,
Expand All @@ -40,6 +41,7 @@ def __init__(
middlewares=middlewares,
debug=debug,
i18n_config=i18n_config,
favicon_url=favicon_url,
)
self.middlewares = [] if self.middlewares is None else list(self.middlewares)
self.middlewares.insert(0, Middleware(EngineMiddleware, engine=engine))
2 changes: 2 additions & 0 deletions starlette_admin/contrib/sqla/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def __init__(
middlewares: Optional[Sequence[Middleware]] = None,
debug: bool = False,
i18n_config: Optional[I18nConfig] = None,
favicon_url: Optional[str] = None,
) -> None:
super().__init__(
title=title,
Expand All @@ -51,6 +52,7 @@ def __init__(
middlewares=middlewares,
debug=debug,
i18n_config=i18n_config,
favicon_url=favicon_url,
)
self.middlewares = [] if self.middlewares is None else list(self.middlewares)
self.middlewares.insert(0, Middleware(DBSessionMiddleware, engine=engine))
Expand Down
3 changes: 3 additions & 0 deletions starlette_admin/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"/>
{% if favicon_url %}
<link rel="icon" type="image/x-icon" href="{{ favicon_url }}"/>
{% endif %}
{% block head_meta %}{% endblock %}
{% block title %}<title>{{ title or app_title }}</title>{% endblock %}
<link rel="stylesheet" href="{{ url_for(__name__ ~ ':statics', path='css/tabler.min.css') }}">
Expand Down
Loading