Compare commits

...

5 Commits

  1. 4
      .gitignore
  2. 30
      app/admin/users_admin.rb
  3. 16
      app/assets/stylesheets/trestle/_theme.scss
  4. 5
      app/helpers/application_helper.rb
  5. 15
      app/models/cover_letter.rb
  6. 32
      app/views/templates/awesome/_colors_section.html.erb
  7. 29
      app/views/templates/awesome/_personal_heading_section.erb
  8. 73
      app/views/templates/awesome/coverletter.html.erb
  9. 60
      app/views/templates/awesome/resume.html.erb
  10. 37
      app/views/users/show.json.jbuilder
  11. 1
      config/application.rb
  12. 7
      db/migrate/20241104003755_add_sections_to_cover_letter.rb
  13. 5
      db/schema.rb
  14. 23
      lib/settings.rb

4
.gitignore

@ -31,9 +31,11 @@
/public/assets /public/assets
/db/*.bu
# Ignore master key for decrypting credentials and more. # Ignore master key for decrypting credentials and more.
/config/master.key /config/master.key
.vscode
*.tex *.tex
*.log *.log

30
app/admin/users_admin.rb

@ -17,14 +17,14 @@ Trestle.resource(:users) do
toolbar.edit if admin && admin.actions.include?(:edit) toolbar.edit if admin && admin.actions.include?(:edit)
toolbar.delete if admin && admin.actions.include?(:destroy) toolbar.delete if admin && admin.actions.include?(:destroy)
toolbar.link 'CV', instance, action: :generate, method: :get, style: :primary, icon: "fa fa-file-pdf", target: "_blank" toolbar.link 'CV', instance, action: :generate, method: :get, style: :primary, icon: "fa fa-file-pdf", target: "_blank"
toolbar.link 'CLS', instance, action: :generate_cls, method: :get, style: :secondary, icon: "fa", target: "_blank"
toolbar.link 'JSON', instance, action: :generate_json, method: :get, style: :secondary, icon: "fa", target: "_blank"
end end
end end
controller do controller do
def generate def generate
user = admin.find_instance(params) tex_content = generate_tex
ac = ActionController::Base.new()
tex_content = ac.render_to_string(layout: false, template: 'templates/awesome/resume', locals: { "@user": user } )
destination_dir = "#{Rails.root}/app/views/templates/awesome" destination_dir = "#{Rails.root}/app/views/templates/awesome"
`cd #{destination_dir} && make clean` `cd #{destination_dir} && make clean`
File.open("#{destination_dir}/resume.tex", "w") do |f| File.open("#{destination_dir}/resume.tex", "w") do |f|
@ -33,9 +33,33 @@ Trestle.resource(:users) do
`cd #{destination_dir} && make resume.pdf` `cd #{destination_dir} && make resume.pdf`
render file: "#{destination_dir}/resume.pdf", layout: false render file: "#{destination_dir}/resume.pdf", layout: false
end end
def generate_cls
tex_content = generate_tex
destination_dir = "#{Rails.root}/app/views/templates/awesome"
File.open("#{destination_dir}/resume.tex", "w") do |f|
f << tex_content
end
render file: "#{destination_dir}/resume.tex", layout: false
end
def generate_json
user = admin.find_instance(params)
ac = ActionController::Base.new()
json = ac.render_to_string(layout: false, template: "users/show", locals: { "@user": user } )
render json: json, layout: false
end
def generate_tex(template: "resume")
user = admin.find_instance(params)
ac = ActionController::Base.new()
ac.render_to_string(layout: false, template: "templates/awesome/#{template}", locals: { "@user": user } )
end
end end
routes do routes do
get :generate, on: :member get :generate, on: :member
get :generate_cls, on: :member
get :generate_json, on: :member
end end
end end

16
app/assets/stylesheets/trestle/_theme.scss

@ -11,3 +11,19 @@
// "primary": #337ab7, // "primary": #337ab7,
// "secondary": #719dc3 // "secondary": #719dc3
// ); // );
textarea#work_experience_items_csv {
height: 400px !important;
}
textarea#cover_letter_about_me {
height: 400px !important;
}
textarea#cover_letter_why_me {
height: 400px !important;
}
textarea#cover_letter_why_company {
height: 400px !important;
}

5
app/helpers/application_helper.rb

@ -1,2 +1,7 @@
module ApplicationHelper module ApplicationHelper
def color_scheme
#% Awesome Colors: awesome-emerald, awesome-skyblue, awesome-red, awesome-pink, awesome-orange
#% awesome-nephritis, awesome-concrete, awesome-darknight
"awesome-orange"
end
end end

15
app/models/cover_letter.rb

@ -4,8 +4,19 @@ class CoverLetter < ApplicationRecord
default_scope -> { order(order: :asc) } default_scope -> { order(order: :asc) }
scope :active, -> { where.not(order: nil) } scope :active, -> { where.not(order: nil) }
def tex_intro_paragraph
def tex_paragraph
csv_paragraphs.split(";").join("\n").tex_safe csv_paragraphs.split(";").join("\n").tex_safe
end end
def tex_why_me
why_me.tex_safe
end
def tex_why_company
why_company.tex_safe
end
def tex_why_role
why_role.tex_safe
end
end end

32
app/views/templates/awesome/_colors_section.html.erb

@ -0,0 +1,32 @@
% Color for highlights
% Awesome Colors: awesome-emerald, awesome-skyblue, awesome-red, awesome-pink, awesome-orange
% awesome-nephritis, awesome-concrete, awesome-darknight
\colorlet{awesome}{<%= Settings.color_scheme %>}
% Uncomment if you would like to specify your own color
% \definecolor{awesome}{HTML}{CA63A8}
% Color for highlights (defaults to red)
% \definecolor{awesome}{HTML}{<%= Settings.darktext_html_color %>}
% Colors for text
% Uncomment if you would like to specify your own color
% \definecolor{darktext}{HTML}{<%= Settings.darktext_html_color %>}
% DARK TEXT THAT GOES WITH THE HIGTLIGHT COLOR
% \definecolor{text}{HTML}{<%= Settings.darktext_html_color %>}
% REGULAR TEXT THAT IS GRAY
\definecolor{graytext}{HTML}{<%= Settings.regular_text_html_color %>}
\definecolor{lighttext}{HTML}{040720}
% Divider color
\definecolor{sectiondivider}{HTML}{<%= Settings.divider_html_color %>}
% \definecolor{darktext}{HTML}{414141}
% \definecolor{text}{HTML}{333333}
% \definecolor{graytext}{HTML}{5D5D5D}
% \definecolor{lighttext}{HTML}{999999}
% \definecolor{sectiondivider}{HTML}{5D5D5D}

29
app/views/templates/awesome/_personal_heading_section.erb

@ -0,0 +1,29 @@
%-------------------------------------------------------------------------------
% PERSONAL INFORMATION
% Comment any of the lines below if they are not required
%-------------------------------------------------------------------------------
% Available options: circle|rectangle,edge/noedge,left/right
\name{<%= user.name.tex_safe %>}{}
\position{<%= user.title.tex_safe %>}
\address{<%= user.address.tex_safe %>}
\mobile{<%= user.phone.tex_safe %>}
\email{<%= user.email.tex_safe %>}
%\dateofbirth{January 1st, 1970}
\homepage{<%= user.other_page_url.tex_safe %>}
\github{<%= user.github.tex_safe %>}
\linkedin{<%= user.linkedin.tex_safe %>}
% \gitlab{gitlab-id}
% \stackoverflow{SO-id}{SO-name}
% \twitter{@twit}
% \skype{skype-id}
% \reddit{reddit-id}
% \medium{madium-id}
% \kaggle{kaggle-id}
% \googlescholar{googlescholar-id}{name-to-display}
%% \firstname and \lastname will be used
% \googlescholar{googlescholar-id}{}
% \extrainfo{extra information}
% \quote{``Be the change that you want to see in the world."}

73
app/views/templates/awesome/coverletter.html.erb

@ -25,20 +25,7 @@
% Configure page margins with geometry % Configure page margins with geometry
\geometry{left=1.4cm, top=.8cm, right=1.4cm, bottom=1.8cm, footskip=.5cm} \geometry{left=1.4cm, top=.8cm, right=1.4cm, bottom=1.8cm, footskip=.5cm}
% Color for highlights <%= render 'templates/awesome/colors_section' %>
% Awesome Colors: awesome-emerald, awesome-skyblue, awesome-red, awesome-pink, awesome-orange
% awesome-nephritis, awesome-concrete, awesome-darknight
\colorlet{awesome}{awesome-red}
% Uncomment if you would like to specify your own color
% \definecolor{awesome}{HTML}{CA63A8}
% Colors for text
% Uncomment if you would like to specify your own color
% \definecolor{darktext}{HTML}{414141}
% \definecolor{text}{HTML}{333333}
% \definecolor{graytext}{HTML}{5D5D5D}
% \definecolor{lighttext}{HTML}{999999}
% \definecolor{sectiondivider}{HTML}{5D5D5D}
% Set false if you don't want to highlight section with awesome color % Set false if you don't want to highlight section with awesome color
\setbool{acvSectionColorHighlight}{true} \setbool{acvSectionColorHighlight}{true}
@ -46,36 +33,7 @@
% If you would like to change the social information separator from a pipe (|) to something else % If you would like to change the social information separator from a pipe (|) to something else
\renewcommand{\acvHeaderSocialSep}{\quad\textbar\quad} \renewcommand{\acvHeaderSocialSep}{\quad\textbar\quad}
<%= render 'templates/awesome/personal_heading_section', user: user %>
%-------------------------------------------------------------------------------
% PERSONAL INFORMATION
% Comment any of the lines below if they are not required
%-------------------------------------------------------------------------------
% Available options: circle|rectangle,edge/noedge,left/right
\name{<%= user.name.tex_safe %>}{}
\position{<%= user.title.tex_safe %>}
\address{<%= user.address.tex_safe %>}
\mobile{<%= user.phone.tex_safe %>}
\email{<%= user.email.tex_safe %>}
%\dateofbirth{January 1st, 1970}
\homepage{<%= user.other_page_url.tex_safe %>}
\github{<%= user.github.tex_safe %>}
\linkedin{<%= user.linkedin.tex_safe %>}
% \gitlab{gitlab-id}
% \stackoverflow{SO-id}{SO-name}
% \twitter{@twit}
% \skype{skype-id}
% \reddit{reddit-id}
% \medium{madium-id}
% \kaggle{kaggle-id}
% \googlescholar{googlescholar-id}{name-to-display}
%% \firstname and \lastname will be used
% \googlescholar{googlescholar-id}{}
% \extrainfo{extra information}
% \quote{``Be the change that you want to see in the world."}
%------------------------------------------------------------------------------- %-------------------------------------------------------------------------------
% LETTER INFORMATION % LETTER INFORMATION
@ -88,15 +46,14 @@
% The date on the letter, default is the date of compilation % The date on the letter, default is the date of compilation
\letterdate{\today} \letterdate{\today}
% The title of the letter % The title of the letter
\lettertitle{<%= @cover_letter.title.tex_safe %>} \lettertitle{Job Application for <%= @cover_letter.title.tex_safe %>}
% How the letter is opened % How the letter is opened
\letteropening{Dear Mr./Ms./Dr. LastName,} \letteropening{To whom it may concern,}
% How the letter is closed % How the letter is closed
\letterclosing{Sincerely,} \letterclosing{Yours Sincerely,}
% Any enclosures with the letter % Any enclosures with the letter
\letterenclosure[Attached]{Curriculum Vitae} \letterenclosure[Attached]{Curriculum Vitae}
%------------------------------------------------------------------------------- %-------------------------------------------------------------------------------
\begin{document} \begin{document}
@ -119,10 +76,26 @@
%------------------------------------------------------------------------------- %-------------------------------------------------------------------------------
\begin{cvletter} \begin{cvletter}
<%= @cover_letter.tex_paragraph %> <%= @cover_letter.tex_intro_paragraph %>
\end{cvletter} <% if @cover_letter.about_me.present? %>
\lettersection{About Me}
<%= @cover_letter.about_me.tex_safe %>
<% end %>
%------------------------------------------------
<% if @cover_letter.why_company.present? %>
\lettersection{Why <%= @cover_letter.company_name.tex_safe %> ?}
<%= @cover_letter.why_company.tex_safe %>
<% end %>
%------------------------------------------------
<% if @cover_letter.why_me.present? %>
\lettersection{Why Me?}
<%= @cover_letter.why_me.tex_safe %>
<% end %>
\end{cvletter}
%------------------------------------------------------------------------------- %-------------------------------------------------------------------------------
% Print the signature and enclosures with above letter information % Print the signature and enclosures with above letter information

60
app/views/templates/awesome/resume.html.erb

@ -34,20 +34,7 @@
% Configure page margins with geometry % Configure page margins with geometry
\geometry{left=1.4cm, top=.8cm, right=1.4cm, bottom=1.8cm, footskip=.5cm} \geometry{left=1.4cm, top=.8cm, right=1.4cm, bottom=1.8cm, footskip=.5cm}
% Color for highlights <%= render 'templates/awesome/colors_section' %>
% Awesome Colors: awesome-emerald, awesome-skyblue, awesome-red, awesome-pink, awesome-orange
% awesome-nephritis, awesome-concrete, awesome-darknight
\colorlet{awesome}{awesome-red}
% Uncomment if you would like to specify your own color
% \definecolor{awesome}{HTML}{CA63A8}
% Colors for text
% Uncomment if you would like to specify your own color
% \definecolor{darktext}{HTML}{414141}
% \definecolor{text}{HTML}{333333}
% \definecolor{graytext}{HTML}{5D5D5D}
% \definecolor{lighttext}{HTML}{999999}
% \definecolor{sectiondivider}{HTML}{5D5D5D}
% Set false if you don't want to highlight section with awesome color % Set false if you don't want to highlight section with awesome color
\setbool{acvSectionColorHighlight}{true} \setbool{acvSectionColorHighlight}{true}
@ -55,36 +42,7 @@
% If you would like to change the social information separator from a pipe (|) to something else % If you would like to change the social information separator from a pipe (|) to something else
\renewcommand{\acvHeaderSocialSep}{\quad\textbar\quad} \renewcommand{\acvHeaderSocialSep}{\quad\textbar\quad}
<%= render 'templates/awesome/personal_heading_section', user: @user %>
%-------------------------------------------------------------------------------
% PERSONAL INFORMATION
% Comment any of the lines below if they are not required
%-------------------------------------------------------------------------------
% Available options: circle|rectangle,edge/noedge,left/right
% \photo[rectangle,edge,right]{./examples/profile}
\name{<%= @user.name.tex_safe %>}{}
\position{<%= @user.title.tex_safe %>}
\address{<%= @user.address.tex_safe %>}
\mobile{<%= @user.phone.tex_safe %>}
\email{<%= @user.email.tex_safe %>}
%\dateofbirth{January 1st, 1970}
\homepage{<%= @user.other_page_url.tex_safe %>}
\github{<%= @user.github.tex_safe %>}
\linkedin{<%= @user.linkedin.tex_safe %>}
% \gitlab{gitlab-id}
% \stackoverflow{SO-id}{SO-name}
% \twitter{@twit}
% \skype{skype-id}
% \reddit{reddit-id}
% \medium{madium-id}
% \kaggle{kaggle-id}
% \googlescholar{googlescholar-id}{name-to-display}
%% \firstname and \lastname will be used
% \googlescholar{googlescholar-id}{}
% \extrainfo{extra information}
% \quote{``Be the change that you want to see in the world."}
%------------------------------------------------------------------------------- %-------------------------------------------------------------------------------
@ -147,8 +105,16 @@
%--------------------------------------------------------- %---------------------------------------------------------
<% @user.work_experiences.active.each do |w| %> <% @user.work_experiences.active.each do |w| %>
\cventry \cventry
{<%= w.title.tex_safe %>} % Job title {
<%= w.title.tex_safe %>
<% if w.technologies.present? %>
\newline
\hspace{0.1cm}
\normalfont
Technologies: <%= w.technologies.tex_safe %>
<% end %>
} % Job title
{<%= w.employer.tex_safe %>} % Organization {<%= w.employer.tex_safe %>} % Organization
{} % Location {} % Location
{<%= w.period.tex_safe %>} % Date(s) {<%= w.period.tex_safe %>} % Date(s)
@ -159,6 +125,7 @@
<% end %> <% end %>
\end{cvitems} \end{cvitems}
} }
<% end %> <% end %>
%--------------------------------------------------------- %---------------------------------------------------------
@ -198,6 +165,7 @@
\end{cvitems} \end{cvitems}
} }
<% end %> <% end %>
<% end %> <% end %>
%--------------------------------------------------------- %---------------------------------------------------------
\end{cventries} \end{cventries}

37
app/views/users/show.json.jbuilder

@ -0,0 +1,37 @@
json.user do
json.id @user.id
json.name @user.name
json.title @user.title
json.work_experiences @user.work_experiences.active do |work|
# json.id work.id
json.title work.title
json.organization work.employer
if work.technologies.present?
json.technologies work.technologies
end
json.period work.period
json.responsibilities do
json.array! work.items_csv&.split(";")
end
end
json.skills @user.skills.active do |skill|
# json.id skill.id
json.title skill.title
json.detail skill.detail
end
json.education_entries @user.education_entries.active do |edu|
json.institution edu.institution
json.title edu.title
json.location edu.location
json.period edu.period
json.items do
json.array! edu.items_csv&.split(";")
end
end
end

1
config/application.rb

@ -30,5 +30,6 @@ module LatexResumes
# #
# config.time_zone = "Central Time (US & Canada)" # config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras") # config.eager_load_paths << Rails.root.join("extras")
config.eager_load_paths << Rails.root.join("lib")
end end
end end

7
db/migrate/20241104003755_add_sections_to_cover_letter.rb

@ -0,0 +1,7 @@
class AddSectionsToCoverLetter < ActiveRecord::Migration[7.0]
def change
add_column :cover_letters, :about_me, :text
add_column :cover_letters, :why_company, :text
add_column :cover_letters, :why_me, :text
end
end

5
db/schema.rb

@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.0].define(version: 2022_12_21_141217) do ActiveRecord::Schema[7.0].define(version: 2024_11_04_003755) do
create_table "cover_letters", force: :cascade do |t| create_table "cover_letters", force: :cascade do |t|
t.string "title" t.string "title"
t.string "company_name" t.string "company_name"
@ -21,6 +21,9 @@ ActiveRecord::Schema[7.0].define(version: 2022_12_21_141217) do
t.text "csv_paragraphs" t.text "csv_paragraphs"
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.text "about_me"
t.text "why_company"
t.text "why_me"
t.index ["user_id"], name: "index_cover_letters_on_user_id" t.index ["user_id"], name: "index_cover_letters_on_user_id"
end end

23
lib/settings.rb

@ -0,0 +1,23 @@
class Settings
class << self
def color_scheme
"awesome-orange"
end
def darktext_html_color
"ff2400"
end
def test_color
"ff0000"
end
def regular_text_html_color
"0C090A"
end
def divider_html_color
"B6B6B6"
end
end
end
Loading…
Cancel
Save