Skip to content

Commit

Permalink
update to Elixir 1.18 and migrate settings to avoid type warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
breunigs committed Dec 26, 2024
1 parent c56f9d5 commit 0974696
Show file tree
Hide file tree
Showing 59 changed files with 322 additions and 289 deletions.
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
elixir 1.17.2
erlang 27.0.1
elixir 1.18.0
erlang 27.2
nodejs 18.14.2
2 changes: 2 additions & 0 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,5 @@ config :mime, :types, %{
# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "#{Mix.env()}.exs"

import_config "settings.exs"
2 changes: 1 addition & 1 deletion config/runtime.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Config

if config_env() == :prod do
parsed = URI.new!(Settings.url())
parsed = URI.new!(Settings.r(:url))

config :veloroute, VelorouteWeb.Endpoint,
url: [host: parsed.host, port: parsed.port, scheme: parsed.scheme]
Expand Down
150 changes: 150 additions & 0 deletions config/settings.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
import Config

config :veloroute, Settings, %{
# max extent the user may navigate the map (min lon, min lat, max lon, max lat)
bounds: [8.9236, 53.1336, 10.8897, 53.9682],
# tiny debug area around Landungsbrücken for basemap testing
# bounds: [9.95815, 53.54178, 9.97641, 53.54781],

# start settings if no other map location/image is selected
initial: %{minLon: 9.724553, minLat: 53.454363, maxLon: 10.21779, maxLat: 53.715809},

# which basemap styles to show, their display name, and if they're default or not
map_styles: [
%{
name: "Karte",
id: "/assets/basemap/styles/standard.json",
active: true
},
%{
name: "Satellitenbild",
id: "/assets/basemap/styles/satellite.json",
active: false
}
],

# which individual map layers are grouped into a human readable combination of
# those
map_layers: [
%{
name: "Artikel",
route_group: nil,
active: true,
line: [],
icon: ["article-areas title"],
fill: ["article-areas bg"],
outline: ["article-areas bg outline", "article-areas bg outline dash"]
},
%{
name: "Alltagsrouten",
route_group: :alltag,
active: true,
line: ["vr-line-off-p1", "vr-line-off-m1", "vr-line-off-none"],
icon: ["vr-oneway", "vr-sign"],
fill: [],
outline: []
},
%{
name: "Freizeitrouten",
route_group: :freizeit,
active: false,
line: ["fr-line"],
icon: ["fr-oneway", "fr-sign", "fr-warning-icons"],
fill: [],
outline: []
},
%{
name: "Bezirksrouten",
route_group: :bezirk,
active: false,
line: ["br-line-off-p1", "br-line-off-m1", "br-line-off-none"],
icon: ["br-oneway", "br-sign"],
fill: [],
outline: []
},
%{
name: "Radschnellwege",
route_group: :rsw,
active: false,
line: ["rsw-line"],
icon: ["rsw-oneway", "rsw-sign"],
fill: [],
outline: []
}
],

# the start video/image to display if the user visits the start page
start_image: %{
article_id: "11",
direction: :forward,
position: %{lat: 53.55044, lon: 9.99440}
},

# city/area/region name that will have its results boosted over the ones
# outside of it. Should be written like it is in OpenStreetMap data.
boost_search_results_within: "Hamburg",

# no trailing slash, absolute URL to the project
url: "https://veloroute.hamburg",
# full URL up until host and TLD, no trailing slash. Or nil for "same".
video_serve_host: "https://veloroute.hamburg",
# appended to `video_serve_host` or `url`
video_serve_path: "videos-rendered",

# where do download the OpenStreetMap data from
osm_data_source: "https://download.geofabrik.de/europe/germany-latest.osm.pbf",
# how stale it may be
osm_data_source_max_age_days: 30 * 2,
# extra shapes if needed
osm_data_source_extra_shapes: [
"https://osmdata.openstreetmap.de/download/water-polygons-split-4326.zip"
# "https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_urban_areas.zip"
],

# various names and titles
feed_title: "veloroute.hamburg – Neue Artikel",
feed_author: "veloroute.hamburg",
sitebar_name: "veloroute.hamburg",
page_title_short: "veloroute.hamburg · ",
page_title_long: "veloroute.hamburg · Fahrradwege für Alltag und Freizeit",
email: "[email protected]",
email_name: "Stefan Breunig",
twitter_handle: "@VelorouteHH",
mastodon_url: "https://norden.social/@VelorouteHamburg",
bluesky_url: "https://bsky.app/profile/veloroutehh.bsky.social",

# which SSH handle to use to deploy the page
deploy_ssh_name: "veloroute-deploy",

# specify command if videos need to be copied to the server
# spec: [binary()] | nil
deploy_video_copy_cmd: nil,
# [
# "ssh",
# deploy_ssh_name(),
# "--",
# "rclone",
# "sync",
# "--max-delete",
# "15",
# "hsbssh:veloroute/videos/rendered/",
# "/home/veloroute-rendered-videos/"
# ],

# which language to use if none available match the user's
default_language: "de",

# which links to tag with a [€] marker
paywall_hostnames: ["abendblatt.de", "www.abendblatt.de"],

# Thumbnails have approximately 100 kB, so 100 thumbs are ~10 MB, 1000 are ~100MB
video_thumbnail_cache_entry_limit: 1000,
external_map_cache_entry_limit: 1000,
static_map_cache_entry_limit: 200,

# various video related paths
video_dir_rel: "videos",
video_dir_abs: Path.join(File.cwd!(), "videos"),
video_source_dir_abs: Path.join(Path.join(File.cwd!(), "videos"), "source"),
video_target_dir_abs: Path.join(Path.join(File.cwd!(), "videos"), "rendered")
}
8 changes: 4 additions & 4 deletions data/articles/static/changes.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ defmodule Data.Article.Static.Changes do
<ul class="imgbullet">
<li><.a href="/updates.atom"><img src="/images/rss.svg"> RSS-Feed</.a> (benötigt einen <.a href="https://www.rss-readers.org/">Feedreader</.a>)</li>
<%= if Settings.mastodon_url() != nil do %>
<li><.a href={Settings.mastodon_url()} rel="me"><img src="/images/mastodon.svg"> Mastodon</.a></li>
<%= if Settings.r(:mastodon_url) != nil do %>
<li><.a href={Settings.r(:mastodon_url)} rel="me"><img src="/images/mastodon.svg"> Mastodon</.a></li>
<% end %>
<%= if Settings.bluesky_url() != nil do %>
<li><.a href={Settings.bluesky_url()}><img src="/images/bluesky.svg"> Bluesky</.a></li>
<%= if Settings.r(:bluesky_url) != nil do %>
<li><.a href={Settings.r(:bluesky_url)}><img src="/images/bluesky.svg"> Bluesky</.a></li>
<% end %>
<li><.mailto subject="veloroute.hamburg Newsletter abonnieren" body={"Hallo,\n\nbitte halte mich zu neuen oder aktualisierten Artikeln auf dem Laufenden. Nimm dazu einfach diese E-Mail Adresse.\n\nDanke!"}><img src="/images/email.svg"> E-Mail Newsletter abonnieren</.mailto></li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion data/articles/static/datenexport.ex
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ defmodule Data.Article.Static.Datenexport do
path = Video.RenderedTools.highest_quality_video_file(hash)

path =
[Settings.video_serve_host(), Settings.video_serve_path(), path]
[Settings.r(:video_serve_host), Settings.r(:video_serve_path), path]
|> Util.compact()
|> Path.join()

Expand Down
137 changes: 0 additions & 137 deletions data/settings.ex

This file was deleted.

8 changes: 4 additions & 4 deletions lib/article/decorators.ex
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ defmodule Article.Decorators do

def search_result(art, relevance) do
bbox = Article.Decorators.bbox(art)
bounds = if bbox, do: bbox, else: Settings.initial()
bounds = if bbox, do: bbox, else: Settings.r(:initial)
type = if art.created_at(), do: "article", else: "page"

subtext =
Expand Down Expand Up @@ -59,15 +59,15 @@ defmodule Article.Decorators do
show_map_image: false,
enable_drawing_tools: false,
ref: art,
lang: Settings.default_language()
lang: Settings.r(:default_language)
}

