Commit 1dd5543f by thanhnd

toppage 20200224

parent 163cba16
...@@ -21,6 +21,34 @@ body { ...@@ -21,6 +21,34 @@ body {
margin: 0; margin: 0;
background: #f2f6e9; background: #f2f6e9;
} }
.rowtp {
color: red;
text-transform: uppercase;
text-align: center;
margin: auto;
width: 50%;
border: 3px solid green;
padding: 10px;
}
ul.class-name li {
float:left; width:50%;
}
.text {
display: block;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
#banner{
overflow: hidden;
background-image:url(https://ads.careerbuilder.vn/www/images/64ad182ac0b52d0f4c9bcc2bc24beb6b.jpg);
background-size:100% 100%;
}
/*--- navigation bar ---*/ /*--- navigation bar ---*/
.navbar { .navbar {
background:#262626 background:#262626
...@@ -39,3 +67,4 @@ body { ...@@ -39,3 +67,4 @@ body {
.navbar-collapse { .navbar-collapse {
justify-content: flex-end; justify-content: flex-end;
} }
class ToppageController < ApplicationController class ToppageController < ApplicationController
def index def index
end @totaljob = Job.all.count
@latestjobs = Job.order(:last_updated).first(5)
def new @topjobbyindustry = Job.select("industry_id, job_name").
#@topindustry = Industry.where(INNER JOIN Job ON Job.industry_id = Industry.id).count(industry_name).order("orders_count DESC")
end end
end end
class Industry < ApplicationRecord class Industry < ApplicationRecord
has_many :industry_jobs has_many :industry_jobs
has_many :jobs
validates_presence_of :industry_name validates_presence_of :industry_name
end end
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<body> <body>
<div class="container p-0 my-2 "> <div class="container p-0 my-2 ">
<nav class="navbar navbar-expand-md"> <nav class="navbar navbar-expand-md">
<a class="navbar-brand" href="#">Logo</a> <a class="navbar-brand" href="#"><img src="https://www.w3schools.com/images/w3schools_green.jpg" alt="W3Schools.com" style="width:104px;height:142px;"></a>
<button class="navbar-toggler navbar-dark" type="button" data-toggle="collapse" data-target="#main-navigation"> <button class="navbar-toggler navbar-dark" type="button" data-toggle="collapse" data-target="#main-navigation">
</button> </button>
<div class="collapse navbar-collapse" id="main-navigation"> <div class="collapse navbar-collapse" id="main-navigation">
......
<div class="container p-5 my-2 bg-secondary text-white"> <div id="banner" class="container p-5 my-2 bg-secondary text-white">
<img src="/app/assets/images/workspace.jpg" class="img-fluid" alt="Responsive image"> <div class="rowtp")>
<label> Total Jobs: <%= @totaljob %></label>
</div>
</div> </div>
<div class="container p-5 my-2 bg-secondary text-white"> <div id="search" class="container p-5 my-2 bg-secondary text-white">
<h1>My First Bootstrap Page</h1>
</div> </div>
<div class="container p-5 my-2 bg-secondary text-white"> <div id="latestjobs"class="container p-5 my-2 bg-secondary text-white">
<h1>My First Bootstrap Page</h1>
<font color="red"><b><label > Latest Jobs:</label></b></font>
<% @latestjobs.each do |j| %>
<ul>
<li><%= j.job_name %></li>
<li><%= j.salary.to_s %></li>
<li><%= j.experience %></li>
<li><%= j.last_updated %></li>
<li ><span class="text"><%= j.description %></span></li>
</ul>
<% end %>
</div> </div>
<div class="container p-5 my-2 bg-secondary text-white"> <div id="topcity" class="container p-5 my-2 bg-secondary text-white">
<h1>My First Bootstrap Page</h1>
<font color="red"><b><label > Top Cities:</label></b></font>
</div> </div>
<div class="container p-5 my-2 bg-secondary text-white"> <div id="topindustry" class="container p-5 my-2 bg-secondary text-white">
<h1>My First Bootstrap Page</h1>
<font color="red"><b><label > Top Industries:</label></b></font>
<% @topjobbyindustry.each do |j| %>
<ul>
<li><%= j.industry_id %></li>
</ul>
<% end %>
</div>
</div> </div>
...@@ -60,6 +60,9 @@ namespace :crawler do ...@@ -60,6 +60,9 @@ namespace :crawler do
#insert data to Jobs table #insert data to Jobs table
Job.find_or_create_by(area_id: area.id, city_id: city.id , industry_id: industry.id, company_id: company.id, job_name: title.text, salary: salary.text, deadline: deadline.text, level: level.text, experience: experience.text.strip, last_updated: updated_date.text.strip, description: description.text) Job.find_or_create_by(area_id: area.id, city_id: city.id , industry_id: industry.id, company_id: company.id, job_name: title.text, salary: salary.text, deadline: deadline.text, level: level.text, experience: experience.text.strip, last_updated: updated_date.text.strip, description: description.text)
#industryjob = IndustryJob.find_or_create_by(industry_id: industry.industry_id , job_id: job.job_id)
end end
list_url = nextpage[0]["href"] list_url = nextpage[0]["href"]
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