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.
37 lines
1.1 KiB
37 lines
1.1 KiB
Trestle.resource(:users) do
|
|
menu do
|
|
item :users, icon: "fa fa-star"
|
|
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 'Template 1', instance, action: :generate, method: :get, style: :primary, icon: "fa fa-file-pdf"
|
|
end
|
|
end
|
|
|
|
controller do
|
|
def generate
|
|
user = admin.find_instance(params)
|
|
ac = ActionController::Base.new()
|
|
# debugger
|
|
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`
|
|
render file: "#{destination_dir}/resume.pdf", layout: false
|
|
end
|
|
end
|
|
|
|
routes do
|
|
get :generate, on: :member
|
|
end
|
|
end
|
|
|