assigns = Map.merge(default, assigns)
apply(art, fun, [assigns])
end

@spec full_title(Article.t(), Article.language()) :: binary()
def full_title(art, lang \\ Settings.default_language()) do
def full_title(art, lang \\ Settings.r(:default_language)) do
tn = type_name(art, lang)

cond do
Expand Down Expand Up @@ -173,7 +173,7 @@ defmodule Article.Decorators do
do: "?lang=#{lang}",
else: ""

Settings.url() <> path(art) <> query
Settings.r(:url) <> path(art) <> query
end

@type_names %{
Expand Down
4 changes: 2 additions & 2 deletions lib/article/default.ex
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ defmodule Article.Default do
def icon, do: type()

def map_image(), do: nil
def languages(), do: [Settings.default_language()]
def languages(), do: [Settings.r(:default_language)]

def compiled_at(), do: unquote(Macro.escape(DateTime.utc_now()))

Expand Down Expand Up @@ -56,7 +56,7 @@ defmodule Article.Default do

!s0 && s1 ->
quote do
def summary(), do: summary(Settings.default_language())
def summary(), do: summary(Settings.r(:default_language))
end

!s0 && !s1 ->
Expand Down
2 changes: 1 addition & 1 deletion lib/basemap/map_matcher.ex
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ defmodule Basemap.MapMatcher.OSRM do
GenServer.call(__MODULE__, {:query, coords, params}, :infinity) do
merged =
[points, matches]
|> List.zip()
|> Enum.zip()
|> Enum.map(fn {p, m} -> Map.merge(p, m) end)
|> Enum.map(&fallback/1)

Expand Down
Loading

0 comments on commit 0974696

Please sign in to comment.