diff --git a/config.ini.example b/config.ini.example index 20893d4..f2a0106 100644 --- a/config.ini.example +++ b/config.ini.example @@ -39,3 +39,16 @@ default-amount=10 # Pick between "monthly" and "once" default-type=monthly + +# Display monthly donations publically +public-income=yes + +# How much are you hoping to earn monthly, in cents +goal=500 + +# Optional Patreon integration +# Register a client here: https://www.patreon.com/portal/registration/register-clients +# And put in the "Creator's Access Token" here: +patreon-access-token= +# And the Patreon campaign you want to connect with: +patreon-campaign= diff --git a/fosspay/app.py b/fosspay/app.py index d50fe5a..5753235 100644 --- a/fosspay/app.py +++ b/fosspay/app.py @@ -75,5 +75,6 @@ def inject(): '_cfg': _cfg, '_cfgi': _cfgi, 'debug': app.debug, - 'str': str + 'str': str, + 'int': int } diff --git a/fosspay/blueprints/html.py b/fosspay/blueprints/html.py index c8abe81..bbd97a8 100644 --- a/fosspay/blueprints/html.py +++ b/fosspay/blueprints/html.py @@ -30,8 +30,34 @@ def index(): selected_project = int(selected_project) except: selected_project = None + active_recurring = (Donation.query + .filter(Donation.type == DonationType.monthly) + .filter(Donation.active == True)) + recurring_count = active_recurring.count() + recurring_sum = sum([d.amount for d in active_recurring]) + + access_token = _cfg("patreon-access-token") + campaign = _cfg("patreon-campaign") + if access_token and campaign: + import patreon + client = patreon.API(access_token) + campaign = client.fetch_campaign() + attrs = campaign.json_data["data"][0]["attributes"] + patreon_count = attrs["patron_count"] + patreon_sum = attrs["pledge_sum"] + else: + patreon_count = 0 + patreon_sum = 0 + + recurring_count = 1 + recurring_sum = 5000 + return render_template("index.html", projects=projects, - avatar=avatar, selected_project=selected_project) + avatar=avatar, selected_project=selected_project, + recurring_count=recurring_count, + recurring_sum=recurring_sum, + patreon_count=patreon_count, + patreon_sum=patreon_sum) @html.route("/setup", methods=["POST"]) def setup(): diff --git a/templates/goal-summary.html b/templates/goal-summary.html new file mode 100644 index 0000000..f472771 --- /dev/null +++ b/templates/goal-summary.html @@ -0,0 +1,4 @@ +{# + This is a little blurb you can write to explain why your goal is set to what + it is. +#} diff --git a/templates/goal.html b/templates/goal.html new file mode 100644 index 0000000..02c830e --- /dev/null +++ b/templates/goal.html @@ -0,0 +1,71 @@ +{% if _cfg("public-income") == "yes" %} +
+ ${{ "{:.2f}".format(recurring_sum / 100) }}/mo + via {{ domain }} + ({{ recurring_count }} supporter{{ "s" if recurring_count != 1 else "" }}) +
++ ${{ "{:.2f}".format(patreon_sum / 100) }}/mo + via + + Patreon + ({{ patreon_count }} supporter{{ "s" if patreon_count != 1 else "" }}) +
+ {% endif %} + {% if goal %} ++ ${{ "{:.2f}".format(total_sum / 100)}}/mo + of + ${{ "{:.2f}".format(goal / 100) }}/mo + goal +
+ {% else %} ++ Supported with ${{ "{:.2f}".format(total_sum / 100) }} + from {{ total_count }} supporters! +
+ {% endif %} +You can make changes and refresh this page if you like.
diff --git a/templates/summary.html b/templates/summary.html index ab9a7e2..0ff4baf 100644 --- a/templates/summary.html +++ b/templates/summary.html @@ -3,7 +3,3 @@ the donation UI and will reduce the number of conversions you actually get. #} - --As donations permit, I will take leave from my day job, a week at a time, to work on these projects. -