Compare commits

...

10 Commits

Author SHA1 Message Date
The Needful DO
4efddc271d Add czechers checkers concept page 2025-03-27 20:54:39 +00:00
The Needful DO
eec52c2630 Uodate git url 2025-03-27 20:53:06 +00:00
The Needful DO
8d59463f43 Add swipable delete to all doodads on index 2025-03-27 16:59:13 +00:00
TheNeedful-DO
00fe1f1e5a Use safer identity args for dfx 2024-07-18 15:03:39 +00:00
TheNeedful-DO
fe82a1de21 Disable Delayed Job scheduler and Telegram bots 2024-06-24 09:52:17 +00:00
TheNeedful-DO
3203bf13c4 Remove index sums 2024-06-03 23:09:16 +00:00
TheNeedful-DO
1db9c19adf Fix icpswap pool index parser 2024-05-22 05:57:20 +00:00
TheNeedful-DO
0f2827e0f4 Require login to add tokens 2024-04-20 02:42:23 +00:00
TheNeedful-DO
35dbf61bb3 Add swipe delete global doodads 2024-03-26 15:09:03 +00:00
TheNeedful-DO
efe8f8d1b1 Update metapurse policies for private 2024-03-25 17:57:17 +00:00
35 changed files with 286 additions and 129 deletions

View File

@ -16,7 +16,7 @@ require 'capistrano/rails/assets'
require 'capistrano/rails/migrations' require 'capistrano/rails/migrations'
require 'capistrano/postgresql' require 'capistrano/postgresql'
#require 'capistrano/bower' #require 'capistrano/bower'
require 'capistrano/delayed_job' # TODO enable job scheduler require 'capistrano/delayed_job'
# Includes tasks from other gems included in your Gemfile # Includes tasks from other gems included in your Gemfile

10
Gemfile
View File

@ -38,7 +38,7 @@ group :development do
gem 'capistrano-nginx', github: 'koenpunt/capistrano-nginx' gem 'capistrano-nginx', github: 'koenpunt/capistrano-nginx'
gem "capistrano-db-tasks", require: false gem "capistrano-db-tasks", require: false
gem "capistrano-postgresql" #, '~> 4.2.0' gem "capistrano-postgresql" #, '~> 4.2.0'
gem 'capistrano3-delayed-job', '~> 1.0' # TODO enable job scheduler gem 'capistrano3-delayed-job', '~> 1.0'
# required for ecdsa key # required for ecdsa key
gem "bcrypt_pbkdf", require: false gem "bcrypt_pbkdf", require: false
gem "net-ssh", ">= 4.0.0", require: false gem "net-ssh", ">= 4.0.0", require: false
@ -84,8 +84,8 @@ gem 'importmap-rails'
gem 'turbo-rails' gem 'turbo-rails'
gem 'stimulus-rails' gem 'stimulus-rails'
gem 'will_paginate' gem 'will_paginate'
gem 'telegram-bot-ruby', '~> 1.0' # TODO enable telegram bots with job scheduler gem 'telegram-bot-ruby', '~> 1.0'
gem 'delayed_job_active_record' # TODO enable job scheduler gem 'delayed_job_active_record'
gem 'daemons' # TODO enable job scheduler gem 'daemons'
gem "activejob-status", "~> 1.0" # TODO enable job scheduler gem "activejob-status", "~> 1.0"

View File

