Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscriptions billed monthly for premium membership #173

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions app/usecases/funcmap/funcmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import (
"zxq.co/ripple/playstyle"
)

const PREMIUM_PRICE_PER_MONTH = 5.0

// funcMap contains useful functions for the various templates.
var FuncMap = template.FuncMap{
"print": fmt.Println,
Expand Down Expand Up @@ -436,13 +438,9 @@ var FuncMap = template.FuncMap{
"shift": func(n1, n2 int) int {
return n1 << uint(n2)
},
// calculateDonorPrice calculates the price of x donor months in euros.
"calculateDonorPrice": func(a float64) string {
return fmt.Sprintf("%.2f", math.Pow(a*30*0.2, 0.72)) //20 2nd arg for 66%
},
// calculatePremiumPrice calculates the price of x premium months in euros.
"calculatePremiumPrice": func(a float64) string {
return fmt.Sprintf("%.2f", math.Pow(a*68*0.15, 0.93)) //44 2nd arg for 66%
"calculatePremiumPrice": func(months float64) string {
return fmt.Sprintf("%.2f", months * PREMIUM_PRICE_PER_MONTH)
},
// csrfGenerate creates a csrf token input
"csrfGenerate": func(u int) template.HTML {
Expand Down
55 changes: 0 additions & 55 deletions internal/btcconversions/btcconversions.go

This file was deleted.

3 changes: 0 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import (
settingsState "github.com/osuAkatsuki/hanayo/app/states/settings"
tu "github.com/osuAkatsuki/hanayo/app/usecases/templates"
"github.com/osuAkatsuki/hanayo/app/version"
"github.com/osuAkatsuki/hanayo/internal/btcconversions"
"github.com/osuAkatsuki/hanayo/internal/csrf/cieca"
"github.com/thehowl/qsql"
gintrace "gopkg.in/DataDog/dd-trace-go.v1/contrib/gin-gonic/gin"
Expand Down Expand Up @@ -240,8 +239,6 @@ func generateEngine() *gin.Engine {
profileEditHandlers.ProfileBackgroundSubmitHandler,
)

r.GET("/donate/rates", btcconversions.GetRates)

r.GET("/about", miscHandlers.AboutPageHandler)

tu.LoadSimplePages(r)
Expand Down
89 changes: 19 additions & 70 deletions web/src/js/akatsuki_src.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

// this object contains tiny snippets that were deemed too small to be worth
// their own file.

const PREMIUM_PRICE_PER_MONTH = 5.0;

var singlePageSnippets = {
"/clans": function () {
page = 0 === page ? 1 : page;
Expand Down Expand Up @@ -517,48 +520,6 @@ var singlePageSnippets = {
});
},

"/support": function () {
var sl = $("#months-slider")[0];
noUiSlider.create(sl, {
start: [1],
step: 1,
connect: [true, false],
range: {
min: [1],
max: [36],
},
});
var rates = {};
var us = sl.noUiSlider;
$.getJSON("/donate/rates", function (data) {
rates = data;
us.on("update", function () {
var months = us.get();
var priceEUR = Math.pow(months * 30 * 0.2, 0.72); // 2nd arg: 20 for 66%
var priceBTC = priceEUR / rates.EUR;
var priceUSD = priceBTC * rates.USD;
$("#cost").html(
T("<b>{{ months }}</b> month costs <b>€ {{ eur }}</b>", {
count: Math.round(+months),
months: (+months).toFixed(0),
eur: priceEUR.toFixed(2),
}) +
"<br>" +
T("($ {{ usd }} / BTC {{ btc }})", {
usd: priceUSD.toFixed(2),
btc: priceBTC.toFixed(10),
})
);
$("input[name='os0']").attr(
"value",
(+months).toFixed(0) + " month" + (months == 1 ? "" : "s")
);
$("#bitcoin-amt").text(priceBTC.toFixed(6));
$("#paypal-amt").val(priceEUR.toFixed(2));
});
});
},

"/premium": function () {
var sl = $("#months-slider")[0];
noUiSlider.create(sl, {
Expand All @@ -567,37 +528,25 @@ var singlePageSnippets = {
connect: [true, false],
range: {
min: [1],
max: [36],
max: [50],
},
});
var rates = {};
var us = sl.noUiSlider;
$.getJSON("/donate/rates", function (data) {
rates = data;
us.on("update", function () {
var months = us.get();
var priceEUR = Math.pow(months * 68 * 0.15, 0.93); // 2nd arg: 44 for 66%
var priceBTC = priceEUR / rates.EUR;
var priceUSD = priceBTC * rates.USD;
$("#cost").html(
T("<b>{{ months }}</b> month costs <b>€ {{ eur }}</b>", {
count: Math.round(+months),
months: (+months).toFixed(0),
eur: priceEUR.toFixed(2),
}) +
"<br>" +
T("($ {{ usd }} / BTC {{ btc }})", {
usd: priceUSD.toFixed(2),
btc: priceBTC.toFixed(10),
})
);
$("input[name='os0']").attr(
"value",
(+months).toFixed(0) + " month" + (months == 1 ? "" : "s")
);
$("#bitcoin-amt").text(priceBTC.toFixed(6));
$("#paypal-amt").val(priceEUR.toFixed(2));
});
us.on("update", function () {
var months = us.get();
var priceUSD = months * PREMIUM_PRICE_PER_MONTH;
$("#cost").html(
T("<b>{{ months }}</b> {{ monthSpelling }} costs <b>${{ amount }} USD</b>", {
monthSpelling: months == 1 ? T("month") : T("months"),
months: (+months).toFixed(0),
amount: priceUSD.toFixed(2),
})
);
$("input[name='os0']").attr(
"value",
(+months).toFixed(0) + " month" + (months == 1 ? "" : "s")
);
$("#paypal-amt").val(priceUSD.toFixed(2));
});
},

Expand Down
2 changes: 1 addition & 1 deletion web/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@

<div id="messages-container">
<noscript>
Research has proven this website works 10000% better if you have
Research has proven this website works 727% better if you have
JavaScript enabled.
</noscript>
{{ if and .Context.User.Username (not (has .Context.User.Privileges 1)) }}
Expand Down
51 changes: 0 additions & 51 deletions web/templates/donate.html

This file was deleted.

2 changes: 1 addition & 1 deletion web/templates/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
{{ end }}
{{ end }}
<div class="firetrucking-right-menu">
{{ navbarItem .Path (printf "<span data-tooltip=\"Support us! (♥ω♥ ) ~♪\" data-position=\"bottom right\"><i class=\"red heart icon m-less\"></i></span>") "/donate" }}
{{ navbarItem .Path (printf "<span data-tooltip=\"Support us! (♥ω♥ ) ~♪\" data-position=\"bottom right\"><i class=\"red heart icon m-less\"></i></span>") "/premium" }}


<div class="item">
Expand Down
Loading