Skip to content

Commit

Permalink
Add (head|body) custom script settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
kaishuu0123 committed Jul 23, 2024
1 parent d94b65c commit 80eda0e
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 45 deletions.
14 changes: 8 additions & 6 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,24 @@
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"eslint.workingDirectories": [{ "mode": "auto" }],
"rubyLsp.rubyVersionManager": "none"
"rubyLsp.erbSupport": false,
"rubyLsp.rubyVersionManager": "none",
"[ruby]": {
"editor.defaultFormatter": "Shopify.ruby-lsp",
"editor.semanticHighlighting.enabled": true
}
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
// Add the IDs of extensions you want installed when the container is created.
"cschleiden.vscode-github-actions",
"msjsdiag.debugger-for-chrome",
"firefox-devtools.vscode-firefox-debug",
"editorconfig.editorconfig",
"vscode-icons-team.vscode-icons",
"Shopify.ruby-lsp",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"stylelint.vscode-stylelint",
"mikestead.dotenv",
"mhutchie.git-graph",
"eamodio.gitlens"
"mhutchie.git-graph"
]
}
}
Expand Down
8 changes: 3 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ group :development, :test do

# Call 'byebug' anywhere in the code to stop execution and get a debugger console
# Ruby fast debugger - base + CLI (https://github.com/deivid-rodriguez/byebug)
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'byebug', platforms: %i[mri mingw x64_mingw]
end

group :development do
Expand All @@ -51,8 +51,6 @@ group :development do
gem 'spring'
# Makes spring watch files using the listen gem. (https://github.com/jonleighton/spring-watcher-listen)
gem 'spring-watcher-listen', '~> 2.0.0'
# Solargraph for Ruby (http://solargraph.org)
gem 'solargraph'
# Automatic Ruby code style checking tool. (https://github.com/rubocop-hq/rubocop)
gem 'rubocop'
# An IRB alternative and runtime developer console (http://pryrepl.org)
Expand Down Expand Up @@ -85,7 +83,7 @@ end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
# Timezone Data for TZInfo (http://tzinfo.github.io)
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]

# Flexible authentication solution for Rails with Warden (https://github.com/plataformatec/devise)
gem 'devise'
Expand Down Expand Up @@ -120,5 +118,5 @@ gem 'omniauth-google-oauth2', '~> 0.8'

gem 'config'

gem 'kaminari', '~> 1.2'
gem 'gravatar_image_tag'
gem 'kaminari', '~> 1.2'
32 changes: 1 addition & 31 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,8 @@ GEM
annotate_gem (0.0.14)
bundler (>= 1.1)
ast (2.4.2)
backport (1.2.0)
base64 (0.2.0)
bcrypt (3.1.20)
benchmark (0.3.0)
bigdecimal (3.1.8)
bindex (0.8.1)
builder (3.3.0)
Expand Down Expand Up @@ -119,9 +117,7 @@ GEM
warden (~> 1.2.3)
devise-i18n (1.12.1)
devise (>= 4.9.0)
diff-lcs (1.5.1)
drb (2.2.1)
e2mmap (0.1.0)
erubi (1.13.0)
faraday (2.10.0)
faraday-net_http (>= 2.0, < 3.2)
Expand All @@ -142,7 +138,6 @@ GEM
irb (1.14.0)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
jaro_winkler (1.6.0)
jbuilder (2.12.0)
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
Expand All @@ -161,10 +156,6 @@ GEM
activerecord
kaminari-core (= 1.2.2)
kaminari-core (1.2.2)
kramdown (2.4.0)
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
language_server-protocol (3.17.0.3)
launchy (3.0.1)
addressable (~> 2.8)
Expand Down Expand Up @@ -246,7 +237,7 @@ GEM
method_source (~> 1.0)
psych (5.1.2)
stringio
public_suffix (6.0.0)
public_suffix (6.0.1)
puma (6.4.2)
nio4r (~> 2.0)
racc (1.8.0)
Expand Down Expand Up @@ -302,7 +293,6 @@ GEM
rb-fsevent (0.11.2)
rb-inotify (0.11.1)
ffi (~> 1.0)
rbs (2.8.4)
rdoc (6.7.0)
psych (>= 4.0.0)
regexp_parser (2.9.2)
Expand All @@ -313,8 +303,6 @@ GEM
responders (3.1.1)
actionpack (>= 5.2)
railties (>= 5.2)
reverse_markdown (2.1.1)
nokogiri
rexml (3.3.2)
strscan
rolify (6.0.1)
Expand Down Expand Up @@ -358,22 +346,6 @@ GEM
snaky_hash (2.0.1)
hashie
version_gem (~> 1.1, >= 1.1.1)
solargraph (0.50.0)
backport (~> 1.2)
benchmark
bundler (~> 2.0)
diff-lcs (~> 1.4)
e2mmap
jaro_winkler (~> 1.5)
kramdown (~> 2.3)
kramdown-parser-gfm (~> 1.1)
parser (~> 3.0)
rbs (~> 2.0)
reverse_markdown (~> 2.0)
rubocop (~> 1.38)
thor (~> 1.0)
tilt (~> 2.0)
yard (~> 0.9, >= 0.9.24)
spring (2.1.1)
spring-watcher-listen (2.0.1)
listen (>= 2.7, < 4.0)
Expand Down Expand Up @@ -421,7 +393,6 @@ GEM
websocket-extensions (0.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)
yard (0.9.36)
zeitwerk (2.6.16)