@ -60,9 +60,6 @@ GEM
activejob (7.1.2) activejob (7.1.2)
activesupport (= 7.1.2) activesupport (= 7.1.2)
globalid (>= 0.3.6) globalid (>= 0.3.6)
activejob-status (1.0.0)
activejob (>= 6.0)
activesupport (>= 6.0)
activemodel (7.1.2) activemodel (7.1.2)
activesupport (= 7.1.2) activesupport (= 7.1.2)
activerecord (7.1.2) activerecord (7.1.2)
@ -126,9 +123,6 @@ GEM
capistrano-rbenv (2.2.0) capistrano-rbenv (2.2.0)
capistrano (~> 3.1) capistrano (~> 3.1)
sshkit (~> 1.3) sshkit (~> 1.3)
capistrano3-delayed-job (1.7.6)
capistrano (~> 3.0, >= 3.0.0)
daemons (~> 1.3)
capistrano3-puma (6.0.0.beta.1) capistrano3-puma (6.0.0.beta.1)
capistrano (~> 3.7) capistrano (~> 3.7)
capistrano-bundler capistrano-bundler
@ -162,7 +156,6 @@ GEM
concurrent-ruby (1.2.2) concurrent-ruby (1.2.2)
connection_pool (2.4.1) connection_pool (2.4.1)
crass (1.0.6) crass (1.0.6)
daemons (1.4.1)
database_cleaner (2.0.2) database_cleaner (2.0.2)
database_cleaner-active_record (>= 2, < 3) database_cleaner-active_record (>= 2, < 3)
database_cleaner-active_record (2.1.0) database_cleaner-active_record (2.1.0)
@ -171,11 +164,6 @@ GEM
database_cleaner-core (2.0.1) database_cleaner-core (2.0.1)
date (3.3.4) date (3.3.4)
debug_inspector (1.1.0) debug_inspector (1.1.0)
delayed_job (4.1.11)
activesupport (>= 3.0, < 8.0)
delayed_job_active_record (4.1.8)
activerecord (>= 3.0, < 8.0)
delayed_job (>= 3.0, < 5)
devise (4.9.3) devise (4.9.3)
bcrypt (~> 3.0) bcrypt (~> 3.0)
orm_adapter (~> 0.1) orm_adapter (~> 0.1)
@ -193,25 +181,6 @@ GEM
railties (>= 3.2) railties (>= 3.2)
drb (2.2.0) drb (2.2.0)
ruby2_keywords ruby2_keywords
dry-core (1.0.1)
concurrent-ruby (~> 1.0)
zeitwerk (~> 2.6)
dry-inflector (1.0.0)
dry-logic (1.5.0)
concurrent-ruby (~> 1.0)
dry-core (~> 1.0, < 2)
zeitwerk (~> 2.6)
dry-struct (1.6.0)
dry-core (~> 1.0, < 2)
dry-types (>= 1.7, < 2)
ice_nine (~> 0.11)
zeitwerk (~> 2.6)
dry-types (1.7.1)
concurrent-ruby (~> 1.0)
dry-core (~> 1.0)
dry-inflector (~> 1.0)
dry-logic (~> 1.4)
zeitwerk (~> 2.6)
ed25519 (1.3.0) ed25519 (1.3.0)
em-websocket (0.5.3) em-websocket (0.5.3)
eventmachine (>= 0.12.9) eventmachine (>= 0.12.9)
@ -227,13 +196,6 @@ GEM
railties (>= 3.0.0) railties (>= 3.0.0)
faker (3.2.2) faker (3.2.2)
i18n (>= 1.8.11, < 2) i18n (>= 1.8.11, < 2)
faraday (2.7.12)
base64
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday-multipart (1.0.4)
multipart-post (~> 2)
faraday-net_http (3.0.2)
ffi (1.16.3) ffi (1.16.3)
formatador (1.1.0) formatador (1.1.0)
friendly_id (5.4.2) friendly_id (5.4.2)
@ -288,7 +250,6 @@ GEM
hub (1.12.4) hub (1.12.4)
i18n (1.14.1) i18n (1.14.1)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
ice_nine (0.11.2)
importmap-rails (1.2.3) importmap-rails (1.2.3)
actionpack (>= 6.0.0) actionpack (>= 6.0.0)
activesupport (>= 6.0.0) activesupport (>= 6.0.0)
@ -333,7 +294,6 @@ GEM
mini_portile2 (2.8.5) mini_portile2 (2.8.5)
minitest (5.20.0) minitest (5.20.0)
multi_json (1.15.0) multi_json (1.15.0)
multipart-post (2.3.0)
mutex_m (0.2.0) mutex_m (0.2.0)
nenv (0.3.0) nenv (0.3.0)
net-imap (0.4.7) net-imap (0.4.7)
@ -533,11 +493,6 @@ GEM
stimulus-rails (1.3.0) stimulus-rails (1.3.0)
railties (>= 6.0.0) railties (>= 6.0.0)
stringio (3.1.0) stringio (3.1.0)
telegram-bot-ruby (1.0.0)
dry-struct (~> 1.6)
faraday (~> 2.0)
faraday-multipart (~> 1.0)
zeitwerk (~> 2.6)
temple (0.10.3) temple (0.10.3)
thor (1.3.0) thor (1.3.0)
tilt (2.3.0) tilt (2.3.0)
@ -570,7 +525,6 @@ PLATFORMS
x86_64-linux x86_64-linux
DEPENDENCIES DEPENDENCIES
activejob-status (~> 1.0)
bcrypt_pbkdf bcrypt_pbkdf
better_errors better_errors
binding_of_caller binding_of_caller
@ -582,15 +536,12 @@ DEPENDENCIES
capistrano-rails capistrano-rails
capistrano-rails-console capistrano-rails-console
capistrano-rbenv capistrano-rbenv
capistrano3-delayed-job (~> 1.0)
capistrano3-puma (~> 6.0.beta) capistrano3-puma (~> 6.0.beta)
capybara capybara
capybara-screenshot capybara-screenshot
ci_reporter_rspec ci_reporter_rspec
coffee-rails coffee-rails
daemons
database_cleaner database_cleaner
delayed_job_active_record
devise devise
devise_invitable devise_invitable
dotenv-rails dotenv-rails
@ -641,7 +592,6 @@ DEPENDENCIES
spring-commands-rspec spring-commands-rspec
sprockets sprockets
stimulus-rails stimulus-rails
telegram-bot-ruby (~> 1.0)
turbo-rails turbo-rails
webdrivers webdrivers
will_paginate will_paginate

