-
Notifications
You must be signed in to change notification settings - Fork 0
Set Repositories
ShiraKamiSRS uses a repository system for users to discover new card sets to add. By default, every ShiraKamiSRS instance is loaded up with the main public repository. Users can add third-party repositories to ShiraKamiSRS to gain access to more sets hosted within these repositories.
Table of Contents:
Anyone can host a custom set repository to share around. A repository in its most basic form is just a webserver that hosts some set export json files, with an index file for ShiraKamiSRS to read.
In the future it might be made possible to host public repositories from ShiraKamiSRS itself, removing the need for users to host the repository themselves, and lowering the barrier to entry.
The easiest way to host your own repository, is by forking the repository template and hosting the files from GitHub using GitHub Pages.
As a prerequisite, make sure you have a recent version of NodeJS (and npm) installed on your local machine.
-
Start by forking the repository template.
-
Clone it to your local machine with
git clone <git_url>
. -
Export any sets you want your repository to host from ShiraKamiSRS
-
Place all your exported set json files into
repository/sets/
. -
Run
npm install
in the root of the repository. -
Run
npm run build
to generate the repository index file. -
Make some changes in the now generated
repository/index.json
file.- Change the
name
property to what you want your repository to be named when loaded within ShiraKamiSRS. - (Optionally) fill the
imageUrl
property with the url for an image you would like to display as your repository icon within ShiraKamiSRS. - (Optionally) fill the
homePageUrl
property with a url to the homepage of your set. - (Optionally) fill the
description
property for each set.
- Change the
-
Commit your changes and push them to the GitHub repository.
-
Go to your GitHub repository settings, scroll down and enable GitHub Pages for your repository on the root level.
Your repository should now be available to use with any ShiraKamiSRS instance using the url:
https://<GITHUB_USERNAME>.github.io/<GITHUB_REPOSITORY_NAME>/repository/
To update the repository:
- Start by adding, removing, or changing any sets.
- Run
npm run build
again in the root of your repository to update your existing repository index file. Old customizations will persist. - Optionally make your desired changes in
repository/index.json
. - Commit your changes and push them to the GitHub repository.
You're done! It can take a few minutes before ShiraKamiSRS instances stop caching the old index of your repository.
You do not have to host your set repository on GitHub, or even use the template if you do not want to. If you have your own webserver, you can simply host the files yourself. The publicly accessible url to access the index file is your repository URL.
Even when hosting the repository yourself, the simplest option is still to use the repository template:
Simply follow the instructions in the section above, and host the files within the repository
folder on your own webserver.
In case you want to manually write the repository index file rather than use the repository template to generate it, the format is described below.
A good idea could be to look at an example index file.
RepositoryIndex
Key | Value type | Required | Description |
---|---|---|---|
version |
"v1" | Yes | Describes the version of the repository index specification used. |
publicId |
String | Yes | A unique identifier for your repository. Usually a UUID. It is recommended to randomly generate this property to avoid any overlap with other repositories. |
name |
String | Yes | The name for your repository, as shown in ShiraKamiSRS. |
imageUrl |
String | No | The url for the image to be shown as the icon for your repository. |
homePageUrl |
String | No | The home page url for your set. |
sets |
RepositoryIndexSet[] | Yes | An array of set references |
RepositoryIndexSet
Key | Value type | Required | Description |
---|---|---|---|
name |
String | Yes | The name of the set. Should match the name specified in the set export. |
exportVersion |
String | Yes | The version of the set export. Should match the version specified in the set export. |
description |
String | No | A description for the set to be shown in the repository listing in ShiraKamiSRS. |
modes |
ReviewMode[] | Yes | An array of the supported/default set modes. Should match the modes specified in the set export. |
cardCount |
Number | Yes | The amount of cards in the set. Should match the amount of cards specified in the set export. |
file |
String | Yes | A relative path to the set export file. |
ReviewMode
ReviewMode
is a string enum, and should be one of the following values:
enToJp
jpToEn
kanjiToKana
export interface RepositoryIndex {
version: 'v1';
publicId: string;
name: string;
imageUrl?: string;
homePageUrl?: string;
sets: RepositoryIndexSet[];
}
export interface RepositoryIndexSet {
name: string;
exportVersion: string;
description?: string;
modes: ReviewMode[];
cardCount: number;
file: string;
}
export type ReviewMode = 'enToJp' | 'jpToEn' | 'kanjiToKana';