-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
396 lines (335 loc) · 13.2 KB
/
script.js
File metadata and controls
396 lines (335 loc) · 13.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
// Project data
const projects = [
{
displayName: '🚩 Pixel Banner',
shortName: 'pixel-banner',
obsidianPluginName: 'Pixel%20Banner',
hashtags: '#Obsidian #ObsidianMD #Plugins #Banners',
},
{
displayName: '🦶 Rich Foot',
shortName: 'rich-foot',
obsidianPluginName: 'rich%20foot',
hashtags: '#Obsidian #ObsidianMD #Plugins #Footnotes'
},
{
displayName: '🍱 Semantic Chunking',
shortName: 'semantic-chunking',
demo: 'https://chunking.dyndns.org',
hashtags: '#LLM #RAG #AI #AITools #Chunking',
npmPackageName: 'semantic-chunking'
},
{
displayName: '🕵️ Chunk Match',
shortName: 'chunk-match',
demo: 'https://chunk-match.dyndns.org',
hashtags: '#LLM #RAG #AI #AITools #Chunking',
npmPackageName: 'chunk-match'
},
{
displayName: '🌐 Web-Augmented Generation',
shortName: 'web-augmented-generation',
hashtags: '#LLM #AITools #NodeJS #SearXNG #WebScraping'
},
{
displayName: '🏷️ Fast Topic Analysis',
shortName: 'fast-topic-analysis',
hashtags: '#LLM #AITools #NodeJS #TopicAnalysis'
},
{
displayName: '📄 Sentence Parse',
shortName: 'sentence-parse',
hashtags: '#sentence #parse #split #segment',
npmPackageName: 'sentence-parse'
},
{
displayName: '👽 Extract Topics',
shortName: 'extract-topics',
hashtags: '#LLM #AITools #NodeJS #TopicExtraction',
npmPackageName: 'extract-topics'
},
{
displayName: '🪨 Bedrock Wrapper',
shortName: 'bedrock-wrapper',
hashtags: '#LLM #AWS #AI #AITools #Bedrock',
npmPackageName: 'bedrock-wrapper'
},
{
displayName: '🔀 Bedrock Proxy Endpoint',
shortName: 'bedrock-proxy-endpoint',
hashtags: '#LLM #AWS #AI #AITools #Bedrock'
},
{
displayName: '💦 K-Batch',
shortName: 'k-batch',
demo: 'https://k-batch.dyndns.org',
hashtags: '#Sentence #Batch #K-Means #NLP #ML',
npmPackageName: 'k-batch'
},
{
displayName: '🐇 MCP SQLite Server',
shortName: 'mcp-sqlite',
hashtags: '#MCP #SQLite #NodeJS #Cursor #AITools',
npmPackageName: 'mcp-sqlite'
},
];
const discordServerLink = 'https://discord.gg/sp8AQQhMJ7';
// DOM Elements
const form = document.getElementById('releaseForm');
const projectSelect = document.getElementById('project');
const versionInput = document.getElementById('versionNumber');
const tagLineInput = document.getElementById('tagLine');
const releaseNotesInput = document.getElementById('releaseNotes');
const imgURLInput = document.getElementById('imgURL');
const youTubeVideoIdInput = document.getElementById('youTubeVideoId');
const output = document.getElementById('output');
const outputContent = document.getElementById('outputContent');
const outputHeader = document.getElementById('outputHeader');
const obsidianCss = document.getElementById('obsidianCss');
const resetButton = document.getElementById('resetButton');
// Populate project select
projects.forEach(project => {
const option = document.createElement('option');
option.value = JSON.stringify(project);
option.textContent = project.displayName;
projectSelect.appendChild(option);
});
// Generate Discord release notes template
function generateDiscordReleaseNotes(project, version, notes, imgUrl, youTubeVideoId) {
let template = `# ${project.displayName} [v${version}](<https://github.com/jparkerweb/${project.shortName}/releases/tag/${version}>)`;
template += `\n\n`;
if (project.tagLine) {
template += `## ${project.tagLine}`;
} else {
template += `## What's New 🎉`;
}
template += `\n${notes}\n\n`;
if (project.obsidianPluginName) {
template += `### Grab the latest update directly from the Obsidian app!`;
}
template += `\n_If you have any suggestions or encounter any issues, don't hesitate to reach out._ 😁\n\n`;
template += `🐙 [github](<https://github.com/jparkerweb/${project.shortName}>)`;
if (project.npmPackageName) {
template += ` — 📦 [npm](<https://www.npmjs.com/package/${project.npmPackageName}>)`;
}
if (project.obsidianPluginName) {
template += ` — 💎 [plugin](<https://obsidian.md/plugins?search=${encodeURIComponent(project.obsidianPluginName)}>)`;
}
template += ` — 💻 [eQuill Labs](https://www.equilllabs.com)`;
template += `\n`;
// if (imgUrl.trim()) {
// template += `\n`;
// }
if (youTubeVideoId.trim()) {
template += `\nhttps://www.youtube.com/watch?v=${youTubeVideoId}`;
}
return template;
}
// Generate GitHub release notes template
function generateGitHubReleaseNotes(version, notes, imgUrl, youTubeVideoId) {
let template = `## What's New 🎉`;
template += `\n\n### v${version}`;
template += `\n${notes}\n\n`;
if (imgUrl.trim()) {
template += `\n\n`;
}
if (youTubeVideoId.trim()) {
template += `[](https://www.youtube.com/watch?v=${youTubeVideoId})\n\n`;
}
template += `---\n\n`;
template += `Please consider sending me a tip to support my work 😀\n`;
template += `# 🍵 [tip me here](https://ko-fi.com/jparkerweb)`;
template += `\n`;
template += `⇢ 💻 Visit [eQuill Labs](https://www.equilllabs.com)`;
template += `\n`;
template += `⇢ 💬 Join the [Discord](${discordServerLink})`;
return template;
}
// Generate Ko-Fi release notes template
function generateKoFiReleaseNotes(project, notes) {
const formattedNotes = formatNotesWithEmojis(notes);
let template = `${project.displayName} Release\n\n${formattedNotes}\n\n🐙 https://github.com/jparkerweb/${project.shortName}`;
if (project.obsidianPluginName) {
template += `\n💎 https://obsidian.md/plugins?search=${project.obsidianPluginName}`;
}
if (project.npmPackageName) {
template += `\n🥡 https://www.npmjs.com/package/${project.npmPackageName}`;
}
template += `\n💻 https://www.equilllabs.com`;
template += `\n💬 ${discordServerLink}`;
return template;
}
// Generate X post release notes template
function generateXReleaseNotes(project, version, notes, tagLine) {
const formattedNotes = formatNotesWithEmojis(notes);
let template = `${project.displayName} Release`;
template += `\nv${version}`;
if (tagLine) {
template += ` - ${tagLine}`;
}
template += `\n\n${formattedNotes}\n\n🐙 https://github.com/jparkerweb/${project.shortName}`;
if (project.obsidianPluginName) {
template += `\n💎 https://obsidian.md/plugins?search=${project.obsidianPluginName}`;
}
if (project.npmPackageName) {
template += `\n🥡 https://www.npmjs.com/package/${project.npmPackageName}`;
}
template += `\n 💻 https://www.equilllabs.com`;
template += `\n 💬 ${discordServerLink}`;
template += `\n\n${project.hashtags}`;
return template;
}
// Generate Obsidian release notes template
function generateObsidianReleaseNotes(project, version, notes, tagLine) {
let template = `---\nbanner: \n---\n # ${project.displayName} ⋅ v${version}${tagLine ? ` - ${tagLine}` : ''} { .release-title }`;
template += `\n\n#### What's New 🎉\n\n${notes}`;
return template;
}
// Helper function to format notes with section emojis
function formatNotesWithEmojis(notes) {
const lines = notes.split('\n');
let currentSection = '';
let currentEmoji = '';
const formattedLines = [];
for (const line of lines) {
const trimmedLine = line.trim();
if (!trimmedLine) continue;
if (trimmedLine.startsWith('### ')) {
// Extract emoji and section from "### 🫧 Added" format
const [emoji, ...sectionParts] = trimmedLine.substring(4).split(' ');
currentEmoji = emoji;
currentSection = sectionParts.join(' ').toLowerCase();
} else if (trimmedLine.startsWith('- ')) {
const bulletText = trimmedLine.substring(2);
formattedLines.push(`⇢ ${currentEmoji} ${currentSection} ${bulletText}`);
}
}
return formattedLines.join('\n');
}
// Generate release notes based on template type
function generateReleaseNotes(templateType) {
if (!form.checkValidity()) {
form.reportValidity();
return;
}
const project = JSON.parse(projectSelect.value);
const version = versionInput.value;
const tagLine = tagLineInput.value;
const notes = releaseNotesInput.value;
const imgUrl = imgURLInput.value;
const youTubeVideoId = youTubeVideoIdInput.value;
let generatedNotes = '';
let generatedHeader = '';
// Hide CSS snippet by default
obsidianCss.style.display = 'none';
switch (templateType) {
case 'discord':
generatedNotes = generateDiscordReleaseNotes(project, version, notes, imgUrl, youTubeVideoId);
generatedHeader = "";
break;
case 'github':
generatedNotes = generateGitHubReleaseNotes(version, notes, imgUrl, youTubeVideoId);
generatedHeader = `v${version}${tagLine ? ` - ${tagLine}` : ''}`;
break;
case 'kofi':
generatedNotes = generateKoFiReleaseNotes(project, notes);
generatedHeader = `${project.displayName} ⋅ v${version}${tagLine ? ` - ${tagLine}` : ''}`;
break;
case 'x':
generatedNotes = generateXReleaseNotes(project, version, notes, tagLine);
generatedHeader = "";
break;
case 'obsidian':
generatedNotes = generateObsidianReleaseNotes(project, version, notes, tagLine);
generatedHeader = `v${version}${tagLine ? ` - ${tagLine}` : ''}`;
obsidianCss.style.display = 'block';
break;
}
output.classList.remove('hidden');
const title = document.querySelector('#output h2');
title.textContent = `Generated Release Notes for ${templateType.charAt(0).toUpperCase() + templateType.slice(1)}`;
outputContent.textContent = generatedNotes;
outputHeader.textContent = generatedHeader;
if (outputHeader.textContent === "") {
outputHeader.classList.add('hidden');
} else {
outputHeader.classList.remove('hidden');
}
// scroll to output section
output.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
// Event listeners
discordButton.addEventListener('click', () => generateReleaseNotes('discord'));
githubButton.addEventListener('click', () => generateReleaseNotes('github'));
kofiButton.addEventListener('click', () => generateReleaseNotes('kofi'));
xButton.addEventListener('click', () => generateReleaseNotes('x'));
obsidianButton.addEventListener('click', () => generateReleaseNotes('obsidian'));
resetButton.addEventListener('click', () => {
form.reset();
output.classList.add('hidden');
});
// Copy functionality for output header
outputHeader.addEventListener('click', async () => {
if (outputHeader.textContent.trim() === '') return;
const success = await copyToClipboard(outputHeader.textContent);
if (success) {
showToast('Header copied to clipboard!');
}
});
// Copy functionality for output content
outputContent.addEventListener('click', async () => {
if (outputContent.textContent.trim() === '') return;
const success = await copyToClipboard(outputContent.textContent);
if (success) {
showToast('Release notes copied to clipboard!');
}
});
// Copy functionality for CSS snippet
obsidianCss.addEventListener('click', async () => {
if (obsidianCss.textContent.trim() === '') return;
const success = await copyToClipboard(obsidianCss.textContent);
if (success) {
showToast('CSS class copied to clipboard!');
}
});
// Copy to clipboard helper function
function copyToClipboard(text) {
const textArea = document.createElement("textarea");
textArea.value = text;
textArea.style.position = "fixed";
textArea.style.left = "-999999px";
textArea.style.top = "-999999px";
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try {
document.execCommand('copy');
textArea.remove();
return true;
} catch (err) {
console.error('execCommand Error:', err);
textArea.remove();
return false;
}
}
// Function to show toast message
function showToast(message) {
const container = document.createElement('div');
container.className = 'toast-container';
const toast = document.createElement('div');
toast.className = 'toast';
toast.textContent = message;
container.appendChild(toast);
document.body.appendChild(container);
// Function to remove toast
const removeToast = () => {
container.classList.add('fade-out');
setTimeout(() => {
document.body.removeChild(container);
}, 300);
};
// Click anywhere to dismiss
container.addEventListener('click', removeToast);
// Auto dismiss after delay
setTimeout(removeToast, 2000);
}