experimental support for site tipping integration via paypal or bitcoin

This commit is contained in:
Kyle Drake 2016-12-25 13:40:35 -06:00
parent 119381c222
commit 571e445dc3
10 changed files with 146 additions and 2 deletions

View file

@ -62,6 +62,7 @@
$("a#like").tooltip({html: true})
$("a.comment_like").tooltip({html: true})
$('#shareButton').popover({html: true})
$('#tipButton').popover({html: true})
$('.typeahead').typeahead({
minLength: 2,

View file

@ -27,6 +27,9 @@
<!-- <li><a href="#domain" data-toggle="tab">Domain Name</a></li> -->
<li><a href="#custom_domain" data-toggle="tab">Custom Domain</a></li>
<li><a href="#username" data-toggle="tab">Change Site (User) Name</a></li>
<% if current_site.supporter? %>
<li><a href="#tipping" data-toggle="tab">Tipping</a></li>
<% end %>
<% if @site.admin_nsfw != true %>
<li><a href="#nsfw" data-toggle="tab">18+</a></li>
@ -49,6 +52,9 @@
<div class="tab-pane" id="username">
<%== erb :'settings/site/username' %>
</div>
<div class="tab-pane" id="tipping">
<%== erb :'settings/site/tipping' %>
</div>
<% if @site.admin_nsfw != true %>
<div class="tab-pane" id="nsfw">

View file

@ -0,0 +1,28 @@
<h2>Site Tipping</h2>
<p>
This adds a "Send a Tip" button to your site profile, allowing people to send tips to you for your site. This will send users to PayPal to send money to your account. If you have a Bitcoin address, you can add that too.
</p>
<div>
<form method="POST" action="/settings/<%= current_site.username %>/tipping">
<%== csrf_token_input_html %>
<fieldset>
<input name="site[tipping_enabled]" type="hidden" value="false">
<p style="font-size: 11pt">
Enable Site Tipping: <input name="site[tipping_enabled]" type="checkbox" value="true"
<% if current_site.tipping_enabled == true %>checked<% end %>
>
</p>
<label for="site[tipping_paypal]">PayPal email address:</label>
<input name="site[tipping_paypal]" type="text" placeholder="" class="input-Area" autocapitalize="off" autocorrect="off" value="<%= current_site.tipping_paypal %>" style="width: 400px">
<label for="site[tipping_bitcoin]">Bitcoin address:</label>
<input name="site[tipping_bitcoin]" type="text" placeholder="" class="input-Area" autocapitalize="off" autocorrect="off" value="<%= current_site.tipping_bitcoin %>" style="width: 400px">
</fieldset>
<input class="btn-Action" type="submit" value="Update">
</form>
</div>

View file

@ -54,8 +54,11 @@
<!-- <a href="#" class="btn-Action tip"><span>Tip</span></a> -->
<% end %>
<a href="#" id="shareButton" class="btn-Action" data-container="body" data-toggle="popover" data-placement="bottom" data-content='<%== erb :'_share', layout: false, locals: {site: site} %>'>
<i class="fa fa-share-alt"></i> <span>Share</span></a>
<a href="#" id="shareButton" class="btn-Action" data-container="body" data-toggle="popover" data-placement="bottom" data-content='<%== erb :'_share', layout: false, locals: {site: site} %>'><i class="fa fa-share-alt"></i> <span>Share</span></a>
<% if site.tipping_enabled && (!site.tipping_paypal.blank? || !site.tipping_bitcoin.blank?) %>
<a href="#" id="tipButton" class="btn-Action" data-container="body" data-toggle="popover" data-placement="bottom" data-content='<%== erb :'site/_tip', layout: false, locals: {site: site} %>'><i class="fa fa-usd"></i> <span>Send a Tip</span></a>
<% end %>
</div>
</div>
</div>

17
views/site/_tip.erb Normal file
View file

@ -0,0 +1,17 @@
<% unless site.tipping_paypal.blank? %>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top" style="margin-bottom: 0px">
<input type="hidden" name="cmd" value="_donations">
<input type="hidden" name="business" value="<%= site.tipping_paypal %>">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="item_name" value="Site Donation for <%= site.title %>">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="bn" value="PP-DonationsBF:btn_donateCC_LG.gif:NonHostedGuest">
<a href="#" onclick="parentNode.submit()">Credit Card</a>
<br>
<a href="#" onclick="parentNode.submit()">PayPal</a>
</form>
<% end %>
<% unless site.tipping_bitcoin.blank? %>
<a href="bitcoin:<%= site.tipping_bitcoin %>?message=<%= Rack::Utils.escape "Site donation for #{site.title}" %>">Bitcoin</a>
<% end %>