Merge branch 'chore/upgrade_rails' into live

This commit is contained in:
Râu Cao 2025-04-28 15:58:17 +04:00
commit ebaca5ba65
Signed by: raucao
GPG Key ID: 37036C356E56CC51
24 changed files with 394 additions and 311 deletions

3
.gitignore vendored
View File

@ -47,3 +47,6 @@ dump.rdb
/app/assets/builds/* /app/assets/builds/*
!/app/assets/builds/.keep !/app/assets/builds/.keep
# Ignore generated ctags
*.tags

View File

@ -2,7 +2,7 @@ source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" } git_source(:github) { |repo| "https://github.com/#{repo}.git" }
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 7.1' gem 'rails', '~> 7.2'
# Use Puma as the app server # Use Puma as the app server
gem 'puma', '~> 4.1' gem 'puma', '~> 4.1'
# View components # View components

View File

@ -1,80 +1,77 @@
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
actioncable (7.1.3) actioncable (7.2.2.1)
actionpack (= 7.1.3) actionpack (= 7.2.2.1)
activesupport (= 7.1.3) activesupport (= 7.2.2.1)
nio4r (~> 2.0) nio4r (~> 2.0)
websocket-driver (>= 0.6.1) websocket-driver (>= 0.6.1)
zeitwerk (~> 2.6) zeitwerk (~> 2.6)
actionmailbox (7.1.3) actionmailbox (7.2.2.1)
actionpack (= 7.1.3) actionpack (= 7.2.2.1)
activejob (= 7.1.3) activejob (= 7.2.2.1)
activerecord (= 7.1.3) activerecord (= 7.2.2.1)
activestorage (= 7.1.3) activestorage (= 7.2.2.1)
activesupport (= 7.1.3) activesupport (= 7.2.2.1)
mail (>= 2.7.1) mail (>= 2.8.0)
net-imap actionmailer (7.2.2.1)
net-pop actionpack (= 7.2.2.1)
net-smtp actionview (= 7.2.2.1)
actionmailer (7.1.3) activejob (= 7.2.2.1)
actionpack (= 7.1.3) activesupport (= 7.2.2.1)
actionview (= 7.1.3) mail (>= 2.8.0)
activejob (= 7.1.3)
activesupport (= 7.1.3)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
rails-dom-testing (~> 2.2) rails-dom-testing (~> 2.2)
actionpack (7.1.3) actionpack (7.2.2.1)
actionview (= 7.1.3) actionview (= 7.2.2.1)
activesupport (= 7.1.3) activesupport (= 7.2.2.1)
nokogiri (>= 1.8.5) nokogiri (>= 1.8.5)
racc racc
rack (>= 2.2.4) rack (>= 2.2.4, < 3.2)
rack-session (>= 1.0.1) rack-session (>= 1.0.1)
rack-test (>= 0.6.3) rack-test (>= 0.6.3)
rails-dom-testing (~> 2.2) rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6) rails-html-sanitizer (~> 1.6)
actiontext (7.1.3) useragent (~> 0.16)
actionpack (= 7.1.3) actiontext (7.2.2.1)
activerecord (= 7.1.3) actionpack (= 7.2.2.1)
activestorage (= 7.1.3) activerecord (= 7.2.2.1)
activesupport (= 7.1.3) activestorage (= 7.2.2.1)
activesupport (= 7.2.2.1)
globalid (>= 0.6.0) globalid (>= 0.6.0)
nokogiri (>= 1.8.5) nokogiri (>= 1.8.5)
actionview (7.1.3) actionview (7.2.2.1)
activesupport (= 7.1.3) activesupport (= 7.2.2.1)
builder (~> 3.1) builder (~> 3.1)
erubi (~> 1.11) erubi (~> 1.11)
rails-dom-testing (~> 2.2) rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6) rails-html-sanitizer (~> 1.6)
activejob (7.1.3) activejob (7.2.2.1)
activesupport (= 7.1.3) activesupport (= 7.2.2.1)
globalid (>= 0.3.6) globalid (>= 0.3.6)
activemodel (7.1.3) activemodel (7.2.2.1)
activesupport (= 7.1.3) activesupport (= 7.2.2.1)
activerecord (7.1.3) activerecord (7.2.2.1)
activemodel (= 7.1.3) activemodel (= 7.2.2.1)
activesupport (= 7.1.3) activesupport (= 7.2.2.1)
timeout (>= 0.4.0) timeout (>= 0.4.0)
activestorage (7.1.3) activestorage (7.2.2.1)
actionpack (= 7.1.3) actionpack (= 7.2.2.1)
activejob (= 7.1.3) activejob (= 7.2.2.1)
activerecord (= 7.1.3) activerecord (= 7.2.2.1)
activesupport (= 7.1.3) activesupport (= 7.2.2.1)
marcel (~> 1.0) marcel (~> 1.0)
activesupport (7.1.3) activesupport (7.2.2.1)
base64 base64
benchmark (>= 0.3)
bigdecimal bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2) concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5) connection_pool (>= 2.2.5)
drb drb
i18n (>= 1.6, < 2) i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1) minitest (>= 5.1)
mutex_m securerandom (>= 0.3)
tzinfo (~> 2.0) tzinfo (~> 2.0, >= 2.0.5)
addressable (2.8.6) addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0) public_suffix (>= 2.0.2, < 6.0)
ast (2.4.2) ast (2.4.2)
@ -99,12 +96,12 @@ GEM
bcrypt (3.1.20) bcrypt (3.1.20)
bech32 (1.4.2) bech32 (1.4.2)
thor (>= 1.1.0) thor (>= 1.1.0)
benchmark (0.3.0) benchmark (0.4.0)
bigdecimal (3.1.6) bigdecimal (3.1.9)
bindex (0.8.1) bindex (0.8.1)
bip-schnorr (0.7.0) bip-schnorr (0.7.0)
ecdsa_ext (~> 0.5.0) ecdsa_ext (~> 0.5.0)
builder (3.2.4) builder (3.3.0)
capybara (3.40.0) capybara (3.40.0)
addressable addressable
matrix matrix
@ -115,21 +112,21 @@ GEM
regexp_parser (>= 1.5, < 3.0) regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2) xpath (~> 3.2)
chunky_png (1.4.0) chunky_png (1.4.0)
concurrent-ruby (1.2.3) concurrent-ruby (1.3.5)
connection_pool (2.4.1) connection_pool (2.5.2)
crack (0.4.6) crack (0.4.6)
bigdecimal bigdecimal
rexml rexml
crass (1.0.6) crass (1.0.6)
cssbundling-rails (1.4.0) cssbundling-rails (1.4.0)
railties (>= 6.0.0) railties (>= 6.0.0)
database_cleaner (2.0.2) database_cleaner (2.1.0)
database_cleaner-active_record (>= 2, < 3) database_cleaner-active_record (>= 2, < 3)
database_cleaner-active_record (2.1.0) database_cleaner-active_record (2.2.0)
activerecord (>= 5.a) activerecord (>= 5.a)
database_cleaner-core (~> 2.0.0) database_cleaner-core (~> 2.0.0)
database_cleaner-core (2.0.1) database_cleaner-core (2.0.1)
date (3.3.4) date (3.4.1)
devise (4.9.3) devise (4.9.3)
bcrypt (~> 3.0) bcrypt (~> 3.0)
orm_adapter (~> 0.1) orm_adapter (~> 0.1)
@ -151,13 +148,12 @@ GEM
railties (>= 3.2) railties (>= 3.2)
down (5.4.1) down (5.4.1)
addressable (~> 2.8) addressable (~> 2.8)
drb (2.2.0) drb (2.2.1)
ruby2_keywords
e2mmap (0.1.0) e2mmap (0.1.0)
ecdsa (1.2.0) ecdsa (1.2.0)
ecdsa_ext (0.5.1) ecdsa_ext (0.5.1)
ecdsa (~> 1.2.0) ecdsa (~> 1.2.0)
erubi (1.12.0) erubi (1.13.1)
et-orbi (1.2.7) et-orbi (1.2.7)
tzinfo tzinfo
event_emitter (0.2.6) event_emitter (0.2.6)
@ -200,7 +196,7 @@ GEM
gpgme (2.0.24) gpgme (2.0.24)
mini_portile2 (~> 2.7) mini_portile2 (~> 2.7)
hashdiff (1.1.0) hashdiff (1.1.0)
i18n (1.14.1) i18n (1.14.7)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
image_processing (1.12.2) image_processing (1.12.2)
mini_magick (>= 4.9.5, < 5) mini_magick (>= 4.9.5, < 5)
@ -209,9 +205,10 @@ GEM
actionpack (>= 6.0.0) actionpack (>= 6.0.0)
activesupport (>= 6.0.0) activesupport (>= 6.0.0)
railties (>= 6.0.0) railties (>= 6.0.0)
io-console (0.7.2) io-console (0.8.0)
irb (1.11.1) irb (1.15.2)
rdoc pp (>= 0.6.0)
rdoc (>= 4.0.0)
reline (>= 0.4.2) reline (>= 0.4.2)
jaro_winkler (1.5.6) jaro_winkler (1.5.6)
jbuilder (2.11.5) jbuilder (2.11.5)
@ -238,8 +235,9 @@ GEM
rb-inotify (~> 0.9, >= 0.9.10) rb-inotify (~> 0.9, >= 0.9.10)
lnurl (1.1.0) lnurl (1.1.0)
bech32 (~> 1.1) bech32 (~> 1.1)
lockbox (1.3.2) lockbox (2.0.1)
loofah (2.22.0) logger (1.7.0)
loofah (2.24.0)
crass (~> 1.0.2) crass (~> 1.0.2)
nokogiri (>= 1.12.0) nokogiri (>= 1.12.0)
mail (2.8.1) mail (2.8.1)
@ -251,18 +249,17 @@ GEM
faraday (~> 2.9.0) faraday (~> 2.9.0)
faraday-follow_redirects (= 0.3.0) faraday-follow_redirects (= 0.3.0)
nokogiri (~> 1.16.0) nokogiri (~> 1.16.0)
marcel (1.0.2) marcel (1.0.4)
matrix (0.4.2) matrix (0.4.2)
method_source (1.0.0) method_source (1.0.0)
mini_magick (4.12.0) mini_magick (4.12.0)
mini_mime (1.1.5) mini_mime (1.1.5)
mini_portile2 (2.8.5) mini_portile2 (2.8.8)
minitest (5.21.2) minitest (5.25.5)
multipart-post (2.3.0) multipart-post (2.3.0)
mutex_m (0.2.0)
net-http (0.4.1) net-http (0.4.1)
uri uri
net-imap (0.4.9.1) net-imap (0.5.7)
date date
net-protocol net-protocol
net-ldap (0.19.0) net-ldap (0.19.0)
@ -270,15 +267,15 @@ GEM
net-protocol net-protocol
net-protocol (0.2.2) net-protocol (0.2.2)
timeout timeout
net-smtp (0.4.0.1) net-smtp (0.5.1)
net-protocol net-protocol
nio4r (2.7.0) nio4r (2.7.4)
nokogiri (1.16.0) nokogiri (1.16.8)
mini_portile2 (~> 2.8.2) mini_portile2 (~> 2.8.2)
racc (~> 1.4) racc (~> 1.4)
nokogiri (1.16.0-arm64-darwin) nokogiri (1.16.8-arm64-darwin)
racc (~> 1.4) racc (~> 1.4)
nokogiri (1.16.0-x86_64-linux) nokogiri (1.16.8-x86_64-linux)
racc (~> 1.4) racc (~> 1.4)
nostr (0.6.0) nostr (0.6.0)
bech32 (~> 1.4) bech32 (~> 1.4)
@ -294,38 +291,42 @@ GEM
ast (~> 2.4.1) ast (~> 2.4.1)
racc racc
pg (1.5.4) pg (1.5.4)
psych (5.1.2) pp (0.6.2)
prettyprint
prettyprint (0.2.0)
psych (5.2.3)
date
stringio stringio
public_suffix (5.0.4) public_suffix (5.0.4)
puma (4.3.12) puma (4.3.12)
nio4r (~> 2.0) nio4r (~> 2.0)
raabro (1.4.0) raabro (1.4.0)
racc (1.7.3) racc (1.8.1)
rack (2.2.8) rack (2.2.13)
rack-protection (3.2.0) rack-protection (3.2.0)
base64 (>= 0.1.0) base64 (>= 0.1.0)
rack (~> 2.2, >= 2.2.4) rack (~> 2.2, >= 2.2.4)
rack-session (1.0.2) rack-session (1.0.2)
rack (< 3) rack (< 3)
rack-test (2.1.0) rack-test (2.2.0)
rack (>= 1.3) rack (>= 1.3)
rackup (1.0.0) rackup (1.0.1)
rack (< 3) rack (< 3)
webrick webrick
rails (7.1.3) rails (7.2.2.1)
actioncable (= 7.1.3) actioncable (= 7.2.2.1)
actionmailbox (= 7.1.3) actionmailbox (= 7.2.2.1)
actionmailer (= 7.1.3) actionmailer (= 7.2.2.1)
actionpack (= 7.1.3) actionpack (= 7.2.2.1)
actiontext (= 7.1.3) actiontext (= 7.2.2.1)
actionview (= 7.1.3) actionview (= 7.2.2.1)
activejob (= 7.1.3) activejob (= 7.2.2.1)
activemodel (= 7.1.3) activemodel (= 7.2.2.1)
activerecord (= 7.1.3) activerecord (= 7.2.2.1)
activestorage (= 7.1.3) activestorage (= 7.2.2.1)
activesupport (= 7.1.3) activesupport (= 7.2.2.1)
bundler (>= 1.15.0) bundler (>= 1.15.0)
railties (= 7.1.3) railties (= 7.2.2.1)
rails-controller-testing (1.0.5) rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1) actionpack (>= 5.0.1.rc1)
actionview (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1)
@ -334,31 +335,31 @@ GEM
activesupport (>= 5.0.0) activesupport (>= 5.0.0)
minitest minitest
nokogiri (>= 1.6) nokogiri (>= 1.6)
rails-html-sanitizer (1.6.0) rails-html-sanitizer (1.6.2)
loofah (~> 2.21) loofah (~> 2.21)
nokogiri (~> 1.14) nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
rails-settings-cached (2.8.3) rails-settings-cached (2.8.3)
activerecord (>= 5.0.0) activerecord (>= 5.0.0)
railties (>= 5.0.0) railties (>= 5.0.0)
railties (7.1.3) railties (7.2.2.1)
actionpack (= 7.1.3) actionpack (= 7.2.2.1)
activesupport (= 7.1.3) activesupport (= 7.2.2.1)
irb irb (~> 1.13)
rackup (>= 1.0.0) rackup (>= 1.0.0)
rake (>= 12.2) rake (>= 12.2)
thor (~> 1.0, >= 1.2.2) thor (~> 1.0, >= 1.2.2)
zeitwerk (~> 2.6) zeitwerk (~> 2.6)
rainbow (3.1.1) rainbow (3.1.1)
rake (13.1.0) rake (13.2.1)
rb-fsevent (0.11.2) rb-fsevent (0.11.2)
rb-inotify (0.10.1) rb-inotify (0.10.1)
ffi (~> 1.0) ffi (~> 1.0)
rbs (2.8.4) rbs (2.8.4)
rdoc (6.6.2) rdoc (6.13.1)
psych (>= 4.0.0) psych (>= 4.0.0)
redis (4.8.1) redis (4.8.1)
regexp_parser (2.9.0) regexp_parser (2.9.0)
reline (0.4.2) reline (0.6.1)
io-console (~> 0.5) io-console (~> 0.5)
responders (3.1.1) responders (3.1.1)
actionpack (>= 5.2) actionpack (>= 5.2)
@ -403,12 +404,12 @@ GEM
ruby-progressbar (1.13.0) ruby-progressbar (1.13.0)
ruby-vips (2.2.0) ruby-vips (2.2.0)
ffi (~> 1.12) ffi (~> 1.12)
ruby2_keywords (0.0.5)
rufus-scheduler (3.9.1) rufus-scheduler (3.9.1)
fugit (~> 1.1, >= 1.1.6) fugit (~> 1.1, >= 1.1.6)
sanitize (6.1.0) sanitize (6.1.0)
crass (~> 1.0.2) crass (~> 1.0.2)
nokogiri (>= 1.12.0) nokogiri (>= 1.12.0)
securerandom (0.4.1)
sentry-rails (5.16.1) sentry-rails (5.16.1)
railties (>= 5.0) railties (>= 5.0)
sentry-ruby (~> 5.16.1) sentry-ruby (~> 5.16.1)
@ -451,10 +452,10 @@ GEM
sqlite3 (1.7.2-x86_64-linux) sqlite3 (1.7.2-x86_64-linux)
stimulus-rails (1.3.3) stimulus-rails (1.3.3)
railties (>= 6.0.0) railties (>= 6.0.0)
stringio (3.1.0) stringio (3.1.7)
thor (1.3.0) thor (1.3.2)
tilt (2.3.0) tilt (2.3.0)
timeout (0.4.1) timeout (0.4.3)
turbo-rails (1.5.0) turbo-rails (1.5.0)
actionpack (>= 6.0.0) actionpack (>= 6.0.0)
activejob (>= 6.0.0) activejob (>= 6.0.0)
@ -463,6 +464,7 @@ GEM
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0) unicode-display_width (2.5.0)
uri (0.13.0) uri (0.13.0)
useragent (0.16.11)
view_component (3.10.0) view_component (3.10.0)
activesupport (>= 5.2.0, < 8.0) activesupport (>= 5.2.0, < 8.0)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
@ -478,15 +480,16 @@ GEM
addressable (>= 2.8.0) addressable (>= 2.8.0)
crack (>= 0.3.2) crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0) hashdiff (>= 0.4.0, < 2.0.0)
webrick (1.8.1) webrick (1.9.1)
websocket-driver (0.7.6) websocket-driver (0.7.7)
base64
websocket-extensions (>= 0.1.0) websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5) websocket-extensions (0.1.5)
xpath (3.2.0) xpath (3.2.0)
nokogiri (~> 1.8) nokogiri (~> 1.8)
yard (0.9.34) yard (0.9.34)
zbase32 (0.1.1) zbase32 (0.1.1)
zeitwerk (2.6.12) zeitwerk (2.7.2)
PLATFORMS PLATFORMS
arm64-darwin-22 arm64-darwin-22
@ -525,7 +528,7 @@ DEPENDENCIES
pagy (~> 6.0, >= 6.0.2) pagy (~> 6.0, >= 6.0.2)
pg (~> 1.5) pg (~> 1.5)
puma (~> 4.1) puma (~> 4.1)
rails (~> 7.1) rails (~> 7.2)
rails-controller-testing rails-controller-testing
rails-settings-cached (~> 2.8.3) rails-settings-cached (~> 2.8.3)
rqrcode (~> 2.0) rqrcode (~> 2.0)

View File

@ -74,7 +74,7 @@ class WebfingerController < WellKnownController
end end
def remotestorage_link def remotestorage_link
auth_url = new_rs_oauth_url(@username, host: Setting.accounts_domain) auth_url = new_rs_oauth_url(@username, host: Setting.rs_accounts_domain)
storage_url = "#{Setting.rs_storage_url}/#{@username}" storage_url = "#{Setting.rs_storage_url}/#{@username}"
{ {

View File

@ -6,6 +6,9 @@ module Settings
field :remotestorage_enabled, type: :boolean, field :remotestorage_enabled, type: :boolean,
default: ENV["RS_STORAGE_URL"].present? default: ENV["RS_STORAGE_URL"].present?
field :rs_accounts_domain, type: :string,
default: ENV["RS_AKKOUNTS_DOMAIN"] || ENV["AKKOUNTS_DOMAIN"]
field :rs_storage_url, type: :string, field :rs_storage_url, type: :string,
default: ENV["RS_STORAGE_URL"].presence default: ENV["RS_STORAGE_URL"].presence

View File

@ -2,7 +2,7 @@ class RemoteStorageAuthorization < ApplicationRecord
belongs_to :user belongs_to :user
belongs_to :web_app, class_name: "AppCatalog::WebApp", optional: true belongs_to :web_app, class_name: "AppCatalog::WebApp", optional: true
serialize :permissions unless Rails.env.production? serialize :permissions, coder: YAML unless Rails.env.production?
validates_presence_of :permissions validates_presence_of :permissions
validates_presence_of :client_id validates_presence_of :client_id

View File

@ -14,8 +14,9 @@
<p class="mb-6"> <p class="mb-6">
In order to connect an app to your storage account, give it your address: In order to connect an app to your storage account, give it your address:
</p> </p>
<p data-controller="clipboard" class="flex items-center gap-1 sm:w-2/5"> <p data-controller="clipboard" class="flex gap-1 sm:w-2/5">
<img src="/img/logos/icon_remotestorage.svg" class="inline-block h-6 w-6 mr-1"> <img src="/img/logos/icon_remotestorage.svg"
class="inline-block h-6 w-6 mr-1 self-center">
<input type="text" id="user_address" class="grow" <input type="text" id="user_address" class="grow"
value=<%= current_user.address %> disabled="disabled" value=<%= current_user.address %> disabled="disabled"
data-clipboard-target="source" /> data-clipboard-target="source" />

View File

@ -1,9 +1,4 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
begin APP_PATH = File.expand_path("../config/application", __dir__)
load File.expand_path('../spring', __FILE__) require_relative "../config/boot"
rescue LoadError => e require "rails/commands"
raise unless e.message.include?('spring')
end
APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require 'rails/commands'

View File

@ -1,9 +1,4 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
begin require_relative "../config/boot"
load File.expand_path('../spring', __FILE__) require "rake"
rescue LoadError => e
raise unless e.message.include?('spring')
end
require_relative '../config/boot'
require 'rake'
Rake.application.run Rake.application.run

8
bin/rubocop Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env ruby
require "rubygems"
require "bundler/setup"
# explicit rubocop config increases performance slightly while avoiding config confusion.
ARGV.unshift("--config", File.expand_path("../.rubocop.yml", __dir__))
load Gem.bin_path("rubocop", "rubocop")

View File

@ -1,36 +1,37 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
require 'fileutils' require "fileutils"
# path to your application root. APP_ROOT = File.expand_path("..", __dir__)
APP_ROOT = File.expand_path('..', __dir__) APP_NAME = "akkounts"
def system!(*args) def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==") system(*args, exception: true)
end end
FileUtils.chdir APP_ROOT do FileUtils.chdir APP_ROOT do
# This script is a way to setup or update your development environment automatically. # This script is a way to set up or update your development environment automatically.
# This script is idempotent, so that you can run it at anytime and get an expectable outcome. # This script is idempotent, so that you can run it at any time and get an expectable outcome.
# Add necessary setup steps to this file. # Add necessary setup steps to this file.
puts '== Installing dependencies ==' puts "== Installing dependencies =="
system! 'gem install bundler --conservative' system! "gem install bundler --conservative"
system('bundle check') || system!('bundle install') system("bundle check") || system!("bundle install")
# Install JavaScript dependencies
# system('bin/yarn')
# puts "\n== Copying sample files ==" # puts "\n== Copying sample files =="
# unless File.exist?('config/database.yml') # unless File.exist?("config/database.yml")
# FileUtils.cp 'config/database.yml.sample', 'config/database.yml' # FileUtils.cp "config/database.yml.sample", "config/database.yml"
# end # end
puts "\n== Preparing database ==" puts "\n== Preparing database =="
system! 'bin/rails db:prepare' system! "bin/rails db:prepare"
puts "\n== Removing old logs and tempfiles ==" puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear' system! "bin/rails log:clear tmp:clear"
puts "\n== Restarting application server ==" puts "\n== Restarting application server =="
system! 'bin/rails restart' system! "bin/rails restart"
# puts "\n== Configuring puma-dev =="
# system "ln -nfs #{APP_ROOT} ~/.puma-dev/#{APP_NAME}"
# system "curl -Is https://#{APP_NAME}.test/up | head -n 1"
end end

View File

@ -1,4 +1,4 @@
require_relative 'boot' require_relative "boot"
require "rails" require "rails"
# Pick the frameworks you want: # Pick the frameworks you want:
@ -12,7 +12,6 @@ require "action_mailbox/engine"
# require "action_text/engine" # require "action_text/engine"
require "action_view/railtie" require "action_view/railtie"
require "action_cable/engine" require "action_cable/engine"
require "sprockets/railtie"
# require "rails/test_unit/railtie" # require "rails/test_unit/railtie"
# Require the gems listed in Gemfile, including any gems # Require the gems listed in Gemfile, including any gems
@ -22,12 +21,20 @@ Bundler.require(*Rails.groups)
module Akkounts module Akkounts
class Application < Rails::Application class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version. # Initialize configuration defaults for originally generated Rails version.
config.load_defaults 7.0 config.load_defaults 7.2
# Settings in config/environments/* take precedence over those specified here. # Please, add to the `ignore` list any other `lib` subdirectories that do
# Application configuration can go into files in config/initializers # not contain `.rb` files, or that should not be reloaded or eager loaded.
# -- all .rb files in that directory are automatically loaded after loading # Common ones are `templates`, `generators`, or `middleware`, for example.
# the framework and any gems in your application. config.autoload_lib(ignore: %w[assets tasks])
# Configuration for the application, engines, and railties goes here.
#
# These settings can be overridden in specific environments using the files
# in config/environments, which are processed later.
#
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")
# Don't generate system test files. # Don't generate system test files.
config.generators.system_tests = nil config.generators.system_tests = nil
@ -41,6 +48,10 @@ module Akkounts
end end
config.active_job.queue_adapter = :sidekiq config.active_job.queue_adapter = :sidekiq
config.action_mailer.deliver_later_queue_name = nil # use "default" queue config.action_mailer.deliver_later_queue_name = nil # use "default" queue
# The default includes webp, which requires webp support everywhere
config.active_storage.web_image_content_types = %w[image/png image/jpeg image/gif]
end end
end end

View File

@ -1,5 +1,5 @@
# Load the Rails application. # Load the Rails application.
require_relative 'application' require_relative "application"
# Initialize the Rails application. # Initialize the Rails application.
Rails.application.initialize! Rails.application.initialize!

View File

@ -1,10 +1,12 @@
require "active_support/core_ext/integer/time"
Rails.application.configure do Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb. # Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on # In the development environment your application's code is reloaded any time
# every request. This slows down response time but is perfect for development # it changes. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes. # since you don't have to restart the web server when you make code changes.
config.cache_classes = false config.enable_reloading = true
# Do not eager load code on boot. # Do not eager load code on boot.
config.eager_load = false config.eager_load = false
@ -12,16 +14,17 @@ Rails.application.configure do
# Show full error reports. # Show full error reports.
config.consider_all_requests_local = true config.consider_all_requests_local = true
# Enable server timing.
config.server_timing = true
# Enable/disable caching. By default caching is disabled. # Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching. # Run rails dev:cache to toggle caching.
if Rails.root.join('tmp', 'caching-dev.txt').exist? if Rails.root.join("tmp/caching-dev.txt").exist?
config.action_controller.perform_caching = true config.action_controller.perform_caching = true
config.action_controller.enable_fragment_cache_logging = true config.action_controller.enable_fragment_cache_logging = true
config.cache_store = :memory_store config.cache_store = :memory_store
config.public_file_server.headers = { config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{2.days.to_i}" }
'Cache-Control' => "public, max-age=#{2.days.to_i}"
}
else else
config.action_controller.perform_caching = false config.action_controller.perform_caching = false
@ -31,41 +34,51 @@ Rails.application.configure do
# Don't care if the mailer can't send. # Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false config.action_mailer.raise_delivery_errors = false
# Disable caching for Action Mailer templates even if Action Controller
# caching is enabled.
config.action_mailer.perform_caching = false config.action_mailer.perform_caching = false
# Print deprecation notices to the Rails logger. # Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log config.active_support.deprecation = :log
# Raise exceptions for disallowed deprecations.
config.active_support.disallowed_deprecation = :raise
# Tell Active Support which deprecation messages to disallow.
config.active_support.disallowed_deprecation_warnings = []
# Raise an error on page load if there are pending migrations. # Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load config.active_record.migration_error = :page_load
# Highlight code that triggered database queries in logs. # Highlight code that triggered database queries in logs.
config.active_record.verbose_query_logs = true config.active_record.verbose_query_logs = true
# Debug mode disables concatenation and preprocessing of assets. # Highlight code that enqueued background job in logs.
# This option may cause significant delays in view rendering with a large config.active_job.verbose_enqueue_logs = true
# number of complex assets.
config.assets.debug = true
# Suppress logger output for asset requests. # Suppress logger output for asset requests.
config.assets.quiet = true config.assets.quiet = true
# Raises error for missing translations. # Raises error for missing translations.
# config.action_view.raise_on_missing_translations = true # config.i18n.raise_on_missing_translations = true
# Use an evented file watcher to asynchronously detect changes in source code, # Annotate rendered view with file names.
# routes, locales, etc. This feature depends on the listen gem. config.action_view.annotate_rendered_view_with_filenames = true
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
# Don't actually send emails, cache them for viewing via letter opener # Don't actually send emails, cache them for viewing via letter opener
config.action_mailer.delivery_method = :letter_opener config.action_mailer.delivery_method = :letter_opener
# Uncomment if you wish to allow Action Cable access from any origin.
# config.action_cable.disable_request_forgery_protection = true
# Don't care if the mailer can't send # Raise error when a before_action's only/except options reference missing actions.
config.action_controller.raise_on_missing_callback_actions = true
# Notice if the mailer can't send
config.action_mailer.raise_delivery_errors = true config.action_mailer.raise_delivery_errors = true
# Base URL to be used by email template link helpers # Base URL to be used by email template link helpers
config.action_mailer.default_url_options = { config.action_mailer.default_url_options = {
host: "localhost:3000", host: "localhost:3000", # TODO port: 3000
protocol: "http" protocol: "http"
} }

View File

@ -1,8 +1,10 @@
require "active_support/core_ext/integer/time"
Rails.application.configure do Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb. # Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests. # Code is not reloaded between requests.
config.cache_classes = true config.enable_reloading = false
# Eager load code on boot. This eager loads most of Rails and # Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers # your application in memory, allowing both threaded web servers
@ -11,11 +13,11 @@ Rails.application.configure do
config.eager_load = true config.eager_load = true
# Full error reports are disabled and caching is turned on. # Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false config.consider_all_requests_local = false
config.action_controller.perform_caching = true config.action_controller.perform_caching = true
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] # Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files). # key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files).
# config.require_master_key = true # config.require_master_key = true
# Disable serving static files from the `/public` folder by default since # Disable serving static files from the `/public` folder by default since
@ -29,32 +31,47 @@ Rails.application.configure do
config.assets.compile = false config.assets.compile = false
# Enable serving of images, stylesheets, and JavaScripts from an asset server. # Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com' # config.asset_host = "http://assets.example.com"
# Specifies the header that your server uses for sending files. # Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
# Mount Action Cable outside main process or domain. # Mount Action Cable outside main process or domain.
# config.action_cable.mount_path = nil # config.action_cable.mount_path = nil
# config.action_cable.url = 'wss://example.com/cable' # config.action_cable.url = "wss://example.com/cable"
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ]
# Assume all access to the app is happening through a SSL-terminating reverse proxy.
# Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies.
# config.assume_ssl = true
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true # config.force_ssl = true
# Use the lowest log level to ensure availability of diagnostic information # Skip http-to-https redirect for the default health check endpoint.
# when problems arise. # config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } }
config.log_level = :debug
# Log to STDOUT if configured
if ENV["RAILS_LOG_TO_STDOUT"].present?
config.logger = ActiveSupport::Logger.new(STDOUT)
.tap { |logger| logger.formatter = ::Logger::Formatter.new }
.then { |logger| ActiveSupport::TaggedLogging.new(logger) }
end
# Prepend all log lines with the following tags. # Prepend all log lines with the following tags.
config.log_tags = [ :request_id ] config.log_tags = [ :request_id ]
# "info" includes generic and useful information about system operation, but avoids logging too much
# information to avoid inadvertent exposure of personally identifiable information (PII). If you
# want to log everything, set the level to "debug".
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
# Use a different cache store in production. # Use a different cache store in production.
# config.cache_store = :mem_cache_store # config.cache_store = :mem_cache_store
# Use a real queuing backend for Active Job (and separate queues per environment). # Use a real queuing backend for Active Job (and separate queues per environment).
# config.active_job.queue_adapter = :resque # config.active_job.queue_adapter = :resque
# config.active_job.queue_name_prefix = "akkounts_production" # config.active_job.queue_name_prefix = "akkounts_production"
# E-mail settings, adapted from https://github.com/mastodon/mastodon # E-mail settings, adapted from https://github.com/mastodon/mastodon
@ -106,6 +123,10 @@ Rails.application.configure do
config.action_mailer.delivery_method = ENV.fetch('SMTP_DELIVERY_METHOD', 'smtp').to_sym config.action_mailer.delivery_method = ENV.fetch('SMTP_DELIVERY_METHOD', 'smtp').to_sym
# Disable caching for Action Mailer templates even if Action Controller
# caching is enabled.
config.action_mailer.perform_caching = false
# Ignore bad email addresses and do not raise email delivery errors. # Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors.
config.action_mailer.raise_delivery_errors = true config.action_mailer.raise_delivery_errors = true
@ -120,43 +141,21 @@ Rails.application.configure do
# the I18n.default_locale when a translation cannot be found). # the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true config.i18n.fallbacks = true
# Send deprecation notices to registered listeners. # Don't log any deprecations.
config.active_support.deprecation = :notify config.active_support.report_deprecations = true
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# Use a different logger for distributed setups.
# require 'syslog/logger'
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
# Do not dump schema after migrations. # Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false config.active_record.dump_schema_after_migration = false
# Inserts middleware to perform automatic connection switching. # Only use :id for inspections in production.
# The `database_selector` hash is used to pass options to the DatabaseSelector config.active_record.attributes_for_inspect = [ :id ]
# middleware. The `delay` is used to determine how long to wait after a write
# to send a subsequent read to the primary. # Enable DNS rebinding protection and other `Host` header attacks.
# # config.hosts = [
# The `database_resolver` class is used by the middleware to determine which # "example.com", # Allow requests from example.com
# database is appropriate to use based on the time delay. # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
# # ]
# The `database_resolver_context` class is used by the middleware to set # Skip DNS rebinding protection for the default health check endpoint.
# timestamps for the last write to the primary. The resolver uses the context # config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
# class timestamps to determine how long to wait before reading from the
# replica.
#
# By default Rails will store a last write timestamp in the session. The
# DatabaseSelector middleware is designed as such you can define your own
# strategy for connection switching and pass that into the middleware through
# these configuration options.
# config.active_record.database_selector = { delay: 2.seconds }
# config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
# config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
end end

View File

@ -1,3 +1,5 @@
require "active_support/core_ext/integer/time"
# The test environment is used exclusively to run your application's # The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that # test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped # your test database is "scratch space" for the test suite and is wiped
@ -6,31 +8,33 @@
Rails.application.configure do Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb. # Settings specified here will take precedence over those in config/application.rb.
config.cache_classes = false # While tests run files are not watched, reloading is not necessary.
config.action_view.cache_template_loading = true config.enable_reloading = false
# Do not eager load code on boot. This avoids loading your whole application # Eager loading loads your entire application. When running a single test locally,
# just for the purpose of running a single test. If you are using a tool that # this is usually not necessary, and can slow down your test suite. However, it's
# preloads Rails for running tests, you may have to set it to true. # recommended that you enable it in continuous integration systems to ensure eager
config.eager_load = false # loading is working properly before deploying your code.
config.eager_load = ENV["CI"].present?
# Configure public file server for tests with Cache-Control for performance. # Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{1.hour.to_i}" }
config.public_file_server.headers = {
'Cache-Control' => "public, max-age=#{1.hour.to_i}"
}
# Show full error reports and disable caching. # Show full error reports and disable caching.
config.consider_all_requests_local = true config.consider_all_requests_local = true
config.action_controller.perform_caching = false config.action_controller.perform_caching = false
config.cache_store = :null_store config.cache_store = :null_store
# Raise exceptions instead of rendering exception templates. # Render exception templates for rescuable exceptions and raise for other exceptions.
config.action_dispatch.show_exceptions = :none config.action_dispatch.show_exceptions = :rescuable
# Disable request forgery protection in test environment. # Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false config.action_controller.allow_forgery_protection = false
config.active_job.queue_adapter = :test
# Disable caching for Action Mailer templates even if Action Controller
# caching is enabled.
config.action_mailer.perform_caching = false config.action_mailer.perform_caching = false
# Tell Action Mailer not to deliver emails to the real world. # Tell Action Mailer not to deliver emails to the real world.
@ -38,27 +42,37 @@ Rails.application.configure do
# ActionMailer::Base.deliveries array. # ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test config.action_mailer.delivery_method = :test
# Print deprecation notices to the stderr. config.action_mailer.default_options = {
config.active_support.deprecation = :stderr from: "accounts@kosmos.org",
message_id: -> { "<#{Mail.random_tag}@kosmos.org>" },
# Raises error for missing translations. }
# config.action_view.raise_on_missing_translations = true
config.action_mailer.default_url_options = { config.action_mailer.default_url_options = {
host: "accounts.kosmos.org", host: "accounts.kosmos.org",
protocol: "https" protocol: "https"
} }
config.action_mailer.default_options = { # Print deprecation notices to the stderr.
from: "accounts@kosmos.org", config.active_support.deprecation = :stderr
message_id: -> { "<#{Mail.random_tag}@kosmos.org>" },
}
config.active_job.queue_adapter = :test # Raise exceptions for disallowed deprecations.
config.active_support.disallowed_deprecation = :raise
# Tell Active Support which deprecation messages to disallow.
config.active_support.disallowed_deprecation_warnings = []
# Raises error for missing translations.
# config.i18n.raise_on_missing_translations = true
# Annotate rendered view with file names.
# config.action_view.annotate_rendered_view_with_filenames = true
if ENV["S3_ENABLED"] && ENV["S3_ENABLED"].to_s != "false" if ENV["S3_ENABLED"] && ENV["S3_ENABLED"].to_s != "false"
config.active_storage.service = :s3 config.active_storage.service = :s3
else else
config.active_storage.service = :local config.active_storage.service = :local
end end
# Raise error when a before_action's only/except options reference missing actions.
config.action_controller.raise_on_missing_callback_actions = true
end end

View File

@ -1,7 +1,7 @@
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets. # Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0' Rails.application.config.assets.version = "1.0"
# Add additional assets to the asset load path. # Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path # Rails.application.config.assets.paths << Emoji.images_path
@ -11,4 +11,4 @@ Rails.application.config.assets.paths << Rails.root.join('node_modules')
# Precompile additional assets. # Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets # application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added. # folder are already added.
# Rails.application.config.assets.precompile += %w( admin.js admin.css ) # Rails.application.config.assets.precompile += %w[ admin.js admin.css ]

View File

@ -1,30 +1,25 @@
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# Define an application-wide content security policy # Define an application-wide content security policy.
# For further information see the following documentation # See the Securing Rails Applications Guide for more information:
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy # https://guides.rubyonrails.org/security.html#content-security-policy-header
# Rails.application.config.content_security_policy do |policy| # Rails.application.configure do
# policy.default_src :self, :https # config.content_security_policy do |policy|
# policy.font_src :self, :https, :data # policy.default_src :self, :https
# policy.img_src :self, :https, :data # policy.font_src :self, :https, :data
# policy.object_src :none # policy.img_src :self, :https, :data
# policy.script_src :self, :https # policy.object_src :none
# policy.style_src :self, :https # policy.script_src :self, :https
# # If you are using webpack-dev-server then specify webpack-dev-server host # policy.style_src :self, :https
# policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development? # # Specify URI for violation reports
# # policy.report_uri "/csp-violation-report-endpoint"
# # Specify URI for violation reports # end
# # policy.report_uri "/csp-violation-report-endpoint" #
# # Generate session nonces for permitted importmap, inline scripts, and inline styles.
# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
# config.content_security_policy_nonce_directives = %w(script-src style-src)
#
# # Report violations without enforcing the policy.
# # config.content_security_policy_report_only = true
# end # end
# If you are using UJS then enable automatic nonce generation
# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
# Set the nonce only to specific directives
# Rails.application.config.content_security_policy_nonce_directives = %w(script-src)
# Report CSP violations to a specified URI
# For further information see the following documentation:
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
# Rails.application.config.content_security_policy_report_only = true

View File

@ -1,4 +1,8 @@
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# Configure sensitive parameters which will be filtered from the log file. # Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file.
Rails.application.config.filter_parameters += [:password] # Use this to limit dissemination of sensitive information.
# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors.
Rails.application.config.filter_parameters += [
:password, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
]

View File

@ -4,13 +4,13 @@
# are locale specific, and you may define rules for as many different # are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default: # locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect| # ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.plural /^(ox)$/i, '\1en' # inflect.plural /^(ox)$/i, "\\1en"
# inflect.singular /^(ox)en/i, '\1' # inflect.singular /^(ox)en/i, "\\1"
# inflect.irregular 'person', 'people' # inflect.irregular "person", "people"
# inflect.uncountable %w( fish sheep ) # inflect.uncountable %w( fish sheep )
# end # end
# These inflection rules are supported but not enabled by default: # These inflection rules are supported but not enabled by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect| # ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.acronym 'RESTful' # inflect.acronym "RESTful"
# end # end

View File

@ -1 +0,0 @@
Rails.application.routes.default_url_options[:host] = ENV['APP_DOMAIN']

View File

@ -0,0 +1,13 @@
# Be sure to restart your server when you modify this file.
# Define an application-wide HTTP permissions policy. For further
# information see: https://developers.google.com/web/updates/2018/06/feature-policy
# Rails.application.config.permissions_policy do |policy|
# policy.camera :none
# policy.gyroscope :none
# policy.microphone :none
# policy.usb :none
# policy.fullscreen :self
# policy.payment :self, "https://secure.example.com"
# end

View File

@ -1,38 +1,35 @@
# Puma can serve each request in a thread from an internal thread pool. # This configuration file will be evaluated by Puma. The top-level methods that
# The `threads` method setting takes two numbers: a minimum and maximum. # are invoked here are part of Puma's configuration DSL. For more information
# Any libraries that use thread pools should be configured to match # about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html.
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record. # Puma starts a configurable number of processes (workers) and each process
# serves each request in a thread from an internal thread pool.
# #
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } # The ideal number of threads per worker depends both on how much time the
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } # application spends waiting for IO operations and on how much you wish to
# to prioritize throughput over latency.
#
# As a rule of thumb, increasing the number of threads will increase how much
# traffic a given process can handle (throughput), but due to CRuby's
# Global VM Lock (GVL) it has diminishing returns and will degrade the
# response time (latency) of the application.
#
# The default is set to 3 threads as it's deemed a decent compromise between
# throughput and latency for the average Rails application.
#
# Any libraries that use a connection pool or another resource pool should
# be configured to provide at least as many connections as the number of
# threads. This includes Active Record's `pool` parameter in `database.yml`.
max_threads_count = ENV.fetch("RAILS_MAX_THREADS", 5)
min_threads_count = ENV.fetch("RAILS_MAX_THREADS", 3)
threads min_threads_count, max_threads_count threads min_threads_count, max_threads_count
# Specifies the `port` that Puma will listen on to receive requests; default is 3000. port ENV.fetch("PORT", 3000)
#
port ENV.fetch("PORT") { 3000 }
# Specifies the `environment` that Puma will run in.
#
environment ENV.fetch("RAILS_ENV") { "development" } environment ENV.fetch("RAILS_ENV") { "development" }
# Specifies the `pidfile` that Puma will use. # Allow puma to be restarted by `bin/rails restart` command.
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked web server processes. If using threads and workers together
# the concurrency of the application would be max `threads` * `workers`.
# Workers do not work on JRuby or Windows (both of which do not support
# processes).
#
# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
# Use the `preload_app!` method when specifying a `workers` number.
# This directive tells Puma to first boot the application and load code
# before forking the application. This takes advantage of Copy On Write
# process behavior so workers use less memory.
#
# preload_app!
# Allow puma to be restarted by `rails restart` command.
plugin :tmp_restart plugin :tmp_restart
# Specify the PID file. Defaults to tmp/pids/server.pid in development.
# In other environments, only set the PID file if requested.
pidfile ENV["PIDFILE"] if ENV["PIDFILE"]

29
lib/tasks/ctags.rake Normal file
View File

@ -0,0 +1,29 @@
module Kosmos
class Ctags
def self.generate_app_tags
excludes = %w[.git gitno log tmp public].join(" --exclude ")
cmd = "ctags -R --languages=ruby --exclude #{excludes} ."
system cmd
end
def self.generate_bundler_tags
runtime = ::Bundler::Runtime.new Dir.pwd, ::Bundler.definition
paths = runtime.specs.map(&:full_gem_path)
generate_tags(paths, "gems.tags")
end
def self.generate_tags(paths, tag_file)
paths = paths.join(' ').strip
cmd = "find #{paths} -ignore_readdir_race -type f -name '*.rb' 2>/dev/null | ctags -f #{tag_file} -L -"
system cmd
end
end
end
namespace :ctags do
desc 'generate ctags'
task :create do
Kosmos::Ctags.generate_app_tags
Kosmos::Ctags.generate_bundler_tags
end
end