View File

@ -1,5 +1,6 @@
//= link gems.js //= link gems.js
//= link jquery.js //= link jquery.js
//= link libraries/swiped.min.js
//= link_tree ../images //= link_tree ../images
//= link_directory ../stylesheets .css //= link_directory ../stylesheets .css
//= link_tree ../../javascript .js //= link_tree ../../javascript .js

View File

@ -0,0 +1 @@
!function(){function t(t,e){document.addEventListener(t,function(t){a._elems.forEach(function(i){for(var n=t.target;n;){if(n===i.elem)return i[e](t),!1;n=n.parentNode}return!1})})}function e(){var t=[].shift.call(arguments),e=arguments[0];for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);return t}var i=window.navigator.msPointerEnabled,n={start:i?"MSPointerDown":"touchstart",move:i?"MSPointerMove":"touchmove",end:i?"MSPointerUp":"touchend"},o=function(){var t=window.getComputedStyle(document.documentElement,""),e=(Array.prototype.slice.call(t).join("").match(/-(moz|webkit|ms)-/)||""===t.OLink&&["","o"])[1];return"-"+e+"-"}(),s=function(){var t,e=document.createElement("fakeelement"),i={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(t in i)if(void 0!==e.style[t])return i[t]}(),r={transition:o+"transition",transform:o+"transform"},h=function(){},a=function(t){var i={duration:200,tolerance:50,time:200,dir:1,right:0,left:0};t=e(i,t||{}),this.duration=t.duration,this.tolerance=t.tolerance,this.time=t.time,this.width=t.left||t.right,this.elem=t.elem,this.list=t.list,this.dir=t.dir,this.group=t.group,this.id=a.elemId++,this.onOpen="function"==typeof t.onOpen?t.onOpen:h,this.onClose="function"==typeof t.onClose?t.onClose:h,this.right=t.right,this.left=t.left,(t.right>0&&t.tolerance>t.right||t.left>0&&t.tolerance>t.left)&&console.warn("tolerance must be less then left and right")};a._elems=[],a.groupCounter=0,a.elemId=0,a.init=function(t){a.groupCounter++;var i=document.querySelectorAll(t.query),n=[];return delete t.query,[].forEach.call(i,function(i){var o=e({elem:i,group:a.groupCounter},t);n.push(new a(o))}),a._bindEvents(),a._elems=a._elems.concat(n),1===n.length?n[0]:n},a._closeAll=function(t){a._elems.forEach(function(e){e.group===t&&e.close(!0)})},a.prototype.transitionEnd=function(t,e){function i(){e.call(n),t.removeEventListener(s,i)}var n=this;t.addEventListener(s,i)},a.prototype.touchStart=function(t){var e=t.changedTouches[0];1===t.touches.length&&(this.touchId=e.identifier,this.x=e.pageX,this.y=e.pageY,this.startTime=new Date,this.resetValue(),this.list?a._closeAll(this.group):this.close(!0))},a.prototype.touchMove=function(t){var e=t.changedTouches[0];this.isValidTouch(t)&&(this.delta=e.pageX-this.x,this.dir=this.delta<0?-1:1,this.width=this.delta<0?this.right:this.left,this.defineUserAction(e),this.startSwipe&&(this.move(),t.preventDefault()))},a.prototype.touchEnd=function(t){this.isValidTouch(t,!0)&&this.startSwipe&&(this.dir*this.delta>this.tolerance||new Date-this.startTime<this.time?this.open():this.close(),t.stopPropagation(),t.preventDefault())},a.prototype.open=function(t){this.animation(this.dir*this.width),this.swiped=!0,t||this.transitionEnd(this.elem,this.onOpen),this.resetValue()},a.prototype.close=function(t){this.animation(0),this.swiped=!1,t||this.transitionEnd(this.elem,this.onClose),this.resetValue()},a.prototype.toggle=function(){this.swiped?this.close():this.open()},a.prototype.resetValue=function(){this.startSwipe=!1,this.startScroll=!1,this.delta=0},a._bindEvents=function(){return a.eventBinded?!1:(t(n.move,"touchMove"),t(n.end,"touchEnd"),t(n.start,"touchStart"),void(a.eventBinded=!0))},a.prototype.defineUserAction=function(t){var e=10,i=10;Math.abs(this.y-t.pageY)>i&&!this.startSwipe?this.startScroll=!0:Math.abs(this.delta)>e&&!this.startScroll&&(this.startSwipe=!0)},a.prototype.isValidTouch=function(t,e){var i=e?"changedTouches":"targetTouches";return t[i][0].identifier===this.touchId},a.prototype.move=function(){if(this.dir>0&&(this.delta<0||0===this.left)||this.dir<0&&(this.delta>0||0===this.right))return!1;var t=Math.abs(this.delta);t>this.width&&(this.delta=this.dir*(this.width+(t-this.width)/8)),this.animation(this.delta,0)},a.prototype.animation=function(t,e){e=void 0===e?this.duration:e,this.elem.style.cssText=r.transition+":"+r.transform+" "+e+"ms; "+r.transform+":translate3d("+t+"px, 0px, 0px)"},a.prototype.destroy=function(t){var e=this.id;a._elems.forEach(function(t,i){t.id===e&&a._elems.splice(i,1)}),t&&this.elem.parentNode.removeChild(this.elem)},window.Swiped=a}();

