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

Add support for themes that point to git repositories #37

Open
KNOXDEV opened this issue Jun 5, 2019 · 8 comments
Open

Add support for themes that point to git repositories #37

KNOXDEV opened this issue Jun 5, 2019 · 8 comments
Labels
enhancement New feature or request

Comments

@KNOXDEV
Copy link

KNOXDEV commented Jun 5, 2019

As of commit 0685244, the theme configuration is handled via the config.json file. I propose that a theme can be configured by simply referring to its Git repository, like so:

config.json
{
	"theme": [
		"dark",
		"github.com/nektro/OfficialDarkTheme",
		"custom.url/KNOXDEV/UnofficialButStillPrettyCoolTheme.git"
	]
}

The first entry, dark, is a built-in theme that internally translates to a git repository.
The second entry is a GitHub URL to the repository that contains the theme to be downloaded directly.
The third entry isn't a GitHub URL, but it IS a valid git repository, and will be interpreted the same.

Andesite can then be responsible for reading the configuration at runtime, downloading the theme from the provided Git repository (with a very specific structure), placing the files into the .andesite/theme-name/ folder, and serving from there like previously.

Having the ability to install themes like this makes both configuration and 3rd party theme creation very easy.

@nektro nektro added the proposal-pending Feature request that requires more discussion label Jun 5, 2019
@nektro
Copy link
Owner

nektro commented Jun 5, 2019

As of commit 0685244, themes are also now found in ~/.config/andesite/themes/ so as you be able to support this change of themes whose name is not necessarily theme-XXX.

@nektro
Copy link
Owner

nektro commented Jun 5, 2019

As far as enabling remote themes more specifically, beyond the user manually downloading them to their config directory, is there a standard way to translate Git URLs to raw file data?

ie. github.com/nektro/OfficialDarkTheme could be translated to https://raw.githubusercontent.com/nektro/OfficialDarkTheme/{{branch}}/main.go by testing for https://github.com at the beginning of the URL. But for custom Git hosting options like https://custom.url, Gitea, or https://go.googlesource.com/andesite-theme-google is there a standard way to get the raw version of a file?

edit: Gitea could also be tested if the syntax was perhaps changed to github:nektro/andesite-theme-dark and gitea:git.knox.dev/knox/andesite-theme respectively, for example.

@nektro
Copy link
Owner

nektro commented Jun 5, 2019

Also, would this support multiple themes inside a single repo? Or would each theme have to be its own repository?

@KNOXDEV
Copy link
Author

KNOXDEV commented Jun 5, 2019

I think the idea is that each theme is its own repository, which makes sense since fomantic themes will generally need a build process of some kind. We can very easily provide a starting repository that a theme developer can simply fork, change some variables, and compile.

With regards to downloading the Git repositories, there are three main options:

  1. Straight up clone the repo into the themes folder. This will probably require Git, or at the very least a Git-compatible go library of some kind, but if we do choose to rely on Git, it wouldn't pose an additional dependency at the moment, since installing andesite in the first place requires it.
  2. With both Github and Gitea, you can create a stop-gap installation strategy where andesite simply queries the git repository url with the added path: https://github.com/user/ThemeRepo/archive/master.zip. This would also be trivial to implement, but has the downside of not working properly with Git hosting services that don't provide such a download.
  3. Attempt to query raw paths as you suggested, such as https://raw.githubusercontent.com/nektro/OfficialDarkTheme/{{branch}}/theme.hdb but this requires downloading the theme components one at a time, and isn't very forwards or backwards compatible, and so far only works with GitHub.

I recommend the first option.

@nektro
Copy link
Owner

nektro commented Jun 6, 2019

With the proper error messages, we could do 1, with a potential fallback to 2 if git is missing and the url supports it.

@KNOXDEV
Copy link
Author

KNOXDEV commented Jun 6, 2019

I like that strategy a lot. Let's do it.

@nektro nektro added enhancement New feature or request and removed proposal-pending Feature request that requires more discussion labels Jun 8, 2019
@nektro
Copy link
Owner

nektro commented Jan 8, 2020

Adding on to this,
"rainbow" -> ~/.config/andesite/themes/rainbow/
"https://github.com/nektro/andesite-theme-dark.git" -> git repo
"./blue/" -> folder relative to CWD

@nektro
Copy link
Owner

nektro commented Jan 8, 2020

Actually going to make a new issue for that.

@nektro nektro changed the title Proposal for theme configuration Add support for themes that point to git repositories Jan 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants