Parse RSS/Atom bytes into a list of items: {title,url,source,topic_key,topic,published}.
(xml_bytes: bytes, source: str, topic_key: str, topic_label: str, is_google: bool)
| 10430 | |
| 10431 | This docstring was expanded to make future maintenance easier. |
| 10432 | |
| 10433 | Args: |
| 10434 | rel: Parameter. |
| 10435 | name: Parameter. |
| 10436 | |
| 10437 | Returns: |
| 10438 | Varies. |
| 10439 | """ |
| 10440 | rel = (rel or "").strip("/") |
| 10441 | return f"{rel}/{name}" if rel else name |
| 10442 | u = current_user() |
| 10443 | prefs = get_user_prefs(u) if u else dict(DEFAULT_PREFS) |
| 10444 | but_css = BUT_CSS + prefs_css(prefs) |
| 10445 | try: |
| 10446 | story_users = _story_active_usernames() if u else set() |
| 10447 | except Exception: |
| 10448 | story_users = set() |
| 10449 | def has_active_story(username): |
| 10450 | try: |
| 10451 | return bool(username and (username in story_users)) |
| 10452 | except Exception: |
| 10453 | return False |
| 10454 | return dict( |
| 10455 | but_css=but_css, |
| 10456 | user=u, |
| 10457 | user_prefs=prefs, |
| 10458 | my_profile=getattr(g, "my_profile", None), |
| 10459 | child_path=child_path, |
| 10460 | request=request, |
| 10461 | is_admin=user_is_admin(current_user()), |
| 10462 | has_active_story=has_active_story, |
| 10463 | story_active_users=story_users, |
| 10464 | log_path=LOG_PATH, |
| 10465 | app_data_dir=BASE_DIR, |
| 10466 | watermark=WATERMARK, |
| 10467 | notifications=getattr(g, "notifs", None), |
| 10468 | ) |
| 10469 | |
| 10470 | @app.before_request |
| 10471 | def _attach_profile_and_presence(): |
| 10472 | # Presence is scoped by the host used to reach the app (local vs cloudflared vs tor). |
| 10473 | """_attach_profile_and_presence. |
| 10474 | |
| 10475 | Internal helper function. |
| 10476 | |
| 10477 | This docstring was expanded to make future maintenance easier. |
| 10478 | |
| 10479 | Returns: |
| 10480 | Varies. |
| 10481 | """ |
| 10482 | # Presence is scoped by the host used to reach the app (local vs cloudflared vs tor). |
| 10483 | g.scope = current_scope() |
| 10484 | u = current_user() |
| 10485 | if u: |
| 10486 | g.my_profile = type("Obj", (), get_profile(u))() |
| 10487 | mark_online(u, g.scope) |
| 10488 | |
| 10489 | # Notifications (numbered indicators) |
no test coverage detected