View File

@ -23,7 +23,8 @@ class BotsController < ApplicationController
def telegram_listen def telegram_listen
authorize @bot authorize @bot
@bot.delay.telegram_listen # TODO enable bots with job scheduler
# @bot.delay.telegram_listen
redirect_to request.referrer redirect_to request.referrer
end end

View File

@ -0,0 +1,5 @@
class PagesController < ApplicationController
before_action :skip_authorization
def czechers
end
end

View File

@ -0,0 +1,2 @@
module PagesHelper
end

View File

@ -1,2 +1 @@
import 'controllers' // Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
import "@hotwired/turbo-rails"

View File

@ -21,9 +21,7 @@ class Play < ActiveRecord::Base
# TODO Pay out crypto # TODO Pay out crypto
# pay icypees rewards # pay icypees rewards
if !self.player.principal.nil? if !self.player.principal.nil?
`dfx identity use 13rewards` player_wallet_balance = `dfx --identity 13rewards canister --network ic call es3he-kyaaa-aaaah-abzna-cai transfer '(principal "#{self.player.principal.strip}", 100000000:nat)'`
player_wallet_balance = `dfx canister --network ic call es3he-kyaaa-aaaah-abzna-cai transfer '(principal "#{self.player.principal.strip}", 100000000:nat)'`
`dfx identity use anonymous`
end end
self.game.save self.game.save

View File

@ -15,11 +15,9 @@ class Player < ActiveRecord::Base
if stp.principal.nil? if stp.principal.nil?
#TODO use principal #TODO use principal
if !soft_token.nil? if !soft_token.nil?
if `dfx identity use #{soft_token}; echo $?`.to_i == 255 if `dfx --identity #{soft_token} identity whoami; echo $?`.to_i == 255
`dfx identity new #{soft_token} --disable-encryption` `dfx identity new #{soft_token} --disable-encryption`
`dfx identity use #{soft_token}` @principal = `dfx --identity #{soft_token} identity get-principal`
@principal = `dfx identity get-principal`
`dfx identity use anonymous`
stp.principal = @principal stp.principal = @principal
stp.save stp.save
end end

View File

@ -3,26 +3,21 @@ class TelegramWallet < ActiveRecord::Base
return self.icp_principal if self.icp_principal return self.icp_principal if self.icp_principal
if self.icp_id.nil? if self.icp_id.nil?
if !self.telegram_id.nil? if !self.telegram_id.nil?
if `dfx identity use #{self.telegram_id}; echo $?`.to_i == 255 if `dfx --identity #{self.telegram_id} identity whoami; echo $?`.to_i == 255
`dfx identity new #{self.telegram_id} --storage-mode=plaintext` `dfx identity new #{self.telegram_id} --storage-mode=plaintext`
`dfx identity use #{self.telegram_id}` self.icp_principal = `dfx --identity #{self.telegram_id} identity get-principal`.strip
self.icp_principal = `dfx identity get-principal`.strip self.icp_id = `dfx --identity #{self.telegram_id} ledger account-id`.strip
self.icp_id = `dfx ledger account-id`.strip
`dfx identity use anonymous`
self.save self.save
else else
# Identity already exist # Identity already exist
self.icp_id = `dfx ledger account-id`.strip self.icp_id = `dfx --identity #{self.telegram_id} ledger account-id`.strip
self.icp_principal = `dfx identity get-principal`.strip self.icp_principal = `dfx --identity #{self.telegram_id} identity get-principal`.strip
`dfx identity use anonymous`
self.save self.save
end end
end end
elsif elsif
`dfx identity use #{self.telegram_id}` self.icp_id = `dfx --identity #{self.telegram_id} ledger account-id`.strip
self.icp_id = `dfx ledger account-id`.strip self.icp_principal = `dfx --identity #{self.telegram_id} identity get-principal`.strip
self.icp_principal = `dfx identity get-principal`.strip
`dfx identity use anonymous`
self.save self.save
end end
return self.icp_principal return self.icp_principal
@ -31,26 +26,21 @@ class TelegramWallet < ActiveRecord::Base
return self.icp_id if self.icp_id return self.icp_id if self.icp_id
if self.icp_principal.nil? if self.icp_principal.nil?
if !self.telegram_id.nil? if !self.telegram_id.nil?
if `dfx identity use #{self.telegram_id}; echo $?`.to_i == 255 if `dfx --identity #{self.telegram_id} identity whoami; echo $?`.to_i == 255
`dfx identity new #{self.telegram_id} --storage-mode=plaintext` `dfx identity new #{self.telegram_id} --storage-mode=plaintext`
`dfx identity use #{self.telegram_id}` self.icp_principal = `dfx --identity #{self.telegram_id} identity get-principal`.strip
self.icp_principal = `dfx identity get-principal`.strip self.icp_id = `dfx --identity #{self.telegram_id} ledger account-id`.strip
self.icp_id = `dfx ledger account-id`.strip
`dfx identity use anonymous`
self.save self.save
else else
# Identity already exist # Identity already exist
self.icp_id = `dfx ledger account-id`.strip self.icp_id = `dfx --identity #{self.telegram_id} ledger account-id`.strip
self.icp_principal = `dfx identity get-principal`.strip self.icp_principal = `dfx --identity #{self.telegram_id} identity get-principal`.strip
`dfx identity use anonymous`
self.save self.save
end end
end end
elsif elsif
`dfx identity use #{self.telegram_id}` self.icp_id = `dfx --identity #{self.telegram_id} ledger account-id`.strip
self.icp_id = `dfx ledger account-id`.strip self.icp_principal = `dfx --identity #{self.telegram_id} identity get-principal`.strip
self.icp_principal = `dfx identity get-principal`.strip
`dfx identity use anonymous`
self.save self.save
end end
return self.icp_id return self.icp_id

