From e948e1011f3e5ace1df88fc79effd4ab72c45fcb Mon Sep 17 00:00:00 2001 From: pvincent Date: Sun, 28 Jan 2024 22:29:12 +0400 Subject: [PATCH] erb formatter --- .vscode/extensions.json | 3 +- .vscode/settings.json | 13 +++- Gemfile | 1 + Gemfile.lock | 2 + README.md | 39 +++++++++--- app/controllers/scores_controller.rb | 6 +- app/views/layouts/_notification.html.erb | 44 +++++++++++++ app/views/layouts/application.html.erb | 5 +- app/views/layouts/toaster/_toaster.html.erb | 68 +++++++++++++++++++++ app/views/scores/_form.html.erb | 4 -- app/views/scores/edit.html.erb | 4 +- app/views/scores/index.html.erb | 5 +- app/views/scores/new.html.erb | 1 - app/views/scores/show.html.erb | 4 -- lib/formatters/basic_formatter.rb | 2 +- 15 files changed, 170 insertions(+), 31 deletions(-) create mode 100644 app/views/layouts/_notification.html.erb create mode 100644 app/views/layouts/toaster/_toaster.html.erb diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 4edc49b..1dd6141 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -4,6 +4,7 @@ "aki77.rails-db-schema", "yzhang.markdown-all-in-one", "jgclark.vscode-todo-highlight", - "bradlc.vscode-tailwindcss" + "bradlc.vscode-tailwindcss", + "aliariff.vscode-erb-beautify" ] } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 239e2c9..ff74f27 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -8,8 +8,19 @@ "editor.semanticHighlighting.enabled": true, // Enable semantic highlighting "editor.formatOnType": true // Enable formatting while typing }, + "[erb]": { + "editor.defaultFormatter": "aliariff.vscode-erb-beautify", + "editor.formatOnSave": true + }, + "emmet.includeLanguages": { "erb": "html" }, - "debug.onTaskErrors": "abort" + "files.associations": { + "*.html.erb": "erb" + }, + + "debug.onTaskErrors": "abort", + "vscode-erb-beautify.keepBlankLines": 1 + } \ No newline at end of file diff --git a/Gemfile b/Gemfile index adcb860..2d10add 100644 --- a/Gemfile +++ b/Gemfile @@ -71,6 +71,7 @@ group :development do gem 'ruby-lsp-rails' gem 'amazing_print' + gem 'htmlbeautifier' gem 'rails_live_reload' gem 'rails_semantic_logger' end diff --git a/Gemfile.lock b/Gemfile.lock index 5090129..9479bd9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -108,6 +108,7 @@ GEM ffi (1.16.3) globalid (1.2.1) activesupport (>= 6.1) + htmlbeautifier (1.4.2) i18n (1.14.1) concurrent-ruby (~> 1.0) importmap-rails (2.0.1) @@ -337,6 +338,7 @@ DEPENDENCIES capybara debug error_highlight (>= 0.4.0) + htmlbeautifier importmap-rails pg (~> 1.1) puma (>= 5.0) diff --git a/README.md b/README.md index 66a0e48..ab645a5 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ gem install bundler bundle install ``` -## database.yml +### database.yml ```yaml [...] @@ -22,10 +22,20 @@ development: host: ct1.lxd [...] ``` - rails generate scaffold score name:string grade:integer rails db:migrate +## TODO + +* [ ] Popup Notification +* [x] Customized Turbo + * [x] Progress Bar + * [ ] Confirm Method using HTML modal +* [ ] Production Ready + * [ ] ./bin/prod + * [ ] Syslog +* [ ] Data Turbo Frame + ## Featuring * [x] VsCodium development improvement @@ -33,20 +43,29 @@ rails db:migrate * [x] Ruby-lsp-rails * [x] Ruby Db Schema * [x] Markdown All in One - * [x] TODO Highliter + * [x] TODO Highlighter * [x] run ` rails notes` to show up any TODO or FIXME * [x] Debugger friendly * [x] ask before killing ./bin/dev * [x] Tailwind CSS * [x] Rails Live Reload * [x] compliant with Tailwind build +* [x] ERB Formatter + * [x] Keep 1 blank line -## TODO -* [x] Customized Turbo - * [x] Progress Bar - * [ ] Confirm Method using HTML modal -* [ ] Production Ready - * [ ] ./bin/prod - * [ ] Log +## MAYBE + +* [ ] /bin/setup + * [ ] check debian12 + * [ ] git clone from public repository + * [ ] remove .git folder + * [ ] remove /bin/setup + * [ ] ask for main configuration (application_title, alpineJs) + +* [ ] ViewComponent + * [ ] https://viewcomponent.org/ + +* [ ] Postgresql text search + * [ ] Fuzzy search with trigrams diff --git a/app/controllers/scores_controller.rb b/app/controllers/scores_controller.rb index 0cc2fcc..1c6ca2f 100644 --- a/app/controllers/scores_controller.rb +++ b/app/controllers/scores_controller.rb @@ -10,8 +10,8 @@ class ScoresController < ApplicationController # logger.info 'this is an information', { four: 4, five: 5 } # logger.debug BigDecimal('0.0003') # logger.warn 'scores are', @scores - logger.warn 'this is a warning' - logger.error 'this is an error message' + # logger.warn 'this is a warning' + # logger.error 'this is an error message' logger.info 'end of normal message' # logger.debug @scores # sleep 0.5 @@ -23,6 +23,8 @@ class ScoresController < ApplicationController # GET /scores/new def new @score = Score.new + flash.now[:notice] = 'Unique name is mandatory!' + flash.now[:alert] = 'Your book was not found' sleep 0.3 end diff --git a/app/views/layouts/_notification.html.erb b/app/views/layouts/_notification.html.erb new file mode 100644 index 0000000..5c996ba --- /dev/null +++ b/app/views/layouts/_notification.html.erb @@ -0,0 +1,44 @@ +

