YarikHrom

Untitled

Jun 6th, 2022 (edited)
433
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 9.28 KB | None | 0 0
  1. cvs_controller#show:
  2.  
  3.     def show
  4.         respond_to do |format|
  5.           format.json { render json: { cv: CvSerializer.new(@cv) } }
  6.  
  7.           format.pdf do
  8.             set_avatar
  9.  
  10.             render pdf: "Curriculum vitae for #{@employee.last_name}",
  11.                    page_size: 'A4', encoding: 'UTF-8', layout: 'pdf',
  12.                    template: 'api/v1/pdf.html.slim', margin: { top: 1, bottom: 0, left: 0, right: 0 }
  13.           end
  14.  
  15.           format.docx { headers['Content-Disposition'] = "attachment; filename=\"CV for #{@employee.last_name}.docx\"" }
  16.         end
  17.       end
  18.  
  19. api/v1/pdf.html.slim
  20.  
  21. pdf-wrapper(style='font-family: Arial, Verdana, sans-serif;')
  22.   - if params['with_logo']
  23.     .logo
  24.       = wicked_pdf_image_tag('logo.svg', style: 'height:50px; width:auto;position:absolute;right:80px;top:60px;')
  25.   .cv-container(style='padding: 0px;')
  26.     .left-image-block(style='height:535px;width: 30%; float:left')
  27.       .photo(style='height:510px; position: absolute; z-index:-1')
  28.         = wicked_pdf_image_tag 'red-circle.svg', style: 'height: 100%'
  29.       .photo(style='border-radius: 50%; border-collapse: collapse;border-collapse: separate;position: absolute; top:110px;left:30px;')
  30.         img(style='border-radius: 50%;height:350px;', src=embed_remote_image(@avatar))
  31.     .right-name-block(style='width: 68%; float:right;')
  32.       .top-block-info(style='padding-top:50px;padding-left:12px;')
  33.         h1(style='font-size: 56px;font-weight: normal;color: #EF4523;margin-bottom: 0;') = raw(@cv.info_by_selector '.name')
  34.         h1(style='font-size: 30px;font-weight: normal;color:#434343;text-transform: capitalize;') = raw(@cv.info_by_selector '.position')
  35.         .numeric_values(style='display: -webkit-box;')
  36.           div(style='padding-right: 50px;border-bottom: 3px solid #EF4523;margin-bottom: 20px;')
  37.             = @cv.info_for_table('.years_of_experience').each_slice(2) do |aa|
  38.               span(style='color: #EF4523;font-size: 35px;')= @cv.employee.years_of_experience
  39.               p(style='margin-top:-5px;')= aa[1]
  40.           div(style='border-bottom: 3px solid #EF4523;margin-bottom: 20px;')
  41.             = @cv.info_for_table('.projects').each_slice(2) do |aa|
  42.               span(style='color: #EF4523;font-size: 35px;')= aa[0]
  43.               p(style='margin-top:-5px;')= aa[1]
  44.         .about
  45.           .about__text(style='font-size:21px;color:#212529;')
  46.             = raw @cv.text_content('.about')
  47.     .board(style='clear:both;')
  48.     .left-block-hard-skills(style='float:left; width:20%;margin-left:65px;')
  49.       .hard-skills(style='margin-top: 35px;')
  50.         .hard-skills__title(style='position: relative;border-bottom:1px solid #000000;padding-bottom:0; margin: 35px 10px 35px 0;')
  51.           p(style='color: #EF4523;font-size: 24px;text-transform: uppercase;') = raw @cv.info_by_selector '.hard-skills__title'
  52.  
  53.         table.hard-skills__table(style='width: 100%;')
  54.           - years = ((DateTime.now.year - 3)..(DateTime.now.year)).to_a
  55.           thead
  56.             tr
  57.               th
  58.               - years.each do |year|
  59.                 th = year
  60.           tbody
  61.             - @employee.hard_skills.each do |skill|
  62.               tr
  63.                 td = skill.name
  64.                 - years.each do |year|
  65.                   td = raw dots_to_pdf(skill, year)
  66.               tr
  67.                 td style='color:Grey' = hard_skill_duration(skill)
  68.       .soft-skills
  69.         .soft-skills__title(style='position: relative; color: #EF4523;font-size: 24px;text-transform: uppercase;border-bottom:1px solid #000000;padding-bottom:0;margin: 35px 10px 35px 0;')
  70.           p = raw @cv.info_by_selector('.soft-skills__title')
  71.         ul.soft-skills__list(style='white-space: nowrap; list-style-type: none; padding-left: 0;')
  72.           - @cv.info_for_table('.soft-skills__list').map{|el| parse_list(el, 'soft-skills__skill-name') }.each do |soft_skill|
  73.             .li(style='padding-bottom:10px;')
  74.               .soft-skills__bullet(style='vertical-align: middle; display:inline-block; background: #EF4523; border-radius: 50%; width:16px; height:16px;')
  75.               .soft-skills__skill-name(style='vertical-align: middle; white-space: normal; display: inline-block; word-break: break-word;padding-left:20px;')
  76.                 = raw soft_skill
  77.       - unless @cv.info_by_selector('.education').empty?
  78.         .education
  79.           .education__title(style='position: relative; color: #EF4523;font-size: 24px;text-transform: uppercase;border-bottom:1px solid #000000;padding-bottom:0;margin: 35px 10px 35px 0;')
  80.             p = raw @cv.info_by_selector('.education__title')
  81.           - @cv.info_for_table('.education').drop(1).each_slice(3) do |education|
  82.             .education__years(style='font-size: 20;margin-bottom: 10px;')
  83.               = raw education[0]
  84.             .education__uni(style='font-size: 20px;margin-bottom: 10px;')
  85.               = raw education[1]
  86.             .education_speciality(style='font-size: 20px;margin-bottom: 20px;')
  87.               = raw education[-1]
  88.       - unless @cv.info_by_selector('.languages').empty?
  89.         .languages__title(style='position: relative; color: #EF4523;font-size: 24px;text-transform: uppercase;border-bottom:1px solid #000000;padding-bottom:0;margin: 35px 10px 35px 0;')
  90.           p = raw @cv.info_by_selector('.languages__title')
  91.         .languages__table(style='display: table;')
  92.           - @cv.info_for_table('.languages__table:last').each do |language|
  93.             .language__level(style='font-size: 20px;margin-bottom: 10px;')
  94.               = raw language
  95.         .publications
  96.           .publications__title(style='position: relative; color: #EF4523;font-size: 24px;text-transform: uppercase;border-bottom:1px solid #000000;padding-bottom:0;margin: 35px 10px 35px 0;')
  97.             p = raw @cv.info_by_selector('.publications__title')
  98.           ul.publications__list(style='white-space: nowrap; list-style-type: none; padding-left: 0;')
  99.             - @cv.info_for_table('.publications__list').map{|el| parse_list(el, 'publication__name') }.each do |publication|
  100.               .li
  101.                 .publication__bullet(style='vertical-align: middle; display:inline-block; background: #EF4523; border-radius:50%; width:11px;height:11px;')
  102.                 .publication__name(style='vertical-align: middle; white-space: normal; display: inline-block; word-break: break-word;padding-left:20px;')
  103.                   = publication
  104.         .interests
  105.           .interests__title(style='position: relative; color: #EF4523;font-size: 24px;text-transform: uppercase;border-bottom:1px solid #000000;padding-bottom:0;margin: 35px 10px 35px 0;')
  106.             p = raw @cv.info_by_selector('.interests__title')
  107.           ul.interests__list(style='white-space: nowrap; list-style-type: none; padding-left: 0;')
  108.             - @cv.info_for_table('.interests__list').map{|el| parse_list(el, 'interests__interest') }.each do |interest|
  109.               .li
  110.                 .interests__bullet(style='vertical-align: middle; display:inline-block; background: #EF4523; border-radius: 50%; width:11px; height:11px;')
  111.                 .interests__interest(style='vertical-align: middle; white-space: normal; display: inline-block; word-break: break-word;padding-left:20px;')
  112.                 = interest
  113.     .right-block(style='float:right; width:71%;position:relative;height:100')
  114.       .general-info
  115.         .experience
  116.           .experience__title(style='position: relative; color: #EF4523;font-size: 24px;text-transform: uppercase;border-bottom:1px solid #000000;padding-bottom:0;margin: 35px 50px;')
  117.             p = raw @cv.info_by_selector('.experience__title')
  118.           .experience__timeline(style='margin-bottom: 30px;')
  119.             - @cv.info_for_table('.experience__timeline').map{|el| parse_work_experience(el) }.each do |work_experience|
  120.               .center-black-line(style='border-left:1px solid #000;')
  121.               .experience__item-info(style='border-left:1px solid #000;padding:0px 20px 0px 50px;position:relative;')
  122.                 .peach-circle(style='position: absolute; top: 0;left: -13px;height: 25px;width: 25px;border-radius: 50%;background-color:#EF4523;')
  123.                 p.experience__company-name(style='font-weight:bold; text-transform: uppercase; margin-top: -25px;font-size:26px;')
  124.                   = raw work_experience[:company]
  125.                 p.experience__item-date(style='font-size:18px;')
  126.                   = raw work_experience[:date]
  127.                 p.experience__description(style='font-size:18px;')
  128.                   = raw work_experience[:description]
  129.                 p.experience__role(style='font-size:18px;')
  130.                   span.font-weight-bold(style='font-weight:bold;')
  131.                   = raw work_experience[:role]
  132.                 p.experience__responsibilities(style='font-size:18px;')
  133.                   span.font-weight-bold(style='font-weight:bold;')
  134.                   = raw work_experience[:responsibilities]
  135.                 p.experience__environment(style='padding-bottom:60px;font-size:18px;')
  136.                   span.font-weight-bold(style='font-weight:bold;')
  137.                   = raw work_experience[:environment]
  138.  
  139.  
  140. layouts/pdf.html.slim
  141.  
  142. doctype html
  143. html(style='height: 100%;')
  144.   head
  145.     title
  146.       = t('common.cv')
  147.     = wicked_pdf_stylesheet_pack_tag 'application'
  148.     = wicked_pdf_stylesheet_link_tag 'application'
  149.   body
  150.     = yield
  151.  
Add Comment
Please, Sign In to add comment