Compare commits

...

10 Commits

Author SHA1 Message Date
8629281c14
feat: add redis gem
Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
2023-04-07 00:34:54 +02:00
57becfdb72
fix: cannot precompile assets before copying rails content
Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
2023-04-07 00:22:50 +02:00
b324436cf0
feat: added production keys
Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
2023-04-06 23:49:06 +02:00
8ffdf1ae89
fix: don't use bundle --without flag as it is deprecated
Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
2023-04-06 21:16:13 +02:00
92410b6fea
fix: removed leftovers from copypasting the .gitlab-ci.yml
Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
2023-04-06 21:13:34 +02:00
c80d2857cb
feat: move assets:precompile to docker preparation instead of at each runtimes
Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
2023-04-06 21:11:24 +02:00
4db7b8f3b8
feat: dockerized rails app
Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
2023-04-06 20:58:58 +02:00
91e2018253
fix: removed email field from update current password
Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
2023-04-06 20:07:44 +02:00
eac85929d1
feat: updated README
Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
2023-04-06 20:00:13 +02:00
09c9feeeef
feat: added possibility to edit your password and your email on your profile
Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
2023-04-06 19:58:34 +02:00
19 changed files with 176 additions and 46 deletions

4
.dockerignore Normal file
View File

@ -0,0 +1,4 @@
.bundle
node_modules
log
vendor

2
.gitignore vendored
View File

@ -41,3 +41,5 @@
/node_modules /node_modules
/.idea /.idea
/config/credentials/production.key

32
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,32 @@
image: docker:latest
services:
- docker:dind
stages:
- release
variables:
# Use TLS https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#tls-enabled
DOCKER_HOST: tcp://docker:2376
DOCKER_TLS_CERTDIR: "/certs"
CONTAINER_BRANCH_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
CONTAINER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE:latest
release:
stage: release
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build . -t $CONTAINER_BRANCH_IMAGE
- docker push $CONTAINER_BRANCH_IMAGE
except:
- master
release-master:
stage: release
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build . -t $CONTAINER_RELEASE_IMAGE
- docker push $CONTAINER_RELEASE_IMAGE
only:
- master

View File

@ -1 +1 @@
ruby-3.0.5 3.2.2

25
Dockerfile Normal file
View File

@ -0,0 +1,25 @@
# syntax=docker/dockerfile:1
FROM ruby:3.2.2
ENV RAILS_ENV=production
ENV RAILS_SERVE_STATIC_FILES=yes
ENV RAILS_LOG_TO_STDOUT=yes
EXPOSE 3000
RUN apt-get update && \
curl -fsSL https://deb.nodesource.com/setup_19.x | bash - && \
apt-get install -y sqlite3 neovim curl nodejs --no-install-recommends && \
apt-get clean && \
bundle config --global frozen 1 && \
npm install --global yarn
WORKDIR /count_anything
COPY Gemfile Gemfile.lock package.json yarn.lock ./
RUN bundle config set --local without 'development test' && \
bundle install && \
yarn install
COPY . .
CMD /count_anything/bin/rails assets:precompile && /count_anything/bin/rails db:migrate && /count_anything/bin/rails server

View File

@ -1,7 +1,7 @@
source "https://rubygems.org" source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" } git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby "3.0.5" ruby "3.2.2"
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.0.4" gem "rails", "~> 7.0.4"
@ -31,7 +31,7 @@ gem "cssbundling-rails"
gem "jbuilder" gem "jbuilder"
# Use Redis adapter to run Action Cable in production # Use Redis adapter to run Action Cable in production
# gem "redis", "~> 4.0" gem "redis", "~> 4.0"
# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis] # Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
# gem "kredis" # gem "kredis"

View File

