fix: 로그인 창에 남은 '또는 아이디로' 구분선과 '아이디로 로그인해 주세요' 안내 빼기, 빈 오류 칸 여백 줄이기
This commit is contained in:
1 parent
cc06d1fa6d
commit
aef8b4a022
10 files changed
+86
-21
No files matched your search
@@ -21,7 +21,7 @@ from services.feed_service import FeedService
|
||||
|
||||
_CODE = re.compile(r'<meta name="region-code" content="(\d+)"')
|
||||
_DESC = re.compile(r'(<meta (?:name|property)="(?:description|og:description|twitter:description)" content=")[^"]*"')
|
||||
_NAME = re.compile(r"<h1>(.+?) 오늘 날씨")
|
||||
_NAME = re.compile(r"<h1>(.+?) (?:오늘|내일) 날씨")
|
||||
_H1 = re.compile(r"(<main><h1>[^<]*</h1>)")
|
||||
|
||||
|
||||
@@ -61,15 +61,27 @@ def today_line(feed: Res_Feed, rows: list[WeatherHourly], sunset_at: Optional[da
|
||||
return " ".join(parts)
|
||||
|
||||
|
||||
def fill(template: str, feed: Res_Feed, rows: list[WeatherHourly], name: str, sunset_at: Optional[datetime]) -> str:
|
||||
"""정적 지역 페이지에 오늘 값을 채운다: 설명 메타와 본문 첫 단락, 오늘 각 순위."""
|
||||
line = today_line(feed, rows, sunset_at)
|
||||
def tomorrow_line(rows: list[WeatherHourly], sunset_at: Optional[datetime]) -> str:
|
||||
"""내일 페이지 한 줄: 내일 하루 예보와 해 지는 시각."""
|
||||
parts = [day_summary(rows)] if rows else []
|
||||
if parts and sunset_at:
|
||||
parts.append(f"해 지는 시각 {_clock(sunset_at)}.")
|
||||
return " ".join(parts)
|
||||
|
||||
|
||||
def _put(template: str, line: str, extra: str = "") -> str:
|
||||
"""설명 메타와 본문 h1 바로 아래에 한 줄을 넣는다."""
|
||||
if not line:
|
||||
return template
|
||||
html = _DESC.sub(lambda m: f'{m.group(1)}{escape(line, quote=True)}"', template)
|
||||
return _H1.sub(lambda m: f"{m.group(1)}<p>{escape(line)}</p>{extra}", html, count=1)
|
||||
|
||||
|
||||
def fill(template: str, feed: Res_Feed, rows: list[WeatherHourly], name: str, sunset_at: Optional[datetime]) -> str:
|
||||
"""정적 지역 페이지에 오늘 값을 채운다: 설명 메타와 본문 첫 단락, 오늘 각 순위."""
|
||||
top = feed.bands.top5 if feed.bands else []
|
||||
ranks = f"<h2>오늘 {escape(name)} 각 순위</h2><ol>{''.join(f'<li>{escape(t.name)} {t.score}점</li>' for t in top)}</ol>" if top else ""
|
||||
html = _DESC.sub(lambda m: f'{m.group(1)}{escape(line, quote=True)}"', template)
|
||||
return _H1.sub(lambda m: f"{m.group(1)}<p>{escape(line)}</p>{ranks}", html, count=1)
|
||||
return _put(template, today_line(feed, rows, sunset_at), ranks)
|
||||
|
||||
|
||||
class SeoService:
|
||||
@@ -98,9 +110,12 @@ class SeoService:
|
||||
LOG.error(f"[seo] feed {code}: {err}")
|
||||
return ErrorType.SUCCESS, template
|
||||
_, region = await DB_SESSION_MNG.execute_lambda(lambda s: self.regions.get(s, code))
|
||||
today = now_kst().date()
|
||||
sunset_at = sun_times(today, float(region.lat), float(region.lon)).sunset_at if region else None
|
||||
start = kst_midnight(today)
|
||||
ahead = path.startswith("tomorrow/")
|
||||
day = now_kst().date() + timedelta(days=1 if ahead else 0)
|
||||
sunset_at = sun_times(day, float(region.lat), float(region.lon)).sunset_at if region else None
|
||||
start = kst_midnight(day)
|
||||
_, rows = await DB_SESSION_MNG.execute_lambda(lambda s: self.weather.hourly_between(s, code, start, start + timedelta(days=1)))
|
||||
if ahead:
|
||||
return ErrorType.SUCCESS, _put(template, tomorrow_line(rows or [], sunset_at))
|
||||
name = _NAME.search(template)
|
||||
return ErrorType.SUCCESS, fill(template, feed, rows or [], name.group(1) if name else (feed.region_name or ""), sunset_at)
|
||||
Reference in new issue
Block a user