Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/extensions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ jobs:
simple-shiny-chat-with-mcp: extensions/simple-shiny-chat-with-mcp/**
chat-with-content: extensions/chat-with-content/**
pqr: extensions/pqr/**
content-collections: extensions/content-collections/**

# Runs for each extension that has changed from `simple-extension-changes`
# Lints and packages in preparation for tests and and release.
Expand Down
2 changes: 2 additions & 0 deletions extensions/content-collections/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.posit/
docs/
42 changes: 42 additions & 0 deletions extensions/content-collections/R/config.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
COLLECTION_NAME_MARKER <- "__content-collection__"

build_config <- function(title, description, intro_markdown, theme,
source_type, guids, tag, owner_email = "") {
cfg <- list(
title = title %||% "",
description = description %||% "",
intro_markdown = intro_markdown %||% "",
theme = theme %||% "minimal",
source_type = source_type %||% "manual",
owner_email = owner_email %||% ""
)
if (identical(source_type, "tag")) {
cfg$source_tag <- tag %||% ""
} else {
cfg$guids <- as.character(guids %||% character(0))
}
cfg
}

parse_config <- function(cfg) {
cfg <- cfg %||% list()
list(
title = cfg$title %||% "",
description = cfg$description %||% "",
intro_markdown = cfg$intro_markdown %||% "",
theme = cfg$theme %||% "minimal",
source_type = cfg$source_type %||% "manual",
source_tag = cfg$source_tag %||% "",
guids = as.character(unlist(cfg$guids %||% character(0))),
owner_email = cfg$owner_email %||% ""
)
}

make_collection_name <- function() {
paste0(COLLECTION_NAME_MARKER, "-", uuid::UUIDgenerate())
}

# Null-coalescing operator. Treats both NULL and a length-1 NA as "missing"
# so config values from JSON or partial Connect API responses fall back to
# defaults consistently.
`%||%` <- function(a, b) if (is.null(a) || (length(a) == 1 && is.na(a))) b else a
Loading
Loading