Commit 0442a3fc by Mai Hoang Thai Ha

create job list page ID4, add gem kaminari, add kaminari bootstrap

parent ed961adb
......@@ -44,6 +44,9 @@ group :development do
gem 'listen', '~> 3.3'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'nokogiri', '~> 1.11', '>= 1.11.7'
gem 'httparty', '~> 0.18.1'
gem 'rubocop-rails', '~> 2.11', '>= 2.11.3'
end
group :test do
......@@ -57,6 +60,4 @@ end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'slim-rails', '~> 3.2'
gem 'nokogiri', '~> 1.11', '>= 1.11.7'
gem 'httparty', '~> 0.18.1'
gem 'rubocop-rails', '~> 2.11', '>= 2.11.3'
\ No newline at end of file
gem 'kaminari', :git => 'https://github.com/kaminari/kaminari'
\ No newline at end of file
GIT
remote: https://github.com/kaminari/kaminari
revision: 45f13dbdaa98be3733ffe6b0e8e948da6919f116
specs:
kaminari (1.2.1)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.2.1)
kaminari-activerecord (= 1.2.1)
kaminari-core (= 1.2.1)
kaminari-actionview (1.2.1)
actionview
kaminari-core (= 1.2.1)
kaminari-activerecord (1.2.1)
activerecord
kaminari-core (= 1.2.1)
kaminari-core (1.2.1)
GEM
remote: https://rubygems.org/
specs:
......@@ -251,6 +268,7 @@ DEPENDENCIES
capybara (>= 3.26)
httparty (~> 0.18.1)
jbuilder (~> 2.7)
kaminari!
listen (~> 3.3)
mysql2 (~> 0.5)
nokogiri (~> 1.11, >= 1.11.7)
......
// Place all the styles related to the Jobs controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: https://sass-lang.com/
class JobsController < ApplicationController
def index
if params[:city_id].present?
city = City.find(params[:city_id])
@name = city.name
@jobs = city.jobs
elsif params[:industry_id].present?
industry = Industry.find(params[:industry_id])
@name = industry.name
@jobs = industry.jobs
else
@name = 'JOBS'
@jobs = Job.all
end
@jobs = @jobs.page(params[:page]).per(20)
end
def show
end
end
module JobsHelper
end
......@@ -7,12 +7,12 @@
= region.upcase
small.text-muted
| (#{pluralize(job_count, "job")})
hr.divider.my-4
hr.my-4
.row
- list = get_cities_list(region)
- list.each do |city, count|
.col-lg-4.col-md-6.text-center
.mt-5
.city-item
h3.h4.mb-2.see-more-text= link_to city, '#', class:'text-decoration-none fw-normal text-reset'
h3.h4.mb-2.see-more-text= link_to city, city_jobs_path(City.find_by(name: city).id) , class:'text-decoration-none fw-normal text-reset'
p.text-muted.mb-0= pluralize(count, "job")
\ No newline at end of file
.countries-list
.container.py-5
h2.mt-0 REGION
hr.divider.my-4
hr.my-4
.row
- @region_job_list.each do |region, job_count|
.col-lg-4.col-md-6.text-center
......
.countries-list
.container.py-5
h2.mt-0 INDUSTRIES
hr.divider.my-4
hr.my-4
#info-box.row
- @industries_job_list.each do |name, job_count|
.col-lg-6.col-md-6.text-center
.mt-5
h3.h4.mb-2.see-more-text= link_to name, '#', class:'text-decoration-none fw-normal text-reset'
h3.h4.mb-2.see-more-text= link_to name, industry_jobs_path(Industry.find_by(name: name).id) , class:'text-decoration-none fw-normal text-reset'
p.text-muted.mb-0= pluralize(job_count, "job")
hr.divider.my-4
.container
- @jobs.each do |job|
.job-item
= link_to job.title, '#', class: 'job-title fs-3 text-decoration-none text-reset'
.job-caption
= link_to job.company.name, "#", class: "job-company text-decoration-none text-secondary"
p.job-salary.text-success
| Salary: #{job.salary}
ul.list-unstyled
- job.cities.each do |city|
li
= city.name
.job-desc
- if job.description.length > 250
= truncate(simple_format(job.description), escape: false, length: 250)
- else
= job.description
hr.my-4
\ No newline at end of file
- provide(:title, 'Job list page')
.search.text-center.my-5
.container
.row
.col-md-10.mb-md-0.no-padding
span.fa.fa-search.form-control-feedback
= search_field_tag :search, params[:search], placeholder: "Find a job", class: "form-control rounded-left no-border-radius bg-light h-100"
.col-md-2.mb-md-0.no-padding
= button_tag "", class: "h-100 w-100 btn btn-block btn-lg btn-info fa fa-search rounded-right no-border-radius ", name: nil
| Search
.container
h1.mt-5
= @name
hr.my-4
.no-padding.d-flex.align-items-center.flex-column
.page-info.p-2
= page_entries_info @jobs
.page-info.p-2
= paginate @jobs
.container
= render 'jobs'
.no-padding.d-flex.align-items-center.flex-column
.page-info.p-2
= page_entries_info @jobs
.page-info.p-2
= paginate @jobs
\ No newline at end of file
h1 Jobs#show
p Find me in app/views/jobs/show.html.slim
li.page-item
= link_to_unless current_page.first?, raw(t 'views.pagination.first'), url, remote: remote, class: 'page-link'
li.page-item.disabled
= link_to raw(t 'views.pagination.truncate'), '#', class: 'page-link'
li.page-item
= link_to_unless current_page.last?, raw(t 'views.pagination.last'), url, remote: remote, class: 'page-link'
li.page-item
= link_to_unless current_page.last?, raw(t 'views.pagination.next'), url, rel: 'next', remote: remote, class: 'page-link'
- if page.current?
li.page-item.active
= content_tag :a, page, data: { remote: remote }, rel: page.rel, class: 'page-link'
- else
li.page-item
= link_to page, url, remote: remote, rel: page.rel, class: 'page-link'
= paginator.render do
nav
ul.pagination
== first_page_tag unless current_page.first?
== prev_page_tag unless current_page.first?
- each_page do |page|
- if page.left_outer? || page.right_outer? || page.inside_window?
== page_tag page
- elsif !page.was_truncated?
== gap_tag
== next_page_tag unless current_page.last?
== last_page_tag unless current_page.last?
li.page-item
= link_to_unless current_page.first?, raw(t 'views.pagination.previous'), url, rel: 'prev', remote: remote, class: 'page-link'
......@@ -4,7 +4,7 @@
.row.align-items-start.mb-3
- @top_cities.each do |city, city_jobs|
.col-4.city-item
= link_to city.name, '#', class: 'city-name'
= link_to city.name, city_jobs_path(City.find_by(name: city.name).id), class: 'city-name'
span.job-count
| (
= pluralize(city_jobs, "job")
......
......@@ -4,7 +4,7 @@
.row.align-items-start
- @top_industries.each do |industry, industry_jobs|
.col-4.industry-item
= link_to industry.name, '#', class: 'industry-name'
= link_to industry.name, industry_jobs_path(Industry.find_by(name: industry.name).id), class: 'industry-name'
span.job-count
| (
= pluralize(industry_jobs, "job")
......
# frozen_string_literal: true
Kaminari.configure do |config|
# config.default_per_page = 25
# config.max_per_page = nil
# config.window = 4
# config.outer_window = 0
# config.left = 0
# config.right = 0
# config.page_method_name = :page
# config.param_name = :page
# config.max_pages = nil
# config.params_on_first_page = false
end
Rails.application.routes.draw do
root 'top#index'
resources :cities, only: %i[index show]
resources :industries, only: %i[index show]
root 'top#index'
resources :cities, only: %i[index show] do
resources :jobs, only: %i[index]
end
resources :industries, only: %i[index show] do
resources :jobs, only: %i[index]
end
resources :jobs, only: %i[index show]
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