Browse Source

Proper sort order + latex char sanitization

main
rodley82 3 years ago
parent
commit
55c750c9b6
  1. 3
      app/models/education_entry.rb
  2. 3
      app/models/skill.rb
  3. 2
      app/models/work_experience.rb
  4. 9
      app/views/templates/awesome/awesome-cv.cls
  5. 78
      app/views/templates/awesome/resume.html.erb
  6. 14
      config/initializers/tex_strings.rb

3
app/models/education_entry.rb

@ -1,3 +1,6 @@
class EducationEntry < ApplicationRecord class EducationEntry < ApplicationRecord
belongs_to :user belongs_to :user
default_scope -> { order(reference_date: :desc) }
scope :active, -> { where.not(reference_date: nil) }
end end

3
app/models/skill.rb

@ -1,3 +1,6 @@
class Skill < ApplicationRecord class Skill < ApplicationRecord
belongs_to :user belongs_to :user
default_scope -> { order(order: :asc) }
scope :active, -> { where.not(order: nil) }
end end

2
app/models/work_experience.rb

@ -1,4 +1,6 @@
class WorkExperience < ApplicationRecord class WorkExperience < ApplicationRecord
belongs_to :user belongs_to :user
default_scope -> { order(reference_date: :desc) } default_scope -> { order(reference_date: :desc) }
scope :active, -> { where.not(reference_date: nil) }
end end

9
app/views/templates/awesome/awesome-cv.cls

@ -726,6 +726,15 @@
\vspace{-4.0mm} \vspace{-4.0mm}
} }
% Define an environment for cvitems(for cventry)
\newenvironment{nobulletcvitems}{%
\vspace{-4.0mm}
\begin{justify}
}{%
\end{justify}
\vspace{-4.0mm}
}
%------------------------------------------------------------------------------- %-------------------------------------------------------------------------------
% Commands for elements of Cover Letter % Commands for elements of Cover Letter

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

