Compare commits
1 Commits
07fe8dba71
...
feature/co
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
462dd24da3
|
3
Gemfile
3
Gemfile
@@ -58,9 +58,6 @@ gem 'discourse_api'
|
|||||||
gem "sentry-ruby"
|
gem "sentry-ruby"
|
||||||
gem "sentry-rails"
|
gem "sentry-rails"
|
||||||
|
|
||||||
# Lightning
|
|
||||||
gem "lnurl"
|
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
# Use sqlite3 as the database for Active Record
|
# Use sqlite3 as the database for Active Record
|
||||||
gem 'sqlite3', '~> 1.4'
|
gem 'sqlite3', '~> 1.4'
|
||||||
|
|||||||
@@ -180,8 +180,6 @@ GEM
|
|||||||
listen (3.7.1)
|
listen (3.7.1)
|
||||||
rb-fsevent (~> 0.10, >= 0.10.3)
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
||||||
rb-inotify (~> 0.9, >= 0.9.10)
|
rb-inotify (~> 0.9, >= 0.9.10)
|
||||||
lnurl (1.0.1)
|
|
||||||
bech32 (~> 1.1)
|
|
||||||
lockbox (1.1.0)
|
lockbox (1.1.0)
|
||||||
loofah (2.19.0)
|
loofah (2.19.0)
|
||||||
crass (~> 1.0.2)
|
crass (~> 1.0.2)
|
||||||
@@ -411,7 +409,6 @@ DEPENDENCIES
|
|||||||
letter_opener
|
letter_opener
|
||||||
letter_opener_web
|
letter_opener_web
|
||||||
listen (~> 3.2)
|
listen (~> 3.2)
|
||||||
lnurl
|
|
||||||
lockbox
|
lockbox
|
||||||
net-ldap
|
net-ldap
|
||||||
pagy (~> 6.0, >= 6.0.2)
|
pagy (~> 6.0, >= 6.0.2)
|
||||||
|
|||||||
3
app/components/header_tab_link_component.html.erb
Normal file
3
app/components/header_tab_link_component.html.erb
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<%= link_to @path, class: @link_class do %>
|
||||||
|
<%= @name %>
|
||||||
|
<% end %>
|
||||||
20
app/components/header_tab_link_component.rb
Normal file
20
app/components/header_tab_link_component.rb
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class HeaderTabLinkComponent < ViewComponent::Base
|
||||||
|
def initialize(name:, path:, active: false, disabled: false)
|
||||||
|
@name = name
|
||||||
|
@path = path
|
||||||
|
@active = active
|
||||||
|
@disabled = disabled
|
||||||
|
@link_class = class_names_link(path)
|
||||||
|
end
|
||||||
|
|
||||||
|
def class_names_link(path)
|
||||||
|
common = "block md:inline-block px-5 py-2 rounded-md font-medium text-base md:text-xl"
|
||||||
|
if @active
|
||||||
|
"#{common} bg-gray-900/50 text-white"
|
||||||
|
else
|
||||||
|
"#{common} text-gray-300 hover:bg-gray-900/30 hover:text-white active:bg-gray-900/30 active:text-white"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
12
app/components/header_with_tabs_component.html.erb
Normal file
12
app/components/header_with_tabs_component.html.erb
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<header class="py-10">
|
||||||
|
<div class="max-w-6xl md:flex md:gap-x-10 mx-auto px-4 sm:px-6 lg:px-8">
|
||||||
|
<% if @title.present? %>
|
||||||
|
<h1 class="text-3xl font-bold text-white">
|
||||||
|
<%= @title %>
|
||||||
|
</h1>
|
||||||
|
<% end %>
|
||||||
|
<nav class="md:grow flex gap-x-4 <%= @title.present? ? "justify-end" : "justify-start" %>" aria-label="Tabs">
|
||||||
|
<%= render partial: @tabnav_partial %>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
8
app/components/header_with_tabs_component.rb
Normal file
8
app/components/header_with_tabs_component.rb
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class HeaderWithTabsComponent < ViewComponent::Base
|
||||||
|
def initialize(title: nil, tabnav_partial:)
|
||||||
|
@title = title
|
||||||
|
@tabnav_partial = tabnav_partial
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
require "rqrcode"
|
require "rqrcode"
|
||||||
require "lnurl"
|
|
||||||
|
|
||||||
class Services::LightningController < ApplicationController
|
class Services::LightningController < ApplicationController
|
||||||
before_action :authenticate_user!
|
before_action :authenticate_user!
|
||||||
@@ -9,55 +8,9 @@ class Services::LightningController < ApplicationController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
@wallet_url = "lndhub://#{current_user.ln_account}:#{current_user.ln_password}@#{ENV['LNDHUB_PUBLIC_URL']}"
|
@wallet_url = "lndhub://#{current_user.ln_account}:#{current_user.ln_password}@#{ENV['LNDHUB_PUBLIC_URL']}"
|
||||||
initialize_lndhub_qr_code
|
|
||||||
end
|
|
||||||
|
|
||||||
def transactions
|
qrcode = RQRCode::QRCode.new(@wallet_url)
|
||||||
@transactions = fetch_transactions
|
@svg = qrcode.as_svg(
|
||||||
end
|
|
||||||
|
|
||||||
def qr_lnurlp
|
|
||||||
lnurlp_url = "https://kosmos.org/.well-known/lnurlp/#{current_user.cn}"
|
|
||||||
lnurlp_bech32 = Lnurl.new(lnurlp_url).to_bech32
|
|
||||||
qr_code = RQRCode::QRCode.new("lightning:" + lnurlp_bech32)
|
|
||||||
|
|
||||||
if params[:format] == "svg"
|
|
||||||
qr_svg = qr_code.as_svg(
|
|
||||||
color: "000",
|
|
||||||
shape_rendering: "crispEdges",
|
|
||||||
module_size: 6,
|
|
||||||
standalone: true,
|
|
||||||
use_path: true,
|
|
||||||
svg_attributes: {
|
|
||||||
class: 'inline-block'
|
|
||||||
}
|
|
||||||
)
|
|
||||||
send_data(
|
|
||||||
qr_svg,
|
|
||||||
filename: "bitcoin-lightning-#{current_user.address}.svg",
|
|
||||||
type: "image/svg+xml"
|
|
||||||
)
|
|
||||||
elsif params[:format] == "png"
|
|
||||||
qr_png = qr_code.as_png(
|
|
||||||
fill: "white",
|
|
||||||
color: "black",
|
|
||||||
size: 1024,
|
|
||||||
)
|
|
||||||
send_data(
|
|
||||||
qr_png,
|
|
||||||
filename: "bitcoin-lightning-#{current_user.address}.png",
|
|
||||||
type: "image/png"
|
|
||||||
)
|
|
||||||
else
|
|
||||||
http_status :not_found
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def initialize_lndhub_qr_code
|
|
||||||
qr_code = RQRCode::QRCode.new(@wallet_url)
|
|
||||||
@lndhub_qr_svg = qr_code.as_svg(
|
|
||||||
color: "000",
|
color: "000",
|
||||||
shape_rendering: "crispEdges",
|
shape_rendering: "crispEdges",
|
||||||
module_size: 6,
|
module_size: 6,
|
||||||
@@ -69,6 +22,12 @@ class Services::LightningController < ApplicationController
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def transactions
|
||||||
|
@transactions = fetch_transactions
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
def authenticate_with_lndhub(options={})
|
def authenticate_with_lndhub(options={})
|
||||||
if session[:ln_auth_token].present? && !options[:force_reauth]
|
if session[:ln_auth_token].present? && !options[:force_reauth]
|
||||||
@ln_auth_token = session[:ln_auth_token]
|
@ln_auth_token = session[:ln_auth_token]
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
<%= render HeaderComponent.new(title: "Contributions") %>
|
<%# <%= render HeaderComponent.new(title: "Contributions") %>
|
||||||
|
<%= render HeaderWithTabsComponent.new(
|
||||||
|
# title: "Contributions",
|
||||||
|
tabnav_partial: "shared/tabnav_contributions"
|
||||||
|
) %>
|
||||||
|
|
||||||
<%= render MainWithTabnavComponent.new(tabnav_partial: "shared/tabnav_contributions") do %>
|
<%= render MainSimpleComponent.new do %>
|
||||||
<section>
|
<section>
|
||||||
<% if @donations.any? %>
|
<% if @donations.any? %>
|
||||||
<p class="mb-12">
|
<p class="mb-12">
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
<%= render HeaderComponent.new(title: "Contributions") %>
|
<%= render HeaderWithTabsComponent.new(
|
||||||
|
# title: "Contributions",
|
||||||
|
tabnav_partial: "shared/tabnav_contributions"
|
||||||
|
) %>
|
||||||
|
|
||||||
<%= render MainWithTabnavComponent.new(tabnav_partial: "shared/tabnav_contributions") do %>
|
<%= render MainSimpleComponent.new do %>
|
||||||
<section>
|
<section>
|
||||||
<p class="mb-8">
|
<p class="mb-8">
|
||||||
Project contributions are how we develop and run all Kosmos software and
|
Project contributions are how we develop and run all Kosmos software and
|
||||||
|
|||||||
@@ -7,25 +7,13 @@
|
|||||||
|
|
||||||
<section>
|
<section>
|
||||||
<h3>Lightning Address</h3>
|
<h3>Lightning Address</h3>
|
||||||
<p class="mb-6">
|
<p>
|
||||||
Your Kosmos user address is also a
|
Your Kosmos user address is also a
|
||||||
<a class="ks-text-link" href="https://lightningaddress.com/" target="_blank">Lightning Address</a>!
|
<a class="ks-text-link" href="https://lightningaddress.com/" target="_blank">Lightning Address</a>!
|
||||||
The easiest way to receive sats is by just giving out your address:
|
The easiest way to receive sats is by just giving out your address:
|
||||||
</p>
|
</p>
|
||||||
<p data-controller="clipboard" class="flex gap-1 sm:w-2/5">
|
<p>
|
||||||
<input type="text" id="user_address" class="grow"
|
<strong><%= current_user.address %></strong>
|
||||||
value=<%= current_user.address %> disabled="disabled"
|
|
||||||
data-clipboard-target="source" />
|
|
||||||
<button id="copy-user-address" class="btn-md btn-icon btn-blue shrink-0"
|
|
||||||
data-clipboard-target="trigger" data-action="clipboard#copy"
|
|
||||||
title="Copy to clipboard">
|
|
||||||
<span class="content-initial">
|
|
||||||
<%= render partial: "icons/copy", locals: { custom_class: "text-white h-4 w-4 inline" } %>
|
|
||||||
</span>
|
|
||||||
<span class="content-active hidden">
|
|
||||||
<%= render partial: "icons/check", locals: { custom_class: "text-white h-4 w-4 inline" } %>
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
</p>
|
</p>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
@@ -51,7 +39,7 @@
|
|||||||
<button id="hide-setup-code" class="hidden btn-md btn-blue w-full sm:w-auto">Hide setup QR code</button>
|
<button id="hide-setup-code" class="hidden btn-md btn-blue w-full sm:w-auto">Hide setup QR code</button>
|
||||||
</p>
|
</p>
|
||||||
<p id="setup-code" class="hidden my-10 w-full text-center">
|
<p id="setup-code" class="hidden my-10 w-full text-center">
|
||||||
<%= raw @lndhub_qr_svg %>
|
<%= raw @svg %>
|
||||||
</p>
|
</p>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
@@ -100,24 +88,6 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="mb-12">
|
|
||||||
<h3>QR Code for Donations/Tips</h3>
|
|
||||||
<p>
|
|
||||||
You can print out or publish a QR code for people to scan with their
|
|
||||||
wallet apps, so they can send you sats without a direct personal
|
|
||||||
interaction (for example at a concert, or on your website).
|
|
||||||
</p>
|
|
||||||
<p class="my-6 text-center md:text-left">
|
|
||||||
<%= link_to "Download SVG file",
|
|
||||||
qr_lnurlp_services_lightning_index_path(format: "svg"),
|
|
||||||
class: "btn-md btn-blue w-full sm:w-auto"%>
|
|
||||||
<span class="mx-2 my-2 md:my-0 block md:inline">or</span>
|
|
||||||
<%= link_to "Download PNG file",
|
|
||||||
qr_lnurlp_services_lightning_index_path(format: "png"),
|
|
||||||
class: "btn-md btn-blue w-full sm:w-auto"%>
|
|
||||||
</p>
|
|
||||||
</section>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|||||||
@@ -1,12 +1,8 @@
|
|||||||
<div class="border-b border-gray-200">
|
<%= render HeaderTabLinkComponent.new(
|
||||||
<nav class="-mb-px flex" aria-label="Tabs">
|
name: "Donations", path: contributions_donations_path,
|
||||||
<%= render TabnavLinkComponent.new(
|
active: current_page?(contributions_donations_path)
|
||||||
name: "Donations", path: contributions_donations_path,
|
) %>
|
||||||
active: current_page?(contributions_donations_path)
|
<%= render HeaderTabLinkComponent.new(
|
||||||
) %>
|
name: "Projects", path: contributions_projects_path,
|
||||||
<%= render TabnavLinkComponent.new(
|
active: current_page?(contributions_projects_path)
|
||||||
name: "Projects", path: contributions_projects_path,
|
) %>
|
||||||
active: current_page?(contributions_projects_path)
|
|
||||||
) %>
|
|
||||||
</nav>
|
|
||||||
</div>
|
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ Rails.application.routes.draw do
|
|||||||
resources :lightning, only: [:index] do
|
resources :lightning, only: [:index] do
|
||||||
collection do
|
collection do
|
||||||
get 'transactions'
|
get 'transactions'
|
||||||
get 'qr_lnurlp'
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user