Skip to content

Commit 56d4ba4

Browse files
sametbasbugclaude
andcommitted
Put the sign-in control in the header readers actually see
6ff4be0 added it to BaseLayout's header, which NewsLayout hides: every news page renders BaseLayout with hideHeader={true} and draws its own masthead. The markup and its CSS shipped and were live -- the class is in the deployed stylesheet -- but nothing rendered, because the header holding it never renders on this site. Only src/pages/sayfa/[page] uses BaseLayout's header at all. Found it by elimination rather than by reading: confirmed the deploy ran on the right commit, confirmed the CSS was present in production, ruled out the edge cache with a unique query string, and ruled out a static asset shadowing the Worker by checking the SSR build emits no HTML. The control is now a component used in both of the masthead's action blocks -- mobile and desktop are separate markup -- so the session read and the configuration check stay in one place rather than being written twice. 212 newsroom tests, 22 + 21 Orbit cases, 0 type errors, both builds. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 6ff4be0 commit 56d4ba4

3 files changed

Lines changed: 63 additions & 49 deletions

File tree

‎src/components/OturumDugmesi.astro‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
/* Orbit oturum düğmesi.
3+
*
4+
* Başlıkta iki kez görünüyor (mobil ve masaüstü blokları ayrı), o yüzden
5+
* bileşen: oturum okuması ve yapılandırma kontrolü tek yerde kalsın.
6+
*
7+
* Okuma sırası ucuzdan pahalıya: veritabanı yoksa (statik derleme) hiç
8+
* sorulmuyor, çerez yoksa D1'e HİÇ gidilmiyor. Giriş yapmamış ziyaretçi —
9+
* yani ziyaretçilerin çoğu — bu bileşen yüzünden tek satır okumuyor.
10+
*
11+
* Giriş yapmış istekler ara katmanda önbelleği zaten atlıyor; o kural
12+
* olmasaydı burada basılan ad başkasının ekranına önbelleklenebilirdi.
13+
*/
14+
import { getDatabase, getWorkerEnv } from '#runtime-env';
15+
import { oturumCereziVarMi, oturumOku } from '../server/session';
16+
17+
const veritabani = getDatabase();
18+
const okuyucu = veritabani && oturumCereziVarMi(Astro.request)
19+
? await oturumOku(veritabani, Astro.request, Date.now())
20+
: null;
21+
22+
/* Düğme yalnız Orbit TAM yapılandırılmışsa çıkıyor: yarım yapılandırmada
23+
* basana 503 veren bir düğme, hiç düğme olmamasından kötüdür. */
24+
let girisAcik = false;
25+
if (veritabani) {
26+
try {
27+
const env = getWorkerEnv();
28+
girisAcik = Boolean(env.ORBIT_ISSUER && env.ORBIT_CLIENT_ID && env.ORBIT_CLIENT_SECRET);
29+
} catch {
30+
girisAcik = false;
31+
}
32+
}
33+
34+
/* Girişten sonra aynı sayfaya dönülüyor. */
35+
const donus = Astro.url.pathname + Astro.url.search;
36+
---
37+
38+
{okuyucu && (
39+
<form class="oturum" method="POST" action="/cikis">
40+
<span class="oturum-ad" title={okuyucu.displayName ?? 'Orbit hesabı'}>
41+
{okuyucu.displayName ?? 'Hesabım'}
42+
</span>
43+
<button type="submit" class="news-action-pill oturum-dugme">Çıkış</button>
44+
</form>
45+
)}
46+
{!okuyucu && girisAcik && (
47+
<form class="oturum" method="POST" action="/giris/orbit">
48+
<input type="hidden" name="donus" value={donus} />
49+
<button type="submit" class="news-action-pill oturum-dugme">Orbit ile giriş</button>
50+
</form>
51+
)}
52+
53+
<style>
54+
.oturum { display: flex; align-items: center; gap: .5rem; margin: 0; }
55+
.oturum-ad {
56+
max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
57+
font-size: .82rem; opacity: .8;
58+
}
59+
.oturum-dugme { border: inherit; font: inherit; cursor: pointer; }
60+
</style>

