Commit 757cbfe4 by Xuan Trung Le

Create the TOP, industry_list, city_list, job_detail pages.

parent 91b545e3
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
* vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
* files in this directory. Styles in this file should be added after the last require_* statement.
* It is generally better to create a new file per style scope.
*
*= require_tree .
*= require_self
*/
.footer{
//position: absolute;
//bottom: 0;
width: 100%;
height: 60px;
line-height: 60px;
background-color: #f5f5f5;
}
.border_rd0{
border-radius: 0px!important;
}
.border_bot{
border-bottom: 1px solid #ccc!important;
}
.mr0{
margin: 0px;
}
.mrBot0{
margin-bottom: 0px!important;
}
.mrBot20{
margin-bottom: 20px;
}
.wid100{
width: 100% !important;
}
.wid80{
width: 80% !important;
}
// key-visual
.key-visual{
width: 100%;
height: 432px;
background: url('https://oejk4q.corednacdn.com/career-advice/web_images/blogs/214/1491/What-recruiters-look-for-in-a-cover-letter-1290x432.jpg') no-repeat center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.caption{
position: absolute;
left: 0;
top: 30%;
width: 100%;
text-align: center;
color: #000;
.border {
background-color: #111;
color: #fff;
padding: 18px;
font-size: 25px;
letter-spacing: 10px;
opacity: 0.65;
}
}
// end
// Search box
.search-box{
width: 100%;
height: 50px;
}// end
// City list
.city{
display: inline-block;
width: 100%;
}
.maxH109{
max-height: 109px;
}
.maxH89{
max-height: 89px;
}
// end
class CitiesController < ApplicationController
def index
@cities = City.city_list
end
end
class IndustriesController < ApplicationController
def index
@industries = Industry.industry_list
end
end
class JobsController < ApplicationController
before_action :set_job, only: [:show]
def index
@jobs = Job.all.order(updated_date: 'DESC').limit(5)
@cities = City.top_cities
@industries = Industry.top_industries
end
def show
#code
end
def job_lists
#code
end
def city
city = City.find(params[:id])
@jobs = city.jobs.page(params[:page]).per(20)
@result = "jobs/City/#{city.name}"
render :action => :job_lists
end
def industry
industry = Industry.find(params[:id])
@jobs = industry.jobs.page(params[:page]).per(20)
@result = "jobs/Industry/#{industry.name}"
render :action => :job_lists
end
def company
company = Company.find(params[:id])
@jobs = company.jobs.page(params[:page]).per(20)
@result = "jobs/Company/#{company.name}"
render :action => :job_lists
end
def set_job
@job = Job.find(params[:id])
end
end
......@@ -2,4 +2,20 @@ class City < ApplicationRecord
belongs_to :country, optional: true
has_and_belongs_to_many :companies
has_and_belongs_to_many :jobs
scope :top_cities, -> { select('cities.id, cities.name AS name, COUNT(jobs.id) AS jobs_count').
joins(:jobs).
group('cities.id').
order('jobs_count DESC, name').
limit(9) }
scope :city_list, -> { select('cities.id, cities.name AS name, countries.name AS country_name,
COUNT(jobs.id) AS jobs_count').
joins(:jobs).
joins(:country).
# where('jobs_count >= 1').
group('cities.id').
order('jobs_count DESC, name') }
scope :get_job, -> id { find(id) }
end
class Country < ApplicationRecord
has_many :cities
VIETNAM = 'Viet Nam'
ANOTHER = 'another'
end
class Industry < ApplicationRecord
has_and_belongs_to_many :jobs
scope :top_industries, -> { select('industries.id, industries.name AS name, COUNT(jobs.id) AS jobs_count').
joins(:jobs).
group('industries.id').
order('jobs_count DESC, name').
limit(9) }
scope :industry_list, -> { select('industries.id, industries.name AS name, COUNT(jobs.id) AS jobs_count').
joins(:jobs).
# where('jobs_count >= 1').
group('industries.id').
order('jobs_count DESC, name') }
end
......@@ -27,6 +27,7 @@ class Job < ApplicationRecord
end
# Company
<<<<<<< 91b545e3685a56b535c9905838040868191d9dc5
company = Company.find_by(name: item[:company_name])
if company.nil?
company = Company.create(name: item[:company_name],
......@@ -36,6 +37,13 @@ class Job < ApplicationRecord
job.company = company
job.company.cities << (job.cities - job.company.cities)
=======
job.company = Company.find_or_initialize_by(name: item[:company_name])
job.company.location = item[:company_location]
job.company.description = item[:company_description]
job.company.cities = job.cities
# job.company.save
>>>>>>> Create the TOP, industry_list, city_list, job_detail pages.
# Industry
unless item[:industry].blank?
......
<div class="col-md-<%= column %>">
<div class="job-intro well mr0 mrBot20" id="vietnam">
<h4 class="mr0"><%= link_to city.name, "#{jobs_path}/city/#{city.id}" %></h4>
<p>Jobs: <span class="badge"><%= city.jobs_count %></span></p>
</div>
</div>
<div class="row">
<div class="container">
<div class="country">
<%= link_to "Viet Nam", "#vietnam", class: "btn btn-default btn-lg" %>
<%= link_to "International", "#international", class: "btn btn-default btn-lg" %>
</div>
<br>
<div class="cities">
<div id="vietnam" class="city">
<p><h4>Viet Nam</h4></p>
<%- @cities.each do |city| -%>
<%- if city.country_name.eql?(Country::VIETNAM) -%>
<div class="col-md-3 maxH109">
<div class="job-intro well mr0 mrBot20 maxH89">
<h4 class="mr0"><%= link_to city.name, "#{jobs_path}/city/#{city.id}" %></h4>
<p>Jobs: <span class="badge"><%= city.jobs_count %></span></p>
</div>
</div>
<%- end -%>
<%- end -%>
</div>
<div id="international" class="city">
<p><h4>International</h4></p>
<%- @cities.each do |city| -%>
<%- if city.country_name.eql?(Country::ANOTHER) -%>
<div class="col-md-3 maxH109">
<div class="job-intro well mr0 mrBot20 maxH89">
<h4 class="mr0"><%= link_to city.name, "#{jobs_path}/city/#{city.id}" %></h4>
<p>Jobs: <span class="badge"><%= city.jobs_count %></span></p>
</div>
</div>
<%- end-%>
<%- end-%>
</div>
</div>
</div>
</div>
<div class="col-md-<%= column %> maxH109">
<div class="job-intro well mr0 mrBot20 maxH89">
<h4 class="mr0"><%= link_to industry.name, "#{jobs_path}/industry/#{industry.id}" %></h4>
<p>Jobs: <span class="badge"><%= industry.jobs_count %></span></p>
</div>
</div>
<div class="row">
<div class="container">
<%= render @industries, column: 3 %>
</div>
</div>
<div class="job-intro well mr0 mrBot20">
<h4 class="mr0"><%= link_to job.name, job_path(job) %></h4>
<p><%= "Loacation: #{job.company.location}" %></p>
<p><%= "Salary: #{job.salary}" %></p>
</div>
<%= render "layouts/key_visual" %>
<div class="container">
<div class="top-page">
<!-- Search -->
<div class="panel border_bot clearfix">
<%= render @jobs %>
</div>
<!-- Cities -->
<div class="panel border_bot clearfix">
<%= render @cities, column: 3 %>
<%= link_to "All Cities", cities_path, class: "btn btn-default navbar-right" %>
</div>
<!-- Cities -->
<div class="panel">
<%= render @industries, column: 4 %>
<%= link_to "All Industries", industries_path, class: "btn btn-default navbar-right" %>
</div>
</div>
</div>
<div class="row">
<div class="container">
<p>
THIS IS A SEARCH BOX
</p>
<div class="job-list">
<p>
<span><%= "1. Total: #{@jobs.count}" %></span>
<span><%= "Result for: #{@result}" %></span>
</p>
<div class="top-page">
<div class="top-page-info">
</div>
</div>
<div class="pagination">
<%= paginate @jobs %>
</div>
<div class="jobs clearfix">
<%- @jobs.each do |job|-%>
<div class="job">
<div class="col-md-10 job-detail well">
<p><h4 class="mr0"><%= link_to job.name, job_path(job) %></h4></p>
<p><%= strip_tags(job.description)[0...250] %>...</p>
<p>
<span>Location: <%= "#{job.company.location}" %></span>
<span class="navbar-right">Salary: <%= job.salary %></span>
</p>
</div>
<div class="col-md-2 favorite">
<%= link_to "FAVORITE", "#", class: "btn btn-default" %>
</div>
</div>
<%- end -%>
</div>
<div class="pagination">
<%= paginate @jobs %>
</div>
</div>
</div>
</div>
<div class="row">
<div class="container">
<ol class="breadcrumb">
<li><a href="/">TOP</a></li>
<li>
<%- @job.cities.each_with_index do |city, index| -%>
<%= "#{index > 0 ? ',' : ''}" %>
<%= link_to city.name, "#{jobs_path}/city/#{city.id}" %>
<%- end -%>
</li>
<li>
<%- @job.industries.each_with_index do |industry, index| -%>
<%= "#{index > 0 ? ',' : ''}" %>
<%= link_to industry.name, "#{jobs_path}/industry/#{industry.id}" %>
<%- end -%>
</li>
<li><%= @job.name %></li>
</ol>
</ol>
<div class="job">
<div class="col-md-9">
<h1>2.<%= @job.name %></h1>
<p>3.<%= link_to @job.company.name, "#{jobs_path}/company/#{@job.company.id}" %></p>
<p>4. Location:
<%- @job.cities.each_with_index do |city, index| -%>
<%= "#{index > 0 ? ',' : ''}" %>
<%= link_to city.name, "#{jobs_path}/city/#{city.id}" %>
<%- end -%>
</p>
<p>5. Salary: <%= @job.salary %></p>
<p>6 Long Description:
<%= @job.description.html_safe %>
</p>
</div>
<div class="col-md-3">
<%= link_to "Aplly", "#", class: "btn btn-primary btn-lg" %>
</div>
<div class="action">
<div class="col-md-6">
<%= link_to "Aplly", "#", class: "btn btn-default btn-lg" %>
</div>
<div class="col-md-6">
<%= link_to "Favorite", "#", class: "btn btn-default btn-lg" %>
</div>
</div>
</div>
</div>
</div>
<div class="footer">
<div class="container-fluid">
<div class="footer-bottom">
<p class="pull-left"> Footer </p>
<div class="pull-right">
ZIGExN VeNtura
</div>
</div>
</div>
</div>
<div class="img-responsive key-visual">
<div class="caption">
<span class="border">Total jobs: 150</span>
</div>
</div>
<nav class="navbar navbar-inverse border_rd0 mrBot0">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="/">WorldJob</a>
</div>
<ul class="nav navbar-nav">
<li class="active"><a href="/">Home</a></li>
</ul>
<!-- check an user is logged in or not -->
<ul class="nav navbar-nav navbar-right">
<%- if current_user -%>
<li><a href="#"><i class="fa fa-sign-in" aria-hidden="true"></i> My Page</a></li>
<li><a href="#"><i class="fa fa-plus" aria-hidden="true"></i> Logout</a></li>
<%- else -%>
<li><a href="#"><i class="fa fa-sign-in" aria-hidden="true"></i> Login</a></li>
<li><a href="#"><i class="fa fa-plus" aria-hidden="true"></i> Register</a></li>
<%- end -%>
<li><a href="#"><i class="fa fa-star" aria-hidden="true"></i></span> Favorite</a></li>
<li><a href="#"><i class="fa fa-history" aria-hidden="true"></i></span> History</a></li>
</ul>
</div>
</nav>
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">WebSiteName</a>
</div>
<ul class="nav navbar-nav navbar-right">
<li><a href="#"><span class="glyphicon glyphicon-user"></span> Sign Up</a></li>
<li><a href="#"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
</ul>
</div>
</nav>
<div class="search-box">
<%= form_tag nil, method: :get, class: "navbar-form navbar-left search-form wid100" do %>
<%= text_field_tag(
:search,
params[:search],
placeholder: "Search",
class: "form-control wid80"
) %>
<%= submit_tag "Search", class: "btn btn-default"%>
<% end %>
</div>
<!DOCTYPE html>
<html>
<head>
<head>
<title>Venjob</title>
<%= csrf_meta_tags %>
<link
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
crossorigin="anonymous">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
rel="stylesheet"
integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN"
crossorigin="anonymous">
<script
src="https://code.jquery.com/jquery-3.2.1.js"
integrity="sha256-DZAnKJ/6XZ9si04Hgrsxu/8s717jcIzLy3oi35EouyE="
crossorigin="anonymous"></script>
<script
src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"
integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
crossorigin="anonymous"></script>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>
</head>
<body>
<body>
<%= render "layouts/menu" %>
<%= yield %>
</body>
<%= render "layouts/footer" %>
</body>
</html>
Rails.application.routes.draw do
devise_for :users
get 'jobs/index'
resources :cities, :industries, :jobs do
get 'cities' => 'cities#index'
get 'industries' => "industries#index"
collection do
get 'city/:id' => "jobs#city"
get 'industry/:id' => "jobs#industry"
get 'company/:id' => "jobs#company"
end
end
root 'jobs#index'
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