View File

@ -23,20 +23,16 @@ class User < ActiveRecord::Base
if stp.principal.nil? if stp.principal.nil?
#TODO use principal #TODO use principal
if !soft_token.nil? if !soft_token.nil?
if `dfx identity use #{soft_token}; echo $?`.to_i == 255 if `dfx --identity #{soft_token} identity whoami; echo $?`.to_i == 255
`dfx identity new #{soft_token} --disable-encryption` `dfx identity new #{soft_token} --disable-encryption`
`dfx identity use #{soft_token}` @principal = `dfx --identity #{soft_token} identity get-principal`
@principal = `dfx identity get-principal` @icid = `dfx --identity #{soft_token} ledger account-id`
@icid = `dfx ledger account-id`
`dfx identity use anonymous`
stp.principal = @principal stp.principal = @principal
stp.save stp.save
end end
end end
elsif elsif
`dfx identity use #{soft_token}` @icid = `dfx --identity #{soft_token} ledger account-id`
@icid = `dfx ledger account-id`
`dfx identity use anonymous`
end end
return @icid.strip return @icid.strip
end end
@ -46,11 +42,9 @@ class User < ActiveRecord::Base
if stp.principal.nil? if stp.principal.nil?
#TODO use principal #TODO use principal
if !soft_token.nil? if !soft_token.nil?
if `dfx identity use #{soft_token}; echo $?`.to_i == 255 if `dfx --identity #{soft_token} identity whoami; echo $?`.to_i == 255
`dfx identity new #{soft_token} --disable-encryption` `dfx identity new #{soft_token} --disable-encryption`
`dfx identity use #{soft_token}` @principal = `dfx --identity #{soft_token} identity get-principal`
@principal = `dfx identity get-principal`
`dfx identity use anonymous`
stp.principal = @principal stp.principal = @principal
stp.save stp.save
end end
@ -60,9 +54,7 @@ class User < ActiveRecord::Base
end end
def icp_balance def icp_balance
`dfx identity use #{soft_token}` balance = `dfx --identity #{soft_token} ledger --network ic balance`
balance = `dfx ledger --network ic balance`
`dfx identity use anonymous`
return balance.strip return balance.strip
end end

View File

@ -31,11 +31,11 @@ class MetapursePolicy
end end
def show? def show?
true @user.admin? || @metapurse.user == @user || @metapurse.user == nil || @metapurse.is_private == false
end end
def data? def data?
true @user.admin? || @metapurse.user == @user || @metapurse.user == nil || @metapurse.is_private == false
end end
def create? def create?
@ -55,7 +55,7 @@ class MetapursePolicy
end end
def destroy? def destroy?
@user.admin? || @metapurse.user == @user @user.admin? || @metapurse.user == @user || @metapurse.user == nil
end end
end end

View File

@ -34,11 +34,11 @@ class TokenPolicy
end end
def create? def create?
@user.admin? || true @user.admin? || @user.signed_in?
end end
def new? def new?
@user.admin? || true @user.admin? || @user.signed_in?
end end
def add_existing? def add_existing?

View File

@ -1,5 +1,5 @@
- if policy(doodad).show? - if policy(doodad).show?
.doodad .doodad{class: "doodad-#{doodad.id}"}
= doodad.body.html_safe = doodad.body.html_safe
- if policy(doodad).edit? - if policy(doodad).edit?
= link_to 'Edit', edit_doodad_path(doodad) = link_to 'Edit', edit_doodad_path(doodad)

View File

