mirror of
https://github.com/skoelle/icloud-contacts-sync.git
synced 2026-09-17 15:30:24 +00:00
web custom links city placeholder
This commit is contained in:
@@ -7,7 +7,9 @@
|
|||||||
"authelia_user": "mmustermann",
|
"authelia_user": "mmustermann",
|
||||||
"custom_links": [
|
"custom_links": [
|
||||||
{"label": "Google Suche", "url": "https://www.google.com/search?q=[fullname]"},
|
{"label": "Google Suche", "url": "https://www.google.com/search?q=[fullname]"},
|
||||||
{"label": "LinkedIn", "url": "https://www.linkedin.com/search/results/all/?keywords=[fullname]"}
|
{"label": "LinkedIn", "url": "https://www.linkedin.com/search/results/all/?keywords=[fullname]"},
|
||||||
|
{"label": "Google Maps Home", "url": "https://www.google.com/maps?q=[homecity]"},
|
||||||
|
{"label": "Google Maps Work", "url": "https://www.google.com/maps?q=[workcity]"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
+25
-1
@@ -356,6 +356,18 @@ def web_contact(
|
|||||||
|
|
||||||
contact = _row_to_contact_out(row)
|
contact = _row_to_contact_out(row)
|
||||||
|
|
||||||
|
homecity = ""
|
||||||
|
workcity = ""
|
||||||
|
for addr in contact.get("addresses", []):
|
||||||
|
city = (addr.get("city") or "").strip()
|
||||||
|
if not city:
|
||||||
|
continue
|
||||||
|
addr_type = (addr.get("type") or "").lower()
|
||||||
|
if addr_type == "home" and not homecity:
|
||||||
|
homecity = city
|
||||||
|
elif addr_type == "work" and not workcity:
|
||||||
|
workcity = city
|
||||||
|
|
||||||
custom_links = []
|
custom_links = []
|
||||||
contact_account = contact.get("account")
|
contact_account = contact.get("account")
|
||||||
if contact_account:
|
if contact_account:
|
||||||
@@ -365,6 +377,18 @@ def web_contact(
|
|||||||
custom_links = acc.custom_links
|
custom_links = acc.custom_links
|
||||||
break
|
break
|
||||||
|
|
||||||
|
resolved_links = []
|
||||||
|
for link in custom_links:
|
||||||
|
url = link["url"]
|
||||||
|
if "[homecity]" in url and not homecity:
|
||||||
|
continue
|
||||||
|
if "[workcity]" in url and not workcity:
|
||||||
|
continue
|
||||||
|
url = url.replace("[fullname]", quote_plus(contact.get("full_name") or ""))
|
||||||
|
url = url.replace("[homecity]", quote_plus(homecity))
|
||||||
|
url = url.replace("[workcity]", quote_plus(workcity))
|
||||||
|
resolved_links.append({"label": link["label"], "url": url})
|
||||||
|
|
||||||
return templates.TemplateResponse(
|
return templates.TemplateResponse(
|
||||||
"contact.html",
|
"contact.html",
|
||||||
{
|
{
|
||||||
@@ -374,6 +398,6 @@ def web_contact(
|
|||||||
"show_all": show_all,
|
"show_all": show_all,
|
||||||
"contact": contact,
|
"contact": contact,
|
||||||
"search": search or "",
|
"search": search or "",
|
||||||
"custom_links": custom_links,
|
"custom_links": resolved_links,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -394,7 +394,7 @@
|
|||||||
<div class="section-title">Schnelllinks</div>
|
<div class="section-title">Schnelllinks</div>
|
||||||
<div class="section-list">
|
<div class="section-list">
|
||||||
{% for link in custom_links %}
|
{% for link in custom_links %}
|
||||||
<a href="{{ link.url | replace('[fullname]', contact.full_name | urlquote) }}" target="_blank" class="quicklink-item">
|
<a href="{{ link.url }}" target="_blank" class="quicklink-item">
|
||||||
{{ link.label }}
|
{{ link.label }}
|
||||||
</a>
|
</a>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|||||||
Reference in New Issue
Block a user