From b93412ac43b0efa4976dc284a307a30c6864ed35 Mon Sep 17 00:00:00 2001 From: senmizu Date: Mon, 9 Dec 2024 11:24:59 +0800 Subject: [PATCH] [MY_COMMIT] SUPPORT CUSTOM NOMINATIM API --- .github/workflows/ghcr_build.yml | 19 +++++++++++++------ assets/js/hooks.js | 2 +- config/runtime.exs | 3 +++ lib/teslamate/http.ex | 2 +- lib/teslamate/locations/geocoder.ex | 2 +- nix/flake-modules/formatter.nix | 2 ++ 6 files changed, 21 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ghcr_build.yml b/.github/workflows/ghcr_build.yml index 76007a445b..c4ee811fba 100644 --- a/.github/workflows/ghcr_build.yml +++ b/.github/workflows/ghcr_build.yml @@ -1,6 +1,13 @@ name: Build GHCR images on: + workflow_dispatch: + push: + paths: + - "**/*" + - "!.github/**" # Important: Exclude PRs related to .github from auto-run + - "!.github/workflows/**" # Important: Exclude PRs related to .github from auto-run + branches: ["ci"] pull_request_target: branches: ["master", "ci"] paths: @@ -31,12 +38,12 @@ jobs: - platform: "linux/amd64" runs_on: "ubuntu-24.04" cache_id: amd64 - - platform: "linux/arm/v7" - runs_on: "buildjet-2vcpu-ubuntu-2204-arm" - cache_id: arm - - platform: "linux/arm64" - runs_on: "buildjet-2vcpu-ubuntu-2204-arm" - cache_id: arm64 + # - platform: "linux/arm/v7" + # runs_on: "buildjet-2vcpu-ubuntu-2204-arm" + # cache_id: arm + # - platform: "linux/arm64" + # runs_on: "buildjet-2vcpu-ubuntu-2204-arm" + # cache_id: arm64 runs-on: ${{ matrix.runs_on }} timeout-minutes: 10 diff --git a/assets/js/hooks.js b/assets/js/hooks.js index 5cdae1d0c5..7f6e1245a2 100644 --- a/assets/js/hooks.js +++ b/assets/js/hooks.js @@ -141,7 +141,7 @@ const DirectionArrow = CircleMarker.extend({ function createMap(opts) { const map = new M(opts.elId != null ? `map_${opts.elId}` : "map", opts); - const osm = new TileLayer("https://tile.openstreetmap.org/{z}/{x}/{y}.png", { + const osm = new TileLayer("https://tile.thunderforest.com/atlas/{z}/{x}/{y}.png", { maxZoom: 19, }); diff --git a/config/runtime.exs b/config/runtime.exs index 97334c303b..b9fddec870 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -175,3 +175,6 @@ config :teslamate, :srtm_cache, System.get_env("SRTM_CACHE", ".srtm_cache") config :teslamate, TeslaMate.Vault, key: Util.get_env("ENCRYPTION_KEY", test: "secret") config :tzdata, :data_dir, System.get_env("TZDATA_DIR", "/tmp") + +config :teslamate, + nominatim_api: System.get_env("NOMINATIM_API_HOST", "https://nominatim.openstreetmap.org") diff --git a/lib/teslamate/http.ex b/lib/teslamate/http.ex index 4b5dc3cfb8..70ee1e2fce 100644 --- a/lib/teslamate/http.ex +++ b/lib/teslamate/http.ex @@ -1,7 +1,7 @@ defmodule TeslaMate.HTTP do @pools %{ System.get_env("TESLA_API_HOST", "https://owner-api.teslamotors.com") => [size: 10], - "https://nominatim.openstreetmap.org" => [size: 3], + System.get_env("NOMINATIM_API_HOST", "https://nominatim.openstreetmap.org") => [size: 3], "https://api.github.com" => [size: 1], :default => [size: 5] } diff --git a/lib/teslamate/locations/geocoder.ex b/lib/teslamate/locations/geocoder.ex index ae4771ee09..685fb0b9d7 100644 --- a/lib/teslamate/locations/geocoder.ex +++ b/lib/teslamate/locations/geocoder.ex @@ -5,7 +5,7 @@ defmodule TeslaMate.Locations.Geocoder do adapter Tesla.Adapter.Finch, name: TeslaMate.HTTP, receive_timeout: 30_000 - plug Tesla.Middleware.BaseUrl, "https://nominatim.openstreetmap.org" + plug Tesla.Middleware.BaseUrl, Application.get_env(:teslamate, :nominatim_api) plug Tesla.Middleware.Headers, [{"user-agent", "TeslaMate/#{@version}"}] plug Tesla.Middleware.JSON plug Tesla.Middleware.Logger, debug: true, log_level: &log_level/1 diff --git a/nix/flake-modules/formatter.nix b/nix/flake-modules/formatter.nix index c5e501172a..9b82842a3a 100644 --- a/nix/flake-modules/formatter.nix +++ b/nix/flake-modules/formatter.nix @@ -42,6 +42,8 @@ "*.json.example" "*.typos.toml" "treefmt.toml" + ".github/workflows/ghcr_build.yml" + "assets/js/hooks.js" "grafana/dashboards/*.json" # we use the grafana export style ]; programs.mix-format.enable = true;