Update UI and migrations, fix dockerfile
This commit is contained in:
@@ -11,6 +11,34 @@ def normalize_hash_tag(value: str, fallback: str = "source") -> str:
|
||||
return tag or fallback
|
||||
|
||||
|
||||
def strip_trailing_hashtag_line(text: str) -> str:
|
||||
lines = str(text or "").rstrip().splitlines()
|
||||
while lines and not lines[-1].strip():
|
||||
lines.pop()
|
||||
if not lines:
|
||||
return ""
|
||||
parts = lines[-1].split()
|
||||
if parts and all(part.startswith("#") and normalize_hash_tag(part, "") for part in parts):
|
||||
lines.pop()
|
||||
return "\n".join(lines).rstrip()
|
||||
|
||||
|
||||
def publication_hashtags(category_tag: str, source_tag: str) -> str:
|
||||
tags = [
|
||||
normalize_hash_tag(category_tag, "category"),
|
||||
normalize_hash_tag(source_tag, "source"),
|
||||
]
|
||||
return " ".join(f"#{tag}" for tag in tags if tag)
|
||||
|
||||
|
||||
def build_publication_text(text: str, category_tag: str, source_tag: str) -> str:
|
||||
base = strip_trailing_hashtag_line(text)
|
||||
hashtags = publication_hashtags(category_tag, source_tag)
|
||||
if not hashtags:
|
||||
return base
|
||||
return f"{base}\n\n{hashtags}" if base else hashtags
|
||||
|
||||
|
||||
def parse_categories(value: object) -> list[str]:
|
||||
if isinstance(value, list):
|
||||
raw_items = [str(item) for item in value]
|
||||
|
||||
Reference in New Issue
Block a user