diff --git a/app/controllers/sites_controller.rb b/app/controllers/sites_controller.rb index bec42b39..49527cf7 100644 --- a/app/controllers/sites_controller.rb +++ b/app/controllers/sites_controller.rb @@ -15,6 +15,13 @@ class SitesController < ApplicationController fresh_when @sites end + # Genera la caja del estado para HTMX + def status + authorize site + + render('sites/status', layout: false) if stale? site + end + # No tenemos propiedades de un sitio aún, así que vamos al listado de # artículos def show diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js index cfc0d5d5..d8ff0dd1 100644 --- a/app/javascript/packs/application.js +++ b/app/javascript/packs/application.js @@ -34,4 +34,4 @@ Rails.start() Turbolinks.start() ActiveStorage.start() -// force ci +window.htmx = require('htmx.org/dist/htmx.js') diff --git a/app/models/site/repository.rb b/app/models/site/repository.rb index eeca72c4..d41e76f5 100644 --- a/app/models/site/repository.rb +++ b/app/models/site/repository.rb @@ -194,6 +194,12 @@ class Site git_sh('git', 'lfs', 'push', remote.name, default_branch) end + # Hace limpieza de LFS + def lfs_cleanup + git_sh("git", "lfs", "prune") + git_sh("git", "lfs", "dedup") + end + private # @deprecated @@ -260,10 +266,5 @@ class Site r&.success? end - - def lfs_cleanup - git_sh("git", "lfs", "prune") - git_sh("git", "lfs", "dedup") - end end end diff --git a/app/views/posts/edit.haml b/app/views/posts/edit.haml index 839f8a8e..d03e08c7 100644 --- a/app/views/posts/edit.haml +++ b/app/views/posts/edit.haml @@ -1,9 +1,3 @@ .row.justify-content-center .col-12.col-lg-8 - - if policy(@site).edit? - = render 'layouts/details', summary: t('posts.edit.post') do - = render 'posts/form', site: @site, post: @post - = render 'layouts/details', summary: t('posts.edit.moderation_queue') do - = render 'posts/moderation_queue', site: @site, post: @post, moderation_queue: @moderation_queue - - else - = render 'posts/form', site: @site, post: @post + = render 'posts/form', site: @site, post: @post diff --git a/app/views/sites/_status.haml b/app/views/sites/_status.haml index 6a610e73..47bed657 100644 --- a/app/views/sites/_status.haml +++ b/app/views/sites/_status.haml @@ -1,21 +1,24 @@ -- link = nil -- if site.not_published_yet? - - message = t('.not_published_yet') -- elsif site.awaiting_publication? - - message = t('.awaiting_publication') -- elsif site.building? - - if site.average_publication_time_calculable? - - average_building_time = site.average_publication_time - - elsif !site.similar_sites? - - average_building_time = 60 +- cache site do + - link = nil + - if site.not_published_yet? + - message = t('.not_published_yet') + - elsif site.awaiting_publication? + - message = t('.awaiting_publication') + - elsif site.building? + - if site.average_publication_time_calculable? + - average_building_time = site.average_publication_time + - elsif !site.similar_sites? + - average_building_time = 60 + - else + - average_building_time = site.average_publication_time_for_similar_sites + + - average_publication_time_human = distance_of_time_in_words average_building_time + - message = t('.building', average_time: average_publication_time_human, seconds: average_building_time) - else - - average_building_time = site.average_publication_time_for_similar_sites + - message = t('.available') + - link = true - - average_publication_time_human = distance_of_time_in_words average_building_time - - message = t('.building', average_time: average_publication_time_human, seconds: average_building_time) -- else - - message = t('.available') - - link = true - -= render 'bootstrap/alert' do - = link_to_if link, message.html_safe, site_build_stats_path(site), class: 'alert-link' + -# TODO: Calcular cada cuanto sería óptimo recargar + %div{ 'hx-get': site_status_path(site), 'hx-trigger': 'every 10s', 'hx-swap': 'outerHTML' } + = render 'bootstrap/alert' do + = link_to_if link, message.html_safe, site_build_stats_path(site), class: 'alert-link' diff --git a/app/views/sites/status.haml b/app/views/sites/status.haml new file mode 100644 index 00000000..3d9793a5 --- /dev/null +++ b/app/views/sites/status.haml @@ -0,0 +1 @@ += render 'sites/status', site: @site diff --git a/config/locales/en.yml b/config/locales/en.yml index 07d1f7e6..da8fc18b 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -578,7 +578,7 @@ en: static_file_migration: 'File migration' find_and_replace: 'Search and replace' status: - building: "Your site is building, refresh this page in ." + building: "Your site is building, it will be ready in ." not_published_yet: "Your site is being published for the first time, please wait up to 1 minute..." available: "Your site is available! Click here to find all the different ways to visit it." awaiting_publication: "There are unpublished changes. Click the button below and wait a moment to find them on your site." diff --git a/config/locales/es.yml b/config/locales/es.yml index a5430277..8d22129a 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -582,7 +582,7 @@ es: static_file_migration: 'Migración de archivos' find_and_replace: 'Búsqueda y reemplazo' status: - building: "Tu sitio se está publicando, recargá esta página en ." + building: "Tu sitio se está publicando, estará listo en ." not_published_yet: "Tu sitio se está publicando por primera vez, por favor espera hasta un minuto..." available: "¡Tu sitio está disponible! Cliqueá aquí para encontrar todas las formas en que podés visitarlo." awaiting_publication: "Hay cambios sin publicar, cliqueá el botón debajo y espera un momento para encontrarlos en tu sitio." diff --git a/config/routes.rb b/config/routes.rb index 4d43d66a..ad9d1744 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -52,6 +52,8 @@ Rails.application.routes.draw do get 'pull', to: 'sites#fetch' post 'pull', to: 'sites#merge' + get 'status', to: 'sites#status' + # Gestionar usuaries get 'usuaries/invite', to: 'usuaries#invite' post 'usuaries/invite', to: 'usuaries#send_invitations' diff --git a/package.json b/package.json index 7901ad41..870b8e9b 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "commonmark": "^0.29.0", "fork-awesome": "^1.1.7", "fork-ts-checker-webpack-plugin": "^6.1.0", + "htmx.org": "^1.9.11", "input-map": "git+https://0xacab.org/sutty/input-map.git", "input-tag": "git+https://0xacab.org/sutty/input-tag.git", "leaflet": "^1.7.1", diff --git a/public/assets/.sprockets-manifest-a1cbb907961024fc033716a7d30668dd.json b/public/assets/.sprockets-manifest-a1cbb907961024fc033716a7d30668dd.json index 10a0bed6..45b7c422 100644 --- a/public/assets/.sprockets-manifest-a1cbb907961024fc033716a7d30668dd.json +++ b/public/assets/.sprockets-manifest-a1cbb907961024fc033716a7d30668dd.json @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5729a4470ad43e6611cee71e8c1c8b0f1817f9c3d3ac2a79c5fd6adf6450f12d -size 15111 +oid sha256:d15ecdd304bac8be507dbba7a3d0aa522e7b6f0e7d6a357df4d3a8d828b618c2 +size 10243 diff --git a/public/assets/application-5c98ae5b7e5b4444349f4c0175aa88fb76292284e1c68bfc4724151ceaf5113a.css.gz b/public/assets/application-5c98ae5b7e5b4444349f4c0175aa88fb76292284e1c68bfc4724151ceaf5113a.css.gz index ff6d5513..01e72c45 100644 --- a/public/assets/application-5c98ae5b7e5b4444349f4c0175aa88fb76292284e1c68bfc4724151ceaf5113a.css.gz +++ b/public/assets/application-5c98ae5b7e5b4444349f4c0175aa88fb76292284e1c68bfc4724151ceaf5113a.css.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:04ad1b588c62bdca68309428d8889203a6af62b4f8dc59fad6bffe75d4f8093a +oid sha256:3df707f1055c66159e723d71cbfa6d501df539538a27e9fc63e789ff7df11e39 size 32845 diff --git a/public/assets/application-df0385d47e55aa7c5b39fafd98674b63637ac6f38a896dbb79597f51adfbfdd1.css b/public/assets/application-df0385d47e55aa7c5b39fafd98674b63637ac6f38a896dbb79597f51adfbfdd1.css new file mode 100644 index 00000000..35f61aec --- /dev/null +++ b/public/assets/application-df0385d47e55aa7c5b39fafd98674b63637ac6f38a896dbb79597f51adfbfdd1.css @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d9a0b60c18452d62be9bb14d88398124b4edee2aa76d4bb6c529b18042b62ca7 +size 238837 diff --git a/public/assets/application-df0385d47e55aa7c5b39fafd98674b63637ac6f38a896dbb79597f51adfbfdd1.css.gz b/public/assets/application-df0385d47e55aa7c5b39fafd98674b63637ac6f38a896dbb79597f51adfbfdd1.css.gz new file mode 100644 index 00000000..66470122 --- /dev/null +++ b/public/assets/application-df0385d47e55aa7c5b39fafd98674b63637ac6f38a896dbb79597f51adfbfdd1.css.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a72678068488f0074c34beea6297b0663e74fba1147dbd664fbc6d688cd4b814 +size 33071 diff --git a/public/assets/application-e103c526f0f1ddba4b6d570ac1bc4318f0e84d522fe2c02eb6fbb594ece6f7a5.css b/public/assets/application-e103c526f0f1ddba4b6d570ac1bc4318f0e84d522fe2c02eb6fbb594ece6f7a5.css deleted file mode 100644 index c79ec1f0..00000000 --- a/public/assets/application-e103c526f0f1ddba4b6d570ac1bc4318f0e84d522fe2c02eb6fbb594ece6f7a5.css +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ba248b242410bc53b4f4ad49b40a6e80f27c1c1586465e3cebf6ff085ec9ba51 -size 236004 diff --git a/public/assets/application-e103c526f0f1ddba4b6d570ac1bc4318f0e84d522fe2c02eb6fbb594ece6f7a5.css.gz b/public/assets/application-e103c526f0f1ddba4b6d570ac1bc4318f0e84d522fe2c02eb6fbb594ece6f7a5.css.gz deleted file mode 100644 index ab063359..00000000 --- a/public/assets/application-e103c526f0f1ddba4b6d570ac1bc4318f0e84d522fe2c02eb6fbb594ece6f7a5.css.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:24baa40e59b12846a5f48ca19176e606fa5fa9b6ef58f3a6e45a22c0a88b6d68 -size 32740 diff --git a/public/assets/dark-591813c5ed25b766eda449e80715f9e51238c5defc9e38e60f02c31e11207839.css.gz b/public/assets/dark-591813c5ed25b766eda449e80715f9e51238c5defc9e38e60f02c31e11207839.css.gz index 92e07bc7..f384cf5a 100644 --- a/public/assets/dark-591813c5ed25b766eda449e80715f9e51238c5defc9e38e60f02c31e11207839.css.gz +++ b/public/assets/dark-591813c5ed25b766eda449e80715f9e51238c5defc9e38e60f02c31e11207839.css.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7d8cdacf4eda8bf6391c3210879583e68bbe203636dd558cec181d44fa7e8927 +oid sha256:771de7cf116906bf574d88d9138a236e4725dfdcc8a007d8a02573b3661528ed size 162 diff --git a/public/packs/js/application-8ce9779d857bfff53532.js b/public/packs/js/application-8ce9779d857bfff53532.js new file mode 100644 index 00000000..134f014c --- /dev/null +++ b/public/packs/js/application-8ce9779d857bfff53532.js @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:632234e427da97d723efe4061b3f432aade159b51949167abeca34826bcff5ea +size 1581325 diff --git a/public/packs/js/application-eff7e393ce95ecf9b900.js.LICENSE.txt b/public/packs/js/application-8ce9779d857bfff53532.js.LICENSE.txt similarity index 100% rename from public/packs/js/application-eff7e393ce95ecf9b900.js.LICENSE.txt rename to public/packs/js/application-8ce9779d857bfff53532.js.LICENSE.txt diff --git a/public/packs/js/application-8ce9779d857bfff53532.js.br b/public/packs/js/application-8ce9779d857bfff53532.js.br new file mode 100644 index 00000000..610a9646 --- /dev/null +++ b/public/packs/js/application-8ce9779d857bfff53532.js.br @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2ac34b76ab95f467a2ffb3c8689266f7706ca00172d130302386ee08b22dede2 +size 347614 diff --git a/public/packs/js/application-8ce9779d857bfff53532.js.gz b/public/packs/js/application-8ce9779d857bfff53532.js.gz new file mode 100644 index 00000000..5886b434 --- /dev/null +++ b/public/packs/js/application-8ce9779d857bfff53532.js.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:73c9f3bd667a29d7026309e5d31ab91e45b9e10e186d9b8abfa3e3a12ff3bf0c +size 458426 diff --git a/public/packs/js/application-8ce9779d857bfff53532.js.map b/public/packs/js/application-8ce9779d857bfff53532.js.map new file mode 100644 index 00000000..e6c66405 --- /dev/null +++ b/public/packs/js/application-8ce9779d857bfff53532.js.map @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2bb17fb9d66535cf55c84efb3c56242050c1e7bc168f44b3ff496df9fe0beb67 +size 6205529 diff --git a/public/packs/js/application-8ce9779d857bfff53532.js.map.br b/public/packs/js/application-8ce9779d857bfff53532.js.map.br new file mode 100644 index 00000000..5eeaead6 --- /dev/null +++ b/public/packs/js/application-8ce9779d857bfff53532.js.map.br @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0598c9fd4ddf8878e5ed6ee980ac35586b305eb9b359605d713283bfbeb19b68 +size 1328792 diff --git a/public/packs/js/application-8ce9779d857bfff53532.js.map.gz b/public/packs/js/application-8ce9779d857bfff53532.js.map.gz new file mode 100644 index 00000000..48ae8089 --- /dev/null +++ b/public/packs/js/application-8ce9779d857bfff53532.js.map.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b9a2ba478f9e5abf2712b9b68a9994f668acb52006aac34189a813b67f4be657 +size 1640525 diff --git a/public/packs/manifest.json b/public/packs/manifest.json index 2dcf2333..189f4782 100644 --- a/public/packs/manifest.json +++ b/public/packs/manifest.json @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:75288aa35e3342e83e5afeb0e324f251b19259954163412c2b259183d1be2bb8 +oid sha256:1a206bab3fa22fb96428b3c46685fa61a059f9db62e3df47037537cd68782c1f size 1426 diff --git a/public/packs/manifest.json.br b/public/packs/manifest.json.br index d182a62b..7222d4cd 100644 --- a/public/packs/manifest.json.br +++ b/public/packs/manifest.json.br @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:30acde91e7a69507c9297823826161ada92641837b5df30edb50f3900ae3718a +oid sha256:923d3edcf9cd76e822ca27c1eafcbdaa8b3f1ed47d25ace25e19b6c416d958f5 size 320 diff --git a/public/packs/manifest.json.gz b/public/packs/manifest.json.gz index 46da36ce..bc4ea39d 100644 --- a/public/packs/manifest.json.gz +++ b/public/packs/manifest.json.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e3b87c3e6311e1f3d15ecd5b88d15e1f87b6bd582f3a29f91a38901e323ee48b +oid sha256:a73c5c3f9d5bbecd9a63d4088c029ea835becbd0a6496b7a6f6ca6505d2095c5 size 365 diff --git a/yarn.lock b/yarn.lock index 0c52b9d3..4619169e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4548,6 +4548,11 @@ html-entities@^1.3.1: resolved "https://registry.npmjs.org/html-entities/-/html-entities-1.4.0.tgz" integrity sha512-8nxjcBcd8wovbeKx7h3wTji4e6+rhaVuPNpMqwWgnHh+N9ToqsCs6XztWRBPQ+UtzsoMAdKZtUENoVzU/EMtZA== +htmx.org@^1.9.11: + version "1.9.11" + resolved "https://registry.yarnpkg.com/htmx.org/-/htmx.org-1.9.11.tgz#00192041ee682d6ca7146d0fbd901169ffe72d87" + integrity sha512-WlVuICn8dfNOOgYmdYzYG8zSnP3++AdHkMHooQAzGZObWpVXYathpz/I37ycF4zikR6YduzfCvEcxk20JkIUsw== + http-deceiver@^1.2.7: version "1.2.7" resolved "https://registry.npmjs.org/http-deceiver/-/http-deceiver-1.2.7.tgz"