@ -124,6 +124,7 @@ GEM
matrix (0.4.2) matrix (0.4.2)
method_source (1.0.0) method_source (1.0.0)
mini_mime (1.1.2) mini_mime (1.1.2)
mini_portile2 (2.8.1)
minitest (5.16.3) minitest (5.16.3)
msgpack (1.6.0) msgpack (1.6.0)
net-imap (0.3.2) net-imap (0.3.2)
@ -136,7 +137,8 @@ GEM
net-smtp (0.3.3) net-smtp (0.3.3)
net-protocol net-protocol
nio4r (2.5.8) nio4r (2.5.8)
nokogiri (1.13.10-x86_64-linux) nokogiri (1.13.10)
mini_portile2 (~> 2.8.0)
racc (~> 1.4) racc (~> 1.4)
orm_adapter (0.5.0) orm_adapter (0.5.0)
public_suffix (5.0.1) public_suffix (5.0.1)
@ -173,6 +175,7 @@ GEM
thor (~> 1.0) thor (~> 1.0)
zeitwerk (~> 2.5) zeitwerk (~> 2.5)
rake (13.0.6) rake (13.0.6)
redis (4.8.1)
regexp_parser (2.6.1) regexp_parser (2.6.1)
reline (0.3.2) reline (0.3.2)
io-console (~> 0.5) io-console (~> 0.5)
@ -192,7 +195,8 @@ GEM
actionpack (>= 5.2) actionpack (>= 5.2)
activesupport (>= 5.2) activesupport (>= 5.2)
sprockets (>= 3.0.0) sprockets (>= 3.0.0)
sqlite3 (1.5.4-x86_64-linux) sqlite3 (1.5.4)
mini_portile2 (~> 2.8.0)
stimulus-rails (1.2.1) stimulus-rails (1.2.1)
railties (>= 6.0.0) railties (>= 6.0.0)
thor (1.2.1) thor (1.2.1)
@ -236,6 +240,7 @@ DEPENDENCIES
jsbundling-rails jsbundling-rails
puma (~> 5.0) puma (~> 5.0)
rails (~> 7.0.4) rails (~> 7.0.4)
redis (~> 4.0)
selenium-webdriver selenium-webdriver
sprockets-rails sprockets-rails
sqlite3 (~> 1.4) sqlite3 (~> 1.4)
@ -246,7 +251,7 @@ DEPENDENCIES
webdrivers webdrivers
RUBY VERSION RUBY VERSION
ruby 3.0.5p211 ruby 3.2.2p53
BUNDLED WITH BUNDLED WITH
2.4.4 2.4.10

View File

@ -1,24 +1,3 @@
# README # Count anything
This README would normally document whatever steps are necessary to get the This is a simple Ruby on Rails project using Websockets for real-time interfaces, to count literally anything.
application up and running.
Things you may want to cover:
* Ruby version
* System dependencies
* Configuration
* Database creation
* Database initialization
* How to run the test suite
* Services (job queues, cache servers, search engines, etc.)
* Deployment instructions
* ...

View File

@ -1,6 +0,0 @@
class Profile::HomeController < ApplicationController
before_action :authenticate_user!
def index
end
end

View File

@ -0,0 +1,27 @@
class ProfileController < ApplicationController
before_action :authenticate_user!
def edit
end
def update_email
if current_user.valid_password?(params["current_password"]) && current_user.update(email: params["email"])
flash[:notice] = I18n.translate("flashes.profile.update.success")
redirect_to profile_path
else
flash[:alert] = I18n.translate("flashes.profile.update.fail")
redirect_to profile_path
end
end
def update_password
if !params["password"].blank? && current_user.valid_password?(params["current_password"]) && params["password"] == params["password_confirmation"] && current_user.update(password: params["password"])
bypass_sign_in(current_user)
flash[:notice] = I18n.translate("flashes.profile.update.success")
redirect_to profile_path
else
flash[:alert] = I18n.translate("flashes.profile.update.fail")
redirect_to profile_path
end
end
end

View File

@ -19,7 +19,7 @@
<li><%= link_to t("fields.home"), root_path, class: "nav-link px-2 #{current_page?(root_path) ? "text-secondary" : "text-white"}" %></li> <li><%= link_to t("fields.home"), root_path, class: "nav-link px-2 #{current_page?(root_path) ? "text-secondary" : "text-white"}" %></li>
<% if current_user %> <% if current_user %>
<li><%= link_to t("fields.count"), count_index_path, class: "nav-link px-2 #{current_page?(count_index_path) ? "text-secondary" : "text-white"}" %></li> <li><%= link_to t("fields.count"), count_index_path, class: "nav-link px-2 #{current_page?(count_index_path) ? "text-secondary" : "text-white"}" %></li>
<li><%= link_to t("fields.profile"), profile_root_path, class: "nav-link px-2 #{current_page?(profile_root_path) ? "text-secondary" : "text-white"}" %></li> <li><%= link_to t("fields.profile"), profile_path, class: "nav-link px-2 #{current_page?(profile_path) ? "text-secondary" : "text-white"}" %></li>
<% end %> <% end %>
</ul> </ul>

