mirror of
https://github.com/revanced/revanced-static-api.git
synced 2025-04-29 22:24:37 +02:00
feat: Convert types
object to array
This commit is contained in:
parent
47fcdd1ce3
commit
046fb6991a
10
README.md
10
README.md
@ -4,10 +4,10 @@ Repository to host a static API using GitHub workflows.
|
||||
|
||||
## How it works
|
||||
|
||||
On CI trigger static files are generated and commited to the `gh-pages` branch.
|
||||
|
||||
The static files are generated by the configuration provided in a `config.json` file in the root.
|
||||
The API configuration consists out of an array of objects. Each object is responsible for an API. Based on the provided pair with the key `type` in these objects a method in `generator.py` is selected to generate the API. The objects are passed to the corresponding method to consume additional key-value pairs.
|
||||
When CI is ran, static files are generated and commited to the `gh-pages` branch.
|
||||
The file `generator.py` provides a list of static file generator classes. Each class has a name.
|
||||
The configuration file `config.json` is read which contains the configuration for the API.
|
||||
By specifying the name of the generator in the `types` array of the configuration, the corresponding generator will be used. The current object of the configuration is passed to the generator.
|
||||
|
||||
The following API configuration generates the `contributor` and `release` API for selected repositories:
|
||||
|
||||
@ -15,7 +15,7 @@ The following API configuration generates the `contributor` and `release` API fo
|
||||
{
|
||||
"api": [
|
||||
{
|
||||
"type": "release+contributor",
|
||||
"types": ["release", "contributor"],
|
||||
"repositories": ["user/repo"]
|
||||
}
|
||||
]
|
||||
|
@ -1,23 +1,31 @@
|
||||
{
|
||||
"api": [
|
||||
{
|
||||
"type": "release+contributor",
|
||||
"types": [
|
||||
"release+contributor"
|
||||
],
|
||||
"repositories": [
|
||||
"user/repo"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "social",
|
||||
"types": [
|
||||
"social"
|
||||
],
|
||||
"socials": {
|
||||
"website": "https://yourwebsite.com"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "team",
|
||||
"types": [
|
||||
"team"
|
||||
],
|
||||
"organization": "yourorg"
|
||||
},
|
||||
{
|
||||
"type": "donation",
|
||||
"types": [
|
||||
"donation"
|
||||
],
|
||||
"links": {
|
||||
"liberapay": "https://liberapay.com/yourteam",
|
||||
"github": "https://github.com/sponsors/yourteam"
|
||||
|
4
main.py
4
main.py
@ -9,9 +9,7 @@ apis = config["api"]
|
||||
api_provider = DefaultApiProvider()
|
||||
|
||||
for api in apis:
|
||||
types = api["type"].split("+")
|
||||
del api["type"] # Don't need the type for the api anymore below
|
||||
for type in types:
|
||||
for type in api["types"]:
|
||||
api_type = api_provider.get(type)
|
||||
if api_type is None:
|
||||
continue
|
||||
|
Loading…
x
Reference in New Issue
Block a user