Compare commits
2 commits
main
...
edit-posts
Author | SHA1 | Date | |
---|---|---|---|
0265891c92 | |||
551ae7157d |
3 changed files with 39 additions and 56 deletions
|
@ -1,33 +0,0 @@
|
|||
when:
|
||||
branch: main
|
||||
event: [push, pull_request]
|
||||
|
||||
variables:
|
||||
- &file Dockerfile
|
||||
- &repo scm.gruezi.net/${CI_REPO}
|
||||
|
||||
steps:
|
||||
dryrun:
|
||||
image: woodpeckerci/plugin-docker-buildx
|
||||
settings:
|
||||
dockerfile: *file
|
||||
platforms: linux/arm/v7,linux/arm64/v8,linux/amd64,linux/ppc64le
|
||||
dry_run: true
|
||||
repo: *repo
|
||||
tags: latest
|
||||
when:
|
||||
event: pull_request
|
||||
|
||||
publish:
|
||||
image: woodpeckerci/plugin-docker-buildx
|
||||
settings:
|
||||
dockerfile: *file
|
||||
platforms: linux/arm/v7,linux/arm64/v8,linux/amd64,linux/ppc64le
|
||||
repo: *repo
|
||||
registry: scm.gruezi.net
|
||||
tags: latest
|
||||
username: ${CI_REPO_OWNER}
|
||||
password:
|
||||
from_secret: FORGEJO_API_TOKEN
|
||||
when:
|
||||
event: push
|
|
@ -1,20 +1,20 @@
|
|||
blurhash==1.1.4
|
||||
certifi==2024.12.14
|
||||
charset-normalizer==3.4.1
|
||||
certifi==2024.8.30
|
||||
charset-normalizer==3.4.0
|
||||
decorator==5.1.1
|
||||
greenlet==3.1.1
|
||||
idna==3.10
|
||||
pip-install==1.3.5
|
||||
Mastodon.py==1.8.1
|
||||
numpy==2.2.1
|
||||
pillow==11.1.0
|
||||
numpy==2.1.3
|
||||
pillow==11.0.0
|
||||
python-dateutil==2.9.0.post0
|
||||
python-magic==0.4.27
|
||||
PyYAML==6.0.2
|
||||
requests==2.32.3
|
||||
shapely==2.0.6
|
||||
six==1.17.0
|
||||
SQLAlchemy==2.0.37
|
||||
six==1.16.0
|
||||
SQLAlchemy==2.0.36
|
||||
staticmap==0.5.7
|
||||
typing_extensions==4.12.2
|
||||
urllib3==2.3.0
|
||||
urllib3==2.2.3
|
||||
|
|
48
scl.py
48
scl.py
|
@ -117,6 +117,35 @@ def get_hashtag_string(event) -> str:
|
|||
return hashtag_string
|
||||
|
||||
|
||||
def get_alt_text_string(event) -> str:
|
||||
try:
|
||||
street = event["geoloc_street"]
|
||||
|
||||
city = event["geoloc_city"]
|
||||
if city != "Seattle":
|
||||
city_not_seattle_text = " of {}".format(city)
|
||||
else:
|
||||
city_not_seattle_text = ""
|
||||
|
||||
try:
|
||||
locality = event["neighborhood"]
|
||||
except KeyError:
|
||||
return "A map showing the location of the outage, centered around {} in {}.".format(
|
||||
street,
|
||||
city,
|
||||
)
|
||||
if locality == "Uptown":
|
||||
locality = "Lower Queen Anne"
|
||||
|
||||
return "A map showing the location of the outage, centered around {} in the {} area{}.".format(
|
||||
street,
|
||||
locality,
|
||||
city_not_seattle_text,
|
||||
)
|
||||
except Exception:
|
||||
return "A map showing the location of the outage."
|
||||
|
||||
|
||||
def do_initial_post(
|
||||
event,
|
||||
event_class,
|
||||
|
@ -174,6 +203,7 @@ def do_initial_post(
|
|||
city = geocode["features"][0]["properties"]["geocoding"]["city"]
|
||||
street = geocode["features"][0]["properties"]["geocoding"]["name"]
|
||||
event["geoloc_city"] = city
|
||||
event["geoloc_street"] = street
|
||||
|
||||
if city != "Seattle":
|
||||
city_not_seattle_text = " of {}".format(city)
|
||||
|
@ -188,33 +218,19 @@ def do_initial_post(
|
|||
if locality == "Uptown":
|
||||
locality = "Lower Queen Anne"
|
||||
|
||||
alt_text = "A map showing the location of the outage, centered around {} in the {} area{}.".format(
|
||||
street,
|
||||
locality,
|
||||
city_not_seattle_text,
|
||||
)
|
||||
area_text = "the {} area{}".format(locality, city_not_seattle_text)
|
||||
event["neighborhood"] = locality
|
||||
elif "district" in geocode["features"][0]["properties"]["geocoding"]:
|
||||
district = geocode["features"][0]["properties"]["geocoding"]["district"]
|
||||
alt_text = "A map showing the location of the outage, centered around {} in the {} area{}.".format(
|
||||
street,
|
||||
district,
|
||||
city_not_seattle_text,
|
||||
)
|
||||
area_text = "the {} area{}".format(
|
||||
district,
|
||||
city_not_seattle_text,
|
||||
)
|
||||
event["neighborhood"] = district
|
||||
else:
|
||||
alt_text = "A map showing the location of the outage, centered around {} in {}.".format(
|
||||
street,
|
||||
city,
|
||||
)
|
||||
area_text = city
|
||||
except Exception:
|
||||
alt_text = "A map showing the location of the outage."
|
||||
pass
|
||||
|
||||
map_image = map.render()
|
||||
|
||||
|
@ -223,7 +239,7 @@ def do_initial_post(
|
|||
map_media_post = mastodon_client.media_post(
|
||||
map_image_file.getvalue(),
|
||||
mime_type="image/webp",
|
||||
description=alt_text,
|
||||
description=get_alt_text_string(event),
|
||||
)
|
||||
map_media_post_id = map_media_post["id"]
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue