Skip to content

Commit 7e24b55

Browse files
committed
chore(release): merge dev into main
2 parents db33d46 + 762af6b commit 7e24b55

29 files changed

Lines changed: 1089 additions & 616 deletions

‎AGENTS.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,7 @@ Examples:
3333
- Use `docs/admin-data-model.md` for backend tables, workflow states, and validation-critical constraints.
3434
- Use `docs/implementation-plan.md` for delivery phases and milestone expectations.
3535
- Use `docs/acceptance-criteria.md` and `docs/quality-assurance.md` for review and validation standards.
36+
- Use `docs/deployment.md` for rollout steps, build settings, and remote operations.
37+
- Use `docs/production-config.md` for the current production inventory, domains, Workers, server paths, and config ownership.
3638
- Use `docs/launch-checklist.md` for launch routes, health checks, domain preparation, and observability notes.
37-
- Use `docs/local-development.md` for transition-era local setup notes and current prototype commands.
39+
- Use `docs/local-development.md` for current local setup, service commands, and archive import notes.

‎README.md‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ The target architecture is no longer a headless CMS workflow.
5353
- `docs/implementation-plan.md`: development phases and milestone plan
5454
- `docs/acceptance-criteria.md`: module-level acceptance criteria for product, content, and operations
5555
- `docs/quality-assurance.md`: browser checks, automated checks, sample content, and release validation flow
56-
- `docs/local-development.md`: current local prototype notes and migration-era development guidance
56+
- `docs/local-development.md`: current local setup, service commands, and archive import notes
5757
- `docs/deployment.md`: Worker, Docker Compose, Tunnel, and rollout commands for production
58+
- `docs/production-config.md`: production inventory, hostnames, Workers, server paths, and config ownership
5859
- `docs/launch-checklist.md`: launch-critical routes, domain preparation, health checks, and observability baseline
5960

6061
## Local Development
@@ -64,7 +65,6 @@ Current reality in this repository:
6465
- the public Astro site is implemented and runnable today
6566
- the custom admin workspace and Hono API are the primary local stack
6667
- PostgreSQL, Drizzle seed data, and the bootstrapped operator account are all runnable from this repo
67-
- legacy Directus files remain only as migration-era reference material
6868

6969
Install dependencies:
7070

@@ -110,13 +110,6 @@ Default local operator account after `pnpm local:bootstrap`:
110110
- email: `admin@rebase.local`
111111
- password: `RebaseAdmin123456!`
112112

113-
Legacy transition commands are still available if you need to inspect the old prototype artifacts:
114-
115-
- `pnpm cms:logs`: inspect Directus prototype logs
116-
- `pnpm cms:down`: stop the local prototype containers
117-
- `pnpm cms:health`: verify the temporary prototype health path
118-
- `pnpm cms:reset`: recreate the local prototype database and baseline
119-
120113
If you receive a refreshed `geekdaily.csv`, regenerate the committed archive SQL with:
121114

