Commit d0151290 by Hoang Nam Nguyen

'register_page'

parent 4471d916
......@@ -5,14 +5,16 @@ git_source(:github) do |repo_name|
"https://github.com/#{repo_name}.git"
end
gem 'sidekiq'
gem 'kaminari'
gem 'bootstrap4-kaminari-views'
gem 'bootstrap-will_paginate', '1.0.0'
gem 'rubyzip', '>= 1.0.0' # will load new rubyzip version
gem 'zip-zip' # will load compatibility for old rubyzip API.
gem 'nokogiri'
gem 'whenever', :require => false
gem "figaro"
gem 'devise'
gem 'bcrypt', '3.1.11'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.3'
# Use mysql as the database for Active Record
......
......@@ -81,4 +81,43 @@
.search_list_jobs_title {
padding: 0.5% 0% 0% 1%;
}
/* form */
/* Color of invalid field */
.has-error .control-label,
.has-error .help-block,
.has-error .form-control-feedback {
color: #a94442;
}
/* Color of valid field */
.has-success .control-label,
.has-success .help-block,
.has-success .form-control-feedback {
color: #3c763d;
}
input, textarea, select, .uneditable-input {
width: 100%;
}
input {
height: auto !important;
}
#error_explanation {
color: red;
ul {
color: red;
margin: 0 0 30px 0;
}
}
.field_with_errors {
@extend .has-error;
.form-control {
color: #a94442;
}
}
\ No newline at end of file
class SearchController < ApplicationController
class JobController < ApplicationController
def index
@jobs = ::Kaminari.paginate_array(Solr.test_solr(params[:s])[0]).page(params[:page]).per(20) unless params[:s].nil?
@total_result = Solr.test_solr(params[:s])[1]
@total_jobs = Job.count
end
def show
end
def detail
@job = Job.find(params[:id])
end
end
......@@ -8,9 +8,6 @@ class TopPagesController < ApplicationController
@industries_page = Industry.order(industry_name: :desc).all
end
def jobs
end
def top_page
@jobs = Job.recent(ENV["Number_top_page_jobs"])
@total_job = Job.count
......
class UsersController < ApplicationController
def show
@user = User.new
end
def new
@user = User.new
end
def confirm_email
@user = User.new(email_params)
@user.validate_name = false
@user.validate_password = false
if @user.save
flash[:success] = "Please confirm your email"
UserMailer.welcome_email(@user.id).deliver_later
render 'confirm_email'
else
render 'show'
end
end
def create
@user = User.find(params[:id])
@user.validate_name = true
@user.validate_password = true
if @user.update_attributes(user_params)
flash[:success] = "Welcome to the Ven Jobs!"
redirect_to @user
else
render 'new'
end
end
def login
@user = User.find(params[:id])
end
private
def user_params
params.require(:user).permit(:name, :email, :password_digest,
:password_confirmation)
end
def email_params
params.require(:user).permit(:email)
end
end
module UsersHelper
end
class ApplicationMailer < ActionMailer::Base
default from: 'from@example.com'
layout 'mailer'
def signup_confirmation(user)
@greeting = "Hi"
mail to: user.email, subject:"Email Confirmation"
end
end
class UserMailer < ApplicationMailer
default from: "namnh@zigexn.vn"
def welcome_email(user_id)
@user = User.find(user_id)
@url = users_path_path
mail to: @user.email, subject: 'Welcome to My Ventura Jobs'
end
end
class Company < ApplicationRecord
has_many :jobs
end
......@@ -3,6 +3,6 @@ class Job < ApplicationRecord
has_many :cities, through: :job_cities
has_many :job_industries
has_many :industries, through: :job_industries
belongs_to :company
scope :recent, -> (num) { order(id: :desc).limit(num) }
end
class Register < ApplicationRecord
end
class User < ApplicationRecord
attr_accessor :validate_name, :validate_password
before_save { self.email = email.downcase }
validates :name, presence: true, length: { maximum: 200 }, if: :validate_name
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :email, presence: true, length: {maximum: 255},
format: {with: VALID_EMAIL_REGEX },
uniqueness: {case_sensitive: false}
has_secure_password(validations: false)
validates :password, presence: true, length: { minimum: 6}, if: :validate_password
end
<div class="container mt-5" >
<div class="row mb-5">
<div class="search_list titlejob col-md-10">
<%= link_to job['job_name'].join(','), job_detail_path(job['job_id']), class: 'search_list_jobs_title' %>
<% unless job['short_description'].nil? %>
<li class="detail_description">
<%= truncate job['short_description'].join(',') ,length: 250%>
<%= link_to 'read more',job_detail_path(job['job_id'])%></li>
</li>
<% end %>
<div class="row ml-0">
<li class="detail_description col-md-5">
<%= job['city_name'].join(',') %>
</li>
<% unless job['salary'].nil? %>
<li class=" detail_description float-right text-success col-md-5">
<%= job['salary'].join(',') %>
</li>
<% end -%>
</div>
</div>
<div class="col-md-2 mt-2">
<%= link_to 'Favorite', '#', { class: 'btn btn-success'} %>
</div>
</div>
</div>
\ No newline at end of file
<%= provide(:title,"Job Detail") %>
<div class="container mt-5">
<div class="text-center">
<%= link_to 'TOP', root_path, { class: 'btn btn-success' } %>
<%= link_to 'CITY',cities_path , { class: 'btn btn-success' } %>
<%= link_to 'INDUSTRY', industries_path, { class: 'btn btn-success' } %>
<%= link_to 'SHORT TITLE', '#', { class: 'btn btn-success' } %>
<%= link_to 'Apply','#', {class: 'btn btn-primary float-right'} %>
</div>
</div>
<div class="container">
<div class="row mt-5">
<div class="card text-center wt-100 ml-5">
<div class="card-header success-color white-text">
<h3 class="text-danger"><%= @job.job_title %></h3>
</div>
<div class="card-body">
<h4 class="card-title text-primary"><%= @job.company.company_name %></h4>
<p class="card-texts">Location: <%= @job.cities.map {|l| l.location}.join(',') %></p>
<p class="card-text"><a href="#">Salary: </a><%= @job.salary %></p>
<p class="card-text"><%= @job.descripton.gsub("\t"," ").gsub("\n","<br/>").gsub("\r","<br/>").html_safe %></p>
<a class="btn btn-success text-white w-25">Apply</a>
<a class="btn btn-success text-white w-25">Favorite</a>
</div>
</div>
</div>
</div>
<%= form_tag search_index_path, method: :get do %>
<div class="row search_field">
<%= search_field_tag 's', nil, placeholder: 'Search...', class: 'col-10 form-control' %>
<%= submit_tag 'Search',id: "search_button", class: 'col-1 btn btn-success form-control' %>
</div>
<% end %>
<%= provide(:title, "Job List") %>
<%= form_tag job_index_path, method: :get do %>
<div class="row search_field mt-5">
<%= search_field_tag 's', nil, placeholder: 'Search...', class: 'col-10 form-control' %>
<%= submit_tag 'Search',id: "search_button", class: 'col-1 btn btn-success form-control ml-3 ' %>
</div>
<% end %>
<div class="row mt-4">
<h4 class="text-success col-3">Total: <%= @total_jobs %></h4>
<h4 class="text-success col-3">Result for: <%= @total_result%> </h4>
</div>
<div class="row mt-4">
<h4 class="text-success col-3">Total: <%= @total_jobs %></h4>
<h4 class="text-success col-3">Result for: <%= @total_result%> </h4>
</div>
<div class="mt-4">
<%= paginate @jobs,theme: 'twitter-bootstrap-4'%>
<%= render partial: "search",collection: @jobs, as: :job %>
<%= paginate @jobs,theme: 'twitter-bootstrap-4'%>
</div>
\ No newline at end of file
<div class="mt-4">
<%= paginate @jobs,theme: 'twitter-bootstrap-4'%>
<%= render partial: "search",collection: @jobs, as: :job %>
<%= paginate @jobs,theme: 'twitter-bootstrap-4'%>
</div>
\ No newline at end of file
<%# Link to the "First" page
- available local variables
url: url to the first page
current_page: a page object for the currently displayed page
total_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<span class="first">
<%= link_to_unless current_page.first?, t('views.pagination.first').html_safe, url, remote: remote %>
</span>
<%# Non-link tag that stands for skipped pages...
- available local variables
current_page: a page object for the currently displayed page
total_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<span class="page gap"><%= t('views.pagination.truncate').html_safe %></span>
......@@ -7,15 +7,15 @@
<div class="col-6 col-md-4">
<ul class="nav navbar-nav" >
<li><button type="button" class="btn btn-info distance mt-4 slide" >Login</button></li>
<li><button type="button" class="btn btn-info distance mt-1 slide" >Favorite</button></li>
<li><%= link_to 'Login','#', class: 'btn btn-info distance mt-4 slide'%></li>
<li><%= link_to 'Favorite','#',class: 'btn btn-info distance mt-1 slide'%></li>
</ul>
</div>
<div class="col-6 col-md-4">
<ul class="nav navbar-nav" id="slidebar">
<li><button type="button" class="btn btn-info distance mt-4 no-gutters">Register</button></li>
<li><button type="button" class="btn btn-info distance mt-1 no-gutters">History</button></li>
<li><%= link_to 'Register',sign_up_path, class: 'btn btn-info distance mt-4 no-gutters'%></li>
<li><%= link_to 'History','#',class: 'btn btn-info distance mt-1 no-gutters'%></li>
</ul>
</div>
</div>
<!DOCTYPE html>
<html>
<head>
<title>Top page</title>
<title><%= yield(:title) %></title>
<%= csrf_meta_tags %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
......@@ -13,6 +13,9 @@
<%= yield %>
<%= render 'layouts/footer' %>
</div>
<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>
</body>
</html>
<div class="search_list titlejob">
<a href="#" class="search_list_jobs_title">
<%= job['job_name'].join(',') %>
</a>
<% if job['short_description'] != nil %>
<li class="detail_description">
<%= truncate job['short_description'].join(',') ,length: 200%>
<%= link_to 'read more', '#'%></li>
</li>
<% end %>
<div class="row ml-0">
<li class="detail_description">
<%= job['city_name'].join(',') %>
</li>
<% if job['salary'] != nil %>
<li class=" detail_description float-right">
<%= job['salary'].join(',') %>
</li>
<% end -%>
</div>
</div>
\ No newline at end of file
<% if @user.errors.any? %>
<div id="error_explanation">
<div class="alert alert-danger">
The form contains <%= pluralize(@user.errors.count, "error") %>.
</div>
<ul>
<% @user.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="w-100 list-group-item">
<%= render partial: "job",collection: @jobs, as: :job %>
<%= render partial: "job",collection: @jobs, as: :job %>
</div>
\ No newline at end of file
......@@ -3,13 +3,15 @@
<%= job.job_title %>
</p>
</a>
<div class="content_job">
<% if job.short_description != nil %>
<% unless job.short_description.nil? %>
<li class="detail_description"><%= truncate job.short_description,length: 160%>
<%= link_to 'read more', '#' %></li>
<% end %>
<li class="detail_description"> <%= job.salary %></li>
<li class="detail_description"><%= job.salary %></li>
<% job.cities.each do |city| %>
<li class="detail_description"><%= city.location %></li>
<li class="detail_description"><%= city.location %></li>
<% end %>
</div>
\ No newline at end of file
<h1 class="text-success line_job">City List</h1>
<div class="ct_local">
<%= link_to "Viet Nam", '#' , id: "viet_nam_city" , class: "ct_local_font" %>
<%= link_to "International", '#', id: "international_city", class: "ct_local_font" %>
</div>
<%= provide(:title, "City List") %>
<h1 class="text-success line_job">City List</h1>
<h1 class="text-success line_job">Viet Nam</h1>
<div class="row">
<%= render partial: "city_list",collection: @vn_cities, as: :city %>
</div>
<div class="ct_local">
<%= link_to "Viet Nam", '#' , id: "viet_nam_city" , class: "ct_local_font" %>
<%= link_to "International", '#', id: "international_city", class: "ct_local_font" %>
</div>
<h1 class="text-success line_job">International</h1>
<div class="row">
<%= render partial: "city_list",collection: @international_cities, as: :city %>
</div>
\ No newline at end of file
<h1 class="text-success line_job">Viet Nam</h1>
<div class="row">
<%= render partial: "city_list",collection: @vn_cities, as: :city %>
</div>
<h1 class="text-success line_job">International</h1>
<div class="row">
<%= render partial: "city_list",collection: @international_cities, as: :city %>
</div>
\ No newline at end of file
<%= provide(:title, "Industry List") %>
<h1 class="text-success line_job">Industry List</h1>
<div class="row">
<%= render partial: "industry_list", collection: @industries_page, as: :industry %>
......
<%= provide(:title, "Top Pages") %>
<%= image_tag("home_page.jpg", id: "image_height", class: "col-md-12 padding-0") %>
<div class="row">
<div class="col">
......@@ -5,7 +6,7 @@
</div>
</div>
<%= form_tag search_index_path, method: :get do %>
<%= form_tag job_index_path, method: :get do %>
<div class="row search_field mt-3">
<%= search_field_tag 's', nil, placeholder: 'Search...', class: 'col-10 form-control' %>
<%= submit_tag 'Search', class: 'col-1 btn btn-success form-control ml-4' %>
......
<!DOCTYPE html>
<html>
<head>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
</head>
<body>
<h1>Welcome to Venjobs, <%= @user.name %></h1>
<p>
Let's confirm your email address.,
your username is <br>
</p>
<p>
By clicking on the following link, you are confirming your email address and agreeing to VeNJOB's Terms of Service.: <%= @url %>.
</p>
<p>Thanks for joining and have a great day!</p>
</body>
</html>
\ No newline at end of file
<%= provide(:title, "Register Email Finish") %>
<div class="mt-5 text-success text-center mb-5">
<h1>Register</h1>
</div>
<p>Thank you for register our service, an confirmation email with registration link has been sent to your email. Please check your email within 24 hours.<br></br>Please note that the registration link is only valid for 24 hours.Over that period, you will have to register your email again.</p>
\ No newline at end of file
<% provide(:title, 'User information Form') %>
<h1 class="text-success text-center">Register</h1>
<div class="row ml-5">
<div class="col-md-10 col-md-offset-3">
<%= form_for(@user, url: create_user_path) do |f| %>
<%= render 'shared/error_messages'%>
<div class="row mt-5 mb-5">
<div class= "col-md-2">
<strong><i><%= f.label :name,'Full Name'%></i></strong>
</div>
<div class="col-md-10">
<%= f.text_field :name, class: 'form-control' %>
</div>
</div>
<div class="row mt-3 mb-5">
<div class="col-md-2">
<strong><i><%= f.label :email %></i></strong>
</div>
<div class="col-md-10">
<%= f.email_field :email, class: 'form-control' %>
</div>
</div>
<div class="row mt-3 mb-5">
<div class="col-md-2">
<strong><i><%= f.label :password %></i></strong>
</div>
<div class="col-md-10">
<%= f.password_field :password, class: 'form-control' %>
</div>
</div>
<div class="row mt-3 mb-5">
<div class="col-md-2">
<strong><i><%= f.label :password_confirmation, "Password Confirmation" %></i></strong>
</div>
<div class="col-md-10">
<%= f.password_field :password_confirmation, class: 'form-control' %>
</div>
</div>
<div class="row col-md-12 ml-5 mt-3">
<%= f.submit "Register", class: "btn btn-primary" %>
</div>
<% end %>
</div>
</div>
<%= provide(:title, "Register Email") %>
<div class="mt-5 text-success text-center mb-5">
<h1>Register</h1>
</div>
<%= form_for(@user, url: create_email_path) do |f| %>
<%= render 'shared/error_messages'%>
<div class="row mt-3 mb-3">
<div class="col-md-2">
<strong><i><%= f.label :email %></i></strong>
</div>
<div class="col-md-10">
<%= f.email_field :email, class: 'form-control',placeholder: 'Enter Email' %>
</div>
</div>
<div class="text-center">
<%= f.submit "Confirm your email", class: "btn btn-primary form-control ml-3 w-50" %>
</div>
<% end %>
\ No newline at end of file
......@@ -11,7 +11,7 @@ module VenJob
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.1
config.eager_load_paths += %W(#{config.root}/lib)
config.active_job.queue_adapter = :sidekiq
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
......
......@@ -48,6 +48,30 @@ Rails.application.configure do
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
# config.action_mailer.delivery_method = :smtp
# SMTP settings for gmail
# config.action_mailer.smtp_settings = {
# :address => "smtp.gmail.com",
# :port => 587,
# :domain => "zigexn.vn",
# :user_name => ENV['gmail_username'],
# :password => ENV['gmail_password'],
# :authentication => "plain",
# :enable_starttls_auto => true
# }
config.action_mailer.delivery_method = :smtp
config.action_mailer.raise_delivery_errors = true
config.action_mailer.smtp_settings = {
enable_starttls_auto: true,
address: 'smtp.gmail.com',
port: '587',
domain: 'gmail.com',
authentication: 'plain',
user_name: 'ventura.testmail@gmail.com',
password: '12345678@'
}
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
......
require 'sidekiq/web'
Rails.application.routes.draw do
get '/cities', to: 'top_pages#cities'
get '/industries', to: 'top_pages#industries'
get '/jobs', to: 'top_pages#jobs'
get 'users/new'
get '/cities',to: 'top_pages#cities'
get '/industries',to: 'top_pages#industries'
get 'top_pages/cities'
get 'top_pages/industries'
get 'top_pages/top_page'
get 'top_pages/jobs'
root 'top_pages#top_page'
resources :search, only: :index
resources :job, except: :show
get 'detail/:id', controller: :job, action: :detail, as: :job_detail
get 'register/1', controller: :users, action: :show, as: :sign_up
get 'register/2', controller: :users, action: :confirm_email,as: :create_email
post 'register/2', controller: :users, action: :confirm_email
get 'register/new', controller: :users, action: :new,as: :users_path
post 'register/create/:id', controller: :users, action: :create, as: :create_user
get 'login', controller: :users,action: :login,as: :login_user
mount Sidekiq::Web => '/sidekiq'
# get '/job',to: 'job#index'
# get '/job/detail', to: 'job#detail'
# only: :index
# get '/detail', to: 'job#detail'
end
every 1.day, :at => '8:30 am' do
rake "crawl:job"
every 1.day, :at => '9:43 am' do
rake "crawl:job", :output => 'log/check_status_update.log'
end
\ No newline at end of file
---
:concurrency: 5
:pidfile: tmp/pids/sidekiq.pid
staging:
:concurrency: 10
production:
:concurrency: 20
:queues:
- default
- mailers
\ No newline at end of file
class CreateUsers < ActiveRecord::Migration[5.1]
def change
create_table :users do |t|
t.string :name
t.string :email
t.timestamps
end
end
end
class AddPasswordDigestToUsers < ActiveRecord::Migration[5.1]
def change
add_column :users, :password_digest, :string
end
end
class CreateRegisters < ActiveRecord::Migration[5.1]
def change
create_table :registers do |t|
t.string :email
t.timestamps
end
end
end
......@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170914072404) do
ActiveRecord::Schema.define(version: 20170925092617) do
create_table "cities", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "location"
......@@ -66,4 +66,18 @@ ActiveRecord::Schema.define(version: 20170914072404) do
t.text "short_description"
end
create_table "registers", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "email"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "users", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "name"
t.string "email"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "password_digest"
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment