kosmos/akkounts-web
kosmos
/
akkounts-web
Archived
8
1
Fork 0

Basic Mastodon signup

This commit is contained in:
Basti 2019-03-12 14:00:48 +07:00
parent b679058b01
commit fe652fd276
No known key found for this signature in database
GPG Key ID: BE4634D632D39B67
18 changed files with 347 additions and 93 deletions

4
app/controllers/index.js Normal file
View File

@ -0,0 +1,4 @@
import Controller from '@ember/controller';
export default Controller.extend({
});

View File

@ -0,0 +1,70 @@
import Controller from '@ember/controller';
import { computed } from '@ember/object';
import { isEmpty, isPresent } from '@ember/utils';
export default Controller.extend({
emailAddress: '',
amount: 24,
currency: 'USD',
invoiceId: null,
invoiceStatus: null,
init () {
this._super(...arguments)
window.btcpay.onModalWillLeave(() => {
fetch(`http://localhost:3200/accounts/mastodon/invoices/${this.invoiceId}`, {
headers:{ 'Content-Type': 'application/json' }
}).then(res => res.json())
.then(invoice => {
this.set('invoiceStatus', invoice.status);
});
})
},
invoiceNotCreated: computed('invoiceId', function () {
return isEmpty(this.invoiceId);
}),
invoiceUnpaid: computed('invoiceId', 'invoiceStatus', function () {
return isPresent(this.invoiceId) &&
this.invoiceStatus !== 'complete';
}),
invoicePaid: computed('invoiceId', 'invoiceStatus', function () {
return isPresent(this.invoiceId) &&
this.invoiceStatus === 'complete';
}),
actions: {
createInvoice () {
const amount = parseFloat(this.amount);
// TODO validate input
if (isPresent(this.invoiceId)) {
return window.btcpay.showInvoice(this.invoiceId);
}
fetch('http://localhost:3200/accounts/mastodon/invoices', {
method: 'POST',
body: JSON.stringify({
email: this.emailAddress,
price: amount,
currency: this.currency
}),
headers:{
'Content-Type': 'application/json'
}
})
.then(res => res.json())
.then(res => {
this.set('invoiceId', res.invoice.id);
window.btcpay.showInvoice(this.invoiceId);
})
}
}
});

View File

@ -16,5 +16,6 @@
<script src="{{rootURL}}assets/vendor.js"></script>
<script src="{{rootURL}}assets/akkounts-web.js"></script>
{{content-for "body-footer"}}
<script src ="http://andromeda.kosmos.org:23001/modal/btcpay.js"></script>
</body>
</html>

View File

@ -7,6 +7,9 @@ const Router = EmberRouter.extend({
});
Router.map(function() {
this.route('mastodon', function() {
this.route('signup');
});
});
export default Router;

4
app/routes/index.js Normal file
View File

@ -0,0 +1,4 @@
import Route from '@ember/routing/route';
export default Route.extend({
});

View File

@ -0,0 +1,4 @@
import Route from '@ember/routing/route';
export default Route.extend({
});

View File

@ -0,0 +1,30 @@
fieldset {
border: none;
}
body {
font-size: 16px;
text-align: center;
}
main {
margin: 5rem auto;
}
p {
margin-bottom: 2rem;
}
input#email, input#amount {
padding: 1rem;
font-size: 1.25rem;
font-family: sans-serif;
}
input#email {
width: 300px;
}
input#amount {
width: 100px;
}

View File

@ -1 +1,3 @@
{{outlet}}
<main>
{{outlet}}
</main>

1
app/templates/index.hbs Normal file
View File

@ -0,0 +1 @@
{{#link-to "mastodon.signup"}}Mastodon sign-up{{/link-to}}

View File

@ -0,0 +1,46 @@
{{#if invoiceNotCreated}}
<form {{action "createInvoice" on="submit"}}>
<fieldset>
<p>
<label for="email">Tell us an email address, where we can send the invite:</label>
</p>
<p>
{{input type="email" value=emailAddress id="email"}}
</p>
</fieldset>
<fieldset>
<p>
<label for="amount">Select your donation amount:</label>
</p>
<p>
{{input type="number" value=amount id="amount"}} USD
</p>
</fieldset>
<p>
<input type="submit" value="continue to payment">
</p>
</form>
{{/if}}
{{#if invoiceUnpaid}}
<p>
Waiting for donation payment to be completed
</p>
<form {{action "createInvoice" on="submit"}}>
<p>
<input type="submit" value="re-open payment dialog">
</p>
</form>
{{/if}}
{{#if invoicePaid}}
<p>
Thanks for your donation!
</p>
<p>
An invite link is on the way to {{emailAddress}}.
</p>
<p>
<img src="/img/youre-awesome.gif" alt="Carl Sagan says: you're awesome.">
</p>
{{/if}}

View File

@ -4,7 +4,14 @@ const EmberApp = require('ember-cli/lib/broccoli/ember-app');
module.exports = function(defaults) {
let app = new EmberApp(defaults, {
// Add options here
'ember-fetch': {
preferNative: true
},
fingerprint: {
exclude: [
'public/img/'
],
},
});
// Use `app.import` to add additional libraries to the generated

216
package-lock.json generated
View File

@ -1363,6 +1363,12 @@
"integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
"dev": true
},
"abortcontroller-polyfill": {
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/abortcontroller-polyfill/-/abortcontroller-polyfill-1.2.5.tgz",
"integrity": "sha512-vhu1mYi7ANQZE0K7BBjcOTQZWkH/mzyGVXFqCr05piYuKJQjWcD9Nu3qIM5B7qKSPzqRv+2cQOoCFv6eMP4w5Q==",
"dev": true
},
"accepts": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz",
@ -3323,6 +3329,19 @@
}
}
},
"broccoli-templater": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/broccoli-templater/-/broccoli-templater-2.0.2.tgz",
"integrity": "sha512-71KpNkc7WmbEokTQpGcbGzZjUIY1NSVa3GB++KFKAfx5SZPUozCOsBlSTwxcv8TLoCAqbBnsX5AQPgg6vJ2l9g==",
"dev": true,
"requires": {
"broccoli-plugin": "^1.3.1",
"fs-tree-diff": "^0.5.9",
"lodash.template": "^4.4.0",
"rimraf": "^2.6.2",
"walk-sync": "^0.3.3"
}
},
"broccoli-uglify-sourcemap": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/broccoli-uglify-sourcemap/-/broccoli-uglify-sourcemap-2.2.0.tgz",
@ -3509,6 +3528,31 @@
"tmp": "0.0.28"
}
},
"caniuse-api": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/caniuse-api/-/caniuse-api-3.0.0.tgz",
"integrity": "sha512-bsTwuIg/BZZK/vreVTYYbSWoe2F+71P7K5QGEX+pT250DZbfU1MQ5prOKpPR+LL6uWKK3KMwMCAS74QB3Um1uw==",
"dev": true,
"requires": {
"browserslist": "^4.0.0",
"caniuse-lite": "^1.0.0",
"lodash.memoize": "^4.1.2",
"lodash.uniq": "^4.5.0"
},
"dependencies": {
"browserslist": {
"version": "4.4.2",
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.4.2.tgz",
"integrity": "sha512-ISS/AIAiHERJ3d45Fz0AVYKkgcy+F/eJHzKEvv1j0wwKGKD9T3BrwKr/5g45L+Y4XIK5PlTqefHciRFcfE1Jxg==",
"dev": true,
"requires": {
"caniuse-lite": "^1.0.30000939",
"electron-to-chromium": "^1.3.113",
"node-releases": "^1.1.8"
}
}
}
},
"caniuse-lite": {
"version": "1.0.30000942",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000942.tgz",
@ -5351,6 +5395,69 @@
}
}
},
"ember-fetch": {
"version": "6.4.0",
"resolved": "https://registry.npmjs.org/ember-fetch/-/ember-fetch-6.4.0.tgz",
"integrity": "sha512-/GtJWQiUAAOX2HMGuLrWQMNWO9YRNH9+AiMzZYc5PrTHKdv+Ib5fciysz0+e97Dj9vyvF2mQa49mrosAPW9ziQ==",
"dev": true,
"requires": {
"abortcontroller-polyfill": "^1.2.1",
"broccoli-concat": "^3.2.2",
"broccoli-debug": "^0.6.5",
"broccoli-merge-trees": "^3.0.0",
"broccoli-rollup": "^2.1.1",
"broccoli-stew": "^2.0.0",
"broccoli-templater": "^2.0.1",
"calculate-cache-key-for-tree": "^1.1.0",
"caniuse-api": "^3.0.0",
"ember-cli-babel": "^6.8.2",
"node-fetch": "^2.3.0",
"whatwg-fetch": "^3.0.0"
},
"dependencies": {
"broccoli-merge-trees": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/broccoli-merge-trees/-/broccoli-merge-trees-3.0.2.tgz",
"integrity": "sha512-ZyPAwrOdlCddduFbsMyyFzJUrvW6b04pMvDiAQZrCwghlvgowJDY+EfoXn+eR1RRA5nmGHJ+B68T63VnpRiT1A==",
"dev": true,
"requires": {
"broccoli-plugin": "^1.3.0",
"merge-trees": "^2.0.0"
}
},
"ember-cli-babel": {
"version": "6.18.0",
"resolved": "https://registry.npmjs.org/ember-cli-babel/-/ember-cli-babel-6.18.0.tgz",
"integrity": "sha512-7ceC8joNYxY2wES16iIBlbPSxwKDBhYwC8drU3ZEvuPDMwVv1KzxCNu1fvxyFEBWhwaRNTUxSCsEVoTd9nosGA==",
"dev": true,
"requires": {
"amd-name-resolver": "1.2.0",
"babel-plugin-debug-macros": "^0.2.0-beta.6",
"babel-plugin-ember-modules-api-polyfill": "^2.6.0",
"babel-plugin-transform-es2015-modules-amd": "^6.24.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.7.0",
"broccoli-babel-transpiler": "^6.5.0",
"broccoli-debug": "^0.6.4",
"broccoli-funnel": "^2.0.0",
"broccoli-source": "^1.1.0",
"clone": "^2.0.0",
"ember-cli-version-checker": "^2.1.2",
"semver": "^5.5.0"
}
},
"merge-trees": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/merge-trees/-/merge-trees-2.0.0.tgz",
"integrity": "sha512-5xBbmqYBalWqmhYm51XlohhkmVOua3VAUrrWh8t9iOkaLpS6ifqm/UVuUjQCeDVJ9Vx3g2l6ihfkbLSTeKsHbw==",
"dev": true,
"requires": {
"fs-updater": "^1.0.4",
"heimdalljs": "^0.2.5"
}
}
}
},
"ember-inflector": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/ember-inflector/-/ember-inflector-3.0.0.tgz",
@ -5795,97 +5902,6 @@
}
}
},
"ember-welcome-page": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/ember-welcome-page/-/ember-welcome-page-3.2.0.tgz",
"integrity": "sha512-aDUIGwPsAvv77K6jplnIvQamNBOuqRKlSXsaWaIkjpIi4ZTbDLnyDkuxMBgxCKiajr7wGhrghAelRQHbKUK5aw==",
"dev": true,
"requires": {
"broccoli-funnel": "^1.0.1",
"ember-cli-babel": "^6.6.0",
"ember-cli-htmlbars": "^2.0.3"
},
"dependencies": {
"broccoli-funnel": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/broccoli-funnel/-/broccoli-funnel-1.2.0.tgz",
"integrity": "sha1-zdw6/F/xaFqAI0iP/3TOb7WlEpY=",
"dev": true,
"requires": {
"array-equal": "^1.0.0",
"blank-object": "^1.0.1",
"broccoli-plugin": "^1.3.0",
"debug": "^2.2.0",
"exists-sync": "0.0.4",
"fast-ordered-set": "^1.0.0",
"fs-tree-diff": "^0.5.3",
"heimdalljs": "^0.2.0",
"minimatch": "^3.0.0",
"mkdirp": "^0.5.0",
"path-posix": "^1.0.0",
"rimraf": "^2.4.3",
"symlink-or-copy": "^1.0.0",
"walk-sync": "^0.3.1"
}
},
"ember-cli-babel": {
"version": "6.18.0",
"resolved": "https://registry.npmjs.org/ember-cli-babel/-/ember-cli-babel-6.18.0.tgz",
"integrity": "sha512-7ceC8joNYxY2wES16iIBlbPSxwKDBhYwC8drU3ZEvuPDMwVv1KzxCNu1fvxyFEBWhwaRNTUxSCsEVoTd9nosGA==",
"dev": true,
"requires": {
"amd-name-resolver": "1.2.0",
"babel-plugin-debug-macros": "^0.2.0-beta.6",
"babel-plugin-ember-modules-api-polyfill": "^2.6.0",
"babel-plugin-transform-es2015-modules-amd": "^6.24.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.7.0",
"broccoli-babel-transpiler": "^6.5.0",
"broccoli-debug": "^0.6.4",
"broccoli-funnel": "^2.0.0",
"broccoli-source": "^1.1.0",
"clone": "^2.0.0",
"ember-cli-version-checker": "^2.1.2",
"semver": "^5.5.0"
},
"dependencies": {
"broccoli-funnel": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/broccoli-funnel/-/broccoli-funnel-2.0.2.tgz",
"integrity": "sha512-/vDTqtv7ipjEZQOVqO4vGDVAOZyuYzQ/EgGoyewfOgh1M7IQAToBKZI0oAQPgMBeFPPlIbfMuAngk+ohPBuaHQ==",
"dev": true,
"requires": {
"array-equal": "^1.0.0",
"blank-object": "^1.0.1",
"broccoli-plugin": "^1.3.0",
"debug": "^2.2.0",
"fast-ordered-set": "^1.0.0",
"fs-tree-diff": "^0.5.3",
"heimdalljs": "^0.2.0",
"minimatch": "^3.0.0",
"mkdirp": "^0.5.0",
"path-posix": "^1.0.0",
"rimraf": "^2.4.3",
"symlink-or-copy": "^1.0.0",
"walk-sync": "^0.3.1"
}
}
}
},
"ember-cli-htmlbars": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/ember-cli-htmlbars/-/ember-cli-htmlbars-2.0.5.tgz",
"integrity": "sha512-3f3PAxdnQ/fhQa8XP/3z4RLRgLHxV8j4Ln75aHbRdemOCjBa048KxL9l+acRLhCulbGQCMnLiIUIC89PAzLrcA==",
"dev": true,
"requires": {
"broccoli-persistent-filter": "^1.4.3",
"hash-for-dep": "^1.2.3",
"json-stable-stringify": "^1.0.0",
"strip-bom": "^3.0.0"
}
}
}
},
"encodeurl": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
@ -9021,6 +9037,12 @@
"lodash.isobject": "~2.3.0"
}
},
"lodash.memoize": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz",
"integrity": "sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4=",
"dev": true
},
"lodash.merge": {
"version": "4.6.1",
"resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.1.tgz",
@ -9569,6 +9591,12 @@
"lower-case": "^1.1.1"
}
},
"node-fetch": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.3.0.tgz",
"integrity": "sha512-MOd8pV3fxENbryESLgVIeaGKrdl+uaYhCSSVkjeOb/31/njTpcis5aWfdqgNlHIrKOLRbMnfPINPOML2CIFeXA==",
"dev": true
},
"node-int64": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz",
@ -12131,6 +12159,12 @@
"integrity": "sha512-nqHUnMXmBzT0w570r2JpJxfiSD1IzoI+HGVdd3aZ0yNi3ngvQ4jv1dtHt5VGxfI2yj5yqImPhOK4vmIh2xMbGg==",
"dev": true
},
"whatwg-fetch": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz",
"integrity": "sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q==",
"dev": true
},
"which": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz",