@ -1,7 +1,7 @@
.original_flash_message_code .original_flash_message_code
- flash.each do |key, value| - flash.each do |key, value|
%div{class: "alert alert-#{key}"} %div{class: "alert alert-#{key}"}
= value.html_safe = value.to_s.html_safe
.react_flash_messages .react_flash_messages
%div#flash_messages %div#flash_messages

View File

@ -7,3 +7,27 @@
.global-doodads .global-doodads
%h1 Global Doodads %h1 Global Doodads
= render collection: @global_doodads, partial: "doodads/doodad" = render collection: @global_doodads, partial: "doodads/doodad"
:javascript
function destroyDoodad(doodad_id) {
return fetch("/doodads/" + doodad_id, {
method: 'DELETE',
headers: {
"Content-Type": "application/json",
"Accept": "application/json"
}
})
.then(response => response)
};
// var s2 = Swiped.init({ query: '.bar li', list: true, left: 200, right: 200 });
var global_doodad_swiped = Swiped.init({ query: '.global-doodads .doodad',
list: true,
left: 200,
right: 200,
onOpen: function() {
var doodad_id = this.elem.className.split("-")[1];
destroyDoodad(doodad_id)
.then(results => console.log(results));
this.destroy(true)
}
});

View File

@ -10,6 +10,7 @@
<link href="https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap" rel="stylesheet">
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'gems', 'data-turbolinks-track' => true %> <%= javascript_include_tag 'gems', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'libraries/swiped.min.js', 'data-turbolinks-track' => true %>
<%= javascript_importmap_tags %> <%= javascript_importmap_tags %>
<%= csrf_meta_tags %> <%= csrf_meta_tags %>
<%= yield :head %> <%= yield :head %>

View File

@ -15,7 +15,7 @@
%tr %tr
%td %td
= link_to metapurse.name, metapurse = link_to metapurse.name, metapurse
= "#{number_to_currency metapurse.total_usd} USD" -# = "#{number_to_currency metapurse.total_usd} USD"
-# %td= metapurse.data -# %td= metapurse.data
- if policy(metapurse).update? - if policy(metapurse).update?
-# %td= link_to 'Show', metapurse -# %td= link_to 'Show', metapurse

View File

