Skip to content

Commit 5e0287c

Browse files
add titiler in map attributions (#1030)
1 parent 7a4b688 commit 5e0287c

File tree

6 files changed

+34
-26
lines changed

6 files changed

+34
-26
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Release Notes
22

3+
## 0.19.1 (2024-11-14)
4+
5+
* Add `titiler` links in Map attributions
6+
37
## 0.19.0 (2024-11-07)
48

59
### Misc

src/titiler/application/titiler/application/main.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,27 @@
5050

5151
api_settings = ApiSettings()
5252

53-
###############################################################################
54-
# Setup a global API access key, if configured
55-
api_key_query = APIKeyQuery(name="access_token", auto_error=False)
56-
53+
app_dependencies = []
54+
if api_settings.global_access_token:
55+
###############################################################################
56+
# Setup a global API access key, if configured
57+
api_key_query = APIKeyQuery(name="access_token", auto_error=False)
58+
59+
def validate_access_token(access_token: str = Security(api_key_query)):
60+
"""Validates API key access token, set as the `api_settings.global_access_token` value.
61+
Returns True if no access token is required, or if the access token is valid.
62+
Raises an HTTPException (401) if the access token is required but invalid/missing.
63+
"""
64+
if not access_token:
65+
raise HTTPException(status_code=401, detail="Missing `access_token`")
66+
67+
# if access_token == `token` then OK
68+
if access_token != api_settings.global_access_token:
69+
raise HTTPException(status_code=401, detail="Invalid `access_token`")
5770

58-
def validate_access_token(access_token: str = Security(api_key_query)):
59-
"""Validates API key access token, set as the `api_settings.global_access_token` value.
60-
Returns True if no access token is required, or if the access token is valid.
61-
Raises an HTTPException (401) if the access token is required but invalid/missing.
62-
"""
63-
if api_settings.global_access_token is None:
6471
return True
6572

66-
if not access_token:
67-
raise HTTPException(status_code=401, detail="Missing `access_token`")
68-
69-
# if access_token == `token` then OK
70-
if access_token != api_settings.global_access_token:
71-
raise HTTPException(status_code=401, detail="Invalid `access_token`")
72-
73-
return True
73+
app_dependencies.append(Depends(validate_access_token))
7474

7575

7676
###############################################################################
@@ -91,7 +91,7 @@ def validate_access_token(access_token: str = Security(api_key_query)):
9191
""",
9292
version=titiler_version,
9393
root_path=api_settings.root_path,
94-
dependencies=[Depends(validate_access_token)],
94+
dependencies=app_dependencies,
9595
)
9696

9797
###############################################################################

src/titiler/application/titiler/application/templates/index.html

Lines changed: 3 additions & 2 deletions
Large diffs are not rendered by default.

src/titiler/core/titiler/core/templates/map.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,12 @@
6161
var map = L.map('map', {
6262
crs: crs,
6363
minZoom: {{ tms.minzoom }},
64-
maxZoom: {{ tms.maxzoom }}
64+
maxZoom: {{ tms.maxzoom }},
65+
attributionControl: false
6566
});
6667

68+
L.control.attribution({prefix: '<a href="https://leafletjs.com" target="_blank">Leaflet</a> | <a href="https://developmentseed.org/titiler" target="_blank">Titiler</a>'}).addTo(map)
69+
6770
const nullIsland = L.marker([0, 0]).addTo(map);
6871
const madrid = L.marker([40, -3]).addTo(map);
6972
const london = L.marker([51.50722, -0.1275]).addTo(map)

src/titiler/extensions/titiler/extensions/templates/cog_viewer.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,10 +387,10 @@
387387
'basemap': {
388388
type: 'raster',
389389
tiles: [
390-
'https://tile.openstreetmap.org/{z}/{x}/{y}.png'
390+
'https://tile.openstreetmap.org/{z}/{x}/{y}.png'
391391
],
392392
tileSize: 256,
393-
attribution: '<a href="http://www.openstreetmap.org/copyright">© OpenStreetMap</a>'
393+
attribution: '<a href="https://developmentseed.org/titiler" target="_blank">Titiler</a> | <a href="http://www.openstreetmap.org/copyright">© OpenStreetMap</a>'
394394
}
395395
},
396396
layers: [

src/titiler/extensions/titiler/extensions/templates/stac_viewer.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,10 +362,10 @@
362362
'basemap': {
363363
type: 'raster',
364364
tiles: [
365-
'https://tile.openstreetmap.org/{z}/{x}/{y}.png'
365+
'https://tile.openstreetmap.org/{z}/{x}/{y}.png'
366366
],
367367
tileSize: 256,
368-
attribution: '<a href="http://www.openstreetmap.org/copyright">© OpenStreetMap</a>'
368+
attribution: '<a href="https://developmentseed.org/titiler" target="_blank">Titiler</a> | <a href="http://www.openstreetmap.org/copyright">© OpenStreetMap</a>'
369369
}
370370
},
371371
layers: [

0 commit comments

Comments
 (0)