commit
6c7c28e44d
8 changed files with 3741 additions and 71 deletions
18
.github/workflows/documentation.yml
vendored
Normal file
18
.github/workflows/documentation.yml
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
name: Generate documentation
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Use Node.js 14.x
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 14.x
|
||||
- run: npm run docs:deploy
|
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -103,4 +103,6 @@ dist
|
|||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
diskcache/
|
||||
diskcache/
|
||||
|
||||
docs/
|
|
@ -1 +1,4 @@
|
|||
index.js
|
||||
docs/
|
||||
gh-pages.js
|
||||
.github/
|
|
@ -78,10 +78,20 @@ const infoTextBigStartY = infoTextSmallStartY + 25;
|
|||
const infoTextSpacing = 50;
|
||||
|
||||
class CardCreator {
|
||||
/**
|
||||
* Creates a new card creator.
|
||||
* @constructor
|
||||
*/
|
||||
constructor() {
|
||||
this.isInit = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that the instance is ready to generate character cards.
|
||||
* This function must be resolved before using character card
|
||||
* generation methods.
|
||||
* @returns {Promise} A promise representing the initialization state of this generator.
|
||||
*/
|
||||
async ensureInit() {
|
||||
if (this.isInit) {
|
||||
return;
|
||||
|
@ -236,6 +246,23 @@ class CardCreator {
|
|||
return num;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a character card for a character.
|
||||
* @param {number | string} charaId The Lodestone ID of the character to generate a card for.
|
||||
* @example
|
||||
* const fs = require("fs");
|
||||
*
|
||||
* const card = new CardCreator();
|
||||
* const lodestoneId = "13821878";
|
||||
*
|
||||
* await card.ensureInit();
|
||||
* const png = await card.createCard(lodestoneId);
|
||||
*
|
||||
* fs.writeFile("./test.png", png, err => {
|
||||
* if (err) console.error(err);
|
||||
* });
|
||||
* @returns {Promise<Buffer>} A promise representating the construction of the card's image data.
|
||||
*/
|
||||
async createCard(charaId) {
|
||||
var response = await fetch(`https://xivapi.com/character/${charaId}?extended=1&data=FC,mimo`);
|
||||
var data = await response.json();
|
||||
|
|
6
gh-pages.js
Normal file
6
gh-pages.js
Normal file
|
@ -0,0 +1,6 @@
|
|||
const ghpages = require("gh-pages");
|
||||
ghpages.publish("docs/", (err) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
}
|
||||
});
|
3742
package-lock.json
generated
3742
package-lock.json
generated
File diff suppressed because it is too large
Load diff
10
package.json
10
package.json
|
@ -10,14 +10,20 @@
|
|||
],
|
||||
"scripts": {
|
||||
"start": "node index.js",
|
||||
"dev": "nodemon index.js"
|
||||
"dev": "nodemon index.js",
|
||||
"docs:generate": "jsdoc create-card.js -d docs -R readme.md",
|
||||
"docs:deploy": "npm run docs:generate && node gh-pages.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"cache-manager-fs": "^1.0.8",
|
||||
"cache-manager-fs-binary": "^1.0.4",
|
||||
"canvas": "^2.6.1",
|
||||
"express": "^4.17.1",
|
||||
"node-fetch": "^2.6.1",
|
||||
"node-fetch": "^2.6.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gh-pages": "^3.2.0",
|
||||
"jsdoc": "^3.6.7",
|
||||
"nodemon": "^2.0.7"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
# XIV Character Cards
|
||||

|
||||
[](https://xivapi.github.io/XIV-Character-Cards/)
|
||||
|
||||
API to create fancy cards for FFXIV characters based on their Lodestone data, hosted at https://ffxiv-character-cards.herokuapp.com.
|
||||
|
||||
|
|
Loading…
Reference in a new issue