@ -31,7 +31,7 @@
$#{number_with_delimiter(value_amount)} USD $#{number_with_delimiter(value_amount)} USD
- total_value += value_amount rescue 0 - total_value += value_amount rescue 0
- else - else
- value = icpswap_pool_data_raw.split("record {").select{|pool| !pool.scan(canister_id).empty? && !pool.scan(icp_canister_id).empty? }[0].scan(/token0Price = [+-]?([1-9]\d*|0)(\.\d+)?/).join.to_f rescue nil - value = icpswap_pool_data_raw.split("record {").select{|pool| !pool.scan(canister_id).empty? && !pool.scan(icp_canister_id).empty? }[-1].scan(/token0Price = [+-]?([1-9]\d*|0)(\.\d+)?/).join.to_f rescue nil
* *
= "$#{value.round(2)}" = "$#{value.round(2)}"
= icpswap_pool_data_raw.split("record {").select{|pool| !pool.scan(canister_id).empty? && !pool.scan(icp_canister_id).empty? }[0].scan(/token0Symbol = \"(.*)\"; /)[0][0] rescue nil = icpswap_pool_data_raw.split("record {").select{|pool| !pool.scan(canister_id).empty? && !pool.scan(icp_canister_id).empty? }[0].scan(/token0Symbol = \"(.*)\"; /)[0][0] rescue nil

View File

@ -0,0 +1,142 @@
%h1{style: "padding-left: 0.5em;"} Czechers
:css
.board {
position: relative;
margin-top: 1em;
margin-bottom: 1em;
display: grid;
grid-template-columns: repeat(8, 80px);
grid-template-rows: repeat(8, 80px);
gap: 1px;
}
.cell {
width: 80px;
height: 80px;
background-color: white;
}
.cell:nth-child(2n+1):nth-child(-n+8),
.cell:nth-child(2n):nth-child(n+9):nth-child(-n+16),
.cell:nth-child(2n+1):nth-child(n+17):nth-child(-n+24),
.cell:nth-child(2n):nth-child(n+25):nth-child(-n+32),
.cell:nth-child(2n+1):nth-child(n+33):nth-child(-n+40),
.cell:nth-child(2n):nth-child(n+41):nth-child(-n+48),
.cell:nth-child(2n+1):nth-child(n+49):nth-child(-n+56),
.cell:nth-child(2n):nth-child(n+57):nth-child(-n+64) {
background-color: black;
}
.czecher-piece {
border-radius: 5em;
width: 50px;
outline: 2px #cccccc solid;
position: absolute;
z-index: 100;
}
.czecher-piece:active {
outline: 2px #00ffff solid;
}
%img.czecher-piece{src:"/czech-logo-dip20.png", style: "left: 182px; top: 912px;"}
%img.czecher-piece{src:"/czech-logo-dip20.png", style: "left: 262px; top: 912px;"}
%img.czecher-piece{src:"/czech-logo-dip20.png", style: "left: 343px; top: 912px;"}
%img.czecher-piece{src:"/czech-logo-dip20.png", style: "left: 424px; top: 912px;"}
%img.czecher-piece{src:"/czech-logo-dip20.png", style: "left: 505px; top: 912px;"}
%img.czecher-piece{src:"/czech-logo-dip20.png", style: "left: 586px; top: 912px;"}
%img.czecher-piece{src:"/czech-logo-dip20.png", style: "left: 667px; top: 912px;"}
%img.czecher-piece{src:"/czech-logo-dip20.png", style: "left: 748px; top: 912px;"}
%img.czecher-piece{src:"/czech-logo-dip20.png", style: "left: 182px; top: 993px;"}
%img.czecher-piece{src:"/czech-logo-dip20.png", style: "left: 262px; top: 993px;"}
%img.czecher-piece{src:"/czech-logo-dip20.png", style: "left: 343px; top: 993px;"}
%img.czecher-piece{src:"/czech-logo-dip20.png", style: "left: 424px; top: 993px;"}
%img.czecher-piece{src:"/czech-logo-dip20.png", style: "left: 505px; top: 993px;"}
%img.czecher-piece{src:"/czech-logo-dip20.png", style: "left: 586px; top: 993px;"}
%img.czecher-piece{src:"/czech-logo-dip20.png", style: "left: 667px; top: 993px;"}
%img.czecher-piece{src:"/czech-logo-dip20.png", style: "left: 748px; top: 993px;"}
%img.czecher-piece{src:"/tendy-logo-icrc1.jpg", style: "left: 181px; top: 1480px;"}
%img.czecher-piece{src:"/tendy-logo-icrc1.jpg", style: "left: 261px; top: 1480px;"}
%img.czecher-piece{src:"/tendy-logo-icrc1.jpg", style: "left: 342px; top: 1480px;"}
%img.czecher-piece{src:"/tendy-logo-icrc1.jpg", style: "left: 423px; top: 1480px;"}
%img.czecher-piece{src:"/tendy-logo-icrc1.jpg", style: "left: 504px; top: 1480px;"}
%img.czecher-piece{src:"/tendy-logo-icrc1.jpg", style: "left: 585px; top: 1480px;"}
%img.czecher-piece{src:"/tendy-logo-icrc1.jpg", style: "left: 666px; top: 1480px;"}
%img.czecher-piece{src:"/tendy-logo-icrc1.jpg", style: "left: 747px; top: 1480px;"}
%img.czecher-piece{src:"/tendy-logo-icrc1.jpg", style: "left: 181px; top: 1399px;"}
%img.czecher-piece{src:"/tendy-logo-icrc1.jpg", style: "left: 261px; top: 1399px; outline: 2px #00ffff solid;"}
%img.czecher-piece{src:"/tendy-logo-icrc1.jpg", style: "left: 342px; top: 1399px;"}
%img.czecher-piece{src:"/tendy-logo-icrc1.jpg", style: "left: 423px; top: 1399px;"}
%img.czecher-piece{src:"/tendy-logo-icrc1.jpg", style: "left: 504px; top: 1399px;"}
%img.czecher-piece{src:"/tendy-logo-icrc1.jpg", style: "left: 585px; top: 1399px;"}
%img.czecher-piece{src:"/tendy-logo-icrc1.jpg", style: "left: 666px; top: 1399px;"}
%img.czecher-piece{src:"/tendy-logo-icrc1.jpg", style: "left: 747px; top: 1399px;"}
.board
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell{style: "background: #EFFA8D;"}
.cell
.cell{style: "background: #EFFA8D;"}
.cell
.cell
.cell
.cell
.cell
.cell
.cell{style: "background: #B5FFFF;"}
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell
.cell

View File

@ -15,6 +15,30 @@
%p= link_to '+ New Doodad', new_doodad_path %p= link_to '+ New Doodad', new_doodad_path
= render @doodads = render @doodads
:javascript
function destroyDoodad(doodad_id) {
return fetch("/doodads/" + doodad_id, {
method: 'DELETE',
headers: {
"Content-Type": "application/json",
"Accept": "application/json"
}
})
.then(response => response)
};
// var s2 = Swiped.init({ query: '.bar li', list: true, left: 200, right: 200 });
var index_doodad_swiped = Swiped.init({ query: '#doodads .doodad',
list: true,
left: 200,
right: 200,
onOpen: function() {
var doodad_id = this.elem.className.split("-")[1];
destroyDoodad(doodad_id)
.then(results => console.log(results));
this.destroy(true)
}
});
-# #canisters -# #canisters
= render @canisters = render @canisters
- if current_user.signed_in? - if current_user.signed_in?

4
bin/importmap Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env ruby
require_relative "../config/application"
require "importmap/commands"

View File

@ -1,7 +1,7 @@
require_relative "boot" require_relative "boot"
require "rails/all" require "rails/all"
require 'telegram/bot' # TODO enable telegram bots with job scheduler require 'telegram/bot'
# Require the gems listed in Gemfile, including any gems # Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production. # you've limited to :test, :development, or :production.
@ -20,6 +20,6 @@ module MyTendyZone
# #
# config.time_zone = "Central Time (US & Canada)" # config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras") # config.eager_load_paths << Rails.root.join("extras")
config.active_job.queue_adapter = :delayed_job # TODO enable job scheduler config.active_job.queue_adapter = :delayed_job
end end
end end

View File

@ -1,5 +1,5 @@
set :application, "thirteen_tien_len_#{fetch(:stage)}" set :application, "thirteen_tien_len_#{fetch(:stage)}"
set :repo_url, 'git@pineapple.punked.us:Bort/thirteen-tien-len.git' set :repo_url, 'git@git.tendy.zone:Bort/thirteen-tien-len.git'
# If you want to import assets, you can change default asset dir (default = system) # If you want to import assets, you can change default asset dir (default = system)
# This directory must be in your shared directory on the server # This directory must be in your shared directory on the server

View File

@ -1,9 +1,3 @@
pin 'application', preload: true # Pin npm packages by running ./bin/importmap
pin 'jquery'
pin '@hotwired/turbo-rails', to: "turbo.js" pin "application", preload: true
pin '@hotwired/stimulus', to: 'stimulus.min.js', preload: true
pin '@hotwired/stimulus-loading', to: 'stimulus-loading.js', preload: true
pin_all_from 'app/javascript/models', under: 'models'
pin_all_from 'app/javascript/controllers', under: 'controllers'
pin_all_from 'app/javascript/subscriptions', under: 'subscriptions'
pin "@hotwired/turbo-rails", to: "turbo.min.js", preload: true

View File

@ -2,4 +2,4 @@
# Available options are: :status, :serialized_job, :exception # Available options are: :status, :serialized_job, :exception
# Default is [:status] # Default is [:status]
# #
ActiveJob::Status.options = { includes: %i[status exception] } # TODO enable job scheduler ActiveJob::Status.options = { includes: %i[status exception] }

View File

@ -1,4 +1,5 @@
Rails.application.routes.draw do Rails.application.routes.draw do
get 'pages/czechers'
resources :metapurses do resources :metapurses do
member do member do
get 'data' get 'data'

View File

@ -79,7 +79,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_03_25_142502) do
t.integer "sluggable_id", null: false t.integer "sluggable_id", null: false
t.string "sluggable_type", limit: 50 t.string "sluggable_type", limit: 50
t.string "scope" t.string "scope"
t.datetime "created_at" t.datetime "created_at", precision: nil
t.index ["slug", "sluggable_type", "scope"], name: "index_friendly_id_slugs_on_slug_and_sluggable_type_and_scope", unique: true t.index ["slug", "sluggable_type", "scope"], name: "index_friendly_id_slugs_on_slug_and_sluggable_type_and_scope", unique: true
t.index ["slug", "sluggable_type"], name: "index_friendly_id_slugs_on_slug_and_sluggable_type" t.index ["slug", "sluggable_type"], name: "index_friendly_id_slugs_on_slug_and_sluggable_type"
t.index ["sluggable_type", "sluggable_id"], name: "index_friendly_id_slugs_on_sluggable_type_and_sluggable_id" t.index ["sluggable_type", "sluggable_id"], name: "index_friendly_id_slugs_on_sluggable_type_and_sluggable_id"
@ -295,7 +295,6 @@ ActiveRecord::Schema[7.1].define(version: 2024_03_25_142502) do
t.integer "invitations_count", default: 0 t.integer "invitations_count", default: 0
t.string "soft_token" t.string "soft_token"
t.integer "win_count", default: 0 t.integer "win_count", default: 0
t.integer "points"
t.index ["email"], name: "index_users_on_email", unique: true t.index ["email"], name: "index_users_on_email", unique: true
t.index ["invitation_token"], name: "index_users_on_invitation_token", unique: true t.index ["invitation_token"], name: "index_users_on_invitation_token", unique: true
t.index ["invitations_count"], name: "index_users_on_invitations_count" t.index ["invitations_count"], name: "index_users_on_invitations_count"

BIN
public/czech-logo-dip20.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

BIN
public/tendy-logo-icrc1.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

View File

@ -0,0 +1,15 @@
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the PagesHelper. For example:
#
# describe PagesHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe PagesHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -0,0 +1,11 @@
require 'rails_helper'
RSpec.describe "Pages", type: :request do
describe "GET /czechers" do
it "returns http success" do
get "/pages/czechers"
expect(response).to have_http_status(:success)
end
end
end

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe "pages/czechers.html.haml", type: :view do
pending "add some examples to (or delete) #{__FILE__}"
end