goodmap 1.0.4__py3-none-any.whl → 1.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
goodmap/config.py ADDED
@@ -0,0 +1,42 @@
1
+ import sys
2
+ import typing as t
3
+
4
+ import yaml
5
+ from platzky.config import Config as PlatzkyConfig
6
+ from pydantic import Field
7
+
8
+
9
+ class GoodmapConfig(PlatzkyConfig):
10
+ """Extended configuration for Goodmap with additional frontend library URL."""
11
+
12
+ goodmap_frontend_lib_url: str = Field(
13
+ default="https://cdn.jsdelivr.net/npm/@problematy/goodmap@0.4.2",
14
+ alias="GOODMAP_FRONTEND_LIB_URL",
15
+ )
16
+
17
+ @classmethod
18
+ def model_validate(
19
+ cls,
20
+ obj: t.Any,
21
+ *,
22
+ strict: bool | None = None,
23
+ from_attributes: bool | None = None,
24
+ context: dict[str, t.Any] | None = None,
25
+ ) -> "GoodmapConfig":
26
+ """Override to return correct type for GoodmapConfig."""
27
+ return t.cast(
28
+ "GoodmapConfig",
29
+ super().model_validate(
30
+ obj, strict=strict, from_attributes=from_attributes, context=context
31
+ ),
32
+ )
33
+
34
+ @classmethod
35
+ def parse_yaml(cls, path: str) -> "GoodmapConfig":
36
+ """Parse YAML configuration file and return GoodmapConfig instance."""
37
+ try:
38
+ with open(path, "r") as f:
39
+ return cls.model_validate(yaml.safe_load(f))
40
+ except FileNotFoundError:
41
+ print(f"Config file not found: {path}", file=sys.stderr)
42
+ raise SystemExit(1)
goodmap/goodmap.py CHANGED
@@ -3,25 +3,26 @@ import os
3
3
  from flask import Blueprint, redirect, render_template, session
4
4
  from flask_wtf.csrf import CSRFProtect, generate_csrf
5
5
  from platzky import platzky
6
- from platzky.config import Config, languages_dict
6
+ from platzky.config import languages_dict
7
7
  from platzky.models import CmsModule
8
8
 
9
+ from goodmap.config import GoodmapConfig
9
10
  from goodmap.core_api import core_pages
10
11
  from goodmap.data_models.location import create_location_model
11
12
  from goodmap.db import extend_db_with_goodmap_queries, get_location_obligatory_fields
12
13
 
13
14
 
14
15
  def create_app(config_path: str) -> platzky.Engine:
15
- config = Config.parse_yaml(config_path)
16
+ config = GoodmapConfig.parse_yaml(config_path)
16
17
  return create_app_from_config(config)
17
18
 
18
19
 
19
20
  # TODO Checking if there is a feature flag secition should be part of configs logic not client app
20
- def is_feature_enabled(config: Config, feature: str) -> bool:
21
+ def is_feature_enabled(config: GoodmapConfig, feature: str) -> bool:
21
22
  return config.feature_flags.get(feature, False) if config.feature_flags else False
22
23
 
23
24
 
24
- def create_app_from_config(config: Config) -> platzky.Engine:
25
+ def create_app_from_config(config: GoodmapConfig) -> platzky.Engine:
25
26
  directory = os.path.dirname(os.path.realpath(__file__))
26
27
 
27
28
  locale_dir = os.path.join(directory, "locale")
@@ -52,7 +53,11 @@ def create_app_from_config(config: Config) -> platzky.Engine:
52
53
 
53
54
  @goodmap.route("/")
54
55
  def index():
55
- return render_template("map.html", feature_flags=config.feature_flags)
56
+ return render_template(
57
+ "map.html",
58
+ feature_flags=config.feature_flags,
59
+ goodmap_frontend_lib_url=config.goodmap_frontend_lib_url,
60
+ )
56
61
 
57
62
  @goodmap.route("/goodmap-admin")
58
63
  def admin():
@@ -65,6 +70,7 @@ def create_app_from_config(config: Config) -> platzky.Engine:
65
70
  return render_template(
66
71
  "goodmap-admin.html",
67
72
  feature_flags=config.feature_flags,
73
+ goodmap_frontend_lib_url=config.goodmap_frontend_lib_url,
68
74
  user=user,
69
75
  cms_modules=app.cms_modules,
70
76
  )