‎src/layouts/BaseLayout.astro‎

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
---
22
import { ClientRouter } from 'astro:transitions';
33
import { getMainSiteUrl } from '../data/newsSite';
4-
import { getDatabase, getWorkerEnv } from '#runtime-env';
5-
import { oturumCereziVarMi, oturumOku } from '../server/session';
64
interface Props {
75
title: string;
86
description: string;
@@ -17,35 +15,6 @@ interface Props {
1715
hideHeader?: boolean;
1816
}
1917
20-
/* Oturum durumu.
21-
*
22-
* Sıra bilinçli ve ucuzdan pahalıya: veritabanı yoksa (statik derleme) hiç
23-
* sorulmuyor; çerez yoksa D1'e HİÇ gidilmiyor. Yani giriş yapmamış ziyaretçi
24-
* — yani ziyaretçilerin çoğu — bu blok yüzünden tek satır bile okumuyor.
25-
*
26-
* Giriş yapmış istekler ara katmanda önbelleği zaten atlıyor; oradaki kural
27-
* olmasaydı burada okunan ad başkasının ekranına önbelleklenebilirdi.
28-
*/
29-
const veritabani = getDatabase();
30-
const okuyucu = veritabani && oturumCereziVarMi(Astro.request)
31-
? await oturumOku(veritabani, Astro.request, Date.now())
32-
: null;
33-
34-
/* Giriş düğmesi yalnız Orbit TAM yapılandırılmışsa çıkıyor. Yarım
35-
* yapılandırmada düğmeyi göstermek, basana 503 vermek olurdu. */
36-
let girisAcik = false;
37-
if (veritabani) {
38-
try {
39-
const env = getWorkerEnv();
40-
girisAcik = Boolean(env.ORBIT_ISSUER && env.ORBIT_CLIENT_ID && env.ORBIT_CLIENT_SECRET);
41-
} catch {
42-
girisAcik = false;
43-
}
44-
}
45-
46-
/* Girişten sonra aynı sayfaya dönülüyor. */
47-
const suankiYol = Astro.url.pathname + Astro.url.search;
48-
4918
const {
5019
title,
5120
description,
@@ -209,20 +178,6 @@ const fullTitle = title === publicationName ? publicationName : `${publicationNa
209178
<a href="/iletisim/">İletişim</a>
210179
<a href="/rss.xml">RSS</a>
211180
</div>
212-
{okuyucu && (
213-
<form class="oturum" method="POST" action="/cikis">
214-
<span class="oturum-ad" title={okuyucu.displayName ?? 'Orbit hesabı'}>
215-
{okuyucu.displayName ?? 'Hesabım'}
216-
</span>
217-
<button type="submit" class="oturum-dugme">Çıkış</button>
218-
</form>
219-
)}
220-
{!okuyucu && girisAcik && (
221-
<form class="oturum" method="POST" action="/giris/orbit">
222-
<input type="hidden" name="donus" value={suankiYol} />
223-
<button type="submit" class="oturum-dugme oturum-giris">Orbit ile giriş</button>
224-
</form>
225-
)}
226181
<div class="theme-switch-wrapper" id="theme-switch-wrapper">
227182
<button id="theme-toggle" class="theme-switch" aria-label="Temayı Değiştir">
228183
<div class="switch-handle">
@@ -544,10 +499,6 @@ const fullTitle = title === publicationName ? publicationName : `${publicationNa
544499

545500
.logo-area { display: inline-flex; align-items: center; gap: 0.7rem; flex-shrink: 0; }
546501
.nav-right { display: flex; align-items: center; gap: 1.5rem; min-width: 0; }
547-
.oturum { display: flex; align-items: center; gap: .6rem; margin: 0; }
548-
.oturum-ad { max-width: 12ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .85rem; opacity: .85; }
549-
.oturum-dugme { padding: .3rem .7rem; border: 1px solid currentColor; border-radius: 999px; background: none; color: inherit; font: inherit; font-size: .8rem; cursor: pointer; opacity: .8; }
550-
.oturum-dugme:hover { opacity: 1; }
551502
.links { display: flex; align-items: center; gap: 0.5rem; }
552503

553504
.links a, .dropbtn {

‎src/layouts/NewsLayout.astro‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
import BaseLayout from './BaseLayout.astro';
3+
import OturumDugmesi from '../components/OturumDugmesi.astro';
34
import { getNewsCategoryHref } from '../data/equinoxHaber';
45
import { getMainSiteUrl, getNewsArchiveHref, getNewsHomePath, getNewsHomeHref, getSourceCodeHref, isNewsSubdomainEnabled } from '../data/newsSite';
56
@@ -68,6 +69,7 @@ const blogHomeHref = isNewsSubdomainEnabled() ? getMainSiteUrl() : '/';
6869
<button class="news-theme-pill" type="button" aria-label="Temayı Değiştir" data-news-theme-toggle>
6970
<span data-news-theme-icon>🌙</span>
7071
</button>
72+
<OturumDugmesi />
7173
<a href={blogHomeHref} class="news-action-pill">Blog'a dön</a>
7274
</div>
7375
</div>
@@ -95,6 +97,7 @@ const blogHomeHref = isNewsSubdomainEnabled() ? getMainSiteUrl() : '/';
9597
<button class="news-theme-pill" type="button" aria-label="Temayı Değiştir" data-news-theme-toggle>
9698
<span data-news-theme-icon>🌙</span>
9799
</button>
100+
<OturumDugmesi />
98101
<a href={blogHomeHref} class="news-action-pill">Blog'a dön</a>
99102
</div>
100103
</div>

0 commit comments

Comments
 (0)