Skip to content

Instantly share code, notes, and snippets.

View index.cr
class Bitcoins::Index < BrowserAction
get "/bitcoins" do
addresses = populate_balances(KeyPairQuery.new.user_id(current_user.id))
render IndexPage, addresses: addresses, form: KeyPairForm.new
end
private def populate_balances(key_pair_query)
View app.scss
// Lucky generates 3 folders to help you organize your CSS:
@import "~normalize-scss/sass/normalize/import-now";
@import "variables/colors";
@import "components/authentication";
body {
font-family: Sans-Serif;
}
View authentication.scss
.authentication {
background-color: $color-grey;
h1 {
text-align: center;
text-transform: uppercase;
color: $color-dark-grey;
}
View colors.scss
$color-white: white;
$color-grey: #fafafa;
$color-dark-grey: #333;
View guest_layout.cr
abstract class GuestLayout
# Edit shared layout code in src/components/shared/layout.cr
include Shared::Layout
def render
html_doctype
html lang: "en" do
shared_layout_head
View new_page.cr
class SignIns::NewPage < GuestLayout
needs form : SignInForm
def content
h1 "Sign In"
render_sign_in_form(@form)
end
private def render_sign_in_form(f)
form_for SignIns::Create do
View 20180810125258_create_key_pair.cr
class CreateKeyPair::V20180810125258 < LuckyMigrator::Migration::V1
def migrate
create :key_pairs do
add user_id : Int32
add public_key : String
add private_key : String
end
end
def rollback
View database.cr
LuckyRecord::Repo.configure do
if Lucky::Env.production?
settings.url = ENV.fetch("DATABASE_URL")
else
settings.url = ENV["DATABASE_URL"]? ||
LuckyRecord::PostgresURL.build(
hostname: "localhost",
database: database,
username: "ubuntu",
password: "password")
View shards.yml
github: onchain/onchain-shard
View index.cr
class Bitcoins::Index < BrowserAction
get "/bitcoins" do
addresses = KeyPairQuery.new.user_id(current_user.id).map { |key_pair|
{ key_pair.label, key_pair.public_key, "0" }
}
render IndexPage, addresses: addresses
end
end