View File

@ -35,6 +35,7 @@
"ember-cli-uglify": "^2.1.0",
"ember-data": "~3.8.0",
"ember-export-application-global": "^2.0.0",
"ember-fetch": "^6.4.0",
"ember-load-initializers": "^1.1.0",
"ember-maybe-import-regenerator": "^0.1.6",
"ember-qunit": "^3.4.1",

Binary file not shown.

After

Width:  |  Height:  |  Size: 467 KiB

View File

@ -0,0 +1,12 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Controller | index', function(hooks) {
setupTest(hooks);
// Replace this with your real tests.
test('it exists', function(assert) {
let controller = this.owner.lookup('controller:index');
assert.ok(controller);
});
});

View File

@ -0,0 +1,13 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Controller | mastodon/signup', function(hooks) {
setupTest(hooks);
window.btcpay = { onModalWillLeave (/* cb */) {} }
// Replace this with your real tests.
test('it exists', function(assert) {
let controller = this.owner.lookup('controller:mastodon/signup');
assert.ok(controller);
});
});

View File

@ -0,0 +1,11 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Route | index', function(hooks) {
setupTest(hooks);
test('it exists', function(assert) {
let route = this.owner.lookup('route:index');
assert.ok(route);
});
});

View File

@ -0,0 +1,11 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Route | mastodon/signup', function(hooks) {
setupTest(hooks);
test('it exists', function(assert) {
let route = this.owner.lookup('route:mastodon/signup');
assert.ok(route);
});
});