NOTIFICATION BAR

+ + diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 66b66df..e44d233 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -12,7 +12,10 @@ -
+ + <%=render '/layouts/notification' %> + +
<%= yield %>
diff --git a/app/views/layouts/toaster/_toaster.html.erb b/app/views/layouts/toaster/_toaster.html.erb new file mode 100644 index 0000000..176b625 --- /dev/null +++ b/app/views/layouts/toaster/_toaster.html.erb @@ -0,0 +1,68 @@ + + + + + + + + +

Snackbar / Toast

+

Snackbars are often used as a tooltips/popups to show a message at the bottom of the screen.

+

Click on the button to show the snackbar. It will disappear after 3 seconds.

+ + + +
Some text some message..
+ + + + + diff --git a/app/views/scores/_form.html.erb b/app/views/scores/_form.html.erb index 0676a05..f8660e6 100644 --- a/app/views/scores/_form.html.erb +++ b/app/views/scores/_form.html.erb @@ -2,7 +2,6 @@ <% if score.errors.any? %>

<%= pluralize(score.errors.count, "error") %> prohibited this score from being saved:

-
    <% score.errors.each do |error| %>
  • <%= error.full_message %>
  • @@ -10,17 +9,14 @@
<% end %> -
<%= form.label :name %> <%= form.text_field :name, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full" %>
-
<%= form.label :grade %> <%= form.number_field :grade, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full" %>
-
<%= form.submit class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer" %>
diff --git a/app/views/scores/edit.html.erb b/app/views/scores/edit.html.erb index d7154bd..860d093 100644 --- a/app/views/scores/edit.html.erb +++ b/app/views/scores/edit.html.erb @@ -1,8 +1,8 @@

Editing score

- <%= render "form", score: @score %> + <%= render "form", score: @score %> - <%= link_to "Show this score", @score, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> + <%= link_to "Show this score", @score, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> <%= link_to "Back to scores", scores_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
diff --git a/app/views/scores/index.html.erb b/app/views/scores/index.html.erb index 9514a77..d02d698 100644 --- a/app/views/scores/index.html.erb +++ b/app/views/scores/index.html.erb @@ -1,7 +1,4 @@ -
- <% if notice.present? %> -

<%= notice %>

- <% end %> +

Scores

diff --git a/app/views/scores/new.html.erb b/app/views/scores/new.html.erb index 1b45532..d993f4f 100644 --- a/app/views/scores/new.html.erb +++ b/app/views/scores/new.html.erb @@ -2,6 +2,5 @@

New score

<%= render "form", score: @score %> - <%= link_to "Back to scores", scores_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
diff --git a/app/views/scores/show.html.erb b/app/views/scores/show.html.erb index adfcddb..a4b0aea 100644 --- a/app/views/scores/show.html.erb +++ b/app/views/scores/show.html.erb @@ -1,9 +1,5 @@
- <% if notice.present? %> -

<%= notice %>

- <% end %> - <%= render @score %> <%= link_to "Edit this score", edit_score_path(@score), class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> diff --git a/lib/formatters/basic_formatter.rb b/lib/formatters/basic_formatter.rb index 72a47e0..35048d9 100644 --- a/lib/formatters/basic_formatter.rb +++ b/lib/formatters/basic_formatter.rb @@ -69,7 +69,7 @@ class BasicFormatter < SemanticLogger::Formatters::Color # rubocop:disable Metri def payload return unless log.payload - lines = log.payload.ai(ruby19_syntax: true, indent: 2).split("\n") + lines = log.payload.ai(ruby19_syntax: true, indent: 2, object_id: false).split("\n") first_line = lines.shift space_prefix = first_line.match(/^\s*/) lines = lines.map do |l|