Skip to content

Commit 86645c1

Browse files
committed
Implemented go
1 parent 33943af commit 86645c1

5 files changed

Lines changed: 39 additions & 66 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@churchapps/content-providers": minor
3+
---
4+
5+
GoCurriculum: data.json now uses Go Curriculum's own catalog export format verbatim (`catalog`/`thumbnail`/`playlist` with `duration`, file ids slugified from filenames) instead of the hand-rolled `collections`/`files` schema — new exports from Go drop in unmodified. Lesson `resources` (PDF/docx leader material) are carried in the data but not surfaced.
Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,40 @@
1-
export interface GoCurriculumFile {
2-
id: string;
3-
name: string;
1+
export interface GoCurriculumPlaylistItem {
2+
title: string;
3+
file: string;
44
url: string;
5-
fileType?: string;
6-
seconds?: number;
7-
loop?: boolean;
8-
loopVideo?: boolean;
5+
mediaType?: string;
6+
duration?: number;
97
thumbnail?: string;
8+
shareUrl?: string;
9+
}
10+
11+
export interface GoCurriculumResource {
12+
title: string;
13+
file: string;
14+
url: string;
15+
shareUrl?: string;
1016
}
1117

1218
export interface GoCurriculumLesson {
1319
id: string;
1420
name: string;
15-
image?: string;
16-
files: GoCurriculumFile[];
21+
thumbnail?: string;
22+
bigIdea?: string;
23+
bibleBasis?: string;
24+
keyVerse?: string;
25+
playlist: GoCurriculumPlaylistItem[];
26+
resources?: GoCurriculumResource[];
1727
}
1828

1929
export interface GoCurriculumCollection {
2030
id: string;
2131
name: string;
22-
image?: string;
32+
thumbnail?: string;
2333
lessons: GoCurriculumLesson[];
2434
}
2535

2636
export interface GoCurriculumData {
27-
collections: GoCurriculumCollection[];
37+
generatedAt?: string;
38+
provider?: { name?: string };
39+
catalog: GoCurriculumCollection[];
2840
}

‎content-providers/src/providers/goCurriculum/GoCurriculumProvider.ts‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { AuthType, ContentFile, ContentItem, ContentProviderAuthData, ContentProviderConfig, Instructions, ProviderCapabilities, ProviderLogos } from "../../interfaces";
22
import { parsePath } from "../../pathUtils";
3-
import { createFolder, createFile, detectMediaType, filesToInstructions } from "../../utils";
3+
import { createFolder, createFile, detectMediaType, filesToInstructions, slugify } from "../../utils";
44
import { OAuthHelper } from "../../helpers";
55
import { getProviderSecret } from "../../helpers/ProviderSecrets";
66
import { BaseProvider } from "../BaseProvider";
@@ -9,8 +9,8 @@ import { GoCurriculumData, GoCurriculumCollection } from "./GoCurriculumInterfac
99

1010
/**
1111
* Path: / → collections, /{collection} → lessons (leaf), /{collection}/{lesson} → files.
12-
* Content is curated in data.json (media hosted on Dropbox); a valid gocurriculum.com
13-
* login (WP OAuth Server plugin) gates all of it.
12+
* data.json is Go's catalog export dropped in verbatim (media hosted on Dropbox);
13+
* a valid gocurriculum.com login (WP OAuth Server plugin) gates all of it.
1414
*/
1515
export class GoCurriculumProvider extends BaseProvider {
1616
private readonly oauthHelper = new OAuthHelper();
@@ -61,12 +61,12 @@ export class GoCurriculumProvider extends BaseProvider {
6161
if (!(await this.verifyAuth(auth))) return [];
6262
const { segments, depth } = parsePath(path);
6363

64-
if (depth === 0) return this.data.collections.map(c => createFolder(c.id, c.name, `/${c.id}`, c.image));
64+
if (depth === 0) return this.data.catalog.map(c => createFolder(c.id, c.name, `/${c.id}`, c.thumbnail));
6565

66-
const collection = this.data.collections.find(c => c.id === segments[0]);
66+
const collection = this.data.catalog.find(c => c.id === segments[0]);
6767
if (!collection) return [];
6868

69-
if (depth === 1) return collection.lessons.map(l => createFolder(l.id, l.name, `/${collection.id}/${l.id}`, l.image || collection.image, true));
69+
if (depth === 1) return collection.lessons.map(l => createFolder(l.id, l.name, `/${collection.id}/${l.id}`, l.thumbnail || collection.thumbnail, true));
7070
if (depth === 2) return this.getLessonFiles(collection, segments[1]);
7171

7272
return [];
@@ -75,16 +75,16 @@ export class GoCurriculumProvider extends BaseProvider {
7575
private getLessonFiles(collection: GoCurriculumCollection, lessonId: string): ContentFile[] {
7676
const lesson = collection.lessons.find(l => l.id === lessonId);
7777
if (!lesson) return [];
78-
// Dropbox temp links can be extension-less; the name usually carries the original filename
79-
return lesson.files.map(f => createFile(f.id, f.name, f.url, { mediaType: detectMediaType(`${f.url} ${f.name}`, f.fileType), thumbnail: f.thumbnail || lesson.image || collection.image, seconds: f.seconds, loop: f.loop, loopVideo: f.loopVideo }));
78+
// ponytail: playlist only — resources are PDFs/docx leader material with nothing to present; wire them into instructions if a consumer grows a downloads section
79+
return lesson.playlist.map(f => createFile(slugify(f.file), f.title, f.url, { mediaType: detectMediaType(`${f.url} ${f.file}`, f.mediaType), thumbnail: f.thumbnail || lesson.thumbnail || collection.thumbnail, seconds: f.duration }));
8080
}
8181

8282
async getPlaylist(path: string, auth?: ContentProviderAuthData | null, _resolution?: number): Promise<ContentFile[] | null> {
8383
if (!(await this.verifyAuth(auth))) return null;
8484
const { segments, depth } = parsePath(path);
8585
if (depth !== 2) return null;
8686

87-
const collection = this.data.collections.find(c => c.id === segments[0]);
87+
const collection = this.data.catalog.find(c => c.id === segments[0]);
8888
if (!collection) return null;
8989

9090
const files = this.getLessonFiles(collection, segments[1]);
@@ -98,7 +98,7 @@ export class GoCurriculumProvider extends BaseProvider {
9898
const files = await this.getPlaylist(path, auth);
9999
if (!files) return null;
100100

101-
const collection = this.data.collections.find(c => c.id === segments[0]);
101+
const collection = this.data.catalog.find(c => c.id === segments[0]);
102102
const lesson = collection?.lessons.find(l => l.id === segments[1]);
103103
return filesToInstructions(lesson?.name || "Lesson", files);
104104
}

‎content-providers/src/providers/goCurriculum/README.md‎

Lines changed: 0 additions & 44 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"collections": []
2+
"catalog": []
33
}

0 commit comments

Comments
 (0)