diff --git a/Gemfile.lock b/Gemfile.lock index fe7361a..f392eac 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -18,60 +18,60 @@ GIT GEM remote: https://gems.sutty.nl/ specs: - actioncable (6.1.3.1) - actionpack (= 6.1.3.1) - activesupport (= 6.1.3.1) + actioncable (6.1.3.2) + actionpack (= 6.1.3.2) + activesupport (= 6.1.3.2) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.3.1) - actionpack (= 6.1.3.1) - activejob (= 6.1.3.1) - activerecord (= 6.1.3.1) - activestorage (= 6.1.3.1) - activesupport (= 6.1.3.1) + actionmailbox (6.1.3.2) + actionpack (= 6.1.3.2) + activejob (= 6.1.3.2) + activerecord (= 6.1.3.2) + activestorage (= 6.1.3.2) + activesupport (= 6.1.3.2) mail (>= 2.7.1) - actionmailer (6.1.3.1) - actionpack (= 6.1.3.1) - actionview (= 6.1.3.1) - activejob (= 6.1.3.1) - activesupport (= 6.1.3.1) + actionmailer (6.1.3.2) + actionpack (= 6.1.3.2) + actionview (= 6.1.3.2) + activejob (= 6.1.3.2) + activesupport (= 6.1.3.2) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.1.3.1) - actionview (= 6.1.3.1) - activesupport (= 6.1.3.1) + actionpack (6.1.3.2) + actionview (= 6.1.3.2) + activesupport (= 6.1.3.2) rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.3.1) - actionpack (= 6.1.3.1) - activerecord (= 6.1.3.1) - activestorage (= 6.1.3.1) - activesupport (= 6.1.3.1) + actiontext (6.1.3.2) + actionpack (= 6.1.3.2) + activerecord (= 6.1.3.2) + activestorage (= 6.1.3.2) + activesupport (= 6.1.3.2) nokogiri (>= 1.8.5) - actionview (6.1.3.1) - activesupport (= 6.1.3.1) + actionview (6.1.3.2) + activesupport (= 6.1.3.2) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.1.3.1) - activesupport (= 6.1.3.1) + activejob (6.1.3.2) + activesupport (= 6.1.3.2) globalid (>= 0.3.6) - activemodel (6.1.3.1) - activesupport (= 6.1.3.1) - activerecord (6.1.3.1) - activemodel (= 6.1.3.1) - activesupport (= 6.1.3.1) - activestorage (6.1.3.1) - actionpack (= 6.1.3.1) - activejob (= 6.1.3.1) - activerecord (= 6.1.3.1) - activesupport (= 6.1.3.1) + activemodel (6.1.3.2) + activesupport (= 6.1.3.2) + activerecord (6.1.3.2) + activemodel (= 6.1.3.2) + activesupport (= 6.1.3.2) + activestorage (6.1.3.2) + actionpack (= 6.1.3.2) + activejob (= 6.1.3.2) + activerecord (= 6.1.3.2) + activesupport (= 6.1.3.2) marcel (~> 1.0.0) mini_mime (~> 1.0.2) - activesupport (6.1.3.1) + activesupport (6.1.3.2) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -89,14 +89,11 @@ GEM jekyll-relative-urls (~> 0.0) jekyll-seo-tag (~> 2.1) ast (2.4.2) - autoprefixer-rails (10.2.4.0) - execjs - bcrypt (3.1.16) + autoprefixer-rails (10.2.5.0) + execjs (< 2.8.0) bcrypt (3.1.16-x86_64-linux-musl) - bcrypt_pbkdf (1.1.0) bcrypt_pbkdf (1.1.0-x86_64-linux-musl) benchmark-ips (2.8.4) - bindex (0.8.1) bindex (0.8.1-x86_64-linux-musl) blazer (2.4.2) activerecord (>= 5) @@ -107,7 +104,7 @@ GEM autoprefixer-rails (>= 9.1.0) popper_js (>= 1.14.3, < 2) sassc-rails (>= 2.0.0) - brakeman (5.0.0) + brakeman (5.0.1) builder (3.2.4) capybara (2.18.0) addressable @@ -116,28 +113,24 @@ GEM rack (>= 1.0.0) rack-test (>= 0.5.4) xpath (>= 2.0, < 4.0) - chartkick (4.0.3) + chartkick (4.0.4) childprocess (3.0.0) coderay (1.1.3) colorator (1.1.0) - commonmarker (0.21.2) - ruby-enum (~> 0.5) commonmarker (0.21.2-x86_64-linux-musl) ruby-enum (~> 0.5) concurrent-ruby (1.1.8) - concurrent-ruby-ext (1.1.8) - concurrent-ruby (= 1.1.8) concurrent-ruby-ext (1.1.8-x86_64-linux-musl) concurrent-ruby (= 1.1.8) crass (1.0.6) database_cleaner (2.0.1) database_cleaner-active_record (~> 2.0.0) - database_cleaner-active_record (2.0.0) + database_cleaner-active_record (2.0.1) activerecord (>= 5.a) database_cleaner-core (~> 2.0.0) database_cleaner-core (2.0.1) - dead_end (1.1.6) - derailed_benchmarks (2.0.1) + dead_end (1.1.7) + derailed_benchmarks (2.1.0) benchmark-ips (~> 2) dead_end get_process_mem (~> 0) @@ -149,26 +142,25 @@ GEM rake (> 10, < 14) ruby-statistics (>= 2.1) thor (>= 0.19, < 2) - devise (4.7.3) + devise (4.8.0) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 4.1.0) responders warden (~> 1.2.3) - devise-i18n (1.9.3) + devise-i18n (1.9.4) devise (>= 4.7.1) - devise_invitable (2.0.4) + devise_invitable (2.0.5) actionmailer (>= 5.0) devise (>= 4.6) dotenv (2.7.6) dotenv-rails (2.7.6) dotenv (= 2.7.6) railties (>= 3.2) - down (5.2.0) + down (5.2.1) addressable (~> 2.5) - ed25519 (1.2.4) ed25519 (1.2.4-x86_64-linux-musl) - editorial-autogestiva-jekyll-theme (0.3.0) + editorial-autogestiva-jekyll-theme (0.3.4) jekyll (~> 4) jekyll-commonmark (~> 1.3) jekyll-data (~> 1.1) @@ -192,22 +184,18 @@ GEM http_parser.rb (~> 0.6.0) errbase (0.2.1) erubi (1.10.0) - eventmachine (1.2.7) eventmachine (1.2.7-x86_64-linux-musl) exception_notification (4.4.3) actionmailer (>= 4.0, < 7) activesupport (>= 4.0, < 7) execjs (2.7.0) - factory_bot (6.1.0) + factory_bot (6.2.0) activesupport (>= 5.0.0) - factory_bot_rails (6.1.0) - factory_bot (~> 6.1.0) + factory_bot_rails (6.2.0) + factory_bot (~> 6.2.0) railties (>= 5.0.0) - fast_blank (1.0.0) fast_blank (1.0.0-x86_64-linux-musl) - fast_jsonparser (0.5.0) fast_jsonparser (0.5.0-x86_64-linux-musl) - ffi (1.15.0) ffi (1.15.0-x86_64-linux-musl) flamegraph (0.9.5) forwardable-extended (2.6.0) @@ -232,10 +220,6 @@ GEM rainbow rubocop (>= 0.50.0) sysexits (~> 1.1) - hamlit (2.15.0) - temple (>= 0.8.2) - thor - tilt hamlit (2.15.0-x86_64-linux-musl) temple (>= 0.8.2) thor @@ -247,9 +231,7 @@ GEM railties (>= 4.0.1) heapy (0.2.0) thor - hiredis (0.6.3) hiredis (0.6.3-x86_64-linux-musl) - http_parser.rb (0.6.0) http_parser.rb (0.6.0-x86_64-linux-musl) httparty (0.18.1) mime-types (~> 3.0) @@ -316,7 +298,7 @@ GEM sassc (> 2.0.1, < 3.0) jekyll-seo-tag (2.7.1) jekyll (>= 3.8, < 5.0) - jekyll-spree-client (0.1.12) + jekyll-spree-client (0.1.14) fast_blank (~> 1) spree-api-client (~> 0.2) jekyll-turbolinks (0.0.5) @@ -365,33 +347,28 @@ GEM mini_histogram (0.3.1) mini_magick (4.11.0) mini_mime (1.0.3) - mini_portile2 (2.5.0) + mini_portile2 (2.5.1) minima (2.5.1) jekyll (>= 3.5, < 5.0) jekyll-feed (~> 0.9) jekyll-seo-tag (~> 2.1) minitest (5.14.4) - mobility (1.1.1) + mobility (1.1.2) i18n (>= 0.6.10, < 2) request_store (~> 1.0) multi_xml (0.6.0) net-ssh (6.1.0) netaddr (2.0.4) - nio4r (2.5.7) nio4r (2.5.7-x86_64-linux-musl) - nokogiri (1.11.3) - mini_portile2 (~> 2.5.0) - racc (~> 1.4) - nokogiri (1.11.3-x86_64-linux-musl) + nokogiri (1.11.5-x86_64-linux-musl) mini_portile2 (~> 2.5.0) racc (~> 1.4) orm_adapter (0.5.0) parallel (1.20.1) - parser (3.0.1.0) + parser (3.0.1.1) ast (~> 2.4.1) pathutil (0.16.2) forwardable-extended (~> 2.6) - pg (1.2.3) pg (1.2.3-x86_64-linux-musl) pg_search (2.3.5) activerecord (>= 5.2) @@ -403,18 +380,15 @@ GEM coderay (~> 1.1) method_source (~> 1.0) public_suffix (4.0.6) - puma (5.2.2) - nio4r (~> 2.0) - puma (5.2.2-x86_64-linux-musl) + puma (5.3.1-x86_64-linux-musl) nio4r (~> 2.0) pundit (2.1.0) activesupport (>= 3.0.0) - racc (1.5.2) racc (1.5.2-x86_64-linux-musl) rack (2.2.3) rack-cors (1.1.1) rack (>= 2.0.0) - rack-mini-profiler (2.3.1) + rack-mini-profiler (2.3.2) rack (>= 1.2.0) rack-proxy (0.6.5) rack @@ -431,20 +405,20 @@ GEM jekyll-relative-urls (~> 0.0) jekyll-seo-tag (~> 2.1) jekyll-turbolinks (~> 0) - rails (6.1.3.1) - actioncable (= 6.1.3.1) - actionmailbox (= 6.1.3.1) - actionmailer (= 6.1.3.1) - actionpack (= 6.1.3.1) - actiontext (= 6.1.3.1) - actionview (= 6.1.3.1) - activejob (= 6.1.3.1) - activemodel (= 6.1.3.1) - activerecord (= 6.1.3.1) - activestorage (= 6.1.3.1) - activesupport (= 6.1.3.1) + rails (6.1.3.2) + actioncable (= 6.1.3.2) + actionmailbox (= 6.1.3.2) + actionmailer (= 6.1.3.2) + actionpack (= 6.1.3.2) + actiontext (= 6.1.3.2) + actionview (= 6.1.3.2) + activejob (= 6.1.3.2) + activemodel (= 6.1.3.2) + activerecord (= 6.1.3.2) + activestorage (= 6.1.3.2) + activesupport (= 6.1.3.2) bundler (>= 1.15.0) - railties (= 6.1.3.1) + railties (= 6.1.3.2) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) @@ -456,15 +430,15 @@ GEM railties (>= 6.0.0, < 7) rails_warden (0.6.0) warden (>= 1.2.0) - railties (6.1.3.1) - actionpack (= 6.1.3.1) - activesupport (= 6.1.3.1) + railties (6.1.3.2) + actionpack (= 6.1.3.2) + activesupport (= 6.1.3.2) method_source rake (>= 0.8.7) thor (~> 1.0) rainbow (3.0.0) rake (13.0.3) - rb-fsevent (0.10.4) + rb-fsevent (0.11.0) rb-inotify (0.10.1) ffi (~> 1.0) recursero-jekyll-theme (0.1.3) @@ -509,28 +483,27 @@ GEM railties (>= 5.0) rexml (3.2.5) rouge (3.26.0) - rubocop (1.12.1) + rubocop (1.15.0) parallel (~> 1.10) parser (>= 3.0.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml - rubocop-ast (>= 1.2.0, < 2.0) + rubocop-ast (>= 1.5.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.4.1) - parser (>= 2.7.1.5) - rubocop-rails (2.9.1) + rubocop-ast (1.5.0) + parser (>= 3.0.1.1) + rubocop-rails (2.10.1) activesupport (>= 4.2.0) rack (>= 1.1) - rubocop (>= 0.90.0, < 2.0) + rubocop (>= 1.7.0, < 2.0) ruby-enum (0.9.0) i18n - ruby-filemagic (0.7.2) ruby-filemagic (0.7.2-x86_64-linux-musl) ruby-progressbar (1.11.0) ruby-statistics (2.1.3) - ruby-vips (2.1.0) + ruby-vips (2.1.2) ffi (~> 1.12) ruby2ruby (2.4.4) ruby_parser (~> 3.1) @@ -539,13 +512,10 @@ GEM ruby_parser (3.15.1) sexp_processor (~> 4.9) rubyzip (2.3.0) - rugged (1.1.0) rugged (1.1.0-x86_64-linux-musl) safe_yaml (1.0.6) safely_block (0.3.0) errbase (>= 0.1.1) - sassc (2.4.0) - ffi (~> 1.9) sassc (2.4.0-x86_64-linux-musl) ffi (~> 1.9) sassc-rails (2.1.2) @@ -584,10 +554,8 @@ GEM actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - sqlite3 (1.4.2) sqlite3 (1.4.2-x86_64-linux-musl) - stackprof (0.2.16) - stackprof (0.2.16-x86_64-linux-musl) + stackprof (0.2.17-x86_64-linux-musl) sucker_punch (3.0.1) concurrent-ruby (~> 1.0) sutty-archives (2.5.4) @@ -616,7 +584,6 @@ GEM jekyll (>= 3.5, < 5.0) jekyll-feed (~> 0.9) jekyll-seo-tag (~> 2.1) - symbol-fstring (1.0.0) symbol-fstring (1.0.0-x86_64-linux-musl) sysexits (1.2.0) temple (0.8.2) @@ -634,7 +601,6 @@ GEM execjs (>= 0.3.0, < 3) unf (0.1.4) unf_ext - unf_ext (0.0.7.7) unf_ext (0.0.7.7-x86_64-linux-musl) unicode-display_width (1.7.0) validates_hostname (1.0.11) @@ -647,14 +613,12 @@ GEM activemodel (>= 6.0.0) bindex (>= 0.4.0) railties (>= 6.0.0) - webpacker (5.2.1) + webpacker (5.4.0) activesupport (>= 5.2) rack-proxy (>= 0.6.1) railties (>= 5.2) semantic_range (>= 2.3.0) webrick (1.7.0) - websocket-driver (0.7.3) - websocket-extensions (>= 0.1.0) websocket-driver (0.7.3-x86_64-linux-musl) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) diff --git a/Makefile b/Makefile index c7f4fd3..e0da9dd 100644 --- a/Makefile +++ b/Makefile @@ -38,8 +38,11 @@ test/%_test.rb: always test: always $(hain) 'cd /Sutty/sutty; RAILS_ENV=test bundle exec rake test' -serve: /etc/hosts - $(hain) 'cd /Sutty/sutty; bundle exec rails s -b "ssl://0.0.0.0:3000?key=../sutty.local/domain/$(SUTTY).key&cert=../sutty.local/domain/$(SUTTY).crt"' +postgresql: /etc/hosts + pgrep postgres >/dev/null || $(hain) postgresql + +serve: /etc/hosts postgresql + $(MAKE) rails args=server # make rails args="db:migrate" rails: @@ -129,5 +132,6 @@ ota-rb: @grep -q " $(SUTTY)$$" $@ || echo -e "127.0.0.1 $(SUTTY)\n::1 $(SUTTY)" | sudo tee -a $@ @grep -q " api.$(SUTTY)$$" $@ || echo -e "127.0.0.1 api.$(SUTTY)\n::1 api.$(SUTTY)" | sudo tee -a $@ @grep -q " panel.$(SUTTY)$$" $@ || echo -e "127.0.0.1 panel.$(SUTTY)\n::1 panel.$(SUTTY)" | sudo tee -a $@ + @grep -q " postgresql.$(SUTTY)$$" $@ || echo -e "127.0.0.1 postgresql.$(SUTTY)\n::1 postgresql.$(SUTTY)" | sudo tee -a $@ .PHONY: always diff --git a/app/models/metadata_template.rb b/app/models/metadata_template.rb index 638bdb8..9db0ffa 100644 --- a/app/models/metadata_template.rb +++ b/app/models/metadata_template.rb @@ -216,9 +216,13 @@ MetadataTemplate = Struct.new(:site, :document, :name, :label, :type, box.decrypt_str value.to_s rescue Lockbox::DecryptionError => e - ExceptionNotifier.notify_exception(e, data: { site: site.name, post: post.path.absolute, name: name }) + if value.to_s.include? ' ' + value + else + ExceptionNotifier.notify_exception(e, data: { site: site.name, post: post.path.absolute, name: name }) - I18n.t('lockbox.help.decryption_error') + I18n.t('lockbox.help.decryption_error') + end end # Cifra el valor. diff --git a/app/models/post.rb b/app/models/post.rb index c2eee8f..cab7665 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -75,6 +75,9 @@ class Post # TODO: Cambiar el locale en otro lado l = lang.value.to_s site.jekyll.config['locale'] = site.jekyll.config['lang'] = l + # XXX: Es necesario leer los layouts para poder renderizar el + # sitio + site.theme_layouts # Payload básico con traducciones. document.renderer.payload = { diff --git a/app/models/site.rb b/app/models/site.rb index abab9f5..58f2074 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -286,6 +286,13 @@ class Site < ApplicationRecord layout_keys.include? layout.to_sym end + # Lee los layouts en HTML desde el sitio + # + # @return [Hash] + def theme_layouts + @jekyll.reader.read_layouts + end + # Trae todos los valores disponibles para un campo # # TODO: Traer recursivamente, si el campo contiene Hash diff --git a/config/database.yml b/config/database.yml index a895ced..742401c 100644 --- a/config/database.yml +++ b/config/database.yml @@ -5,25 +5,28 @@ # gem 'sqlite3' # default: &default + timeout: 5000 adapter: postgresql pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> - timeout: 5000 - database: sutty - user: postgres - host: postgresql encoding: unicode development: <<: *default + database: 'sutty' + host: 'postgresql.sutty.local' + user: <%= ENV['USER'] %> # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: <<: *default - database: sutty_test + database: 'sutty_test' + host: 'postgresql.sutty.local' + user: <%= ENV['USER'] %> production: <<: *default database: <%= ENV.fetch('DATABASE') { 'sutty' } %> user: sutty + host: postgresql diff --git a/config/initializers/core_extensions.rb b/config/initializers/core_extensions.rb index acc4761..66d2c92 100644 --- a/config/initializers/core_extensions.rb +++ b/config/initializers/core_extensions.rb @@ -55,6 +55,11 @@ module Jekyll @site.data = DataReader.new(site).read(site.config['data_dir']) end + # Lee los layouts + def read_layouts + @site.layouts = LayoutReader.new(site).read unless @site.layouts.present? + end + # Lee todos los artículos del sitio def read_collections read_directories diff --git a/config/puma.rb b/config/puma.rb index 48ff0e6..60ee5ec 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -19,8 +19,15 @@ worker_timeout 3600 if ENV.fetch('RAILS_ENV', 'development') == 'development' # Specifies the `port` that Puma will listen on to receive requests; # default is 3000. # -# port ENV.fetch('PORT') { 3000 } -bind 'tcp://[::]:3100' +# XXX: Por alguna razón el puerto en el contenedor es históricamente +# 3100, aunque en desarrollo es 3000. En algún momento deberíamos +# establecer un solo puerto. +if ENV['RAILS_ENV'] == 'production' + bind 'tcp://[::]:3100' +else + sutty = ENV.fetch('SUTTY', 'sutty.local') + bind "ssl://[::]:3000?key=../sutty.local/domain/#{sutty}.key&cert=../sutty.local/domain/#{sutty}.crt" +end # Specifies the `environment` that Puma will run in. #