View File

@ -0,0 +1,41 @@
<div class="mt-2 mb-4">
<div class="mt-2 mb-4">
<h3><%= t("fields.update_email") %></h3>
<%= form_tag profile_update_email_path, method: :post do %>
<div class="col-2 mt-2">
<%= label_tag :email, t("fields.email") %>
<%= email_field_tag :email, current_user.email, class: "form-control" %>
</div>
<div class="col-2 mt-2">
<%= label_tag :current_password, t("fields.current_password") %>
<%= password_field_tag :current_password, nil, class: "form-control" %>
</div>
<%= submit_tag t("fields.save"), class: "btn btn-primary mt-2" %>
<% end %>
</div>
<div class="mt-2 mb-4">
<h3><%= t("fields.update_password") %></h3>
<%= form_tag profile_update_password_path, method: :post do %>
<div class="col-2 mt-2">
<%= label_tag :password, t("fields.new_password") %>
<%= password_field_tag :password, nil, class: "form-control" %>
</div>
<div class="col-2 mt-2">
<%= label_tag :password_confirmation, t("fields.new_password_confirmation") %>
<%= password_field_tag :password_confirmation, nil, class: "form-control" %>
</div>
<div class="col-2 mt-2">
<%= label_tag :current_password, t("fields.current_password") %>
<%= password_field_tag :current_password, nil, class: "form-control" %>
</div>
<%= submit_tag t("fields.save"), class: "btn btn-primary mt-2" %>
<% end %>
</div>
</div>

View File

@ -1,2 +0,0 @@
<h1>Profile::Home#index</h1>
<p>Find me in app/views/profile/home/index.html.erb</p>

View File

@ -0,0 +1 @@
VkHkFcjwHIZ058dE72qEUhZXiE993ohEARNdsjFmbp6UY4UYS+kGizPKM+h3C4VywYa5j0L/tSvuHgwbHIex8buwIsp3AsyoJZcemnCiwXx1q7rvF3amNCT/AcsggB49YdicUZiESinY+ajLsMH/oeVUyNhXBaliGU3LLnft/ACpxBYAnSLXNysTsxfWL43xlUTjsHF3tMyoA+NGr5Nf6OwrLy4ptaoC3MW5/IBwjsXuOdIceEY3tatCRkOgRDJbk+YhDJme3teXdfgUlEgLRw==--OEyLLU8aYtwqGhtI--0Q8owoP/yIviwiyotCGo5Q==

View File

@ -9,3 +9,10 @@ en:
new: "New" new: "New"
name: "Name" name: "Name"
save: "Save" save: "Save"
email: "E-mail"
password: "Password"
current_password: "Current password"
update_email: "Update e-mail"
new_password: "New password"
new_password_confirmation: "Confirm the new password"
update_password: "Update password"

View File

@ -10,3 +10,7 @@ en:
destroy: destroy:
fail: "Count deletion has failed." fail: "Count deletion has failed."
success: "Count has been deleted successfully." success: "Count has been deleted successfully."
profile:
update:
success: "Profile updated successfully."
fail: "Updating the profile failed."

View File

@ -9,3 +9,10 @@ fr:
new: "Nouveau" new: "Nouveau"
name: "Nom" name: "Nom"
save: "Sauvegarder" save: "Sauvegarder"
email: "Courriel"
password: "Mot de passe"
current_password: "Mot de passe actuel"
update_email: "Mettre à jour le courriel"
new_password: "Nouveau mot de passe"
new_password_confirmation: "Confirmez le nouveau mot de passe"
update_password: "Mettre à jour de mot de passe"

View File

@ -10,3 +10,7 @@ fr:
destroy: destroy:
fail: "La suppression du compte a échoué." fail: "La suppression du compte a échoué."
success: "Le compte a été supprimé avec succès." success: "Le compte a été supprimé avec succès."
profile:
update:
success: "Le profil a bien été mis à jour."
fail: "La mise à jour du profil a échoué."

View File

@ -1,11 +1,11 @@
Rails.application.routes.draw do Rails.application.routes.draw do
namespace :profile do
root "home#index"
end
resources :count, except: [:show] resources :count, except: [:show]
get "profile", to: "profile#edit"
post "profile/update_email", to: "profile#update_email"
post "profile/update_password", to: "profile#update_password"
root "home#index" root "home#index"
devise_for :users, controllers: { devise_for :users, controllers: {