Commit 4471d916 by Hoang Nam Nguyen

'finish search solr and fix bootstrap'

parent 91e3d553
...@@ -5,7 +5,8 @@ git_source(:github) do |repo_name| ...@@ -5,7 +5,8 @@ git_source(:github) do |repo_name|
"https://github.com/#{repo_name}.git" "https://github.com/#{repo_name}.git"
end end
gem 'will_paginate', '3.1.5' gem 'kaminari'
gem 'bootstrap4-kaminari-views'
gem 'bootstrap-will_paginate', '1.0.0' gem 'bootstrap-will_paginate', '1.0.0'
gem 'rubyzip', '>= 1.0.0' # will load new rubyzip version gem 'rubyzip', '>= 1.0.0' # will load new rubyzip version
gem 'zip-zip' # will load compatibility for old rubyzip API. gem 'zip-zip' # will load compatibility for old rubyzip API.
......
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
...@@ -648,7 +648,7 @@ pre code { ...@@ -648,7 +648,7 @@ pre code {
.no-gutters { .no-gutters {
margin-right: 0; margin-right: 0;
margin-left: 0; margin-left: 10%;
} }
.no-gutters > .col, .no-gutters > .col,
...@@ -4322,6 +4322,7 @@ tbody.collapse.show { ...@@ -4322,6 +4322,7 @@ tbody.collapse.show {
padding: 0.75rem 1.25rem; padding: 0.75rem 1.25rem;
margin-bottom: -1px; margin-bottom: -1px;
background-color: #fff; background-color: #fff;
border: 1px solid rgba(0, 0, 0, 0.125); border: 1px solid rgba(0, 0, 0, 0.125);
} }
......
/* header */ // /* header */
#logo { #logo {
width: 35%; width: 35%;
} }
#distance { .distance {
margin-top: 10%;
width: 130%;
border-radius: 25px; border-radius: 25px;
width: 30%;
} }
#slidebar { .slide {
padding-right: 5%; float: right;
} }
#slide { // /* content */
padding-left: 32%;
}
.container-fluid {
background-color: white;
}
/* content */
#image_height {
width: 99.5%;
}
#fontwords { #fontwords {
margin-top: 5%; text-align: center;
padding-left: 34%
}
#search_button {
margin-top: 30px;
margin-left: 3%;
}
#search_box {
width: 88%;
margin-top: 30px;
} }
.line_job { .line_job {
margin-left: -17%; margin: 3% 0% 2% -17%;
margin-top: 5%;
font-size: 220%;
}
.jobs {
width: 125%;
margin-left: 2.5%;
} }
.detail_description { .detail_description {
font-size: 80%; font-size: 80%;
margin-left: 2%;
} }
.cities { .cities {
margin-left: 2%;
border: 1px solid rgba(0, 0, 0, 0.125); border: 1px solid rgba(0, 0, 0, 0.125);
} }
.titlejob{
width: 50%;
margin-left: -3%;
}
.total_jobs { .total_jobs {
margin: -5% 0% 0% 30%;
font-size: 80%; font-size: 80%;
margin-left: 30%;
margin-top: -5%;
} }
.column_set { .column_set {
...@@ -78,16 +41,13 @@ ...@@ -78,16 +41,13 @@
} }
#cities_button { #cities_button {
margin-left: 83%; margin: 3% 0% 3% 80%;
margin-bottom: 3%;
margin-top: 3%;
} }
#industries_button{ #industries_button{
margin-bottom: 3%; margin: 3% 0% 3% 89.5%;
margin-top: 3%;
margin-left: 89.7%;
} }
.content_job { .content_job {
margin-top: -1.5%; margin-top: -1.5%;
} }
...@@ -97,7 +57,10 @@ ...@@ -97,7 +57,10 @@
margin-top: 5%; margin-top: 5%;
} }
/* city list */ .titlejob {
margin-left: -3%
}
// /* city list */
.ct_local { .ct_local {
width: 100%; width: 100%;
...@@ -109,6 +72,13 @@ ...@@ -109,6 +72,13 @@
margin-left: 24%; margin-left: 24%;
} }
#viet_nam_city{ /* search list */
margin_left: 10%;
.search_list {
border: 1px solid rgba(0, 0, 0, 0.125);
margin: 3% 0% 3% 0%;
}
.search_list_jobs_title {
padding: 0.5% 0% 0% 1%;
} }
\ No newline at end of file
// Place all the styles related to the Search controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
class SearchController < 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
end
module SearchHelper
end
<%# Link to the "Last" page
- available local variables
url: url to the last 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="last">
<%= link_to_unless current_page.last?, t('views.pagination.last').html_safe, url, remote: remote %>
</span>
<%# Link to the "Next" page
- available local variables
url: url to the next 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="next">
<%= link_to_unless current_page.last?, t('views.pagination.next').html_safe, url, rel: 'next', remote: remote %>
</span>
<%# Link showing page number
- available local variables
page: a page object for "this" page
url: url to this 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="page<%= ' current' if page.current? %>">
<%= link_to_unless page.current?, page, url, {remote: remote, rel: page.rel} %>
</span>
<%# The container tag
- 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
paginator: the paginator that renders the pagination tags inside
-%>
<%= paginator.render do -%>
<nav class="pagination">
<%= first_page_tag unless current_page.first? %>
<%= prev_page_tag unless current_page.first? %>
<% each_page do |page| -%>
<% if page.display_tag? -%>
<%= page_tag page %>
<% elsif !page.was_truncated? -%>
<%= gap_tag %>
<% end -%>
<% end -%>
<% unless current_page.out_of_range? %>
<%= next_page_tag unless current_page.last? %>
<%= last_page_tag unless current_page.last? %>
<% end %>
</nav>
<% end -%>
<%# Link to the "Previous" page
- available local variables
url: url to the previous 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="prev">
<%= link_to_unless current_page.first?, t('views.pagination.previous').html_safe, url, rel: 'prev', remote: remote %>
</span>
<%# 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>
<%# Link to the "Last" page
- available local variables
url: url to the last 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="last">
<%= link_to_unless current_page.last?, t('views.pagination.last').html_safe, url, remote: remote %>
</span>
<%# Link to the "Next" page
- available local variables
url: url to the next 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="next">
<%= link_to_unless current_page.last?, t('views.pagination.next').html_safe, url, rel: 'next', remote: remote %>
</span>
<%# Link showing page number
- available local variables
page: a page object for "this" page
url: url to this 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="page<%= ' current' if page.current? %>">
<%= link_to_unless page.current?, page, url, {remote: remote, rel: page.rel} %>
</span>
<%# The container tag
- 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
paginator: the paginator that renders the pagination tags inside
-%>
<%= paginator.render do -%>
<nav class="pagination">
<%= first_page_tag unless current_page.first? %>
<%= prev_page_tag unless current_page.first? %>
<% each_page do |page| -%>
<% if page.display_tag? -%>
<%= page_tag page %>
<% elsif !page.was_truncated? -%>
<%= gap_tag %>
<% end -%>
<% end -%>
<% unless current_page.out_of_range? %>
<%= next_page_tag unless current_page.last? %>
<%= last_page_tag unless current_page.last? %>
<% end %>
</nav>
<% end -%>
<%# Link to the "Previous" page
- available local variables
url: url to the previous 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="prev">
<%= link_to_unless current_page.first?, t('views.pagination.previous').html_safe, url, rel: 'prev', remote: remote %>
</span>
<nav class="navbar navbar-light bg-faded"> <div class="row">
<div class="container-fluid"> <div class="col">
<div class="navbar-header"> <a class="navbar-brand" href="http://zigexn.vn">
<a href="http://zigexn.vn"> <%= image_tag("logo.png", class: "navbar-brand", id: "logo") %>
<%= image_tag("logo.png", class: "navbar-brand", id: "logo") %> </a>
</a> </div>
</div>
<ul class="nav navbar-nav" id="slide">
<li><button type="button" class="btn btn-info" id="distance">Login</button></li>
<li><button type="button" class="btn btn-info" id="distance">Favorite</button></li>
<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>
</ul> </ul>
<ul class="nav navbar-nav navbar-right" id="slidebar"> </div>
<li><button type="button" class="btn btn-info" id="distance">Register</button></li>
<li><button type="button" class="btn btn-info" id="distance">History</button></li> <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>
</ul> </ul>
</div> </div>
</nav> </div>
<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
<%= 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 %>
<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="jobs list-group-item"> <div class="w-100 list-group-item">
<%= render partial: "job",collection: @jobs, as: :job %> <%= render partial: "job",collection: @jobs, as: :job %>
</div> </div>
\ No newline at end of file
...@@ -3,10 +3,11 @@ ...@@ -3,10 +3,11 @@
<%= job.job_title %> <%= job.job_title %>
</p> </p>
</a> </a>
<div class="content_job"> <div class="content_job">
<li class="detail_description"><%= truncate job.short_description,length: 160%> <% if job.short_description != nil %>
<li class="detail_description"><%= truncate job.short_description,length: 160%>
<%= link_to 'read more', '#' %></li> <%= 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| %> <% job.cities.each do |city| %>
<li class="detail_description"><%= city.location %></li> <li class="detail_description"><%= city.location %></li>
......
<p class="text-success line_job">City List</p> <h1 class="text-success line_job">City List</h1>
<div class="ct_local"> <div class="ct_local">
<%= link_to "Viet Nam", '#' , id: "viet_nam_city" , class: "ct_local_font" %> <%= link_to "Viet Nam", '#' , id: "viet_nam_city" , class: "ct_local_font" %>
<%= link_to "International", '#', id: "international_city", class: "ct_local_font" %> <%= link_to "International", '#', id: "international_city", class: "ct_local_font" %>
</div> </div>
<p class="text-success line_job">Viet Nam</p> <h1 class="text-success line_job">Viet Nam</h1>
<div class="row"> <div class="row">
<%= render partial: "city_list",collection: @vn_cities, as: :city %> <%= render partial: "city_list",collection: @vn_cities, as: :city %>
</div> </div>
<p class="text-success line_job">International</p> <h1 class="text-success line_job">International</h1>
<div class="row"> <div class="row">
<%= render partial: "city_list",collection: @international_cities, as: :city %> <%= render partial: "city_list",collection: @international_cities, as: :city %>
</div> </div>
\ No newline at end of file
<p class="text-success line_job">Industry List</p> <h1 class="text-success line_job">Industry List</h1>
<div class="row"> <div class="row">
<%= render partial: "industry_list", collection: @industries_page, as: :industry %> <%= render partial: "industry_list", collection: @industries_page, as: :industry %>
</div> </div>
<%= image_tag("home_page.jpg", id: "image_height") %> <%= image_tag("home_page.jpg", id: "image_height", class: "col-md-12 padding-0") %>
<div class="row"> <div class="row">
<div class="col"> <div class="col">
<h1 id="fontwords">Total jobs: <em> <%= @total_job %> </em>job</h1> <h1 id="fontwords" class="mt-5">Total jobs: <em> <%= @total_job %> </em>job</h1>
</div> </div>
</div> </div>
<div class="row"> <%= form_tag search_index_path, method: :get do %>
<input type="text" name="search" placeholder="Search...." id="search_box"> <div class="row search_field mt-3">
<button type="button" class="btn btn-success" id="search_button">Search</button> <%= search_field_tag 's', nil, placeholder: 'Search...', class: 'col-10 form-control' %>
</div> <%= submit_tag 'Search', class: 'col-1 btn btn-success form-control ml-4' %>
</div>
<% end %>
<p class="text-success line_job"> Latest Jobs</p> <h1 class="text-success line_job"> Latest Jobs</h1>
<div class="row"> <div class="row">
<%= render 'index' %> <%= render 'index' %>
</div> </div>
<p class="text-success line_job">Top Cities</p> <h1 class="text-success line_job">Top Cities</h1>
<div class="cities"> <div class="cities">
<%= render 'cities' %> <%= render 'cities' %>
</div> </div>
<p class="text-success line_job">Top Industry</p> <h1 class="text-success line_job">Top Industry</h1>
<div class="row cities"> <div class="row cities">
<%= render 'industries' %> <%= render 'industries' %>
</div> </div>
\ No newline at end of file
...@@ -10,6 +10,7 @@ module VenJob ...@@ -10,6 +10,7 @@ module VenJob
class Application < Rails::Application class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version. # Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.1 config.load_defaults 5.1
config.eager_load_paths += %W(#{config.root}/lib)
# Settings in config/environments/* take precedence over those specified here. # Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers # Application configuration should go into files in config/initializers
......
...@@ -7,4 +7,5 @@ Rails.application.routes.draw do ...@@ -7,4 +7,5 @@ Rails.application.routes.draw do
get 'top_pages/top_page' get 'top_pages/top_page'
get 'top_pages/jobs' get 'top_pages/jobs'
root 'top_pages#top_page' root 'top_pages#top_page'
resources :search, only: :index
end end
...@@ -16,7 +16,7 @@ ActiveRecord::Schema.define(version: 20170914072404) do ...@@ -16,7 +16,7 @@ ActiveRecord::Schema.define(version: 20170914072404) do
t.string "location" t.string "location"
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.boolean "is_vietnam" t.boolean "city_type"
t.integer "job_cities_count", default: 0 t.integer "job_cities_count", default: 0
end end
......
class Solr require 'pry'
def initialize
@solr = RSolr.connect :url => 'http://localhost:8983/solr/venjobs'
end
def self.sync_all class Solr
import_fields = [salary,industry,city,company] def self.test_solr(search_string)
solr = RSolr.connect :url => 'http://localhost:8983'
response = solr.get 'solr/venjobs/select', :params => {
:q=> search_string,
:start=>0,
:rows=>50000,
}
result = []
response["response"]["docs"].each do |doc|
result << doc
end
[result, response["response"]["numFound"]]
end end
end end
\ No newline at end of file
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