Compare commits
10 Commits
86f5e7d088
...
8629281c14
Author | SHA1 | Date | |
---|---|---|---|
8629281c14 | |||
57becfdb72 | |||
b324436cf0 | |||
8ffdf1ae89 | |||
92410b6fea | |||
c80d2857cb | |||
4db7b8f3b8 | |||
91e2018253 | |||
eac85929d1 | |||
09c9feeeef |
4
.dockerignore
Normal file
4
.dockerignore
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
.bundle
|
||||||
|
node_modules
|
||||||
|
log
|
||||||
|
vendor
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -41,3 +41,5 @@
|
|||||||
/node_modules
|
/node_modules
|
||||||
|
|
||||||
/.idea
|
/.idea
|
||||||
|
|
||||||
|
/config/credentials/production.key
|
||||||
|
32
.gitlab-ci.yml
Normal file
32
.gitlab-ci.yml
Normal 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
|
||||||
|
|
@ -1 +1 @@
|
|||||||
ruby-3.0.5
|
3.2.2
|
||||||
|
25
Dockerfile
Normal file
25
Dockerfile
Normal 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
|
4
Gemfile
4
Gemfile
@ -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"
|
||||||
|
13
Gemfile.lock
13
Gemfile.lock
@ -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
|
||||||
|
25
README.md
25
README.md
@ -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
|
|
||||||
|
|
||||||
* ...
|
|
@ -1,6 +0,0 @@
|
|||||||
class Profile::HomeController < ApplicationController
|
|
||||||
before_action :authenticate_user!
|
|
||||||
|
|
||||||
def index
|
|
||||||
end
|
|
||||||
end
|
|
27
app/controllers/profile_controller.rb
Normal file
27
app/controllers/profile_controller.rb
Normal 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
|
@ -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>
|
||||||
|
|
||||||
|
41
app/views/profile/edit.html.erb
Normal file
41
app/views/profile/edit.html.erb
Normal 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>
|
@ -1,2 +0,0 @@
|
|||||||
<h1>Profile::Home#index</h1>
|
|
||||||
<p>Find me in app/views/profile/home/index.html.erb</p>
|
|
1
config/credentials/production.yml.enc
Normal file
1
config/credentials/production.yml.enc
Normal file
@ -0,0 +1 @@
|
|||||||
|
VkHkFcjwHIZ058dE72qEUhZXiE993ohEARNdsjFmbp6UY4UYS+kGizPKM+h3C4VywYa5j0L/tSvuHgwbHIex8buwIsp3AsyoJZcemnCiwXx1q7rvF3amNCT/AcsggB49YdicUZiESinY+ajLsMH/oeVUyNhXBaliGU3LLnft/ACpxBYAnSLXNysTsxfWL43xlUTjsHF3tMyoA+NGr5Nf6OwrLy4ptaoC3MW5/IBwjsXuOdIceEY3tatCRkOgRDJbk+YhDJme3teXdfgUlEgLRw==--OEyLLU8aYtwqGhtI--0Q8owoP/yIviwiyotCGo5Q==
|
@ -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"
|
@ -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."
|
@ -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"
|
||||||
|
@ -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é."
|
@ -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: {
|
||||||
|
Loading…
Reference in New Issue
Block a user