You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

41 lines
1.2 KiB

Trestle.resource(:users) do
menu do
item :users, icon: "fa fa-user", priority: 1
end
form do |item|
concat Trestle::Form::Automatic.new(admin).render(self, item)
text_area :objective
end
# Customize the table columns shown on the index view.
table do
column :name
column :created_at, align: :center
actions do |toolbar, instance, admin|
toolbar.edit if admin && admin.actions.include?(:edit)
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"
end
end
controller do
def generate
user = admin.find_instance(params)
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"
`cd #{destination_dir} && make clean`
File.open("#{destination_dir}/resume.tex", "w") do |f|
f << tex_content
end
`cd #{destination_dir} && make resume.pdf`
render file: "#{destination_dir}/resume.pdf", layout: false
end
end
routes do
get :generate, on: :member
end
end