This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- app/views/hello.html --> | |
<h1>Hello!</h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module WebI18nLocale | |
extend ActiveSupport::Concern | |
included do | |
prepend_before_action :digest_locale_params | |
before_action :set_locale | |
helper_method :set_locale_path | |
end | |
private |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% # I have a slide contains 6 images. %> | |
<% # And also I have different versions of them based on media queries. %> | |
<% # We can load the 2nd to 6th images asynchronously. %> | |
<% (2..6).each do |num| %> | |
<div data-controller="preload-img" data-preload-img-src-value='<%= asset_path("slides/pc/#{num}.jpg") %>' data-preload-img-media-value="(min-width: 992px)"></div> | |
<div data-controller="preload-img" data-preload-img-src-value='<%= asset_path("slides/mobile/#{num}.jpg") %>' data-preload-img-media-value="(max-width: 991px)"></div> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import TwCitySelector from 'tw-city-selector/dist/tw-city-selector.min.js' | |
import { Controller } from "@hotwired/stimulus" | |
export default class extends Controller { | |
connect() { | |
let controller = this | |
new TwCitySelector({ | |
el: '.city-selector-set', | |
elCounty: '.county', | |
elDistrict: '.district', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# lib/action_text_parser.rb | |
# require 'action_text_parser' in application.rb | |
class ActionTextParser | |
def self.run(action_text_record) | |
html = action_text_record.body.to_html | |
nodes = Nokogiri::HTML::DocumentFragment.parse html | |
nodes = self.parse_attachments(nodes) | |
nodes = self.parse_code(nodes) | |
nodes.to_html | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//// For Rails projects with rails-ujs Check official guide: https://guides.rubyonrails.org/working_with_javascript_in_rails.html#rails-ujs-event-handlers | |
// In xxx.html.erb, we can write | |
// <%= link_to 'xxx', url, remote: true, data: { type: :json, disalbe_with: "...", confirm: "ok?" }, class: 'js-remote-link' %> | |
$(document).on("ajax:success", ".js-remote-link", function(e) { | |
var data = event.detail[0] | |
var status = event.detail[1] | |
var xhr = event.detail[2] | |
console.log(data) // {message: "SUCCESS ✓"} | |
console.log(status) // OK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Puma HTTP Server | |
After=network.target | |
[Service] | |
Type=simple | |
User=deploy | |
WorkingDirectory=/home/deploy/apps/shiftweb/current | |
Environment=RAILS_ENV=production | |
ExecStart=/home/deploy/.rvm/bin/rvm ruby-2.6.5 do bundle exec puma -C /home/deploy/apps/shiftweb/shared/puma.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Include Quill stylesheet --> | |
<link href="https://cdn.quilljs.com/1.3.5/quill.snow.css" rel="stylesheet"> | |
<div id="form-container"> | |
<%= form_for @portfolio do |f| %> | |
<div class="form-group"> | |
<%= f.label :title %> | |
<%= f.text_field :title, class: "form-control" %> | |
</div> | |
<div class="form-group"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/nginx.conf | |
upstream puma { | |
server unix:///home/deploy/apps/AppName/shared/tmp/sockets/puma.sock; | |
} | |
server { | |
server_name example.com www.example.com.tw; | |
root /home/deploy/apps/AppName/current/public; | |
access_log /home/deploy/apps/AppName/current/log/nginx.access.log; | |
error_log /home/deploy/apps/AppName/current/log/nginx.error.log info; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/letsencrypt/options-ssl-nginx.conf | |
ssl_session_timeout 5m; | |
ssl_session_cache shared:SSL:50m; | |
ssl_session_timeout 1440m; | |
ssl_session_cache shared:ssl_session_cache:10m; | |
ssl_session_tickets off; | |
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; | |
ssl_prefer_server_ciphers on; | |
ssl_ciphers 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; |
NewerOlder