Skip to content

Commit 2bb68bc

Browse files
authored
add support for custom logo/icon to default HTML (#2038)
1 parent 81cd0ae commit 2bb68bc

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

docs/source/configuration.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ For more information related to API design rules (the ``api_rules`` property in
4242
host: 0.0.0.0 # listening address for incoming connections
4343
port: 5000 # listening port for incoming connections
4444
url: http://localhost:5000/ # url of server
45+
icon: https://example.org/favicon.ico # favicon / shortcut icon for default HTML template customization
46+
logo: https://example.org/logo.png # logo/banner for default HTML template customization
4547
mimetype: application/json; charset=UTF-8 # default MIME type
4648
encoding: utf-8 # default server encoding
4749
language: en-US # default server language

docs/source/html-templating.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ Featured themes
7171

7272
Community based themes can be found on the `pygeoapi Community Plugins and Themes wiki page`_.
7373

74+
Customizing the default HTML templates
75+
--------------------------------------
76+
77+
The following aspects of the default HTML templates can be customized (within the ``server`` :ref:`configuration section <Configuration>`):
78+
79+
- **icon**: shortcut icon (typically displays on a given web browser tab)
80+
- **logo**: logo/image banner (displays at the top of HTML pages)
81+
82+
7483
.. _`Jinja`: https://palletsprojects.com/p/jinja/
7584
.. _`Jinja documentation`: https://jinja.palletsprojects.com
7685
.. _`Flask`: https://palletsprojects.com/p/flask/

pygeoapi/schemas/config/pygeoapi-config-0.x.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ properties:
2525
url:
2626
type: string
2727
description: URL of server (as used by client)
28+
icon:
29+
type: string
30+
description: URL of favicon for default HTML customization
31+
logo:
32+
type: string
33+
description: URL of logo image for default HTML customization
2834
admin:
2935
type: boolean
3036
description: whether to enable the Admin API (default is false)

pygeoapi/templates/_base.html

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
11
<!doctype html>
22
<html lang="{{ (locale|lower)[:2] }}" dir="{% trans %}text_direction{% endtrans %}" >
3+
4+
{% if config['server']['icon'] %}
5+
{% set icon = config['server']['icon'] %}
6+
{% else %}
7+
{% set icon = config['server']['url'] + '/static/img/favicon.ico' %}
8+
{% endif %}
9+
10+
{% if config['server']['logo'] %}
11+
{% set logo = config['server']['logo'] %}
12+
{% else %}
13+
{% set logo = config['server']['url'] + '/static/img/logo.png' %}
14+
{% endif %}
15+
316
<head>
417
<meta charset="{{ config['server']['encoding'] }}">
518
<title>{% block title %}{% endblock %}{% if not self.title() %}{{ config['metadata']['identification']['title'] }}{% endif %}</title>
619
<meta name="viewport" content="width=device-width, initial-scale=1">
720
<meta name="language" content="{{ config['server']['language'] }}">
821
<meta name="description" content="{{ config['metadata']['identification']['title'] }}">
922
<meta name="keywords" content="{{ config['metadata']['identification']['keywords']|join(',') }}">
10-
<link rel="shortcut icon" href="{{ config['server']['url'] }}/static/img/favicon.ico" type="image/x-icon">
23+
<link rel="shortcut icon" href="{{ icon }}" type="image/x-icon">
1124
<link rel="stylesheet" href="https://unpkg.com/bootstrap@5.1.3/dist/css/bootstrap.min.css">
1225
<link rel="stylesheet" href="{{ config['server']['url'] }}/static/css/default.css">
1326
<!--[if lt IE 9]>
@@ -40,7 +53,7 @@
4053
<header class="d-flex flex-wrap align-items-center py-3 justify-content-between">
4154
<a href="{{ config['server']['url'] }}"
4255
class="d-flex align-items-center mb-3 mb-md-0 text-dark text-decoration-none">
43-
<img src="{{ config['server']['url'] }}/static/img/logo.png"
56+
<img src="{{ logo }}"
4457
title="{{ config['metadata']['identification']['title'] }}" style="height:40px;vertical-align: middle;" /></a>
4558
<ul class="nav nav-pills">
4659
<li class="nav-item">

0 commit comments

Comments
 (0)