diff --git a/main.ts b/main.ts
index da5e6b2..ad5306f 100644
--- a/main.ts
+++ b/main.ts
@@ -120,9 +120,11 @@ async function main() {
const relevantFiles = await getWorkshopVideos(bot)
const { pages: d, errors: parseErrors } = await fetchPages(relevantFiles, bot)
const t = writeSections(bucketEvents(d))
+
const trigger_summary = 'Triggered by changes to ' + paths.map(v => `[[${v}]]`).join(", ")
const error_summary = parseErrors.join("\n")
const summary = [trigger_summary, error_summary].filter(v => v !== undefined && v.length > 0).join("\n")
+
const response = await bot.save(title, "{{TOC|limit=3}}\n\n" + t, summary);
console.log(response)
})
diff --git a/parse.ts b/parse.ts
index 56f65e4..650b7c0 100644
--- a/parse.ts
+++ b/parse.ts
@@ -79,5 +79,6 @@ export function parseSummary(description: string, name: string): VideoDescriptio
b.path = name
const titleMatch = name.match(/File:WCS \w+ (?
.+)\.[^.]+/)
b.title = titleMatch?.groups ? titleMatch.groups['title'] : name
+ b.title = b.title.trim()
return (b as VideoDescription)
}
diff --git a/util_string.ts b/util_string.ts
new file mode 100644
index 0000000..df1ffe8
--- /dev/null
+++ b/util_string.ts
@@ -0,0 +1,57 @@
+export const SMALL_WORDS = new Set([
+ "a",
+ "an",
+ "and",
+ "as",
+ "at",
+ "because",
+ "but",
+ "by",
+ "en",
+ "for",
+ "if",
+ "in",
+ "neither",
+ "nor",
+ "of",
+ "on",
+ "only",
+ "or",
+ "over",
+ "per",
+ "so",
+ "some",
+ "than",
+ "that",
+ "the",
+ "to",
+ "up",
+ "upon",
+ "v",
+ "versus",
+ "via",
+ "vs",
+ "when",
+ "with",
+ "without",
+ "yet",
+]);
+
+export function capitalize(word: string): string {
+ return word.charAt(0).toUpperCase() + word.slice(1);
+}
+
+export function camelToTitleCase(camelCaseStr: string): string {
+ const titleCaseStr = camelCaseStr.replace(/([A-Z])/g, ' $1');
+
+ const words = titleCaseStr.split(' ')
+ .map(v => v.toLowerCase())
+ .map(word => {
+ if (SMALL_WORDS.has(word)) {
+ return word;
+ }
+ return capitalize(word)
+ });
+
+ return capitalize(words.join(' '));
+}
\ No newline at end of file
diff --git a/util_string_test.ts b/util_string_test.ts
new file mode 100644
index 0000000..1bd1242
--- /dev/null
+++ b/util_string_test.ts
@@ -0,0 +1,12 @@
+import { assertEquals } from "@std/assert/equals";
+import { camelToTitleCase } from "./util_string.ts";
+
+Deno.test("camelToTitleCase transforms camelCase to Title Case", () => {
+ assertEquals(camelToTitleCase("thisIsATest"), "This Is a Test");
+ assertEquals(camelToTitleCase("denoIsAwesome"), "Deno Is Awesome");
+ assertEquals(camelToTitleCase("helloWorld"), "Hello World");
+});
+
+Deno.test("camelToTitleCase handles empty string", () => {
+ assertEquals(camelToTitleCase(""), "");
+});
\ No newline at end of file
diff --git a/write.ts b/write.ts
index 38c8ca7..f667c9c 100644
--- a/write.ts
+++ b/write.ts
@@ -1,65 +1,7 @@
import { VideoDescription } from "./main.ts";
+import { camelToTitleCase } from "./util_string.ts";
-export const SMALL_WORDS = new Set([
- "a",
- "an",
- "and",
- "as",
- "at",
- "because",
- "but",
- "by",
- "en",
- "for",
- "if",
- "in",
- "neither",
- "nor",
- "of",
- "on",
- "only",
- "or",
- "over",
- "per",
- "so",
- "some",
- "than",
- "that",
- "the",
- "to",
- "up",
- "upon",
- "v",
- "versus",
- "via",
- "vs",
- "when",
- "with",
- "without",
- "yet",
-]);
-
-function capitalize(word: string): string {
- return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
-}
-
-function camelToTitleCase(camelCaseStr: string): string {
- // Insert a space before each uppercase letter
- const titleCaseStr = camelCaseStr.replace(/([A-Z])/g, ' $1');
-
- // Split the string into words and process each word using map
- const words = titleCaseStr.split(' ')
- .map(v => v.toLowerCase())
- .map(word => {
- if (SMALL_WORDS.has(word)) {
- return word;
- }
- return capitalize(word)
- });
-
- return capitalize(words.join(' '));
-}
export function singleVideoDescription(video: VideoDescription): string {
const teachersList = video.teachers.map(v => "[[" + v + "]]").join(" & ");