@ -13,6 +13,20 @@
% CC BY-SA 4.0 (https://creativecommons.org/licenses/by-sa/4.0/) % CC BY-SA 4.0 (https://creativecommons.org/licenses/by-sa/4.0/)
% %
% \usepackage{amssymb}
\renewcommand{\labelenumi}{A}
\renewcommand{\labelenumii}{A}
\renewcommand{\labelitemi}{B}
\renewcommand{\labelitemii}{B}
\renewcommand{\labelitemiii}{B}
\renewcommand{\labelcvitemi}{B}
\renewcommand{\labelenumi}{A}
%------------------------------------------------------------------------------- %-------------------------------------------------------------------------------
% CONFIGURATIONS % CONFIGURATIONS
@ -51,16 +65,16 @@
%------------------------------------------------------------------------------- %-------------------------------------------------------------------------------
% Available options: circle|rectangle,edge/noedge,left/right % Available options: circle|rectangle,edge/noedge,left/right
% \photo[rectangle,edge,right]{./examples/profile} % \photo[rectangle,edge,right]{./examples/profile}
\name{<%= @user.name %>}{} \name{<%= @user.name.tex_safe %>}{}
\position{<%= @user.title %>} \position{<%= @user.title.tex_safe %>}
\address{<%= @user.address %>} \address{<%= @user.address.tex_safe %>}
\mobile{<%= @user.phone %>} \mobile{<%= @user.phone.tex_safe %>}
\email{<%= @user.email %>} \email{<%= @user.email.tex_safe %>}
%\dateofbirth{January 1st, 1970} %\dateofbirth{January 1st, 1970}
\homepage{<%= @user.other_page_url %>} \homepage{<%= @user.other_page_url.tex_safe %>}
\github{<%= @user.github %>} \github{<%= @user.github.tex_safe %>}
\linkedin{<%= @user.linkedin %>} \linkedin{<%= @user.linkedin.tex_safe %>}
% \gitlab{gitlab-id} % \gitlab{gitlab-id}
% \stackoverflow{SO-id}{SO-name} % \stackoverflow{SO-id}{SO-name}
% \twitter{@twit} % \twitter{@twit}
@ -87,7 +101,7 @@
% Leave any of these blank if they are not needed % Leave any of these blank if they are not needed
\makecvfooter \makecvfooter
{\today} {\today}
{<%= @user.name %>~~~·~~~Resume} {<%= @user.name.tex_safe %>~~~·~~~Resume}
{\thepage} {\thepage}
%------------------------------------------------------------------------------- %-------------------------------------------------------------------------------
@ -101,7 +115,7 @@
\begin{cvparagraph} \begin{cvparagraph}
%--------------------------------------------------------- %---------------------------------------------------------
<%= @user.objective %> <%= @user.objective.tex_safe %>
\end{cvparagraph} \end{cvparagraph}
%------------------------------------------------------------------------------- %-------------------------------------------------------------------------------
@ -116,10 +130,10 @@
\begin{cvskills} \begin{cvskills}
%--------------------------------------------------------- %---------------------------------------------------------
<% @user.skills.each do |s| %> <% @user.skills.active.each do |s| %>
\cvskill \cvskill
{<%= s.title %>} % Category {<%= s.title.tex_safe %>} % Category
{<%= s.detail %>} % Skills {<%= s.detail.tex_safe %>} % Skills
<% end %> <% end %>
\end{cvskills} \end{cvskills}
@ -135,16 +149,16 @@
\begin{cventries} \begin{cventries}
%--------------------------------------------------------- %---------------------------------------------------------
<% @user.work_experiences.each do |w| %> <% @user.work_experiences.active.each do |w| %>
\cventry \cventry
{<%= w.title %>} % Job title {<%= w.title.tex_safe %>} % Job title
{<%= w.employer %>} % Organization {<%= w.employer.tex_safe %>} % Organization
{} % Location {} % Location
{<%= w.period %>} % Date(s) {<%= w.period.tex_safe %>} % Date(s)
{ {
\begin{cvitems} % Description(s) of tasks/responsibilities \begin{cvitems} % Description(s) of tasks/responsibilities
<% w.items_csv&.split(",")&.each do |i| %> <% w.items_csv&.split(";")&.each do |i| %>
\item {<%= i %>} \item {<%= i.tex_safe %>}
<% end %> <% end %>
\end{cvitems} \end{cvitems}
} }
@ -164,17 +178,29 @@
\begin{cventries} \begin{cventries}
%--------------------------------------------------------- %---------------------------------------------------------
<% @user.education_entries.each do |e| %> <% @user.education_entries.active.each do |e| %>
\cventry \cventry
{<%= e.institution %>} % Institution {<%= e.institution.tex_safe %>} % Institution
{<%= e.title %>} % Degree {<%= e.title.tex_safe %>} % Degree
{<%= e.location %>} % Location {<%= e.location.tex_safe %>} % Location
{<%= e.period %>} % Date(s) {<%= e.period.tex_safe %>} % Date(s)
<%
education_details_arr = e.items_csv&.split(";")
%>
<% if education_details_arr.empty? %>
{
\begin{nobulletcvitems}
\end{nobulletcvitems}
}
<% else %>
{ {
\begin{cvitems} % Description(s) bullet points \begin{cvitems}
\item {<%= e.period %>} <% education_details_arr.each do |item| %>
\item {<%= item.tex_safe %>}
<% end %>
\end{cvitems} \end{cvitems}
} }
<% end %>
<% end %> <% end %>
%--------------------------------------------------------- %---------------------------------------------------------
\end{cventries} \end{cventries}

14
config/initializers/tex_strings.rb

@ -0,0 +1,14 @@
class String
SPECIAL_TEX_CHAR_TABLE = {
"'" => "\\textquotesingle ",
"\"" => "\\textquotedbl " # TODO: see which one works.. "\textquotedbl "
}.freeze
def tex_safe
safe_string = self.dup
SPECIAL_TEX_CHAR_TABLE.each_pair do |key, replacement|
safe_string.gsub!(key,replacement)
end
safe_string
end
end
Loading…
Cancel
Save