@@ -13,20 +13,28 @@ import (
1313 "time"
1414
1515 "google.golang.org/api/drive/v3"
16+
17+ "github.com/steipete/gogcli/internal/slidesmarkdown"
1618)
1719
1820// AssetMap pairs parsed AST references with uploaded Drive ImageRefs.
19- // Icons is keyed by IconRef value (Style+Name); Diagrams is keyed by
20- // DiagramBlock.ID.
21+ // Icons is keyed by slidesmarkdown. IconRef value (Style+Name); Diagrams is
22+ // keyed by slidesmarkdown. DiagramBlock.ID.
2123type AssetMap struct {
22- Icons map [IconRef ]ImageRef
24+ Icons map [slidesmarkdown. IconRef ]ImageRef
2325 Diagrams map [string ]ImageRef
2426}
2527
28+ // ImageRef is the result of uploading an asset to Drive.
29+ type ImageRef struct {
30+ DriveFileID string
31+ PublicURL string
32+ }
33+
2634// NewAssetMap returns an empty initialized AssetMap.
2735func NewAssetMap () AssetMap {
2836 return AssetMap {
29- Icons : map [IconRef ]ImageRef {},
37+ Icons : map [slidesmarkdown. IconRef ]ImageRef {},
3038 Diagrams : map [string ]ImageRef {},
3139 }
3240}
@@ -192,7 +200,7 @@ type AssetPipeline struct {
192200// fetches/renders/uploads each, and returns the resulting AssetMap.
193201//
194202// Per-asset failures are logged (warn-and-skip) unless Config.Strict.
195- func (p * AssetPipeline ) Resolve (ctx context.Context , slides []Slide ) (AssetMap , error ) {
203+ func (p * AssetPipeline ) Resolve (ctx context.Context , slides []slidesmarkdown. Slide ) (AssetMap , error ) {
196204 am := NewAssetMap ()
197205
198206 icons := collectIconRefs (slides )
@@ -274,31 +282,31 @@ func (p *AssetPipeline) Cleanup(ctx context.Context) error {
274282}
275283
276284// collectIconRefs walks all slides, deduping IconRef values.
277- func collectIconRefs (slides []Slide ) map [IconRef ]struct {} {
278- out := map [IconRef ]struct {}{}
279- var walkBlocks func ([]Block )
280- walkBlocks = func (blocks []Block ) {
285+ func collectIconRefs (slides []slidesmarkdown. Slide ) map [slidesmarkdown. IconRef ]struct {} {
286+ out := map [slidesmarkdown. IconRef ]struct {}{}
287+ var walkBlocks func ([]slidesmarkdown. Block )
288+ walkBlocks = func (blocks []slidesmarkdown. Block ) {
281289 for _ , b := range blocks {
282290 switch v := b .(type ) {
283- case ParagraphBlock :
291+ case slidesmarkdown. ParagraphBlock :
284292 if r , ok := leadingIcon (v .Inlines ); ok {
285293 out [r ] = struct {}{}
286294 }
287- case BulletsBlock :
295+ case slidesmarkdown. BulletsBlock :
288296 for _ , item := range v .Items {
289297 if r , ok := leadingIcon (item .Inlines ); ok {
290298 out [r ] = struct {}{}
291299 }
292300 }
293- case HeadingBlock :
301+ case slidesmarkdown. HeadingBlock :
294302 if r , ok := leadingIcon (v .Inlines ); ok {
295303 out [r ] = struct {}{}
296304 }
297- case ColumnsBlock :
305+ case slidesmarkdown. ColumnsBlock :
298306 for _ , col := range v .Columns {
299307 walkBlocks (col )
300308 }
301- case IconRowsBlock :
309+ case slidesmarkdown. IconRowsBlock :
302310 for _ , row := range v .Rows {
303311 if row .Icon != nil {
304312 out [* row .Icon ] = struct {}{}
@@ -313,24 +321,24 @@ func collectIconRefs(slides []Slide) map[IconRef]struct{} {
313321 return out
314322}
315323
316- func leadingIcon (inlines []Inline ) (IconRef , bool ) {
324+ func leadingIcon (inlines []slidesmarkdown. Inline ) (slidesmarkdown. IconRef , bool ) {
317325 if len (inlines ) == 0 {
318- return IconRef {}, false
326+ return slidesmarkdown. IconRef {}, false
319327 }
320- ref , ok := inlines [0 ].(IconRef )
328+ ref , ok := inlines [0 ].(slidesmarkdown. IconRef )
321329 return ref , ok
322330}
323331
324332// collectDiagrams walks all slides for DiagramBlocks, returning {ID: source}.
325- func collectDiagrams (slides []Slide ) map [string ]string {
333+ func collectDiagrams (slides []slidesmarkdown. Slide ) map [string ]string {
326334 out := map [string ]string {}
327- var walkBlocks func ([]Block )
328- walkBlocks = func (blocks []Block ) {
335+ var walkBlocks func ([]slidesmarkdown. Block )
336+ walkBlocks = func (blocks []slidesmarkdown. Block ) {
329337 for _ , b := range blocks {
330338 switch v := b .(type ) {
331- case DiagramBlock :
339+ case slidesmarkdown. DiagramBlock :
332340 out [v .ID ] = v .Source
333- case ColumnsBlock :
341+ case slidesmarkdown. ColumnsBlock :
334342 for _ , col := range v .Columns {
335343 walkBlocks (col )
336344 }
@@ -348,7 +356,7 @@ func collectDiagrams(slides []Slide) map[string]string {
348356// only published under brands/), it tries the other free-tier styles in a
349357// fixed order: brands, regular, solid. Returns the body, the style that
350358// actually served, and the final error.
351- func fetchFAIconWithStyleFallback (ctx context.Context , client * http.Client , ref IconRef ) ([]byte , string , error ) {
359+ func fetchFAIconWithStyleFallback (ctx context.Context , client * http.Client , ref slidesmarkdown. IconRef ) ([]byte , string , error ) {
352360 tried := map [string ]bool {}
353361 order := []string {ref .Style , "brands" , "regular" , "solid" }
354362 var lastErr error
0 commit comments