Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #26 from death-save:v1.1.4
Browse files Browse the repository at this point in the history
v1.1.4
  • Loading branch information
eclarke12 committed Nov 3, 2020
2 parents 91364b7 + 64bad0b commit 54a899b
Show file tree
Hide file tree
Showing 16 changed files with 4,358 additions and 4 deletions.
116 changes: 116 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## [1.1.4] - 2020-11-03
### Added
- Confirmed compatibility with Foundry VTT 0.7.5
- About App (accessible from Module Settings)

## [1.1.3] - 2020-10-06
### Added
- Português (Brasil) translation -- thanks @rinnocenti!
Expand Down
47 changes: 47 additions & 0 deletions about.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* About this module FormApp
* @extends FormApplication
*/
class PinCushionAboutApp extends FormApplication {
constructor(options={}) {
super(options);
}

/**
* Call app default options
* @override
*/
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
id: "pin-cushion-about",
title: `About ${PinCushion.MODULE_TITLE}`,
template: `${PinCushion.PATH}/templates/about.hbs`,
popOut: true,
width: 500,
height: 480
});
}

/**
* Supplies data to the template
*/
async getData() {
return {
moduleName: PinCushion.MODULE_TITLE,
version: game.modules.get(PinCushion.MODULE_NAME).data.version,
patrons: await this.fetchPatrons()
}
}

/**
* Fetches a list of Patrons to display on the About page
*/
async fetchPatrons() {
const jsonPath = `${PinCushion.PATH}/patrons.json`;
const response = await fetch(jsonPath);
if (!response.ok) return null;

const json = await response.json();
return json;
}
}
109 changes: 109 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
const jsdoc2md = require('jsdoc-to-markdown');
const { parallel, series } = require('gulp');
const fs = require('fs');
const zip = require('gulp-zip');
const gulp = require('gulp');
const version = require('./package.json').version;
const fetch = require('node-fetch');

function docs(done) {
jsdoc2md.render({ files: ['modules/*.?(m)js', '*.js'], configure: 'jsdoc-conf.json' })
.then(output => fs.writeFileSync('api.md', output));
return done();
}

async function patrons(done) {

const patrons = await fetchPatrons();
const uniquePatrons = patrons.filter((v, i, a) => {
return a.findIndex(t => (t.attributes.full_name === v.attributes.full_name)) === i;
});

const activePatrons = uniquePatrons.filter(m => m.attributes.patron_status === "active_patron");
const patronList = [];
for (let p of activePatrons) {
const nameParts = p.attributes.full_name.split(" ");
const firstName = nameParts[0];
const lastName = nameParts.length > 1 && nameParts[1].length ? nameParts[1] : "";
const lastInitial = lastName ? lastName.substr(0,1) : "";
const name = lastInitial ? `${firstName} ${lastInitial}` : `${firstName}`;

const patron = {
name
}

patronList.push(patron);
}

fs.writeFileSync('patrons.json', JSON.stringify(patronList, null, 4))
console.log(activePatrons.length);

return done();
}

function build(done) {
gulp.src('module.json')
.pipe(gulp.dest('dist'));

gulp.src([
'**/*',
'!dist/**',
'!out/**',
'!jsdoc/**',
'!node_modules/**',
'!.gitignore',
'!gulpfile.js',
'!package.json',
'!package-lock.json'
])
.pipe(zip(`combat-carousel.zip`))
.pipe(gulp.dest('dist'));
return done();
}

async function fetchPatrons(patrons=[], nextPage=null) {
const accessToken = fs.readFileSync('patreon_key.txt', 'utf-8');
const campaignId = '5254689';
const url = `https://www.patreon.com/api/oauth2/v2/campaigns/${campaignId}/members`;
const query = '?fields%5Bmember%5D=full_name,patron_status';
const pagination = nextPage ? `&page%5Bcursor%5D=${nextPage}` : '';

let myHeaders = new fetch.Headers();
myHeaders.append("Authorization", `Bearer ${accessToken}`);
myHeaders.append("Cookie", "__cfduid=d0ff53e0a0f52232bc3d071e4e41b36f11601349207; patreon_device_id=aa72995a-d296-4e22-8336-fba6580fa49b; __cf_bm=6d8302a7c059da3dc166c9718f7372a386a1911c-1601350627-1800-AXgBmtTqEn83/w2Ka4Mq+ewtUVrvq5+bZppjqM6WDA2ofb1XwF22RNcARQzzHOF2S9K/A2UUeVUnfInGOwqJ6qk=");

const requestOptions = {
method: 'GET',
headers: myHeaders,
redirect: 'follow'
};

const response = await fetch(`${url}${query}${pagination}`, requestOptions);
//console.log(response);
const json = await response.json();
//console.log(json);
const data = json.data;
//console.log(data);
const responseNextPage = json.meta && json.meta.pagination && json.meta.pagination.cursors ? json.meta.pagination.cursors.next : null;
//console.log(responseNextPage);
//console.log(json.meta);
patrons = patrons.concat(data);
//console.log(patrons);

if (responseNextPage) {
const nextPatrons = await fetchPatrons(patrons, responseNextPage);
//console.log(nextPatrons);
patrons = patrons.concat(nextPatrons)
}

console.log(patrons.length);
return patrons;
}

const chores = parallel(patrons, docs);

exports.build = build;
exports.docs = docs;
exports.patrons = patrons;
exports.chores = chores;
exports.default = series(chores, build);
Binary file added img/Digital-Patreon-Logo_FieryCoral.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/Discord-Logo-Color.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/deathsave-newlogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions jsdoc-conf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"source": {
"includePattern": ".+\\.(m|c)?js(doc|x)?$"
},
"plugins": [
"@pixi/jsdoc-template/plugins/es6-fix"
]
}
2 changes: 2 additions & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"SETTINGS.AboutAppN": "About Pin Cushion",
"SETTINGS.AboutAppH": "Displays additional info about Pin Cushion",
"SETTINGS.ShowJournalPreviewN": "Show Journal Preview",
"SETTINGS.ShowJournalPreviewH": "Shows a Journal preview when hovering over a map pin",
"SETTINGS.PreviewTypeN": "Journal Preview Type",
Expand Down
11 changes: 7 additions & 4 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
"name": "pin-cushion",
"title": "Pin Cushion",
"description": "Adds additional map pin functionality",
"version": "1.1.3",
"minimumCoreVersion": "0.6.6",
"compatibleCoreVersion": "0.7.3",
"version": "1.1.4",
"minimumCoreVersion": "0.7.5",
"compatibleCoreVersion": "0.7.5",
"author": "Evan Clarke [errational#2007]",
"url": "https://github.com/death-save/pin-cushion",
"manifest": "https://raw.githubusercontent.com/death-save/pin-cushion/master/module.json",
"download": "https://github.com/death-save/pin-cushion/archive/master.zip",
"scripts": ["./pin-cushion.js"],
"scripts": [
"./pin-cushion.js",
"./about.js"
],
"styles": ["./pin-cushion.css"],
"languages": [
{
Expand Down
Loading

0 comments on commit 54a899b

Please sign in to comment.