|
|
@ -17,14 +17,13 @@ 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" |
|
|
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 +32,36 @@ 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_cover |
|
|
|
|
|
tex_content = generate_tex(template: "cover") |
|
|
|
|
|
destination_dir = "#{Rails.root}/app/views/templates/awesome" |
|
|
|
|
|
`cd #{destination_dir} && make clean` |
|
|
|
|
|
File.open("#{destination_dir}/cover.tex", "w") do |f| |
|
|
|
|
|
f << tex_content |
|
|
|
|
|
end |
|
|
|
|
|
`cd #{destination_dir} && make cover.pdf` |
|
|
|
|
|
render file: "#{destination_dir}/cover.pdf", 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 |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
|