@studyllm/resume-preview 0.0.0-stage → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,57 @@
1
+ {
2
+ "meta": {
3
+ "label": "English",
4
+ "htmlLang": "en"
5
+ },
6
+ "gallery": {
7
+ "title": "Resume Library",
8
+ "subtitle": "Browse and open your resumes",
9
+ "searchPlaceholder": "Search resumes by ID…",
10
+ "loading": "Loading…",
11
+ "count": "{n} resumes",
12
+ "countOne": "{n} resume",
13
+ "emptyTitle": "No resumes found",
14
+ "emptyDesc": "Create a resume using the resume_preview tool to see it here",
15
+ "noResultsTitle": "No matching resumes",
16
+ "noResultsDesc": "Try a different search term",
17
+ "deleteTitle": "Delete",
18
+ "deleteConfirm": "Are you sure you want to delete resume \"{id}\"?",
19
+ "deleteFailed": "Failed to delete resume: {message}",
20
+ "loadFailedTitle": "Failed to load resumes",
21
+ "navGallery": "Library",
22
+ "footerText": "Resume Preview",
23
+ "pageTitle": "Resume Library - Resume Preview"
24
+ },
25
+ "preview": {
26
+ "statusLive": "Live Reload Active",
27
+ "statusStatic": "Static View",
28
+ "statusDisconnected": "Disconnected - Reconnecting…",
29
+ "statusFailed": "Connection failed - Reload page to retry",
30
+ "lastUpdated": "Last updated: {time}",
31
+ "btnBack": "Go back",
32
+ "btnZoomIn": "Zoom in",
33
+ "btnZoomOut": "Zoom out",
34
+ "btnReset": "Reset position",
35
+ "btnExport": "Export resume",
36
+ "exportPdf": "Download PDF",
37
+ "exportHtml": "Download HTML",
38
+ "exportMissingId": "Resume identifier is missing. Try rendering the resume again.",
39
+ "exportFailed": "Failed to export the resume: {message}"
40
+ },
41
+ "resume": {
42
+ "sectionSummary": "Summary",
43
+ "sectionExperience": "Experience",
44
+ "sectionProjects": "Projects",
45
+ "sectionEducation": "Education",
46
+ "sectionSkills": "Skills",
47
+ "sectionExtras": "Extras",
48
+ "namePlaceholder": "Your Name",
49
+ "docTitle": "Resume"
50
+ },
51
+ "common": {
52
+ "switchLanguage": "Language",
53
+ "langZh": "中文",
54
+ "langEn": "English",
55
+ "itemSeparator": ", "
56
+ }
57
+ }
@@ -0,0 +1,57 @@
1
+ {
2
+ "meta": {
3
+ "label": "中文",
4
+ "htmlLang": "zh-CN"
5
+ },
6
+ "gallery": {
7
+ "title": "简历库",
8
+ "subtitle": "浏览并打开你的简历",
9
+ "searchPlaceholder": "按 ID 搜索简历…",
10
+ "loading": "加载中…",
11
+ "count": "{n} 份简历",
12
+ "countOne": "{n} 份简历",
13
+ "emptyTitle": "还没有简历",
14
+ "emptyDesc": "用 resume_preview 工具创建一份简历后就会出现在这里",
15
+ "noResultsTitle": "没有匹配的简历",
16
+ "noResultsDesc": "换个搜索词试试",
17
+ "deleteTitle": "删除",
18
+ "deleteConfirm": "确定要删除简历「{id}」吗?",
19
+ "deleteFailed": "删除失败:{message}",
20
+ "loadFailedTitle": "简历列表加载失败",
21
+ "navGallery": "简历库",
22
+ "footerText": "简历预览",
23
+ "pageTitle": "简历库 - 简历预览"
24
+ },
25
+ "preview": {
26
+ "statusLive": "实时刷新已开启",
27
+ "statusStatic": "静态视图",
28
+ "statusDisconnected": "连接已断开,正在重连…",
29
+ "statusFailed": "连接失败,刷新页面重试",
30
+ "lastUpdated": "最后更新:{time}",
31
+ "btnBack": "返回",
32
+ "btnZoomIn": "放大",
33
+ "btnZoomOut": "缩小",
34
+ "btnReset": "复位",
35
+ "btnExport": "导出简历",
36
+ "exportPdf": "下载 PDF",
37
+ "exportHtml": "下载 HTML",
38
+ "exportMissingId": "缺少简历标识,请重新渲染简历。",
39
+ "exportFailed": "导出失败:{message}"
40
+ },
41
+ "resume": {
42
+ "sectionSummary": "自我评价",
43
+ "sectionExperience": "工作经历",
44
+ "sectionProjects": "项目经历",
45
+ "sectionEducation": "教育经历",
46
+ "sectionSkills": "专业技能",
47
+ "sectionExtras": "其他",
48
+ "namePlaceholder": "你的名字",
49
+ "docTitle": "简历"
50
+ },
51
+ "common": {
52
+ "switchLanguage": "语言",
53
+ "langZh": "中文",
54
+ "langEn": "English",
55
+ "itemSeparator": "、"
56
+ }
57
+ }
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Client-side internationalization
3
+ *
4
+ * The page chrome is rendered by the server in the request language, so the
5
+ * dictionary is only needed for strings that are produced at runtime — counts,
6
+ * relative times, confirmation dialogs and status changes.
7
+ *
8
+ * The dictionary is fetched from the same origin; the Content Security
9
+ * Policy forbids inline scripts, so it cannot be embedded in the page.
10
+ */
11
+
12
+ (function () {
13
+ const DEFAULT_LOCALE = "zh-CN";
14
+ const FALLBACK_LOCALE = "en";
15
+
16
+ let dictionary = {};
17
+ let locale = DEFAULT_LOCALE;
18
+
19
+ /**
20
+ * The server puts the request language on the <html> element.
21
+ */
22
+ function detectLocale() {
23
+ const declared = (document.documentElement.getAttribute("lang") || "").trim();
24
+ if (declared === "zh-CN" || declared === FALLBACK_LOCALE) return declared;
25
+
26
+ const prefix = declared.split("-")[0].toLowerCase();
27
+ if (prefix === "zh") return "zh-CN";
28
+ if (prefix === "en") return FALLBACK_LOCALE;
29
+
30
+ return DEFAULT_LOCALE;
31
+ }
32
+
33
+ function lookup(key) {
34
+ let current = dictionary;
35
+
36
+ for (const part of key.split(".")) {
37
+ if (typeof current !== "object" || current === null) return undefined;
38
+ current = current[part];
39
+ }
40
+
41
+ return typeof current === "string" ? current : undefined;
42
+ }
43
+
44
+ function interpolate(template, vars) {
45
+ if (!vars) return template;
46
+ return template.replace(/\{(\w+)\}/g, function (match, name) {
47
+ const value = vars[name];
48
+ return value === undefined ? match : String(value);
49
+ });
50
+ }
51
+
52
+ /**
53
+ * Looks up a dotted key and substitutes {placeholders}.
54
+ */
55
+ function t(key, vars) {
56
+ const raw = lookup(key);
57
+ if (raw === undefined) return key;
58
+ return interpolate(raw, vars);
59
+ }
60
+
61
+ /**
62
+ * Formats a timestamp as relative time ("2 minutes ago").
63
+ * Intl handles the plural rules, so Chinese and English both come out right.
64
+ */
65
+ function relativeTime(date) {
66
+ const formatter = new Intl.RelativeTimeFormat(locale, { numeric: "auto" });
67
+ const diffMs = new Date(date).getTime() - Date.now();
68
+ const diffSec = Math.round(diffMs / 1000);
69
+ const diffMin = Math.round(diffSec / 60);
70
+ const diffHour = Math.round(diffMin / 60);
71
+ const diffDay = Math.round(diffHour / 24);
72
+
73
+ if (Math.abs(diffSec) < 60) return formatter.format(0, "second");
74
+ if (Math.abs(diffMin) < 60) return formatter.format(-diffMin, "minute");
75
+ if (Math.abs(diffHour) < 24) return formatter.format(-diffHour, "hour");
76
+ if (Math.abs(diffDay) < 7) return formatter.format(-diffDay, "day");
77
+
78
+ return new Intl.DateTimeFormat(locale, { dateStyle: "medium" }).format(new Date(date));
79
+ }
80
+
81
+ /**
82
+ * Points the language switch links at the current URL with only the `lang`
83
+ * parameter replaced, so the other query parameters survive the switch.
84
+ * The server already renders working links — this only refines them.
85
+ */
86
+ function setupLanguageSwitch() {
87
+ const links = document.querySelectorAll(".lang-option");
88
+ links.forEach(function (link) {
89
+ const lang = link.getAttribute("hreflang");
90
+ if (!lang) return;
91
+ const url = new URL(window.location.href);
92
+ url.searchParams.set("lang", lang);
93
+ link.setAttribute("href", url.pathname + url.search + url.hash);
94
+ });
95
+ }
96
+
97
+ /**
98
+ * Resolves once the dictionary is loaded. Callers that render runtime
99
+ * strings wait for it, so no untranslated text is ever shown.
100
+ */
101
+ const ready = (async function () {
102
+ locale = detectLocale();
103
+ try {
104
+ const response = await fetch("/i18n/" + encodeURIComponent(locale) + ".json", {
105
+ headers: { Accept: "application/json" },
106
+ });
107
+ if (!response.ok) {
108
+ throw new Error("HTTP " + response.status + ": " + response.statusText);
109
+ }
110
+ dictionary = await response.json();
111
+ } catch (error) {
112
+ console.warn("Failed to load the translation dictionary:", error);
113
+ }
114
+ setupLanguageSwitch();
115
+ })();
116
+
117
+ window.RPI18n = {
118
+ ready: ready,
119
+ t: t,
120
+ relativeTime: relativeTime,
121
+ get locale() {
122
+ return locale;
123
+ },
124
+ };
125
+ })();
@@ -0,0 +1,13 @@
1
+ <!doctype html>
2
+ <html lang="{{LANG}}">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>{{PAGE_TITLE}}</title>
7
+ {{PAGE_HEAD}}
8
+ </head>
9
+ <!-- prettier-ignore -->
10
+ <body data-resume-id="{{RESUME_ID}}" data-port="{{PORT}}" data-live-enabled="{{LIVE_ENABLED}}"{{BODY_ATTRIBUTES}}>
11
+ {{PAGE_SHELL}} {{CONTENT}} {{PAGE_SCRIPTS}}
12
+ </body>
13
+ </html>
@@ -0,0 +1,237 @@
1
+ /* ===== Resume preview & export styles =====
2
+ * This file is self-contained on purpose: the standalone HTML export inlines
3
+ * it, so it must carry every rule the document needs. The preview page also
4
+ * loads shared.css for the toolbar shell.
5
+ */
6
+
7
+ * {
8
+ box-sizing: border-box;
9
+ }
10
+
11
+ :root {
12
+ --resume-font:
13
+ "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Source Han Sans SC",
14
+ "WenQuanYi Micro Hei", "SimSun", "Heiti SC", sans-serif;
15
+ --resume-text: #1a1a1a;
16
+ --resume-muted: #5a5a5a;
17
+ --resume-accent: #2f6fb0;
18
+ --resume-rule: #d5d5d5;
19
+ }
20
+
21
+ @page {
22
+ size: A4;
23
+ margin: 15mm;
24
+ }
25
+
26
+ body {
27
+ margin: 0;
28
+ padding: 0;
29
+ background: #efefef;
30
+ color: var(--resume-text);
31
+ font-family: var(--resume-font);
32
+ }
33
+
34
+ /* The standalone HTML export: the A4 sheet sits centered on a neutral desk,
35
+ so the page boundary is visible instead of blending into the white page. */
36
+ body.resume-export {
37
+ background: #e6e6e6;
38
+ padding: 24px 16px;
39
+ }
40
+
41
+ /* ===== Preview viewport ===== */
42
+
43
+ .resume-viewport {
44
+ flex: 1;
45
+ overflow: hidden;
46
+ display: flex;
47
+ align-items: center;
48
+ justify-content: center;
49
+ cursor: grab;
50
+ }
51
+
52
+ .resume-sheet {
53
+ padding: 40px;
54
+ min-width: 100%;
55
+ transform-origin: 0 0;
56
+ }
57
+
58
+ /* ===== The page itself ===== */
59
+
60
+ .resume-page {
61
+ box-sizing: content-box;
62
+ width: 180mm;
63
+ margin: 0 auto;
64
+ padding: 15mm;
65
+ background: #ffffff;
66
+ color: var(--resume-text);
67
+ box-shadow: 0 2px 14px rgba(0, 0, 0, 0.18);
68
+ font-size: 10.5pt;
69
+ line-height: 1.6;
70
+ }
71
+
72
+ body.resume-export .resume-page {
73
+ box-sizing: border-box;
74
+ width: 210mm;
75
+ max-width: 100%;
76
+ margin: 0 auto;
77
+ padding: 15mm;
78
+ box-shadow: 0 2px 14px rgba(0, 0, 0, 0.18);
79
+ }
80
+
81
+ .resume-header {
82
+ margin-bottom: 8mm;
83
+ padding-bottom: 4mm;
84
+ border-bottom: 2px solid var(--resume-rule);
85
+ }
86
+
87
+ .resume-name {
88
+ margin: 0;
89
+ font-size: 22pt;
90
+ font-weight: 700;
91
+ letter-spacing: 0.5px;
92
+ }
93
+
94
+ .resume-title {
95
+ margin: 2mm 0 0;
96
+ font-size: 12pt;
97
+ color: var(--resume-accent);
98
+ }
99
+
100
+ .resume-contact {
101
+ margin-top: 3mm;
102
+ display: flex;
103
+ flex-wrap: wrap;
104
+ gap: 2mm 6mm;
105
+ font-size: 9.5pt;
106
+ color: var(--resume-muted);
107
+ }
108
+
109
+ .resume-section {
110
+ margin-top: 7mm;
111
+ }
112
+
113
+ .resume-section-title {
114
+ margin: 0 0 3mm;
115
+ padding-bottom: 1.5mm;
116
+ border-bottom: 1px solid var(--resume-rule);
117
+ font-size: 12pt;
118
+ font-weight: 700;
119
+ color: var(--resume-text);
120
+ }
121
+
122
+ .resume-text {
123
+ margin: 0;
124
+ font-size: 10pt;
125
+ }
126
+
127
+ .resume-entry {
128
+ margin-bottom: 4mm;
129
+ }
130
+
131
+ .resume-entry:last-child {
132
+ margin-bottom: 0;
133
+ }
134
+
135
+ .resume-entry-heading {
136
+ display: flex;
137
+ align-items: baseline;
138
+ flex-wrap: wrap;
139
+ gap: 2mm;
140
+ margin-bottom: 1.5mm;
141
+ }
142
+
143
+ .resume-entry-title {
144
+ font-size: 10.5pt;
145
+ font-weight: 600;
146
+ }
147
+
148
+ .resume-entry-org {
149
+ font-size: 10pt;
150
+ color: var(--resume-text);
151
+ }
152
+
153
+ .resume-entry-period {
154
+ font-size: 9pt;
155
+ color: var(--resume-muted);
156
+ margin-left: auto;
157
+ }
158
+
159
+ .resume-list {
160
+ margin: 1mm 0 0;
161
+ padding-left: 5mm;
162
+ font-size: 10pt;
163
+ }
164
+
165
+ .resume-list li {
166
+ margin-bottom: 1mm;
167
+ }
168
+
169
+ .resume-skill-group {
170
+ display: flex;
171
+ gap: 3mm;
172
+ margin-bottom: 2mm;
173
+ font-size: 10pt;
174
+ }
175
+
176
+ .resume-skill-category {
177
+ flex: 0 0 auto;
178
+ min-width: 18mm;
179
+ font-weight: 600;
180
+ }
181
+
182
+ .resume-skill-items {
183
+ color: var(--resume-text);
184
+ }
185
+
186
+ /* ===== Printing ===== */
187
+
188
+ @media print {
189
+ /* The toolbar and the viewport chrome are screen-only */
190
+ .status-bar {
191
+ display: none;
192
+ }
193
+
194
+ .resume-viewport {
195
+ display: block;
196
+ overflow: visible;
197
+ }
198
+
199
+ .resume-sheet {
200
+ padding: 0;
201
+ min-width: 0;
202
+ transform: none !important;
203
+ }
204
+
205
+ .resume-page {
206
+ box-shadow: none;
207
+ }
208
+
209
+ /* The standalone export carries its own screen chrome; printing it must
210
+ fall back to the plain page the PDF export produces — the @page rule
211
+ already supplies the margins. */
212
+ body.resume-export {
213
+ background: #ffffff;
214
+ padding: 0;
215
+ }
216
+
217
+ body.resume-export .resume-page {
218
+ box-sizing: content-box;
219
+ width: 180mm;
220
+ max-width: none;
221
+ margin: 0;
222
+ padding: 0;
223
+ box-shadow: none;
224
+ }
225
+
226
+ body {
227
+ background: #ffffff;
228
+ }
229
+ }
230
+
231
+ /* ===== Small screens ===== */
232
+
233
+ @media (max-width: 640px) {
234
+ .resume-sheet {
235
+ padding: 16px;
236
+ }
237
+ }