geo-activity-playground 0.38.2__py3-none-any.whl → 0.39.1__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.
- geo_activity_playground/__main__.py +5 -47
- geo_activity_playground/alembic/README +1 -0
- geo_activity_playground/alembic/env.py +76 -0
- geo_activity_playground/alembic/script.py.mako +26 -0
- geo_activity_playground/alembic/versions/451e7836b53d_add_square_planner_bookmark.py +33 -0
- geo_activity_playground/alembic/versions/63d3b7f6f93c_initial_version.py +73 -0
- geo_activity_playground/alembic/versions/ab83b9d23127_add_upstream_id.py +28 -0
- geo_activity_playground/alembic/versions/b03491c593f6_add_crop_indices.py +30 -0
- geo_activity_playground/alembic/versions/e02e27876deb_add_square_planner_bookmark_name.py +28 -0
- geo_activity_playground/alembic/versions/script.py.mako +28 -0
- geo_activity_playground/core/activities.py +53 -136
- geo_activity_playground/core/config.py +3 -3
- geo_activity_playground/core/datamodel.py +257 -0
- geo_activity_playground/core/enrichment.py +90 -92
- geo_activity_playground/core/heart_rate.py +1 -2
- geo_activity_playground/core/parametric_plot.py +101 -0
- geo_activity_playground/core/paths.py +6 -7
- geo_activity_playground/core/raster_map.py +43 -4
- geo_activity_playground/core/similarity.py +1 -2
- geo_activity_playground/core/tasks.py +2 -2
- geo_activity_playground/core/test_meta_search.py +3 -3
- geo_activity_playground/core/test_summary_stats.py +1 -1
- geo_activity_playground/explorer/grid_file.py +2 -2
- geo_activity_playground/explorer/tile_visits.py +8 -10
- geo_activity_playground/heatmap_video.py +7 -8
- geo_activity_playground/importers/activity_parsers.py +2 -2
- geo_activity_playground/importers/directory.py +9 -10
- geo_activity_playground/importers/strava_api.py +9 -9
- geo_activity_playground/importers/strava_checkout.py +12 -13
- geo_activity_playground/importers/test_csv_parser.py +3 -3
- geo_activity_playground/importers/test_directory.py +1 -1
- geo_activity_playground/importers/test_strava_api.py +1 -1
- geo_activity_playground/webui/app.py +96 -86
- geo_activity_playground/webui/authenticator.py +1 -1
- geo_activity_playground/webui/{activity/controller.py → blueprints/activity_blueprint.py} +246 -108
- geo_activity_playground/webui/{auth_blueprint.py → blueprints/auth_blueprint.py} +1 -1
- geo_activity_playground/webui/blueprints/bubble_chart_blueprint.py +61 -0
- geo_activity_playground/webui/{calendar/controller.py → blueprints/calendar_blueprint.py} +19 -19
- geo_activity_playground/webui/{eddington_blueprint.py → blueprints/eddington_blueprint.py} +5 -5
- geo_activity_playground/webui/blueprints/entry_views.py +68 -0
- geo_activity_playground/webui/{equipment_blueprint.py → blueprints/equipment_blueprint.py} +37 -4
- geo_activity_playground/webui/{explorer/controller.py → blueprints/explorer_blueprint.py} +88 -54
- geo_activity_playground/webui/blueprints/heatmap_blueprint.py +233 -0
- geo_activity_playground/webui/blueprints/plot_builder_blueprint.py +43 -0
- geo_activity_playground/webui/{search_blueprint.py → blueprints/search_blueprint.py} +7 -11
- geo_activity_playground/webui/blueprints/settings_blueprint.py +446 -0
- geo_activity_playground/webui/{square_planner_blueprint.py → blueprints/square_planner_blueprint.py} +31 -6
- geo_activity_playground/webui/{summary_blueprint.py → blueprints/summary_blueprint.py} +11 -23
- geo_activity_playground/webui/blueprints/tile_blueprint.py +27 -0
- geo_activity_playground/webui/{upload_blueprint.py → blueprints/upload_blueprint.py} +13 -18
- geo_activity_playground/webui/flasher.py +26 -0
- geo_activity_playground/webui/plot_util.py +1 -1
- geo_activity_playground/webui/search_util.py +4 -6
- geo_activity_playground/webui/static/images/layers-2x.png +0 -0
- geo_activity_playground/webui/static/images/layers.png +0 -0
- geo_activity_playground/webui/static/images/marker-icon-2x.png +0 -0
- geo_activity_playground/webui/static/images/marker-icon.png +0 -0
- geo_activity_playground/webui/static/images/marker-shadow.png +0 -0
- geo_activity_playground/webui/templates/activity/day.html.j2 +81 -0
- geo_activity_playground/webui/templates/activity/edit.html.j2 +38 -0
- geo_activity_playground/webui/{activity/templates → templates}/activity/name.html.j2 +29 -27
- geo_activity_playground/webui/{activity/templates → templates}/activity/show.html.j2 +57 -33
- geo_activity_playground/webui/templates/activity/trim.html.j2 +68 -0
- geo_activity_playground/webui/templates/bubble_chart/index.html.j2 +26 -0
- geo_activity_playground/webui/templates/calendar/index.html.j2 +48 -0
- geo_activity_playground/webui/templates/calendar/month.html.j2 +57 -0
- geo_activity_playground/webui/templates/equipment/index.html.j2 +7 -0
- geo_activity_playground/webui/templates/home.html.j2 +6 -6
- geo_activity_playground/webui/templates/page.html.j2 +2 -1
- geo_activity_playground/webui/templates/plot_builder/index.html.j2 +44 -0
- geo_activity_playground/webui/{settings/templates → templates}/settings/index.html.j2 +9 -20
- geo_activity_playground/webui/templates/settings/manage-equipments.html.j2 +49 -0
- geo_activity_playground/webui/templates/settings/manage-kinds.html.j2 +48 -0
- geo_activity_playground/webui/{settings/templates → templates}/settings/privacy-zones.html.j2 +2 -0
- geo_activity_playground/webui/{settings/templates → templates}/settings/strava.html.j2 +2 -0
- geo_activity_playground/webui/templates/square_planner/index.html.j2 +63 -13
- {geo_activity_playground-0.38.2.dist-info → geo_activity_playground-0.39.1.dist-info}/METADATA +5 -1
- geo_activity_playground-0.39.1.dist-info/RECORD +136 -0
- geo_activity_playground/__init__.py +0 -0
- geo_activity_playground/core/__init__.py +0 -0
- geo_activity_playground/explorer/__init__.py +0 -0
- geo_activity_playground/importers/__init__.py +0 -0
- geo_activity_playground/webui/__init__.py +0 -0
- geo_activity_playground/webui/activity/__init__.py +0 -0
- geo_activity_playground/webui/activity/blueprint.py +0 -109
- geo_activity_playground/webui/activity/templates/activity/day.html.j2 +0 -80
- geo_activity_playground/webui/activity/templates/activity/edit.html.j2 +0 -42
- geo_activity_playground/webui/calendar/__init__.py +0 -0
- geo_activity_playground/webui/calendar/blueprint.py +0 -23
- geo_activity_playground/webui/calendar/templates/calendar/index.html.j2 +0 -46
- geo_activity_playground/webui/calendar/templates/calendar/month.html.j2 +0 -55
- geo_activity_playground/webui/entry_controller.py +0 -63
- geo_activity_playground/webui/explorer/__init__.py +0 -0
- geo_activity_playground/webui/explorer/blueprint.py +0 -62
- geo_activity_playground/webui/heatmap/__init__.py +0 -0
- geo_activity_playground/webui/heatmap/blueprint.py +0 -51
- geo_activity_playground/webui/heatmap/heatmap_controller.py +0 -216
- geo_activity_playground/webui/settings/blueprint.py +0 -262
- geo_activity_playground/webui/settings/controller.py +0 -272
- geo_activity_playground/webui/settings/templates/settings/equipment-offsets.html.j2 +0 -44
- geo_activity_playground/webui/settings/templates/settings/kind-renames.html.j2 +0 -25
- geo_activity_playground/webui/settings/templates/settings/kinds-without-achievements.html.j2 +0 -30
- geo_activity_playground/webui/tile_blueprint.py +0 -42
- geo_activity_playground-0.38.2.dist-info/RECORD +0 -129
- /geo_activity_playground/webui/{activity/templates → templates}/activity/lines.html.j2 +0 -0
- /geo_activity_playground/webui/{explorer/templates → templates}/explorer/index.html.j2 +0 -0
- /geo_activity_playground/webui/{heatmap/templates → templates}/heatmap/index.html.j2 +0 -0
- /geo_activity_playground/webui/{settings/templates → templates}/settings/admin-password.html.j2 +0 -0
- /geo_activity_playground/webui/{settings/templates → templates}/settings/color-schemes.html.j2 +0 -0
- /geo_activity_playground/webui/{settings/templates → templates}/settings/heart-rate.html.j2 +0 -0
- /geo_activity_playground/webui/{settings/templates → templates}/settings/metadata-extraction.html.j2 +0 -0
- /geo_activity_playground/webui/{settings/templates → templates}/settings/segmentation.html.j2 +0 -0
- /geo_activity_playground/webui/{settings/templates → templates}/settings/sharepic.html.j2 +0 -0
- {geo_activity_playground-0.38.2.dist-info → geo_activity_playground-0.39.1.dist-info}/LICENSE +0 -0
- {geo_activity_playground-0.38.2.dist-info → geo_activity_playground-0.39.1.dist-info}/WHEEL +0 -0
- {geo_activity_playground-0.38.2.dist-info → geo_activity_playground-0.39.1.dist-info}/entry_points.txt +0 -0
@@ -1,4 +1,4 @@
|
|
1
|
-
import
|
1
|
+
import abc
|
2
2
|
import dataclasses
|
3
3
|
import functools
|
4
4
|
import logging
|
@@ -10,9 +10,8 @@ import numpy as np
|
|
10
10
|
import requests
|
11
11
|
from PIL import Image
|
12
12
|
|
13
|
-
from
|
14
|
-
from
|
15
|
-
from geo_activity_playground.core.tiles import get_tile_upper_left_lat_lon
|
13
|
+
from .config import Config
|
14
|
+
from .tiles import compute_tile_float
|
16
15
|
|
17
16
|
|
18
17
|
logger = logging.getLogger(__name__)
|
@@ -244,3 +243,43 @@ def download_file(url: str, destination: pathlib.Path):
|
|
244
243
|
with open(destination, "wb") as f:
|
245
244
|
f.write(r.content)
|
246
245
|
time.sleep(0.1)
|
246
|
+
|
247
|
+
|
248
|
+
class TileGetter:
|
249
|
+
def __init__(self, map_tile_url: str):
|
250
|
+
self._map_tile_url = map_tile_url
|
251
|
+
|
252
|
+
def get_tile(
|
253
|
+
self,
|
254
|
+
z: int,
|
255
|
+
x: int,
|
256
|
+
y: int,
|
257
|
+
):
|
258
|
+
return get_tile(z, x, y, self._map_tile_url)
|
259
|
+
|
260
|
+
|
261
|
+
class ImageTransform:
|
262
|
+
@abc.abstractmethod
|
263
|
+
def transform_image(self, image: np.ndarray) -> np.ndarray:
|
264
|
+
pass
|
265
|
+
|
266
|
+
|
267
|
+
class IdentityImageTransform(ImageTransform):
|
268
|
+
def transform_image(self, image: np.ndarray) -> np.ndarray:
|
269
|
+
return image
|
270
|
+
|
271
|
+
|
272
|
+
class GrayscaleImageTransform(ImageTransform):
|
273
|
+
def transform_image(self, image: np.ndarray) -> np.ndarray:
|
274
|
+
image = np.sum(image * [0.2126, 0.7152, 0.0722], axis=2) # to grayscale
|
275
|
+
return np.dstack((image, image, image)) # to rgb
|
276
|
+
|
277
|
+
|
278
|
+
class PastelImageTransform(ImageTransform):
|
279
|
+
def __init__(self, factor: float = 0.7):
|
280
|
+
self._factor = factor
|
281
|
+
|
282
|
+
def transform_image(self, image: np.ndarray) -> np.ndarray:
|
283
|
+
averaged_tile = np.sum(image * [0.2126, 0.7152, 0.0722], axis=2)
|
284
|
+
grayscale_tile = np.dstack((averaged_tile, averaged_tile, averaged_tile))
|
285
|
+
return self._factor * grayscale_tile + (1 - self._factor) * image
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import pathlib
|
2
|
-
import pickle
|
3
2
|
|
4
3
|
import imagehash
|
5
4
|
import numpy as np
|
@@ -10,7 +9,7 @@ from tqdm import tqdm
|
|
10
9
|
|
11
10
|
from .activities import ActivityRepository
|
12
11
|
from .coordinates import get_distance
|
13
|
-
from
|
12
|
+
from .tasks import stored_object
|
14
13
|
|
15
14
|
|
16
15
|
fingerprint_path = pathlib.Path("Cache/activity_fingerprints.pickle")
|
@@ -8,8 +8,8 @@ from typing import Generic
|
|
8
8
|
from typing import Sequence
|
9
9
|
from typing import TypeVar
|
10
10
|
|
11
|
-
from
|
12
|
-
from
|
11
|
+
from .paths import atomic_open
|
12
|
+
from .paths import cache_dir
|
13
13
|
|
14
14
|
|
15
15
|
T = TypeVar("T")
|
@@ -2,9 +2,9 @@ import datetime
|
|
2
2
|
|
3
3
|
import pandas as pd
|
4
4
|
|
5
|
-
from
|
6
|
-
from
|
7
|
-
from
|
5
|
+
from .meta_search import _make_mask
|
6
|
+
from .meta_search import apply_search_query
|
7
|
+
from .meta_search import SearchQuery
|
8
8
|
|
9
9
|
|
10
10
|
def test_empty_query() -> None:
|
@@ -7,8 +7,8 @@ import geojson
|
|
7
7
|
import gpxpy
|
8
8
|
import pandas as pd
|
9
9
|
|
10
|
-
from
|
11
|
-
from
|
10
|
+
from ..core.coordinates import Bounds
|
11
|
+
from ..core.tiles import get_tile_upper_left_lat_lon
|
12
12
|
|
13
13
|
|
14
14
|
logger = logging.getLogger(__name__)
|
@@ -4,7 +4,6 @@ import itertools
|
|
4
4
|
import logging
|
5
5
|
import pathlib
|
6
6
|
import pickle
|
7
|
-
from typing import Any
|
8
7
|
from typing import Iterator
|
9
8
|
from typing import Optional
|
10
9
|
from typing import TypedDict
|
@@ -12,15 +11,14 @@ from typing import TypedDict
|
|
12
11
|
import pandas as pd
|
13
12
|
from tqdm import tqdm
|
14
13
|
|
15
|
-
from
|
16
|
-
from
|
17
|
-
from
|
18
|
-
from
|
19
|
-
from
|
20
|
-
from
|
21
|
-
from
|
22
|
-
from
|
23
|
-
from geo_activity_playground.core.tiles import interpolate_missing_tile
|
14
|
+
from ..core.activities import ActivityRepository
|
15
|
+
from ..core.config import Config
|
16
|
+
from ..core.paths import atomic_open
|
17
|
+
from ..core.tasks import try_load_pickle
|
18
|
+
from ..core.tasks import work_tracker_path
|
19
|
+
from ..core.tasks import WorkTracker
|
20
|
+
from ..core.tiles import adjacent_to
|
21
|
+
from ..core.tiles import interpolate_missing_tile
|
24
22
|
|
25
23
|
|
26
24
|
logger = logging.getLogger(__name__)
|
@@ -9,13 +9,13 @@ from PIL import Image
|
|
9
9
|
from PIL import ImageDraw
|
10
10
|
from tqdm import tqdm
|
11
11
|
|
12
|
-
from
|
13
|
-
from
|
14
|
-
from
|
15
|
-
from
|
16
|
-
from
|
17
|
-
from
|
18
|
-
from
|
12
|
+
from .core.activities import ActivityRepository
|
13
|
+
from .core.config import ConfigAccessor
|
14
|
+
from .core.raster_map import convert_to_grayscale
|
15
|
+
from .core.raster_map import map_image_from_tile_bounds
|
16
|
+
from .core.raster_map import OSM_TILE_SIZE
|
17
|
+
from .core.raster_map import tile_bounds_around_center
|
18
|
+
from .core.tiles import compute_tile_float
|
19
19
|
|
20
20
|
|
21
21
|
def main_heatmap_video(options) -> None:
|
@@ -25,7 +25,6 @@ def main_heatmap_video(options) -> None:
|
|
25
25
|
os.chdir(options.basedir)
|
26
26
|
|
27
27
|
repository = ActivityRepository()
|
28
|
-
repository.reload()
|
29
28
|
assert len(repository) > 0
|
30
29
|
config_accessor = ConfigAccessor()
|
31
30
|
|
@@ -13,8 +13,8 @@ import pandas as pd
|
|
13
13
|
import tcxreader.tcxreader
|
14
14
|
import xmltodict
|
15
15
|
|
16
|
-
from
|
17
|
-
from
|
16
|
+
from ..core.datamodel import ActivityMeta
|
17
|
+
from ..core.time_conversion import convert_to_datetime_ns
|
18
18
|
|
19
19
|
logger = logging.getLogger(__name__)
|
20
20
|
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import hashlib
|
2
2
|
import logging
|
3
|
-
import multiprocessing
|
4
3
|
import pathlib
|
5
4
|
import pickle
|
6
5
|
import re
|
@@ -9,15 +8,15 @@ from typing import Optional
|
|
9
8
|
|
10
9
|
from tqdm import tqdm
|
11
10
|
|
12
|
-
from
|
13
|
-
from
|
14
|
-
from
|
15
|
-
from
|
16
|
-
from
|
17
|
-
from
|
18
|
-
from
|
19
|
-
from
|
20
|
-
from
|
11
|
+
from ..core.config import Config
|
12
|
+
from ..core.datamodel import ActivityMeta
|
13
|
+
from ..core.paths import activity_extracted_dir
|
14
|
+
from ..core.paths import activity_extracted_meta_dir
|
15
|
+
from ..core.paths import activity_extracted_time_series_dir
|
16
|
+
from ..core.tasks import stored_object
|
17
|
+
from ..core.tasks import WorkTracker
|
18
|
+
from .activity_parsers import ActivityParseError
|
19
|
+
from .activity_parsers import read_activity
|
21
20
|
|
22
21
|
logger = logging.getLogger(__name__)
|
23
22
|
|
@@ -11,15 +11,15 @@ from stravalib.exc import ObjectNotFound
|
|
11
11
|
from stravalib.exc import RateLimitExceeded
|
12
12
|
from tqdm import tqdm
|
13
13
|
|
14
|
-
from
|
15
|
-
from
|
16
|
-
from
|
17
|
-
from
|
18
|
-
from
|
19
|
-
from
|
20
|
-
from
|
21
|
-
from
|
22
|
-
from
|
14
|
+
from ..core.config import Config
|
15
|
+
from ..core.datamodel import ActivityMeta
|
16
|
+
from ..core.paths import activity_extracted_meta_dir
|
17
|
+
from ..core.paths import activity_extracted_time_series_dir
|
18
|
+
from ..core.paths import strava_api_dir
|
19
|
+
from ..core.paths import strava_last_activity_date_path
|
20
|
+
from ..core.tasks import get_state
|
21
|
+
from ..core.tasks import set_state
|
22
|
+
from ..core.time_conversion import convert_to_datetime_ns
|
23
23
|
|
24
24
|
|
25
25
|
logger = logging.getLogger(__name__)
|
@@ -6,25 +6,24 @@ import shutil
|
|
6
6
|
import sys
|
7
7
|
import traceback
|
8
8
|
from typing import Optional
|
9
|
-
from typing import Union
|
10
9
|
|
11
10
|
import dateutil.parser
|
12
11
|
import numpy as np
|
13
12
|
import pandas as pd
|
14
13
|
from tqdm import tqdm
|
15
14
|
|
16
|
-
from
|
17
|
-
from
|
18
|
-
from
|
19
|
-
from
|
20
|
-
from
|
21
|
-
from
|
22
|
-
from
|
23
|
-
from
|
24
|
-
from
|
25
|
-
from
|
26
|
-
from
|
27
|
-
from
|
15
|
+
from ..core.datamodel import ActivityMeta
|
16
|
+
from ..core.paths import activity_extracted_meta_dir
|
17
|
+
from ..core.paths import activity_extracted_time_series_dir
|
18
|
+
from ..core.paths import strava_last_activity_date_path
|
19
|
+
from ..core.tasks import get_state
|
20
|
+
from ..core.tasks import set_state
|
21
|
+
from ..core.tasks import work_tracker_path
|
22
|
+
from ..core.tasks import WorkTracker
|
23
|
+
from ..core.time_conversion import convert_to_datetime_ns
|
24
|
+
from .activity_parsers import ActivityParseError
|
25
|
+
from .activity_parsers import read_activity
|
26
|
+
from .csv_parser import parse_csv
|
28
27
|
|
29
28
|
|
30
29
|
logger = logging.getLogger(__name__)
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import pytest
|
2
2
|
|
3
|
-
from
|
4
|
-
from
|
5
|
-
from
|
3
|
+
from .csv_parser import _parse_cell
|
4
|
+
from .csv_parser import _parse_line
|
5
|
+
from .csv_parser import parse_csv
|
6
6
|
|
7
7
|
|
8
8
|
def test_parse_csv() -> None:
|
@@ -1,46 +1,47 @@
|
|
1
1
|
import datetime
|
2
2
|
import importlib
|
3
3
|
import json
|
4
|
+
import os
|
4
5
|
import pathlib
|
5
6
|
import secrets
|
6
7
|
import shutil
|
7
8
|
import urllib.parse
|
8
9
|
|
9
10
|
from flask import Flask
|
10
|
-
from flask import render_template
|
11
11
|
from flask import request
|
12
|
+
from flask_alembic import Alembic
|
12
13
|
|
13
14
|
from ..core.activities import ActivityRepository
|
14
|
-
from ..core.config import Config
|
15
15
|
from ..core.config import ConfigAccessor
|
16
|
+
from ..core.config import import_old_config
|
17
|
+
from ..core.config import import_old_strava_config
|
18
|
+
from ..core.datamodel import DB
|
19
|
+
from ..core.heart_rate import HeartRateZoneComputer
|
20
|
+
from ..core.raster_map import GrayscaleImageTransform
|
21
|
+
from ..core.raster_map import IdentityImageTransform
|
22
|
+
from ..core.raster_map import PastelImageTransform
|
23
|
+
from ..core.raster_map import TileGetter
|
16
24
|
from ..explorer.tile_visits import TileVisitAccessor
|
17
|
-
from .activity.blueprint import make_activity_blueprint
|
18
|
-
from .activity.controller import ActivityController
|
19
|
-
from .auth_blueprint import make_auth_blueprint
|
20
25
|
from .authenticator import Authenticator
|
21
|
-
from .
|
22
|
-
from .
|
23
|
-
from .
|
24
|
-
from .
|
25
|
-
from .
|
26
|
-
from .
|
27
|
-
from .
|
28
|
-
from .
|
29
|
-
from .
|
30
|
-
from .
|
31
|
-
from .
|
32
|
-
from .
|
33
|
-
from .
|
34
|
-
from .
|
35
|
-
from
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
@app.route("/")
|
42
|
-
def index():
|
43
|
-
return render_template("home.html.j2", **entry_controller.render())
|
26
|
+
from .blueprints.activity_blueprint import make_activity_blueprint
|
27
|
+
from .blueprints.auth_blueprint import make_auth_blueprint
|
28
|
+
from .blueprints.bubble_chart_blueprint import make_bubble_chart_blueprint
|
29
|
+
from .blueprints.calendar_blueprint import make_calendar_blueprint
|
30
|
+
from .blueprints.eddington_blueprint import register_eddington_blueprint
|
31
|
+
from .blueprints.entry_views import register_entry_views
|
32
|
+
from .blueprints.equipment_blueprint import make_equipment_blueprint
|
33
|
+
from .blueprints.explorer_blueprint import make_explorer_blueprint
|
34
|
+
from .blueprints.heatmap_blueprint import make_heatmap_blueprint
|
35
|
+
from .blueprints.plot_builder_blueprint import make_plot_builder_blueprint
|
36
|
+
from .blueprints.search_blueprint import make_search_blueprint
|
37
|
+
from .blueprints.settings_blueprint import make_settings_blueprint
|
38
|
+
from .blueprints.square_planner_blueprint import make_square_planner_blueprint
|
39
|
+
from .blueprints.summary_blueprint import make_summary_blueprint
|
40
|
+
from .blueprints.tile_blueprint import make_tile_blueprint
|
41
|
+
from .blueprints.upload_blueprint import make_upload_blueprint
|
42
|
+
from .blueprints.upload_blueprint import scan_for_activities
|
43
|
+
from .flasher import FlaskFlasher
|
44
|
+
from .search_util import SearchQueryHistory
|
44
45
|
|
45
46
|
|
46
47
|
def get_secret_key():
|
@@ -56,15 +57,39 @@ def get_secret_key():
|
|
56
57
|
|
57
58
|
|
58
59
|
def web_ui_main(
|
59
|
-
|
60
|
-
|
61
|
-
config_accessor: ConfigAccessor,
|
60
|
+
basedir: pathlib.Path,
|
61
|
+
skip_reload: bool,
|
62
62
|
host: str,
|
63
63
|
port: int,
|
64
64
|
) -> None:
|
65
|
-
|
65
|
+
os.chdir(basedir)
|
66
66
|
|
67
67
|
app = Flask(__name__)
|
68
|
+
|
69
|
+
app.config["SQLALCHEMY_DATABASE_URI"] = (
|
70
|
+
f"sqlite:///{basedir.absolute()}/database.sqlite"
|
71
|
+
)
|
72
|
+
app.config["ALEMBIC"] = {"script_location": "../alembic/versions"}
|
73
|
+
DB.init_app(app)
|
74
|
+
|
75
|
+
alembic = Alembic()
|
76
|
+
alembic.init_app(app)
|
77
|
+
|
78
|
+
with app.app_context():
|
79
|
+
alembic.upgrade()
|
80
|
+
DB.session.commit()
|
81
|
+
# DB.create_all()
|
82
|
+
|
83
|
+
repository = ActivityRepository()
|
84
|
+
tile_visit_accessor = TileVisitAccessor()
|
85
|
+
config_accessor = ConfigAccessor()
|
86
|
+
import_old_config(config_accessor)
|
87
|
+
import_old_strava_config(config_accessor)
|
88
|
+
|
89
|
+
if not skip_reload:
|
90
|
+
with app.app_context():
|
91
|
+
scan_for_activities(repository, tile_visit_accessor, config_accessor())
|
92
|
+
|
68
93
|
app.config["UPLOAD_FOLDER"] = "Activities"
|
69
94
|
app.secret_key = get_secret_key()
|
70
95
|
|
@@ -82,67 +107,52 @@ def web_ui_main(
|
|
82
107
|
|
83
108
|
authenticator = Authenticator(config_accessor())
|
84
109
|
search_query_history = SearchQueryHistory(config_accessor, authenticator)
|
85
|
-
|
86
110
|
config = config_accessor()
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
app
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
make_explorer_blueprint(
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
make_heatmap_blueprint(
|
111
|
+
tile_getter = TileGetter(config.map_tile_url)
|
112
|
+
image_transforms = {
|
113
|
+
"color": IdentityImageTransform(),
|
114
|
+
"grayscale": GrayscaleImageTransform(),
|
115
|
+
"pastel": PastelImageTransform(),
|
116
|
+
}
|
117
|
+
flasher = FlaskFlasher()
|
118
|
+
heart_rate_zone_computer = HeartRateZoneComputer(config)
|
119
|
+
|
120
|
+
register_entry_views(app, repository, config)
|
121
|
+
|
122
|
+
blueprints = {
|
123
|
+
"/activity": make_activity_blueprint(
|
124
|
+
repository,
|
125
|
+
authenticator,
|
126
|
+
tile_visit_accessor,
|
127
|
+
config,
|
128
|
+
heart_rate_zone_computer,
|
129
|
+
),
|
130
|
+
"/auth": make_auth_blueprint(authenticator),
|
131
|
+
"/bubble-chart": make_bubble_chart_blueprint(repository),
|
132
|
+
"/calendar": make_calendar_blueprint(repository),
|
133
|
+
"/eddington": register_eddington_blueprint(repository, search_query_history),
|
134
|
+
"/equipment": make_equipment_blueprint(repository, config),
|
135
|
+
"/explorer": make_explorer_blueprint(
|
136
|
+
authenticator, repository, tile_visit_accessor, config_accessor
|
137
|
+
),
|
138
|
+
"/heatmap": make_heatmap_blueprint(
|
116
139
|
repository, tile_visit_accessor, config_accessor(), search_query_history
|
117
140
|
),
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
url_prefix="/settings",
|
123
|
-
)
|
124
|
-
app.register_blueprint(
|
125
|
-
make_square_planner_blueprint(tile_visit_accessor),
|
126
|
-
url_prefix="/square-planner",
|
127
|
-
)
|
128
|
-
app.register_blueprint(
|
129
|
-
make_search_blueprint(
|
141
|
+
"/plot-builder": make_plot_builder_blueprint(repository),
|
142
|
+
"/settings": make_settings_blueprint(config_accessor, authenticator, flasher),
|
143
|
+
"/square-planner": make_square_planner_blueprint(tile_visit_accessor),
|
144
|
+
"/search": make_search_blueprint(
|
130
145
|
repository, search_query_history, authenticator, config_accessor
|
131
146
|
),
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
make_summary_blueprint(repository, config, search_query_history),
|
136
|
-
url_prefix="/summary",
|
137
|
-
)
|
138
|
-
|
139
|
-
app.register_blueprint(make_tile_blueprint(config), url_prefix="/tile")
|
140
|
-
app.register_blueprint(
|
141
|
-
make_upload_blueprint(
|
147
|
+
"/summary": make_summary_blueprint(repository, config, search_query_history),
|
148
|
+
"/tile": make_tile_blueprint(image_transforms, tile_getter),
|
149
|
+
"/upload": make_upload_blueprint(
|
142
150
|
repository, tile_visit_accessor, config_accessor(), authenticator
|
143
151
|
),
|
144
|
-
|
145
|
-
|
152
|
+
}
|
153
|
+
|
154
|
+
for url_prefix, blueprint in blueprints.items():
|
155
|
+
app.register_blueprint(blueprint, url_prefix=url_prefix)
|
146
156
|
|
147
157
|
base_dir = pathlib.Path("Open Street Map Tiles")
|
148
158
|
dir_for_source = base_dir / urllib.parse.quote_plus(config_accessor().map_tile_url)
|