diff --git a/app/controllers/scores_controller.rb b/app/controllers/scores_controller.rb index d26597a..350c1e2 100644 --- a/app/controllers/scores_controller.rb +++ b/app/controllers/scores_controller.rb @@ -45,7 +45,7 @@ class ScoresController < ApplicationController end def destroy - # zazaz + zazaz @score.destroy! redirect_to scores_url, notice: 'Score was successfully destroyed.', status: :see_other diff --git a/app/views/scores/index.html.erb b/app/views/scores/index.html.erb index 8ceb420..b04ba03 100644 --- a/app/views/scores/index.html.erb +++ b/app/views/scores/index.html.erb @@ -5,6 +5,14 @@ ACTION_VIEW = <%=Live::Constants::ACTION_VIEW%>
ACTIVE_RECORD = <%=Live::Constants::ACTIVE_RECORD%>
+
+ bg-red-950 + + BLACK + WHITE + RED +
+
<%= link_to "New score", new_score_path, class: "border rounded-lg py-3 px-5 bg-blue-600 text-white block font-medium" %>
diff --git a/bin/dev b/bin/dev index 74ade16..1f535cd 100755 --- a/bin/dev +++ b/bin/dev @@ -1,8 +1,21 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash if ! gem list foreman -i --silent; then echo "Installing foreman..." gem install foreman fi +# ---------------------------------------------------------------------- +# in case of running with RAILS_ENV=production with assets precompiling! +# ---------------------------------------------------------------------- + +if [[ -d public/assets ]]; then + echo "You have probably precompiled assets for production purpose!" + echo "Would you like to remove these assets before running in DEV:" + echo "- Press Enter to continue" + echo "- Press Ctrl+C to cancel" + read + rm -rf public/assets +fi + exec foreman start -f Procfile.dev "$@" diff --git a/bin/sprod b/bin/sprod index fd4c270..8d2c7ba 100644 --- a/bin/sprod +++ b/bin/sprod @@ -1,11 +1,10 @@ #!/bin/bash RAILS_ENV=production SECRET_KEY_BASE='toto est fluo' rails assets:precompile +# TO REMOVE PROD assets: +# rm -rf public/assets SEMANTIC_LOGGER_APP=egr RAILS_ENV=production SECRET_KEY_BASE='toto est fluo' rails server # journalctl --all -o cat --full -t egr journalctl --all -o short --no-hostname -t egr -f - -# TO REMOVE PROD assets -# rm -rf tmp/cache/assets diff --git a/config/command_detection.rb b/config/command_detection.rb index 3aa5996..4d2b927 100644 --- a/config/command_detection.rb +++ b/config/command_detection.rb @@ -4,4 +4,9 @@ module CommandDetection def console? = !server? && defined?(Rails::Console) == 'constant' def rake? = !server? && !console? && Rails.const_defined?('Rake') def tailwind_watcher? = rake? && Rake.application.top_level_tasks.first == 'tailwindcss:watch' + + def procfile_server? + Rails.env.development? && Rails.application.server? && File.exist?(File.join(Rails.root, + 'Procfile.dev')) + end end diff --git a/config/initializers/instrumentalizing.rb b/config/initializers/instrumentalizing.rb index 0338638..3d65172 100644 --- a/config/initializers/instrumentalizing.rb +++ b/config/initializers/instrumentalizing.rb @@ -1,4 +1,4 @@ -return unless Rails.application.server? +return if Rails.application.tailwind_watcher? Rails.application.config.x.action_controller.main_session_tag = 'toto1' Rails.application.config.x.action_controller.main_session_tag_fixed_length = 8 @@ -24,18 +24,24 @@ Rails.configuration.after_initialize do SemanticLogger.add_appender(appender:, formatter:) Semantic::Instrumentalizer.activate(*build_instrumentation_config) + if Rails.application.rake? || Rails.application.console? + io_formatter = Rails.application.config.x.semantic.formatter.constantize.new(time_format: '%H:%M:%S') + SemanticLogger.add_appender(io: $stdout, formatter: io_formatter) + end + else + time_format = '%H:%M:%S' unless Rails.application.procfile_server? SemanticLogger.clear_appenders! SemanticLogger.add_appender( io: $stdout, - formatter: Rails.application.config.x.semantic.formatter.constantize.new + formatter: Rails.application.config.x.semantic.formatter.constantize.new(time_format:) ) Rails.autoloaders.main.on_load('ApplicationController') do SemanticLogger.clear_appenders! SemanticLogger.add_appender( io: $stdout, - formatter: Rails.application.config.x.semantic.formatter.constantize.new + formatter: Rails.application.config.x.semantic.formatter.constantize.new(time_format:) ) Rails.logger.info ' ', dimensions: Semantic::FancyDimensions.new(rails: '╔═╗', before: 1) diff --git a/lib/semantic/abstract_formatter.rb b/lib/semantic/abstract_formatter.rb index d21ca88..8a4c9bb 100644 --- a/lib/semantic/abstract_formatter.rb +++ b/lib/semantic/abstract_formatter.rb @@ -6,6 +6,17 @@ module Semantic CENTER_SIZE = 20 TAG_FIXED_LENGTH = Rails.application.config.x.action_controller.main_session_tag_fixed_length || 10 + def initialize(time_format: nil) + super(color_map: ColorMap.new( + debug: CLEAR + TEXT_GRAY_400, + info: CLEAR + TEXT_GRAY_100, + warn: CLEAR + BG_YELLOW + TEXT_BLACK, + error: CLEAR + DARK_BG_RED + TEXT_WHITE, + fatal: CLEAR + BG_MAGENTA + BOLD + TEXT_WHITE + )) + @time_format = time_format + end + private def exception diff --git a/lib/semantic/basic_formatter.rb b/lib/semantic/basic_formatter.rb index 7c5270f..c17014e 100644 --- a/lib/semantic/basic_formatter.rb +++ b/lib/semantic/basic_formatter.rb @@ -7,15 +7,8 @@ module Semantic PRIME = '▍'.freeze CONTINATION = '▕'.freeze - def initialize - super(color_map: ColorMap.new( - debug: TEXT_GRAY_400, - info: TEXT_GREEN, - warn: TEXT_BROWN, - error: LIGHT_TEXT_RED, - fatal: TEXT_MAGENTA - )) - @time_format = File.exist?(File.join(Rails.root, 'Procfile.dev')) ? nil : '%H:%M:%S' + def initialize(time_format: nil) + super end def call(log, logger) diff --git a/lib/semantic/fancy_formatter.rb b/lib/semantic/fancy_formatter.rb index 84d201d..b2d66ed 100644 --- a/lib/semantic/fancy_formatter.rb +++ b/lib/semantic/fancy_formatter.rb @@ -12,15 +12,8 @@ module Semantic RENDERED_VIEW_DURATION = 100 TOTAL_RENDERED_VIEW_DURATION = RENDERED_VIEW_DURATION * 5 - def initialize - super(color_map: - ColorMap.new( - debug: CLEAR + TEXT_GRAY_400, - info: CLEAR + TEXT_GRAY_100, - warn: CLEAR + BG_YELLOW + TEXT_BLACK, - error: CLEAR + BG_RED + TEXT_WHITE, - fatal: CLEAR + BG_MAGENTA + BOLD + TEXT_WHITE - )) + def initialize(time_format: nil) + super @memory = nil end