@leadertechie/personal-site-kit 0.1.0-alpha.7 → 0.1.0-alpha.9
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.
- package/dist/api/content-utils.d.ts +27 -0
- package/dist/api/content-utils.d.ts.map +1 -0
- package/dist/api/handlers/about-me.d.ts.map +1 -1
- package/dist/api/handlers/content-api.d.ts +0 -1
- package/dist/api/handlers/content-api.d.ts.map +1 -1
- package/dist/api/website-api.d.ts.map +1 -1
- package/dist/api.js +2 -2
- package/dist/chunks/index-CGvOrVf8.js +213 -0
- package/dist/chunks/{index-Bq8WDk9L.js → index-CnSEOZse.js} +1285 -477
- package/dist/chunks/{template-Boh_MKY5.js → template-DWcsZW22.js} +8 -7
- package/dist/chunks/{website-api-XoeLwo_N.js → website-api-BEYGOsT3.js} +137 -156
- package/dist/index.js +19 -9
- package/dist/prerender/data-fetcher.d.ts +19 -0
- package/dist/prerender/data-fetcher.d.ts.map +1 -0
- package/dist/prerender/page-content.d.ts.map +1 -1
- package/dist/prerender/page-generators/about.d.ts +16 -0
- package/dist/prerender/page-generators/about.d.ts.map +1 -0
- package/dist/prerender/page-generators/base.d.ts +26 -0
- package/dist/prerender/page-generators/base.d.ts.map +1 -0
- package/dist/prerender/page-generators/blog-detail.d.ts +15 -0
- package/dist/prerender/page-generators/blog-detail.d.ts.map +1 -0
- package/dist/prerender/page-generators/blogs-list.d.ts +17 -0
- package/dist/prerender/page-generators/blogs-list.d.ts.map +1 -0
- package/dist/prerender/page-generators/home.d.ts +19 -0
- package/dist/prerender/page-generators/home.d.ts.map +1 -0
- package/dist/prerender/page-generators/index.d.ts +9 -0
- package/dist/prerender/page-generators/index.d.ts.map +1 -0
- package/dist/prerender/page-generators/not-found.d.ts +14 -0
- package/dist/prerender/page-generators/not-found.d.ts.map +1 -0
- package/dist/prerender/page-generators/stories-list.d.ts +17 -0
- package/dist/prerender/page-generators/stories-list.d.ts.map +1 -0
- package/dist/prerender/page-generators/story-detail.d.ts +15 -0
- package/dist/prerender/page-generators/story-detail.d.ts.map +1 -0
- package/dist/prerender.js +109 -102
- package/dist/shared.js +1 -1
- package/dist/ui/about-me/index.d.ts +2 -10
- package/dist/ui/about-me/index.d.ts.map +1 -1
- package/dist/ui/admin/api.d.ts +16 -0
- package/dist/ui/admin/api.d.ts.map +1 -0
- package/dist/ui/admin/components/AboutMeSection.d.ts +7 -0
- package/dist/ui/admin/components/AboutMeSection.d.ts.map +1 -0
- package/dist/ui/admin/components/AdminSection.d.ts +13 -0
- package/dist/ui/admin/components/AdminSection.d.ts.map +1 -0
- package/dist/ui/admin/components/BlogsSection.d.ts +7 -0
- package/dist/ui/admin/components/BlogsSection.d.ts.map +1 -0
- package/dist/ui/admin/components/HomeSection.d.ts +7 -0
- package/dist/ui/admin/components/HomeSection.d.ts.map +1 -0
- package/dist/ui/admin/components/ImagesSection.d.ts +7 -0
- package/dist/ui/admin/components/ImagesSection.d.ts.map +1 -0
- package/dist/ui/admin/components/LoginForm.d.ts +9 -0
- package/dist/ui/admin/components/LoginForm.d.ts.map +1 -0
- package/dist/ui/admin/components/LogoSection.d.ts +7 -0
- package/dist/ui/admin/components/LogoSection.d.ts.map +1 -0
- package/dist/ui/admin/components/ProfileSection.d.ts +7 -0
- package/dist/ui/admin/components/ProfileSection.d.ts.map +1 -0
- package/dist/ui/admin/components/StaticSection.d.ts +13 -0
- package/dist/ui/admin/components/StaticSection.d.ts.map +1 -0
- package/dist/ui/admin/components/StoriesSection.d.ts +7 -0
- package/dist/ui/admin/components/StoriesSection.d.ts.map +1 -0
- package/dist/ui/admin/components/index.d.ts +11 -0
- package/dist/ui/admin/components/index.d.ts.map +1 -0
- package/dist/ui/admin/index.d.ts +18 -26
- package/dist/ui/admin/index.d.ts.map +1 -1
- package/dist/ui/admin/types.d.ts +24 -0
- package/dist/ui/admin/types.d.ts.map +1 -0
- package/dist/ui/blog-viewer/index.d.ts.map +1 -1
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/story-viewer/index.d.ts.map +1 -1
- package/dist/ui.js +14 -4
- package/package.json +4 -4
- package/dist/ui/about-me/renderer.d.ts +0 -6
- package/dist/ui/about-me/renderer.d.ts.map +0 -1
- package/src/api/__tests__/info.test.ts +0 -44
- package/src/api/__tests__/utils.test.ts +0 -78
- package/src/api/handlers/about-me.ts +0 -99
- package/src/api/handlers/auth-handler.ts +0 -194
- package/src/api/handlers/auth.ts +0 -157
- package/src/api/handlers/content-api.ts +0 -268
- package/src/api/handlers/content.ts +0 -139
- package/src/api/handlers/home.ts +0 -79
- package/src/api/handlers/info.ts +0 -12
- package/src/api/handlers/logo.ts +0 -55
- package/src/api/handlers/static-details.ts +0 -48
- package/src/api/index.ts +0 -9
- package/src/api/utils.ts +0 -16
- package/src/api/website-api.ts +0 -138
- package/src/index.ts +0 -4
- package/src/prerender/__tests__/page-content.test.ts +0 -54
- package/src/prerender/__tests__/template.test.ts +0 -54
- package/src/prerender/index.ts +0 -7
- package/src/prerender/page-content.ts +0 -263
- package/src/prerender/prerender.ts +0 -25
- package/src/prerender/template.ts +0 -65
- package/src/prerender/website-prerender.ts +0 -152
- package/src/shared/config/api.ts +0 -16
- package/src/shared/config/index.ts +0 -43
- package/src/shared/config/types.ts +0 -16
- package/src/shared/core/__tests__/theme-toggle.test.ts +0 -204
- package/src/shared/core/site-store.ts +0 -38
- package/src/shared/core/theme-toggle.ts +0 -118
- package/src/shared/index.ts +0 -17
- package/src/shared/interfaces/ifooter-link.ts +0 -4
- package/src/shared/interfaces/iroute.ts +0 -4
- package/src/shared/models/theme-variables.css +0 -25
- package/src/shared/page-content.ts +0 -210
- package/src/shared/router.ts +0 -250
- package/src/shared/runtime.ts +0 -11
- package/src/shared/template.ts +0 -35
- package/src/shared/website-ui.ts +0 -92
- package/src/styles/markdown.css +0 -129
- package/src/ui/about-me/api.ts +0 -12
- package/src/ui/about-me/index.ts +0 -164
- package/src/ui/about-me/renderer.ts +0 -23
- package/src/ui/about-me/styles.ts +0 -85
- package/src/ui/admin/index.ts +0 -655
- package/src/ui/admin/styles.ts +0 -270
- package/src/ui/banner/index.ts +0 -38
- package/src/ui/banner/styles.ts +0 -95
- package/src/ui/blog-viewer/__tests__/blogviewer.test.ts +0 -7
- package/src/ui/blog-viewer/index.ts +0 -124
- package/src/ui/blog-viewer/styles.ts +0 -23
- package/src/ui/footer/index.ts +0 -37
- package/src/ui/footer/styles.ts +0 -50
- package/src/ui/index.ts +0 -6
- package/src/ui/story-viewer/__tests__/storyviewer.test.ts +0 -7
- package/src/ui/story-viewer/index.ts +0 -120
- package/src/ui/story-viewer/styles.ts +0 -54
- /package/{src/shared → dist}/styles/markdown.css +0 -0
- /package/{src → dist}/styles/theme.css +0 -0
package/src/ui/admin/index.ts
DELETED
|
@@ -1,655 +0,0 @@
|
|
|
1
|
-
import { LitElement, html, css } from 'lit';
|
|
2
|
-
import { customElement, state } from 'lit/decorators.js';
|
|
3
|
-
|
|
4
|
-
import { adminStyles } from './styles';
|
|
5
|
-
|
|
6
|
-
interface ContentItem {
|
|
7
|
-
key: string;
|
|
8
|
-
size: number;
|
|
9
|
-
uploaded?: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface StaticDetails {
|
|
13
|
-
siteTitle?: string;
|
|
14
|
-
copyright?: string;
|
|
15
|
-
linkedin?: string;
|
|
16
|
-
github?: string;
|
|
17
|
-
email?: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface AuthStatus {
|
|
21
|
-
configured: boolean;
|
|
22
|
-
username: string | null;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
@customElement('admin-portal')
|
|
26
|
-
export class AdminPortal extends LitElement {
|
|
27
|
-
static styles = adminStyles;
|
|
28
|
-
|
|
29
|
-
@state()
|
|
30
|
-
accessor isAuthenticated = false;
|
|
31
|
-
|
|
32
|
-
@state()
|
|
33
|
-
accessor isSetup = false;
|
|
34
|
-
|
|
35
|
-
@state()
|
|
36
|
-
accessor isLoading = true;
|
|
37
|
-
|
|
38
|
-
@state()
|
|
39
|
-
accessor contentList: ContentItem[] = [];
|
|
40
|
-
|
|
41
|
-
@state()
|
|
42
|
-
accessor statusMessage = '';
|
|
43
|
-
|
|
44
|
-
@state()
|
|
45
|
-
accessor activeSection = 'profile';
|
|
46
|
-
|
|
47
|
-
@state()
|
|
48
|
-
accessor staticDetails: StaticDetails = {};
|
|
49
|
-
|
|
50
|
-
@state()
|
|
51
|
-
accessor loginError = '';
|
|
52
|
-
|
|
53
|
-
get apiUrl() {
|
|
54
|
-
return (window as any).__VITE_API_URL__ || import.meta.env.VITE_API_URL || 'http://localhost:8787';
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
async connectedCallback() {
|
|
58
|
-
super.connectedCallback();
|
|
59
|
-
await this.checkAuthStatus();
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
async checkAuthStatus() {
|
|
63
|
-
try {
|
|
64
|
-
const res = await fetch(`${this.apiUrl}/auth/status`, {
|
|
65
|
-
credentials: 'include'
|
|
66
|
-
});
|
|
67
|
-
if (res.ok) {
|
|
68
|
-
const status: AuthStatus = await res.json();
|
|
69
|
-
this.isSetup = status.configured;
|
|
70
|
-
|
|
71
|
-
if (status.configured) {
|
|
72
|
-
await this.tryAutoLogin();
|
|
73
|
-
} else {
|
|
74
|
-
this.isLoading = false;
|
|
75
|
-
}
|
|
76
|
-
} else {
|
|
77
|
-
this.isSetup = false;
|
|
78
|
-
this.isLoading = false;
|
|
79
|
-
}
|
|
80
|
-
} catch (e) {
|
|
81
|
-
this.isSetup = false;
|
|
82
|
-
this.isLoading = false;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
async tryAutoLogin() {
|
|
87
|
-
try {
|
|
88
|
-
const res = await fetch(`${this.apiUrl}/content`, {
|
|
89
|
-
credentials: 'include'
|
|
90
|
-
});
|
|
91
|
-
if (res.ok) {
|
|
92
|
-
this.contentList = await res.json();
|
|
93
|
-
this.isAuthenticated = true;
|
|
94
|
-
}
|
|
95
|
-
} catch (e) {}
|
|
96
|
-
this.isLoading = false;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
async handleLogin(e: Event) {
|
|
100
|
-
e.preventDefault();
|
|
101
|
-
this.loginError = '';
|
|
102
|
-
|
|
103
|
-
const usernameInput = this.shadowRoot?.querySelector('#username') as HTMLInputElement;
|
|
104
|
-
const passwordInput = this.shadowRoot?.querySelector('#password') as HTMLInputElement;
|
|
105
|
-
|
|
106
|
-
if (!usernameInput?.value || !passwordInput?.value) {
|
|
107
|
-
this.loginError = 'Username and password required';
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
try {
|
|
112
|
-
const res = await fetch(`${this.apiUrl}/auth/login`, {
|
|
113
|
-
method: 'POST',
|
|
114
|
-
credentials: 'include',
|
|
115
|
-
headers: { 'Content-Type': 'application/json' },
|
|
116
|
-
body: JSON.stringify({
|
|
117
|
-
username: usernameInput.value,
|
|
118
|
-
password: passwordInput.value
|
|
119
|
-
})
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
if (res.ok) {
|
|
123
|
-
this.isAuthenticated = true;
|
|
124
|
-
await this.fetchContent();
|
|
125
|
-
} else {
|
|
126
|
-
const data = await res.json();
|
|
127
|
-
this.loginError = data.error || 'Login failed';
|
|
128
|
-
}
|
|
129
|
-
} catch (e) {
|
|
130
|
-
this.loginError = 'Connection error';
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
async handleSetup(e: Event) {
|
|
135
|
-
e.preventDefault();
|
|
136
|
-
this.loginError = '';
|
|
137
|
-
|
|
138
|
-
const usernameInput = this.shadowRoot?.querySelector('#username') as HTMLInputElement;
|
|
139
|
-
const passwordInput = this.shadowRoot?.querySelector('#password') as HTMLInputElement;
|
|
140
|
-
const confirmInput = this.shadowRoot?.querySelector('#confirmPassword') as HTMLInputElement;
|
|
141
|
-
|
|
142
|
-
if (!usernameInput?.value || !passwordInput?.value) {
|
|
143
|
-
this.loginError = 'Username and password required';
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
if (usernameInput.value.length < 3) {
|
|
148
|
-
this.loginError = 'Username must be at least 3 characters';
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
if (passwordInput.value.length < 8) {
|
|
153
|
-
this.loginError = 'Password must be at least 8 characters';
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
if (passwordInput.value !== confirmInput?.value) {
|
|
158
|
-
this.loginError = 'Passwords do not match';
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
try {
|
|
163
|
-
const res = await fetch(`${this.apiUrl}/auth/setup`, {
|
|
164
|
-
method: 'POST',
|
|
165
|
-
credentials: 'include',
|
|
166
|
-
headers: { 'Content-Type': 'application/json' },
|
|
167
|
-
body: JSON.stringify({
|
|
168
|
-
username: usernameInput.value,
|
|
169
|
-
password: passwordInput.value
|
|
170
|
-
})
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
if (res.ok) {
|
|
174
|
-
this.isAuthenticated = true;
|
|
175
|
-
this.isSetup = true;
|
|
176
|
-
await this.fetchContent();
|
|
177
|
-
} else {
|
|
178
|
-
const data = await res.json();
|
|
179
|
-
this.loginError = data.error || 'Setup failed';
|
|
180
|
-
}
|
|
181
|
-
} catch (e) {
|
|
182
|
-
this.loginError = 'Connection error';
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
async handleLogout() {
|
|
187
|
-
try {
|
|
188
|
-
await fetch(`${this.apiUrl}/auth/logout`, {
|
|
189
|
-
method: 'POST',
|
|
190
|
-
credentials: 'include'
|
|
191
|
-
});
|
|
192
|
-
} catch (e) {}
|
|
193
|
-
this.isAuthenticated = false;
|
|
194
|
-
this.contentList = [];
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
async fetchContent() {
|
|
198
|
-
try {
|
|
199
|
-
const res = await fetch(`${this.apiUrl}/content`, {
|
|
200
|
-
credentials: 'include'
|
|
201
|
-
});
|
|
202
|
-
if (res.ok) {
|
|
203
|
-
this.contentList = await res.json();
|
|
204
|
-
} else {
|
|
205
|
-
this.statusMessage = 'Failed to fetch content.';
|
|
206
|
-
}
|
|
207
|
-
} catch (e) {
|
|
208
|
-
this.statusMessage = 'Error fetching content.';
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
async fetchStaticDetails() {
|
|
213
|
-
try {
|
|
214
|
-
const res = await fetch(`${this.apiUrl}/static`, {
|
|
215
|
-
credentials: 'include'
|
|
216
|
-
});
|
|
217
|
-
if (res.ok) {
|
|
218
|
-
this.staticDetails = await res.json();
|
|
219
|
-
}
|
|
220
|
-
} catch (e) {}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
async handleUpload(key: string, file: File) {
|
|
224
|
-
try {
|
|
225
|
-
this.statusMessage = 'Uploading...';
|
|
226
|
-
const res = await fetch(`${this.apiUrl}/content/${key}`, {
|
|
227
|
-
method: 'PUT',
|
|
228
|
-
credentials: 'include',
|
|
229
|
-
body: file
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
if (res.ok) {
|
|
233
|
-
this.statusMessage = 'Upload successful!';
|
|
234
|
-
this.fetchContent();
|
|
235
|
-
} else {
|
|
236
|
-
this.statusMessage = 'Upload failed.';
|
|
237
|
-
}
|
|
238
|
-
} catch (e) {
|
|
239
|
-
this.statusMessage = 'Error uploading.';
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
async handleClearCache() {
|
|
244
|
-
try {
|
|
245
|
-
this.statusMessage = 'Clearing cache...';
|
|
246
|
-
const res = await fetch(`${this.apiUrl}/cache-clear`, {
|
|
247
|
-
method: 'POST',
|
|
248
|
-
credentials: 'include'
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
if (res.ok) {
|
|
252
|
-
this.statusMessage = 'Cache cleared!';
|
|
253
|
-
} else {
|
|
254
|
-
this.statusMessage = 'Failed to clear cache.';
|
|
255
|
-
}
|
|
256
|
-
} catch (e) {
|
|
257
|
-
this.statusMessage = 'Error clearing cache.';
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
async handleDelete(key: string) {
|
|
262
|
-
if (!confirm(`Delete ${key}?`)) return;
|
|
263
|
-
|
|
264
|
-
try {
|
|
265
|
-
const res = await fetch(`${this.apiUrl}/content/${key}`, {
|
|
266
|
-
method: 'DELETE',
|
|
267
|
-
credentials: 'include'
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
if (res.ok) {
|
|
271
|
-
this.fetchContent();
|
|
272
|
-
} else {
|
|
273
|
-
this.statusMessage = 'Delete failed.';
|
|
274
|
-
}
|
|
275
|
-
} catch (e) {
|
|
276
|
-
this.statusMessage = 'Error deleting.';
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
getContent(key: string): ContentItem | undefined {
|
|
281
|
-
return this.contentList.find(c => c.key === key);
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
getSectionFiles(prefix: string): ContentItem[] {
|
|
285
|
-
return this.contentList.filter(c => c.key.startsWith(prefix));
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
renderLoginForm() {
|
|
289
|
-
return html`
|
|
290
|
-
<div class="container">
|
|
291
|
-
<div class="login-box">
|
|
292
|
-
<h2>Admin Setup</h2>
|
|
293
|
-
<p>Create your admin credentials</p>
|
|
294
|
-
<form @submit=${this.handleSetup}>
|
|
295
|
-
<input type="text" id="username" placeholder="Username (3+ chars)" />
|
|
296
|
-
<input type="password" id="password" placeholder="Password (8+ chars)" />
|
|
297
|
-
<input type="password" id="confirmPassword" placeholder="Confirm Password" />
|
|
298
|
-
${this.loginError ? html`<div class="error-message">${this.loginError}</div>` : ''}
|
|
299
|
-
<button type="submit" class="btn-primary">Create Account</button>
|
|
300
|
-
</form>
|
|
301
|
-
</div>
|
|
302
|
-
</div>
|
|
303
|
-
`;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
renderLogin() {
|
|
307
|
-
return html`
|
|
308
|
-
<div class="container">
|
|
309
|
-
<div class="login-box">
|
|
310
|
-
<h2>Admin Login</h2>
|
|
311
|
-
<p>Enter your credentials</p>
|
|
312
|
-
<form @submit=${this.handleLogin}>
|
|
313
|
-
<input type="text" id="username" placeholder="Username" autocomplete="username" />
|
|
314
|
-
<input type="password" id="password" placeholder="Password" autocomplete="current-password" />
|
|
315
|
-
${this.loginError ? html`<div class="error-message">${this.loginError}</div>` : ''}
|
|
316
|
-
<button type="submit" class="btn-primary">Login</button>
|
|
317
|
-
</form>
|
|
318
|
-
</div>
|
|
319
|
-
</div>
|
|
320
|
-
`;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
renderHomeSection() {
|
|
324
|
-
const home = this.getContent('home.md');
|
|
325
|
-
return html`
|
|
326
|
-
<div class="section">
|
|
327
|
-
<h3>Home Page</h3>
|
|
328
|
-
<p class="help-text">Content for your home page. Upload home.md with your main content.</p>
|
|
329
|
-
|
|
330
|
-
${home ? html`
|
|
331
|
-
<div class="current-file">
|
|
332
|
-
<strong>Current:</strong> home.md (${home.size} bytes)
|
|
333
|
-
<button class="btn-danger" @click=${() => this.handleDelete('home.md')}>Delete</button>
|
|
334
|
-
</div>
|
|
335
|
-
` : ''}
|
|
336
|
-
|
|
337
|
-
<input type="file" id="homeFile" accept=".md" />
|
|
338
|
-
<button class="btn-primary" @click=${() => {
|
|
339
|
-
const input = this.shadowRoot?.querySelector('#homeFile') as HTMLInputElement;
|
|
340
|
-
if (input.files?.[0]) this.handleUpload('home.md', input.files[0]);
|
|
341
|
-
}}>Upload home.md</button>
|
|
342
|
-
</div>
|
|
343
|
-
`;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
renderProfileSection() {
|
|
347
|
-
const profile = this.getContent('profile.json');
|
|
348
|
-
return html`
|
|
349
|
-
<div class="section">
|
|
350
|
-
<h3>Profile <span class="required-badge">Required</span></h3>
|
|
351
|
-
<p class="help-text">This file contains your profile information (name, title, experience).</p>
|
|
352
|
-
|
|
353
|
-
${profile ? html`
|
|
354
|
-
<div class="current-file">
|
|
355
|
-
<strong>Current:</strong> profile.json (${profile.size} bytes)
|
|
356
|
-
<button class="btn-danger" @click=${() => this.handleDelete('profile.json')}>Delete</button>
|
|
357
|
-
</div>
|
|
358
|
-
` : ''}
|
|
359
|
-
|
|
360
|
-
<input type="file" id="profileFile" accept=".json" />
|
|
361
|
-
<button class="btn-primary" @click=${() => {
|
|
362
|
-
const input = this.shadowRoot?.querySelector('#profileFile') as HTMLInputElement;
|
|
363
|
-
if (input.files?.[0]) this.handleUpload('profile.json', input.files[0]);
|
|
364
|
-
}}>Upload profile.json</button>
|
|
365
|
-
</div>
|
|
366
|
-
`;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
renderAboutMeSection() {
|
|
370
|
-
const aboutMe = this.getContent('about-me.md');
|
|
371
|
-
return html`
|
|
372
|
-
<div class="section">
|
|
373
|
-
<h3>About Me Page <span class="required-badge">Required</span></h3>
|
|
374
|
-
<p class="help-text">Content for your About Me page. Supports Markdown with frontmatter.</p>
|
|
375
|
-
|
|
376
|
-
${aboutMe ? html`
|
|
377
|
-
<div class="current-file">
|
|
378
|
-
<strong>Current:</strong> about-me.md (${aboutMe.size} bytes)
|
|
379
|
-
<button class="btn-danger" @click=${() => this.handleDelete('about-me.md')}>Delete</button>
|
|
380
|
-
</div>
|
|
381
|
-
` : ''}
|
|
382
|
-
|
|
383
|
-
<input type="file" id="aboutFile" accept=".md" />
|
|
384
|
-
<button class="btn-primary" @click=${() => {
|
|
385
|
-
const input = this.shadowRoot?.querySelector('#aboutFile') as HTMLInputElement;
|
|
386
|
-
if (input.files?.[0]) this.handleUpload('about-me.md', input.files[0]);
|
|
387
|
-
}}>Upload about-me.md</button>
|
|
388
|
-
</div>
|
|
389
|
-
`;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
renderBlogsSection() {
|
|
393
|
-
const blogs = this.getSectionFiles('blogs/').filter(b => b.key.endsWith('.json'));
|
|
394
|
-
return html`
|
|
395
|
-
<div class="section">
|
|
396
|
-
<h3>Blog Posts</h3>
|
|
397
|
-
<p class="help-text">Each blog needs 2 files: a JSON (metadata) and MD (content) file.</p>
|
|
398
|
-
|
|
399
|
-
<h4>Upload New Blog</h4>
|
|
400
|
-
<input type="file" id="blogMetaFile" accept=".json" />
|
|
401
|
-
<input type="file" id="blogContentFile" accept=".md" />
|
|
402
|
-
<input type="text" id="blogSlug" placeholder="Slug (e.g., my-new-post)" class="mt-1" />
|
|
403
|
-
<button class="btn-primary" @click=${() => {
|
|
404
|
-
const metaInput = this.shadowRoot?.querySelector('#blogMetaFile') as HTMLInputElement;
|
|
405
|
-
const contentInput = this.shadowRoot?.querySelector('#blogContentFile') as HTMLInputElement;
|
|
406
|
-
const slugInput = this.shadowRoot?.querySelector('#blogSlug') as HTMLInputElement;
|
|
407
|
-
if (metaInput.files?.[0] && contentInput.files?.[0] && slugInput.value) {
|
|
408
|
-
this.handleUpload(`blogs/${slugInput.value}.json`, metaInput.files[0]);
|
|
409
|
-
this.handleUpload(`blogs/${slugInput.value}.md`, contentInput.files[0]);
|
|
410
|
-
}
|
|
411
|
-
}}>Upload Blog (JSON + MD)</button>
|
|
412
|
-
|
|
413
|
-
<div class="file-list">
|
|
414
|
-
<h4>Current Blogs (${blogs.length})</h4>
|
|
415
|
-
${blogs.map(b => html`
|
|
416
|
-
<div class="file-item">
|
|
417
|
-
<span>${b.key.replace('.json', '')}</span>
|
|
418
|
-
<button class="btn-danger" @click=${() => {
|
|
419
|
-
const slug = b.key.replace('blogs/', '').replace('.json', '');
|
|
420
|
-
this.handleDelete(`blogs/${slug}.json`);
|
|
421
|
-
this.handleDelete(`blogs/${slug}.md`);
|
|
422
|
-
}}>Delete</button>
|
|
423
|
-
</div>
|
|
424
|
-
`)}
|
|
425
|
-
${blogs.length === 0 ? html`<p>No blogs yet.</p>` : ''}
|
|
426
|
-
</div>
|
|
427
|
-
</div>
|
|
428
|
-
`;
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
renderStoriesSection() {
|
|
432
|
-
const stories = this.getSectionFiles('stories/').filter(s => s.key.endsWith('.json'));
|
|
433
|
-
return html`
|
|
434
|
-
<div class="section">
|
|
435
|
-
<h3>Stories</h3>
|
|
436
|
-
<p class="help-text">Each story needs 2 files: a JSON (metadata) and MD (content) file.</p>
|
|
437
|
-
|
|
438
|
-
<h4>Upload New Story</h4>
|
|
439
|
-
<input type="file" id="storyMetaFile" accept=".json" />
|
|
440
|
-
<input type="file" id="storyContentFile" accept=".md" />
|
|
441
|
-
<input type="text" id="storySlug" placeholder="Slug (e.g., my-story)" class="mt-1" />
|
|
442
|
-
<button class="btn-primary" @click=${() => {
|
|
443
|
-
const metaInput = this.shadowRoot?.querySelector('#storyMetaFile') as HTMLInputElement;
|
|
444
|
-
const contentInput = this.shadowRoot?.querySelector('#storyContentFile') as HTMLInputElement;
|
|
445
|
-
const slugInput = this.shadowRoot?.querySelector('#storySlug') as HTMLInputElement;
|
|
446
|
-
if (metaInput.files?.[0] && contentInput.files?.[0] && slugInput.value) {
|
|
447
|
-
this.handleUpload(`stories/${slugInput.value}.json`, metaInput.files[0]);
|
|
448
|
-
this.handleUpload(`stories/${slugInput.value}.md`, contentInput.files[0]);
|
|
449
|
-
}
|
|
450
|
-
}}>Upload Story (JSON + MD)</button>
|
|
451
|
-
|
|
452
|
-
<div class="file-list">
|
|
453
|
-
<h4>Current Stories (${stories.length})</h4>
|
|
454
|
-
${stories.map(s => html`
|
|
455
|
-
<div class="file-item">
|
|
456
|
-
<span>${s.key.replace('.json', '')}</span>
|
|
457
|
-
<button class="btn-danger" @click=${() => {
|
|
458
|
-
const slug = s.key.replace('stories/', '').replace('.json', '');
|
|
459
|
-
this.handleDelete(`stories/${slug}.json`);
|
|
460
|
-
this.handleDelete(`stories/${slug}.md`);
|
|
461
|
-
}}>Delete</button>
|
|
462
|
-
</div>
|
|
463
|
-
`)}
|
|
464
|
-
${stories.length === 0 ? html`<p>No stories yet.</p>` : ''}
|
|
465
|
-
</div>
|
|
466
|
-
</div>
|
|
467
|
-
`;
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
renderImagesSection() {
|
|
471
|
-
const images = this.getSectionFiles('images/');
|
|
472
|
-
return html`
|
|
473
|
-
<div class="section">
|
|
474
|
-
<h3>Images</h3>
|
|
475
|
-
<p class="help-text">Upload images for use in your content. In markdown, reference images by filename only (e.g., use <code>my-photo.jpg</code> not <code>/images/my-photo.jpg</code>). The renderer automatically prepends <code>images/</code>.</p>
|
|
476
|
-
|
|
477
|
-
<input type="file" id="imageFile" accept="image/*" />
|
|
478
|
-
<input type="text" id="imagePath" placeholder="Image name (e.g., profile-photo.jpg)" class="mt-1" />
|
|
479
|
-
<button class="btn-primary" @click=${() => {
|
|
480
|
-
const fileInput = this.shadowRoot?.querySelector('#imageFile') as HTMLInputElement;
|
|
481
|
-
const pathInput = this.shadowRoot?.querySelector('#imagePath') as HTMLInputElement;
|
|
482
|
-
if (fileInput.files?.[0] && pathInput.value) {
|
|
483
|
-
this.handleUpload(`images/${pathInput.value}`, fileInput.files[0]);
|
|
484
|
-
}
|
|
485
|
-
}}>Upload to images/</button>
|
|
486
|
-
|
|
487
|
-
<div class="file-list">
|
|
488
|
-
<h4>Current Images (${images.length})</h4>
|
|
489
|
-
${images.map(img => html`
|
|
490
|
-
<div class="file-item">
|
|
491
|
-
<span>${img.key} (${img.size} bytes)</span>
|
|
492
|
-
<button class="btn-danger" @click=${() => this.handleDelete(img.key)}>Delete</button>
|
|
493
|
-
</div>
|
|
494
|
-
`)}
|
|
495
|
-
${images.length === 0 ? html`<p>No images yet.</p>` : ''}
|
|
496
|
-
</div>
|
|
497
|
-
</div>
|
|
498
|
-
`;
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
renderLogoSection() {
|
|
502
|
-
const logo = this.getContent('logo.svg');
|
|
503
|
-
return html`
|
|
504
|
-
<div class="section">
|
|
505
|
-
<h3>Site Logo</h3>
|
|
506
|
-
<p class="help-text">Upload your site logo (SVG format recommended). This appears in the header of your site.</p>
|
|
507
|
-
|
|
508
|
-
${logo ? html`
|
|
509
|
-
<div class="current-file">
|
|
510
|
-
<strong>Current:</strong> logo.svg (${logo.size} bytes)
|
|
511
|
-
<button class="btn-danger" @click=${() => this.handleDelete('logo.svg')}>Delete</button>
|
|
512
|
-
</div>
|
|
513
|
-
` : ''}
|
|
514
|
-
|
|
515
|
-
<input type="file" id="logoFile" accept=".svg,image/svg+xml" />
|
|
516
|
-
<button class="btn-primary mt-1 mb-1" @click=${() => {
|
|
517
|
-
const input = this.shadowRoot?.querySelector('#logoFile') as HTMLInputElement;
|
|
518
|
-
if (input.files?.[0]) this.handleUpload('logo.svg', input.files[0]);
|
|
519
|
-
}}>Upload logo.svg</button>
|
|
520
|
-
|
|
521
|
-
<div class="info-box">
|
|
522
|
-
<strong>Tip:</strong> Use an SVG with transparent background. The logo will automatically adapt to light/dark themes.
|
|
523
|
-
</div>
|
|
524
|
-
</div>
|
|
525
|
-
`;
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
renderStaticSection() {
|
|
529
|
-
return html`
|
|
530
|
-
<div class="section">
|
|
531
|
-
<h3>Site Settings</h3>
|
|
532
|
-
<p class="help-text">Manage your site's static details like title, footer links, etc.</p>
|
|
533
|
-
|
|
534
|
-
<div class="mb-1">
|
|
535
|
-
<label style="display:block;margin-bottom:4px;font-weight:500">Site Title</label>
|
|
536
|
-
<input type="text" id="siteTitle" .value=${this.staticDetails?.siteTitle || ''} />
|
|
537
|
-
</div>
|
|
538
|
-
|
|
539
|
-
<div class="mb-1">
|
|
540
|
-
<label style="display:block;margin-bottom:4px;font-weight:500">Copyright Text</label>
|
|
541
|
-
<input type="text" id="copyright" .value=${this.staticDetails?.copyright || ''} />
|
|
542
|
-
</div>
|
|
543
|
-
|
|
544
|
-
<div class="mb-1">
|
|
545
|
-
<label style="display:block;margin-bottom:4px;font-weight:500">LinkedIn URL</label>
|
|
546
|
-
<input type="text" id="linkedin" .value=${this.staticDetails?.linkedin || ''} />
|
|
547
|
-
</div>
|
|
548
|
-
|
|
549
|
-
<div class="mb-1">
|
|
550
|
-
<label style="display:block;margin-bottom:4px;font-weight:500">GitHub URL</label>
|
|
551
|
-
<input type="text" id="github" .value=${this.staticDetails?.github || ''} />
|
|
552
|
-
</div>
|
|
553
|
-
|
|
554
|
-
<div class="mb-1">
|
|
555
|
-
<label style="display:block;margin-bottom:4px;font-weight:500">Email</label>
|
|
556
|
-
<input type="text" id="email" .value=${this.staticDetails?.email || ''} />
|
|
557
|
-
</div>
|
|
558
|
-
|
|
559
|
-
<button class="btn-primary" @click=${async () => {
|
|
560
|
-
const siteTitle = (this.shadowRoot?.querySelector('#siteTitle') as HTMLInputElement)?.value;
|
|
561
|
-
const copyright = (this.shadowRoot?.querySelector('#copyright') as HTMLInputElement)?.value;
|
|
562
|
-
const linkedin = (this.shadowRoot?.querySelector('#linkedin') as HTMLInputElement)?.value;
|
|
563
|
-
const github = (this.shadowRoot?.querySelector('#github') as HTMLInputElement)?.value;
|
|
564
|
-
const email = (this.shadowRoot?.querySelector('#email') as HTMLInputElement)?.value;
|
|
565
|
-
|
|
566
|
-
const data: Record<string, string> = {};
|
|
567
|
-
if (siteTitle) data.siteTitle = siteTitle;
|
|
568
|
-
if (copyright) data.copyright = copyright;
|
|
569
|
-
if (linkedin) data.linkedin = linkedin;
|
|
570
|
-
if (github) data.github = github;
|
|
571
|
-
if (email) data.email = email;
|
|
572
|
-
|
|
573
|
-
try {
|
|
574
|
-
const url = `${this.apiUrl}/content/staticdetails.json`;
|
|
575
|
-
const res = await fetch(url, {
|
|
576
|
-
method: 'PUT',
|
|
577
|
-
credentials: 'include',
|
|
578
|
-
headers: { 'Content-Type': 'application/json' },
|
|
579
|
-
body: JSON.stringify(data)
|
|
580
|
-
});
|
|
581
|
-
if (res.ok) {
|
|
582
|
-
this.statusMessage = 'Settings saved!';
|
|
583
|
-
this.fetchContent();
|
|
584
|
-
} else {
|
|
585
|
-
this.statusMessage = 'Failed to save settings.';
|
|
586
|
-
}
|
|
587
|
-
} catch (e) {
|
|
588
|
-
this.statusMessage = 'Error saving settings.';
|
|
589
|
-
}
|
|
590
|
-
}}>Save Settings</button>
|
|
591
|
-
</div>
|
|
592
|
-
`;
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
render() {
|
|
596
|
-
if (this.isLoading) {
|
|
597
|
-
return html`<div class="container"><div class="loading">Loading...</div></div>`;
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
if (!this.isSetup) {
|
|
601
|
-
return this.renderLoginForm();
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
if (!this.isAuthenticated) {
|
|
605
|
-
return this.renderLogin();
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
return html`
|
|
609
|
-
<div class="container">
|
|
610
|
-
<div class="header">
|
|
611
|
-
<h1>Content Manager</h1>
|
|
612
|
-
<button class="btn-secondary" @click=${() => this.handleLogout()}>Logout</button>
|
|
613
|
-
<button class="btn-secondary" @click=${() => this.handleClearCache()}>Clear Cache</button>
|
|
614
|
-
</div>
|
|
615
|
-
|
|
616
|
-
<div class="nav-tabs">
|
|
617
|
-
<button class="nav-tab ${this.activeSection === 'home' ? 'active' : ''}"
|
|
618
|
-
@click=${() => this.activeSection = 'home'}>Home</button>
|
|
619
|
-
<button class="nav-tab ${this.activeSection === 'profile' ? 'active' : ''}"
|
|
620
|
-
@click=${() => this.activeSection = 'profile'}>Profile</button>
|
|
621
|
-
<button class="nav-tab ${this.activeSection === 'aboutme' ? 'active' : ''}"
|
|
622
|
-
@click=${() => this.activeSection = 'aboutme'}>About Me</button>
|
|
623
|
-
<button class="nav-tab ${this.activeSection === 'blogs' ? 'active' : ''}"
|
|
624
|
-
@click=${() => this.activeSection = 'blogs'}>Blogs</button>
|
|
625
|
-
<button class="nav-tab ${this.activeSection === 'stories' ? 'active' : ''}"
|
|
626
|
-
@click=${() => this.activeSection = 'stories'}>Stories</button>
|
|
627
|
-
<button class="nav-tab ${this.activeSection === 'images' ? 'active' : ''}"
|
|
628
|
-
@click=${() => this.activeSection = 'images'}>Images</button>
|
|
629
|
-
<button class="nav-tab ${this.activeSection === 'logo' ? 'active' : ''}"
|
|
630
|
-
@click=${() => this.activeSection = 'logo'}>Logo</button>
|
|
631
|
-
<button class="nav-tab ${this.activeSection === 'static' ? 'active' : ''}"
|
|
632
|
-
@click=${() => {
|
|
633
|
-
this.activeSection = 'static';
|
|
634
|
-
this.fetchStaticDetails();
|
|
635
|
-
}}>Site Settings</button>
|
|
636
|
-
</div>
|
|
637
|
-
|
|
638
|
-
${this.statusMessage ? html`
|
|
639
|
-
<div class="status-message ${this.statusMessage.includes('successful') || this.statusMessage.includes('cleared') ? 'success' : this.statusMessage.includes('failed') || this.statusMessage.includes('Error') ? 'error' : ''}">
|
|
640
|
-
${this.statusMessage}
|
|
641
|
-
</div>
|
|
642
|
-
` : ''}
|
|
643
|
-
|
|
644
|
-
${this.activeSection === 'home' ? this.renderHomeSection() : ''}
|
|
645
|
-
${this.activeSection === 'profile' ? this.renderProfileSection() : ''}
|
|
646
|
-
${this.activeSection === 'aboutme' ? this.renderAboutMeSection() : ''}
|
|
647
|
-
${this.activeSection === 'blogs' ? this.renderBlogsSection() : ''}
|
|
648
|
-
${this.activeSection === 'stories' ? this.renderStoriesSection() : ''}
|
|
649
|
-
${this.activeSection === 'images' ? this.renderImagesSection() : ''}
|
|
650
|
-
${this.activeSection === 'logo' ? this.renderLogoSection() : ''}
|
|
651
|
-
${this.activeSection === 'static' ? this.renderStaticSection() : ''}
|
|
652
|
-
</div>
|
|
653
|
-
`;
|
|
654
|
-
}
|
|
655
|
-
}
|