From e12d7546bf6caea9ae7b9a278f87c0070950ccc7 Mon Sep 17 00:00:00 2001 From: Efremov Evgenii Date: Fri, 24 Jun 2022 21:47:36 +0300 Subject: [PATCH 1/5] setup project --- Gemfile | 4 ++-- Gemfile.lock | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Gemfile b/Gemfile index bf57e9a..d5513bc 100644 --- a/Gemfile +++ b/Gemfile @@ -16,7 +16,7 @@ end gem "actionpack-action_caching", "~> 1.2" gem "active_record_union", "~> 1.3" gem "acts-as-taggable-on", "~> 5.0" -gem "acts_as_follower", github: "thepracticaldev/acts_as_follower", branch: "master" +gem "acts_as_follower", github: "forem/acts_as_follower", branch: "master" gem "addressable", "~> 2.5", ">= 2.5.2" gem "administrate", "~> 0.11" gem "ahoy_email", "~> 0.5" @@ -122,7 +122,7 @@ group :development, :test do gem "derailed", "~> 0.1" gem "erb_lint", "~> 0.0", require: false gem "faker", git: "https://github.com/stympy/faker.git", branch: "master" - gem "fix-db-schema-conflicts", github: "thepracticaldev/fix-db-schema-conflicts", branch: "master" + gem "fix-db-schema-conflicts", github: "jakeonrails/fix-db-schema-conflicts", branch: "master" gem "memory_profiler", "~> 0.9" gem "parallel_tests", "~> 2.27" gem "pry-byebug", "~> 3.7" diff --git a/Gemfile.lock b/Gemfile.lock index 331bf9c..574c972 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,26 +1,26 @@ GIT - remote: https://github.com/stympy/faker.git - revision: 9910aa58d92c018abab25d491191576fcc1a7707 + remote: https://github.com/forem/acts_as_follower.git + revision: 06393d3693a1a3d4b390aec4976c8b8f3a81cf01 branch: master specs: - faker (1.9.1) - i18n (>= 0.7) + acts_as_follower (0.2.1) + activerecord (>= 4.0) GIT - remote: https://github.com/thepracticaldev/acts_as_follower.git - revision: 288690cd99bc470eaee493fce5bfa9fe23157692 + remote: https://github.com/jakeonrails/fix-db-schema-conflicts.git + revision: 1e94f518503f1d1addd6ed052454efcbec0b3c6a branch: master specs: - acts_as_follower (0.2.1) - activerecord (>= 4.0) + fix-db-schema-conflicts (3.1.0) + rubocop (>= 0.38.0) GIT - remote: https://github.com/thepracticaldev/fix-db-schema-conflicts.git - revision: 4172392392e1a8d907f7ab673cb5ddd9a4a31940 + remote: https://github.com/stympy/faker.git + revision: 9910aa58d92c018abab25d491191576fcc1a7707 branch: master specs: - fix-db-schema-conflicts (3.0.2) - rubocop (>= 0.38.0) + faker (1.9.1) + i18n (>= 0.7) GEM remote: https://rubygems.org/ From f03b454b5168bbb0850475099ccf41175af2d2d0 Mon Sep 17 00:00:00 2001 From: Efremov Evgenii Date: Mon, 27 Jun 2022 19:12:39 +0300 Subject: [PATCH 2/5] add server push for images --- .gitignore | 3 ++- app/controllers/stories_controller.rb | 8 ++++++++ app/views/articles/index.html.erb | 2 +- app/views/layouts/_top_bar.html.erb | 6 +++--- config/environments/development.rb | 2 +- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index df2840a..0dae2e2 100644 --- a/.gitignore +++ b/.gitignore @@ -52,4 +52,5 @@ package-lock.json .idea/ #sitemap -/public/sitemap.xml.gz \ No newline at end of file +/public/sitemap.xml.gz +crt diff --git a/app/controllers/stories_controller.rb b/app/controllers/stories_controller.rb index df60029..08cad44 100644 --- a/app/controllers/stories_controller.rb +++ b/app/controllers/stories_controller.rb @@ -7,6 +7,14 @@ def index return handle_user_or_organization_or_podcast_index if params[:username] return handle_tag_index if params[:tag] + push_headers = [ + "<#{view_context.asset_path('bell.svg')}>; rel=preload; as=image", + "<#{view_context.asset_path('menu.svg')}>; rel=preload; as=image", + "<#{view_context.asset_path('connect.svg')}>; rel=preload; as=image", + "<#{view_context.asset_path('stack.svg')}>; rel=preload; as=image", + "<#{view_context.asset_path('lightning.svg')}>; rel=preload; as=image", + ] + response.headers["Link"] = push_headers.join(", ") handle_base_index end diff --git a/app/views/articles/index.html.erb b/app/views/articles/index.html.erb index 1137465..814633e 100644 --- a/app/views/articles/index.html.erb +++ b/app/views/articles/index.html.erb @@ -76,7 +76,7 @@ - + stack <% if @featured_story.id %>
diff --git a/app/views/layouts/_top_bar.html.erb b/app/views/layouts/_top_bar.html.erb index bf2750f..fca6cfe 100644 --- a/app/views/layouts/_top_bar.html.erb +++ b/app/views/layouts/_top_bar.html.erb @@ -13,11 +13,11 @@ WRITE A POST - <%= inline_svg("connect.svg", size: "100% * 100%") %> + <%= image_tag("connect.svg", size: "100% * 100%") %>
- <%= inline_svg("bell.svg", size: "100% * 100%") %> + <%= image_tag("bell.svg", size: "100% * 100%") %>
stack + <% if @featured_story.id %>
diff --git a/config/environments/development.rb b/config/environments/development.rb index ff56e94..ad3b97c 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -6,7 +6,7 @@ def yarn_integrity_enabled? Rails.application.configure do # Verifies that versions and hashed value of the package contents in the project's package.json - config.webpacker.check_yarn_integrity = false + config.webpacker.check_yarn_integrity = yarn_integrity_enabled? # Settings specified here will take precedence over those in config/application.rb. diff --git a/nginx.sample.conf b/nginx.sample.conf new file mode 100644 index 0000000..97ddb57 --- /dev/null +++ b/nginx.sample.conf @@ -0,0 +1,117 @@ + +#user nobody; +worker_processes 1; + +#error_log logs/error.log; +#error_log logs/error.log notice; +#error_log logs/error.log info; + +#pid logs/nginx.pid; + + +events { + worker_connections 1024; +} + + +http { + include mime.types; + default_type application/octet-stream; + + #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + # '$status $body_bytes_sent "$http_referer" ' + # '"$http_user_agent" "$http_x_forwarded_for"'; + + #access_log logs/access.log main; + + sendfile on; + #tcp_nopush on; + + #keepalive_timeout 0; + keepalive_timeout 65; + + #gzip on; + + server { + listen 8080; + server_name localhost; + + #charset koi8-r; + + #access_log logs/host.access.log main; + + location / { + root html; + index index.html index.htm; + } + + #error_page 404 /404.html; + + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root html; + } + + # proxy the PHP scripts to Apache listening on 127.0.0.1:80 + # + #location ~ \.php$ { + # proxy_pass http://127.0.0.1; + #} + + # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 + # + #location ~ \.php$ { + # root html; + # fastcgi_pass 127.0.0.1:9000; + # fastcgi_index index.php; + # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; + # include fastcgi_params; + #} + + # deny access to .htaccess files, if Apache's document root + # concurs with nginx's one + # + #location ~ /\.ht { + # deny all; + #} + } + + + # another virtual host using mix of IP-, name-, and port-based configuration + # + #server { + # listen 8000; + # listen somename:8080; + # server_name somename alias another.alias; + + # location / { + # root html; + # index index.html index.htm; + # } + #} + + + # HTTPS server + server { + listen 443 http2 ssl; + server_name localhost; + ssl_certificate /Users/efremovevgenii/Projects/rails-optimization-task5/crt/local.example.com.pem; + ssl_certificate_key /Users/efremovevgenii/Projects/rails-optimization-task5/crt/local.example.com-key.pem; + ssl_session_timeout 5m; + ssl_protocols TLSv1 TLSv1.1 TLSv1.2; + ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:DES-CBC3-SHA:!RC4:!aNULL:!eNULL:!MD5:!EXPORT:!EXP:!LOW:!SEED:!CAMELLIA:!IDEA:!PSK:!SRP:!SSLv:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA'; + ssl_prefer_server_ciphers on; + + location / { + http2_push_preload on; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto https; + proxy_redirect off; + proxy_pass http://127.0.0.1:3000; + } + } + include servers/*; +}