PLATFORMS
Expand Down Expand Up @@ -460,7 +431,6 @@ DEPENDENCIES
selenium-webdriver
sequenced
simple_form
solargraph
spring
spring-watcher-listen (~> 2.0.0)
sqlite3 (~> 1.4)
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/application_settings/dashboard_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ def update
end

private

def settings_params
params.require(:settings).permit(:site_title)
params.require(:settings).permit(:site_title, :head_custom_script, :body_custom_script)
end
end
5 changes: 4 additions & 1 deletion app/models/setting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

# RailsSettings Model
class Setting < RailsSettings::Base
cache_prefix { "v1" }
cache_prefix { 'v2' }

# Define your fields
# field :host, type: :string, default: "http://localhost:3000"
Expand All @@ -24,4 +24,7 @@ class Setting < RailsSettings::Base
field :installed, type: :boolean, default: false

field :site_title, type: :string, default: ''

field :head_custom_script, type: :string, default: ''
field :body_custom_script, type: :string, default: ''
end
4 changes: 3 additions & 1 deletion app/views/application_settings/dashboard/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
<div class="card-body">
<%= simple_form_for :settings, url: application_settings_path do |f| %>
<%= f.input :site_title, as: :string, input_html: { value: Setting.site_title } %>
<%= f.input :head_custom_script, as: :text, input_html: { value: Setting.head_custom_script, rows: 5 } %>
<%= f.input :body_custom_script, as: :text, input_html: { value: Setting.body_custom_script, rows: 5 } %>
<div class="d-flex justify-content-end">
<%= f.submit nil, class: 'btn btn-primary' %>
</div>
Expand All @@ -22,4 +24,4 @@
</div>
</div>
</div>
</div>
</div>
4 changes: 4 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<% custom_title << @project.title if @project.present? %>
<% custom_title << Setting.site_title if Setting.site_title.present? %>
<%= raw(Setting.head_custom_script) if Setting.head_custom_script.present? %>
<%# <meta name="viewport" content="width=device-width,initial-scale=1.0"> %>
<% if custom_title.present? %>
Expand All @@ -30,5 +32,7 @@
<% end %>
<%= yield %>
<%= raw(Setting.body_custom_script) if Setting.body_custom_script.present? %>
</body>
</html>
5 changes: 5 additions & 0 deletions config/locales/simple_form.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ en:
# html: '<abbr title="required">*</abbr>'
error_notification:
default_message: "Please review the problems below:"
labels:
settings:
site_title: 'サイト名'
head_custom_script: '<head> custom script'
body_custom_script: '<body> custom script'
# Examples
# labels:
# defaults:
Expand Down
2 changes: 2 additions & 0 deletions config/locales/simple_form.ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ ja:
labels:
settings:
site_title: 'サイト名'
head_custom_script: '<head> カスタムスクリプト'
body_custom_script: '<body> カスタムスクリプト'
# Examples
# labels:
# defaults:
Expand Down

0 comments on commit 80eda0e

Please sign in to comment.