mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2026-06-12 11:49:47 +02:00
Arreglar alt y mostrar la home, que desaparecía.
This commit is contained in:
+1
-1
@@ -56,4 +56,4 @@ winpaths==0.2
|
|||||||
wxPython==4.2.5
|
wxPython==4.2.5
|
||||||
youtube-dl==2021.12.17
|
youtube-dl==2021.12.17
|
||||||
zipp==4.1.0
|
zipp==4.1.0
|
||||||
atproto>=0.0.67
|
atproto>=0.0.68
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ braille_reporting = boolean(default=True)
|
|||||||
speech_reporting = boolean(default=True)
|
speech_reporting = boolean(default=True)
|
||||||
|
|
||||||
[templates]
|
[templates]
|
||||||
post = string(default="$display_name, $reply_to$safe_text $date.")
|
post = string(default="$display_name, $reply_to$safe_text $image_descriptions $date.")
|
||||||
person = string(default="$display_name (@$screen_name). $followers followers, $following following, $posts posts. Joined $created_at.")
|
person = string(default="$display_name (@$screen_name). $followers followers, $following following, $posts posts. Joined $created_at.")
|
||||||
notification = string(default="$display_name $text, $date")
|
notification = string(default="$display_name $text, $date")
|
||||||
|
|
||||||
|
|||||||
@@ -357,7 +357,7 @@ class Handler:
|
|||||||
buffer.session.settings["templates"] = {}
|
buffer.session.settings["templates"] = {}
|
||||||
templates_cfg = buffer.session.settings.get("templates", {})
|
templates_cfg = buffer.session.settings.get("templates", {})
|
||||||
template_state = {
|
template_state = {
|
||||||
"post": templates_cfg.get("post", "$display_name, $reply_to$safe_text $date."),
|
"post": templates_cfg.get("post", "$display_name, $reply_to$safe_text $image_descriptions $date."),
|
||||||
"person": templates_cfg.get("person", "$display_name (@$screen_name). $followers followers, $following following, $posts posts. Joined $created_at."),
|
"person": templates_cfg.get("person", "$display_name (@$screen_name). $followers followers, $following following, $posts posts. Joined $created_at."),
|
||||||
"notification": templates_cfg.get("notification", "$display_name $text, $date"),
|
"notification": templates_cfg.get("notification", "$display_name $text, $date"),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -804,12 +804,12 @@ class BaseBuffer(base.Buffer):
|
|||||||
try:
|
try:
|
||||||
if self.type == "notifications":
|
if self.type == "notifications":
|
||||||
template = template_settings.get("notification", "$display_name $text, $date")
|
template = template_settings.get("notification", "$display_name $text, $date")
|
||||||
post_template = template_settings.get("post", "$display_name, $reply_to$safe_text $date.")
|
post_template = template_settings.get("post", "$display_name, $reply_to$safe_text $image_descriptions $date.")
|
||||||
return templates.render_notification(item, template, post_template, self.session.settings, relative_times, offset_hours)
|
return templates.render_notification(item, template, post_template, self.session.settings, relative_times, offset_hours)
|
||||||
if self.type in ("user", "post_user_list"):
|
if self.type in ("user", "post_user_list"):
|
||||||
template = template_settings.get("person", "$display_name (@$screen_name). $followers followers, $following following, $posts posts. Joined $created_at.")
|
template = template_settings.get("person", "$display_name (@$screen_name). $followers followers, $following following, $posts posts. Joined $created_at.")
|
||||||
return templates.render_user(item, template, self.session.settings, relative_times, offset_hours)
|
return templates.render_user(item, template, self.session.settings, relative_times, offset_hours)
|
||||||
template = template_settings.get("post", "$display_name, $reply_to$safe_text $date.")
|
template = template_settings.get("post", "$display_name, $reply_to$safe_text $image_descriptions $date.")
|
||||||
return templates.render_post(item, template, self.session.settings, relative_times, offset_hours)
|
return templates.render_post(item, template, self.session.settings, relative_times, offset_hours)
|
||||||
except Exception:
|
except Exception:
|
||||||
# Fallback to compose if any template render fails.
|
# Fallback to compose if any template render fails.
|
||||||
|
|||||||
@@ -136,6 +136,11 @@ def compose_post(post, db, settings, relative_times, show_screen_names=False, sa
|
|||||||
if images:
|
if images:
|
||||||
text += f" [{len(images)} {_('images')}]"
|
text += f" [{len(images)} {_('images')}]"
|
||||||
|
|
||||||
|
if etype and ("gallery" in etype):
|
||||||
|
items = g(embed, "items", [])
|
||||||
|
if items:
|
||||||
|
text += f" [{len(items)} {_('images')}]"
|
||||||
|
|
||||||
if etype and ("recordWithMedia" in etype):
|
if etype and ("recordWithMedia" in etype):
|
||||||
media = g(embed, "media", {})
|
media = g(embed, "media", {})
|
||||||
mtype = g(media, "$type") or g(media, "py_type")
|
mtype = g(media, "$type") or g(media, "py_type")
|
||||||
@@ -143,6 +148,10 @@ def compose_post(post, db, settings, relative_times, show_screen_names=False, sa
|
|||||||
images = g(media, "images", [])
|
images = g(media, "images", [])
|
||||||
if images:
|
if images:
|
||||||
text += f" [{len(images)} {_('images')}]"
|
text += f" [{len(images)} {_('images')}]"
|
||||||
|
elif mtype and "gallery" in mtype:
|
||||||
|
items = g(media, "items", [])
|
||||||
|
if items:
|
||||||
|
text += f" [{len(items)} {_('images')}]"
|
||||||
elif mtype and "external" in mtype:
|
elif mtype and "external" in mtype:
|
||||||
ext = g(media, "external", {})
|
ext = g(media, "external", {})
|
||||||
title = g(ext, "title", "")
|
title = g(ext, "title", "")
|
||||||
|
|||||||
@@ -96,6 +96,18 @@ class Session(base.baseSession):
|
|||||||
self.settings.write()
|
self.settings.write()
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
# Upgrade old default post templates so image descriptions are read.
|
||||||
|
old_post_templates = (
|
||||||
|
"$display_name, $safe_text $date.",
|
||||||
|
"$display_name, $reply_to$safe_text $date.",
|
||||||
|
)
|
||||||
|
templates_cfg = self.settings.get("templates")
|
||||||
|
if templates_cfg is not None and templates_cfg.get("post") in old_post_templates:
|
||||||
|
templates_cfg["post"] = "$display_name, $reply_to$safe_text $image_descriptions $date."
|
||||||
|
try:
|
||||||
|
self.settings.write()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
except Exception:
|
except Exception:
|
||||||
log.exception("Failed to migrate legacy Blueski settings")
|
log.exception("Failed to migrate legacy Blueski settings")
|
||||||
|
|
||||||
|
|||||||
@@ -69,9 +69,13 @@ def _extract_image_descriptions(post, record):
|
|||||||
mtype = _g(media, "$type") or _g(media, "py_type") or ""
|
mtype = _g(media, "$type") or _g(media, "py_type") or ""
|
||||||
if "images" in mtype:
|
if "images" in mtype:
|
||||||
return list(_g(media, "images", []) or [])
|
return list(_g(media, "images", []) or [])
|
||||||
|
if "gallery" in mtype:
|
||||||
|
return list(_g(media, "items", []) or [])
|
||||||
return []
|
return []
|
||||||
if "images" in etype:
|
if "images" in etype:
|
||||||
return list(_g(embed, "images", []) or [])
|
return list(_g(embed, "images", []) or [])
|
||||||
|
if "gallery" in etype:
|
||||||
|
return list(_g(embed, "items", []) or [])
|
||||||
return []
|
return []
|
||||||
|
|
||||||
images = []
|
images = []
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ def _extract_images_from_embed(embed):
|
|||||||
for img in (img_list or []):
|
for img in (img_list or []):
|
||||||
url = None
|
url = None
|
||||||
# Try all possible URL field names
|
# Try all possible URL field names
|
||||||
for key in ["fullsize", "thumb", "url", "uri", "src"]:
|
for key in ["fullsize", "thumb", "thumbnail", "url", "uri", "src"]:
|
||||||
val = g(img, key)
|
val = g(img, key)
|
||||||
if val and isinstance(val, str) and val.startswith("http"):
|
if val and isinstance(val, str) and val.startswith("http"):
|
||||||
url = val
|
url = val
|
||||||
@@ -103,12 +103,18 @@ def _extract_images_from_embed(embed):
|
|||||||
if "images" in etype.lower():
|
if "images" in etype.lower():
|
||||||
images.extend(extract_images(g(embed, "images", [])))
|
images.extend(extract_images(g(embed, "images", [])))
|
||||||
|
|
||||||
|
# Gallery embed (app.bsky.embed.gallery or app.bsky.embed.gallery#view)
|
||||||
|
if "gallery" in etype.lower():
|
||||||
|
images.extend(extract_images(g(embed, "items", [])))
|
||||||
|
|
||||||
# Check in recordWithMedia wrapper
|
# Check in recordWithMedia wrapper
|
||||||
if "recordwithmedia" in etype.lower():
|
if "recordwithmedia" in etype.lower():
|
||||||
media = g(embed, "media", {})
|
media = g(embed, "media", {})
|
||||||
mtype = g(media, "$type") or g(media, "py_type") or ""
|
mtype = g(media, "$type") or g(media, "py_type") or ""
|
||||||
if "images" in mtype.lower():
|
if "images" in mtype.lower():
|
||||||
images.extend(extract_images(g(media, "images", [])))
|
images.extend(extract_images(g(media, "images", [])))
|
||||||
|
if "gallery" in mtype.lower():
|
||||||
|
images.extend(extract_images(g(media, "items", [])))
|
||||||
|
|
||||||
return images
|
return images
|
||||||
|
|
||||||
@@ -136,6 +142,12 @@ def is_image(post):
|
|||||||
if images and len(images) > 0:
|
if images and len(images) > 0:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
# Gallery embed
|
||||||
|
if "gallery" in etype.lower():
|
||||||
|
items = g(embed, "items", [])
|
||||||
|
if items and len(items) > 0:
|
||||||
|
return True
|
||||||
|
|
||||||
# Check in recordWithMedia wrapper
|
# Check in recordWithMedia wrapper
|
||||||
if "recordwithmedia" in etype.lower():
|
if "recordwithmedia" in etype.lower():
|
||||||
media = g(embed, "media", {})
|
media = g(embed, "media", {})
|
||||||
@@ -144,6 +156,10 @@ def is_image(post):
|
|||||||
images = g(media, "images", [])
|
images = g(media, "images", [])
|
||||||
if images and len(images) > 0:
|
if images and len(images) > 0:
|
||||||
return True
|
return True
|
||||||
|
if "gallery" in mtype.lower():
|
||||||
|
items = g(media, "items", [])
|
||||||
|
if items and len(items) > 0:
|
||||||
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user