122115
```bash
@@ -138,6 +131,8 @@ Release policy:
138131
- merge `dev` into `main` only when the release candidate is validated
139132
- production deployment should track `main`, not `dev`
140133

134+
Remote API and service operations can be run through `ops/manage.sh`.
135+
141136
## Repository Conventions
142137

143138
Agent workflow conventions are documented in `AGENTS.md`.

‎apps/admin/src/views/GeekDailyEditorPage.vue‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const errorMessage = ref('');
5858
const successMessage = ref('');
5959
const fieldIssues = ref<Record<string, string>>({});
6060
const suggestedEpisodeNumber = ref(1);
61-
const currentEditorName = ref('');
61+
const currentStaffName = ref('');
6262
const activeWechatTab = ref<'preview' | 'source'>('preview');
6363
const copyFeedback = ref('');
6464
let copyFeedbackTimer: number | null = null;
@@ -71,10 +71,16 @@ const episodeSuggestionHint = computed(() =>
7171
);
7272
const derivedTitle = computed(() => (form.episodeNumber > 0 ? `极客日报#${form.episodeNumber}` : '极客日报#'));
7373
const statusLabel = computed(() => formatContentStatus(form.status));
74-
const currentEditorLabel = computed(() => currentEditorName.value || '当前编辑');
74+
const episodeEditorLabel = computed(() => {
75+
if (record.value) {
76+
return record.value.editors.length > 0 ? record.value.editors.join('、') : '待补充';
77+
}
78+
79+
return currentStaffName.value || '待补充';
80+
});
7581
const wechatInput = computed(() => ({
7682
episodeNumber: form.episodeNumber,
77-
editorName: currentEditorLabel.value,
83+
editorName: episodeEditorLabel.value,
7884
bodyMarkdown: form.bodyMarkdown,
7985
items: form.items,
8086
}));
@@ -168,9 +174,9 @@ const applyRecord = (payload: AdminGeekDailyRecord) => {
168174
const loadCurrentEditor = async () => {
169175
try {
170176
const me = await adminFetch<AdminMePayload>('/api/admin/v1/me');
171-
currentEditorName.value = me.staffAccount?.displayName ?? me.user?.name ?? '';
177+
currentStaffName.value = me.staffAccount?.displayName ?? me.user?.name ?? '';
172178
} catch {
173-
currentEditorName.value = '';
179+
currentStaffName.value = '';
174180
}
175181
};
176182
@@ -345,7 +351,7 @@ onBeforeUnmount(() => {
345351

346352
<div class="geekdaily-meta-item">
347353
<span class="geekdaily-meta-label">本期编辑</span>
348-
<strong class="geekdaily-meta-text">{{ currentEditorLabel }}</strong>
354+
<strong class="geekdaily-meta-text">{{ episodeEditorLabel }}</strong>
349355
</div>
350356
</div>
351357

‎apps/admin/src/views/GeekDailyPage.vue‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ onMounted(() => {
175175
<div class="table-cell-stack">
176176
<strong>{{ row.title }}</strong>
177177
<div class="muted-row">第 {{ row.episodeNumber }} 期</div>
178+
<div v-if="row.editors.length > 0" class="muted-row">编辑:{{ row.editors.join('、') }}</div>
178179
</div>
179180
</td>
180181
<td><span class="status-pill">{{ formatContentStatus(row.status) }}</span></td>

‎apps/api/src/lib/geekdaily.ts‎

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,15 @@ const resolveEpisodeEditors = (actor: AuditActor, fallback: unknown = []) => {
152152
return getEditors(fallback);
153153
};
154154

155+
const resolveStoredEpisodeEditors = (currentEditors: unknown, actor: AuditActor, fallback: unknown = []) => {
156+
const persistedEditors = getEditors(currentEditors);
157+
if (persistedEditors.length > 0) {
158+
return persistedEditors;
159+
}
160+
161+
return resolveEpisodeEditors(actor, fallback);
162+
};
163+
155164
const coerceDate = (value: Date | string | null | undefined) => {
156165
const date = value instanceof Date ? value : value ? new Date(value) : new Date();
157166
return Number.isNaN(date.getTime()) ? new Date() : date;
@@ -222,6 +231,11 @@ interface ListAdminGeekDailyEpisodesInput extends PaginationInput {
222231
status?: ContentStatus;
223232
}
224233

234+
interface ListPublicGeekDailyArchiveInput extends PaginationInput {
235+
year?: number;
236+
tag?: string;
237+
}
238+
225239
const countItemsByEpisodeIds = async (episodeIds: string[]) => {
226240
const db = getDb();
227241
if (episodeIds.length === 0) {
@@ -282,6 +296,7 @@ export const listAdminGeekDailyEpisodes = async (
282296
slug: getGeekDailyEpisodeSlug(row.episodeNumber),
283297
episodeNumber: row.episodeNumber,
284298
title: row.title,
299+
editors: getEditors(row.editorsJson),
285300
status: row.status,
286301
publishedAt: toIsoString(row.publishedAt) ?? new Date().toISOString(),
287302
itemCount: itemCounts.get(row.id) ?? 0,
@@ -344,7 +359,7 @@ export const updateAdminGeekDailyEpisode = async (id: string, input: GeekDailyEp
344359
}
345360

346361
await ensureEpisodeNumberAvailable(input.episodeNumber, id);
347-
const editors = resolveEpisodeEditors(actor, current.editors);
362+
const editors = resolveStoredEpisodeEditors(current.editors, actor, input.editors);
348363

349364
await db
350365
.update(geekdailyEpisodes)
@@ -383,7 +398,7 @@ export const publishAdminGeekDailyEpisode = async (id: string, actor: AuditActor
383398
if (!current) {
384399
throw notFound('GeekDaily episode not found');
385400
}
386-
const editors = resolveEpisodeEditors(actor, current.editors);
401+
const editors = resolveStoredEpisodeEditors(current.editors, actor);
387402

388403
await db
389404
.update(geekdailyEpisodes)
@@ -489,6 +504,58 @@ export const listPublicGeekDailyEpisodePreviews = async (limit = -1) => {
489504
});
490505
};
491506

507+
export const listPublicGeekDailyArchivePage = async (input: ListPublicGeekDailyArchiveInput = {}) => {
508+
const normalizedYear = Number.isFinite(input.year) && (input.year ?? 0) > 0 ? Math.floor(input.year as number) : undefined;
509+
const normalizedTag = input.tag?.trim() ?? '';
510+
const requestedPageSize = Number.isFinite(input.pageSize) && (input.pageSize ?? 0) > 0 ? Math.floor(input.pageSize as number) : 18;
511+
512+
return withPublicGeekDailyCache(
513+
`archive:${input.page ?? 1}:${requestedPageSize}:${normalizedYear ?? 'all'}:${normalizedTag || 'all'}`,
514+
async () => {
515+
const db = getDb();
516+
const where = combineFilters([
517+
eq(geekdailyEpisodes.status, 'published'),
518+
normalizedYear ? sql`extract(year from ${geekdailyEpisodes.publishedAt})::int = ${normalizedYear}` : undefined,
519+
normalizedTag ? sql`${geekdailyEpisodes.tagsJson} @> ${JSON.stringify([normalizedTag])}::jsonb` : undefined,
520+
]);
521+
522+
const countRow = await db.select({ value: count() }).from(geekdailyEpisodes).where(where);
523+
const totalItems = countRow[0]?.value ?? 0;
524+
const pagination = resolvePagination(
525+
{
526+
page: input.page,
527+
pageSize: requestedPageSize,
528+
},
529+
totalItems,
530+
);
531+
const rows =
532+
totalItems === 0
533+
? []
534+
: await db
535+
.select({
536+
id: geekdailyEpisodes.id,
537+
episodeNumber: geekdailyEpisodes.episodeNumber,
538+
title: geekdailyEpisodes.title,
539+
summary: geekdailyEpisodes.summary,
540+
editorsJson: geekdailyEpisodes.editorsJson,
541+
tagsJson: geekdailyEpisodes.tagsJson,
542+
publishedAt: geekdailyEpisodes.publishedAt,
543+
})
544+
.from(geekdailyEpisodes)
545+
.where(where)
546+
.orderBy(desc(geekdailyEpisodes.episodeNumber))
547+
.limit(pagination.pageSize)
548+
.offset(pagination.offset);
549+
const itemsByEpisode = await loadItemsByEpisodeIds(rows.map((row) => row.id));
550+
551+
return {
552+
items: rows.map((row) => mapPublicEpisodePreview(row, itemsByEpisode.get(row.id) ?? [])),
553+
meta: buildPaginatedMeta(pagination),
554+
};
555+
},
556+
);
557+
};
558+
492559
export const getPublicGeekDailyEpisodeBySlug = async (slug: string) => {
493560
return withPublicGeekDailyCache(`episode:${slug}`, async () => {
494561
const row = await getEpisodeRecordBySlug(slug);
@@ -542,6 +609,7 @@ export const getGeekDailySearchDocuments = async () => {
542609
episodeNumber: geekdailyEpisodes.episodeNumber,
543610
title: geekdailyEpisodes.title,
544611
summary: geekdailyEpisodes.summary,
612+
editorsJson: geekdailyEpisodes.editorsJson,
545613
tagsJson: geekdailyEpisodes.tagsJson,
546614
publishedAt: geekdailyEpisodes.publishedAt,
547615
})
@@ -558,6 +626,7 @@ export const getGeekDailySearchDocuments = async () => {
558626
episodeNumber: row.episodeNumber,
559627
title: row.title,
560628
summary: row.summary,
629+
editors: getEditors(row.editorsJson),
561630
tags: getTags(row.tagsJson),
562631
publishedAt,
563632
year: String(new Date(publishedAt).getUTCFullYear()),

‎apps/api/src/lib/site.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ export const getPublicSiteConfig = async () => {
264264
{ label: '首页', href: '/' },
265265
{ label: '极客日报', href: '/geekdaily' },
266266
{ label: 'Who-Is-Hiring', href: '/who-is-hiring' },
267+
{ label: '文章', href: '/articles' },
267268
{ label: '活动', href: '/events' },
268269
{ label: '贡献者们', href: '/contributors' },
269270
{ label: '关于Rebase', href: '/about' },

‎apps/api/src/routes/public.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
getGeekDailySearchDocuments,
99
getPublicGeekDailyEpisodeBySlug,
1010
getPublicGeekDailyOverview,
11+
listPublicGeekDailyArchivePage,
1112
listPublicGeekDailyEpisodePreviews,
1213
listPublicGeekDailyEpisodes,
1314
} from '../lib/geekdaily.js';
@@ -150,6 +151,23 @@ publicRoutes.get('/geekdaily/overview', async (c) => {
150151
return c.json(ok(await getPublicGeekDailyOverview()));
151152
});
152153

154+
publicRoutes.get('/geekdaily/archive', async (c) => {
155+
const rawYear = c.req.query('year');
156+
const year = rawYear && /^\d{4}$/.test(rawYear) ? Number.parseInt(rawYear, 10) : undefined;
157+
const tag = c.req.query('tag')?.trim() ?? '';
158+
const page = getPositiveLimit(c.req.query('page'), 1);
159+
const pageSize = getPositiveLimit(c.req.query('pageSize'), 18);
160+
const result = await listPublicGeekDailyArchivePage({
161+
page,
162+
pageSize,
163+
year,
164+
tag,
165+
});
166+
167+
c.header('Cache-Control', publicCacheControl);
168+
return c.json(ok(result.items, result.meta));
169+
});
170+
153171
publicRoutes.get('/geekdaily/search', async (c) => {
154172
c.header('Cache-Control', publicCacheControl);
155173
return c.json(ok(await getGeekDailySearchDocuments()));

‎apps/web/src/lib/api.ts‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@ export function getApiBaseUrl() {
2121
return API_BASE_URL;
2222
}
2323

24+
export function getPublicApiUrl(pathname: string) {
25+
return new URL(pathname, `${API_BASE_URL}/`);
26+
}
27+
2428
export async function fetchPublicApi<T>(pathname: string): Promise<T> {
25-
const url = new URL(pathname, `${API_BASE_URL}/`);
29+
const url = getPublicApiUrl(pathname);
2630
const response = await fetch(url, {
2731
headers: {
2832
Accept: 'application/json',
@@ -44,6 +48,23 @@ export async function fetchPublicApi<T>(pathname: string): Promise<T> {
4448
return payload.data;
4549
}
4650

51+
export async function proxyPublicApi(pathname: string) {
52+
const response = await fetch(getPublicApiUrl(pathname), {
53+
headers: {
54+
Accept: 'application/json',
55+
},
56+
});
57+
58+
const headers = new Headers();
59+
headers.set('content-type', response.headers.get('content-type') ?? 'application/json; charset=utf-8');
60+
headers.set('cache-control', response.headers.get('cache-control') ?? 'public, max-age=300, stale-while-revalidate=3600');
61+
62+
return new Response(response.body, {
63+
status: response.status,
64+
headers,
65+
});
66+
}
67+
4768
export async function fetchApiReady() {
4869
return fetchPublicApi<{ status: string; checks: { database: string; auth: string } }>('/ready');
4970
}

‎apps/web/src/lib/content.ts‎

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,6 @@ interface PublicGeekDailyEpisodePayload extends Omit<GeekDailyEpisode, 'items'>
5555
items: PublicGeekDailyItemPayload[];
5656
}
5757

58-
interface GeekDailySearchDocument {
59-
slug: string;
60-
episodeNumber: number;
61-
title: string;
62-
summary: string;
63-
tags: string[];
64-
publishedAt: string;
65-
year: string;
66-
items: Array<{
67-
title: string;
68-
authorName: string;
69-
summary: string;
70-
}>;
71-
}
72-
7358
interface GeekDailyArchiveOverviewPayload {
7459
totalEpisodes: number;
7560
years: number[];
@@ -230,10 +215,6 @@ export async function getGeekDailyArchiveOverview() {
230215
return fetchPublicApi<GeekDailyArchiveOverviewPayload>('/api/public/v1/geekdaily/overview');
231216
}
232217

233-
export async function getGeekDailySearchDocuments() {
234-
return fetchPublicApi<GeekDailySearchDocument[]>('/api/public/v1/geekdaily/search');
235-
}
236-
237218
export async function getLatestArticles(count = 3) {
238219
return fetchPublicApi<Article[]>(`/api/public/v1/articles?limit=${count}`);
239220
}
@@ -243,7 +224,10 @@ export async function getLatestJobs(count = 3) {
243224
}
244225

245226
export async function getLatestGeekDaily(count = 3) {
246-
const episodes = await fetchPublicApi<PublicGeekDailyEpisodePayload[]>(`/api/public/v1/geekdaily?limit=${count}`);
227+
const previews = await fetchPublicApi<PublicGeekDailyPreviewPayload[]>(`/api/public/v1/geekdaily?limit=${count}`);
228+
const episodes = await Promise.all(
229+
previews.map((episode) => fetchPublicApi<PublicGeekDailyEpisodePayload>(`/api/public/v1/geekdaily/${episode.slug}`)),
230+
);
247231
return episodes.map(mapGeekDailyEpisode);
248232
}
249233

0 commit comments

Comments
 (0)