@@ -739,5 +739,5 @@ document.addEventListener('DOMContentLoaded', function() {
739
739
  window.USE_LAZY_LOADING = {{ feature_flags.USE_LAZY_LOADING | default(false) | tojson }};
740
740
  window.SHOW_ACCESSIBILITY_TABLE = {{ feature_flags.SHOW_ACCESSIBILITY_TABLE | default(false) | tojson }};
741
741
  </script>
742
- <script src="/static/map.js"></script>
742
+ <script src="{{ goodmap_frontend_lib_url }}"></script>
743
743
  {% endblock %}
@@ -119,5 +119,5 @@ window.USE_LAZY_LOADING = {{ feature_flags.USE_LAZY_LOADING | default(false) | t
119
119
  window.SHOW_ACCESSIBILITY_TABLE = {{ feature_flags.SHOW_ACCESSIBILITY_TABLE | default(false) | tojson }};
120
120
  window.FEATURE_FLAGS = {{ feature_flags | tojson }};
121
121
  </script>
122
- <script src="/static/map.js"></script>
122
+ <script src="{{ goodmap_frontend_lib_url }}"></script>
123
123
  {% endblock %}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: goodmap
3
- Version: 1.0.4
3
+ Version: 1.1.0
4
4
  Summary: Map engine to serve all the people :)
5
5
  License-File: LICENSE.md
6
6
  Author: Krzysztof Kolodzinski
@@ -24,7 +24,7 @@ Requires-Dist: google-cloud-storage (>=2.7.0,<3.0.0)
24
24
  Requires-Dist: gql (>=3.4.0,<4.0.0)
25
25
  Requires-Dist: gunicorn (>=20.1.0,<21.0.0)
26
26
  Requires-Dist: humanize (>=4.6.0,<5.0.0)
27
- Requires-Dist: platzky (>=0.4.3,<0.5.0)
27
+ Requires-Dist: platzky (>=1.0.0,<2.0.0)
28
28
  Requires-Dist: pydantic (>=2.7.1,<3.0.0)
29
29
  Description-Content-Type: text/markdown
30
30
 
@@ -1,14 +1,15 @@
1
1
  goodmap/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
2
+ goodmap/config.py,sha256=sseE4sceFB8OBuFsrRpQJvjv0Vg5KFdkzihBX_hbE2c,1313
2
3
  goodmap/core.py,sha256=rzMhOIYnR1jxTX6uHQJKIPLYxdUm4_v2d6LrtHtJpHU,1465
3
4
  goodmap/core_api.py,sha256=MxJ7SGOFBBnV_cBIiZoImHLaY8_FtEW-dl3od5-mIt8,13529
4
5
  goodmap/data_models/location.py,sha256=H3EKozc-WZvrYm6cwajl8_gaw4rQhxdlvxR1mk4mpkA,1104
5
6
  goodmap/data_validator.py,sha256=lBmVAPxvSmEOdUGeVYSjUvVVmKfPyq4CWoHfczTtEMM,4090
6
7
  goodmap/db.py,sha256=i-fe_f_s9hQxvTqq4alA-RK9j6vQpnaNpXEDPci3s1Y,42049
7
8
  goodmap/formatter.py,sha256=VlUHcK1HtM_IEU0VE3S5TOkZLVheMdakvUeW2tCKdq0,783
8
- goodmap/goodmap.py,sha256=OOcuDEY7GZsHh8vjIJ9brd4SuGxNRq_lC_DMmNuome8,2731
9
- goodmap/templates/goodmap-admin.html,sha256=zGuau239BXyBerV21mDXcHy34ke8cLmZcMngcX1xhAs,35598
10
- goodmap/templates/map.html,sha256=-qbJ313t2EdSyIwULnQy3j81pH4MqI5yjtJ4Xoo7N7M,3979
11
- goodmap-1.0.4.dist-info/METADATA,sha256=XZ4XugRInA3jVCXDDi1lTQQ2Y6uLaScVmAkpMKIs9dc,5356
12
- goodmap-1.0.4.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
13
- goodmap-1.0.4.dist-info/licenses/LICENSE.md,sha256=nkCQOR7uheLRvHRfXmwx9LhBnMcPeBU9d4ebLojDiQU,1067
14
- goodmap-1.0.4.dist-info/RECORD,,
9
+ goodmap/goodmap.py,sha256=q6okPopWBH6jDkKJcGDegebaapHLFUVilJ3p3aKi97k,2960
10
+ goodmap/templates/goodmap-admin.html,sha256=39PJ1drk_xdkyzXgPZZNXYq9gA9oTVeR8hsgeae6E0g,35614
11
+ goodmap/templates/map.html,sha256=N4N0ONzEFUS4bFtOA2jgXVbMQ7cKd1cRYIVnGLUzBIE,3995
12
+ goodmap-1.1.0.dist-info/METADATA,sha256=Guut0eb_hYRPviLOJ8s4BA2goFJrgjQagMkGvZXOQRI,5356
13
+ goodmap-1.1.0.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
14
+ goodmap-1.1.0.dist-info/licenses/LICENSE.md,sha256=nkCQOR7uheLRvHRfXmwx9LhBnMcPeBU9d4ebLojDiQU,1067
15
+ goodmap-1.1.0.dist-info/RECORD,,