Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shiny create: Support submenus in remote template repos #1647

Open
gadenbuie opened this issue Aug 27, 2024 · 0 comments
Open

shiny create: Support submenus in remote template repos #1647

gadenbuie opened this issue Aug 27, 2024 · 0 comments

Comments

@gadenbuie
Copy link
Collaborator

#1631 Adds support for a template-defining metadata file, _template.json, stored at the root of the template folder. After #1631, we'll use this template file to find all templates in a remote template repo, allowing us to create a menu of choices in shiny create, e.g.

❯ shiny create --github posit-dev/py-shiny-templates@template-json
ℹ Using GitHub repository posit-dev/py-shiny-templates@template-json.
? Which template would you like to use?: (Use arrow keys)
 » A Basic app
   Basic reactive plot
   Navigating multiple panels
   Reactive plot in sidebar
   Basic dashboard
   Restaurant tips dashboard
   SQL database explorer
   Location distance calculator
   Model scoring
   Streaming database updates
   Streaming file updates
   Streaming folder updates
   NBA player career comparisons
   Article on regularization in ML
   Stock price tracker
   Survey form
   Survey wizard form
   [Cancel]

As seen in the example above, it would be helpful to have submenus, e.g.

❯ shiny create --github posit-dev/py-shiny-templates@template-json
ℹ Using GitHub repository posit-dev/py-shiny-templates@template-json.
? Which template would you like to use?: (Use arrow keys)
 » Basic apps...
   Dashboards...
   Streaming updates...
   Data entry...
   [Cancel]

As a first approximation, we could organize the templates into subfolders, so that instead of this (considering only streaming/data-entry apps):

.
├── monitor-database
│   └── _template.json
├── monitor-file
│   └── _template.json
├── monitor-folder
│   └── _template.json
├── survey
│   └── _template.json
└── survey-wizard
    └── _template.json

we'd have this

.
├── data-entry
│   ├── survey
│   │   └── _template.json
│   └── survey-wizard
│       └── _template.json
└── streaming
    ├── monitor-database
    │   └── _template.json
    ├── monitor-file
    │   └── _template.json
    └── monitor-folder
        └── _template.json

At the root of data-entry/ and streaming/, we could include an additional _template.json with type: "submenu", e.g.

{
  "type": "submenu",
  "id": "streaming-apps",
  "title": "Streaming updates"
}

In shiny create, we'd have to change how we discover templates, but in walking the templates directory, we could find these type: "submenu" templates and render them as submenus.

This approach is compatible with the _template.json used in #1631 as well as the --github {owner}/{repo}:{path} syntax and importantly could be added later without breaking syntax introduced in #1631.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant