mirror of
https://github.com/revanced/revanced-static-api.git
synced 2025-04-30 06:34:30 +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
|
## How it works
|
||||||
|
|
||||||
On CI trigger static files are generated and commited to the `gh-pages` branch.
|
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 static files are generated by the configuration provided in a `config.json` file in the root.
|
The configuration file `config.json` is read which contains the configuration for the API.
|
||||||
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.
|
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:
|
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": [
|
"api": [
|
||||||
{
|
{
|
||||||
"type": "release+contributor",
|
"types": ["release", "contributor"],
|
||||||
"repositories": ["user/repo"]
|
"repositories": ["user/repo"]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -1,23 +1,31 @@
|
|||||||
{
|
{
|
||||||
"api": [
|
"api": [
|
||||||
{
|
{
|
||||||
"type": "release+contributor",
|
"types": [
|
||||||
|
"release+contributor"
|
||||||
|
],
|
||||||
"repositories": [
|
"repositories": [
|
||||||
"user/repo"
|
"user/repo"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "social",
|
"types": [
|
||||||
|
"social"
|
||||||
|
],
|
||||||
"socials": {
|
"socials": {
|
||||||
"website": "https://yourwebsite.com"
|
"website": "https://yourwebsite.com"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "team",
|
"types": [
|
||||||
|
"team"
|
||||||
|
],
|
||||||
"organization": "yourorg"
|
"organization": "yourorg"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "donation",
|
"types": [
|
||||||
|
"donation"
|
||||||
|
],
|
||||||
"links": {
|
"links": {
|
||||||
"liberapay": "https://liberapay.com/yourteam",
|
"liberapay": "https://liberapay.com/yourteam",
|
||||||
"github": "https://github.com/sponsors/yourteam"
|
"github": "https://github.com/sponsors/yourteam"
|
||||||
|
4
main.py
4
main.py
@ -9,9 +9,7 @@ apis = config["api"]
|
|||||||
api_provider = DefaultApiProvider()
|
api_provider = DefaultApiProvider()
|
||||||
|
|
||||||
for api in apis:
|
for api in apis:
|
||||||
types = api["type"].split("+")
|
for type in api["types"]:
|
||||||
del api["type"] # Don't need the type for the api anymore below
|
|
||||||
for type in types:
|
|
||||||
api_type = api_provider.get(type)
|
api_type = api_provider.get(type)
|
||||||
if api_type is None:
|
if api_type is None:
|
||||||
continue
|
continue
|
||||||
|
Loading…
x
Reference in New Issue
Block a user