From a0e1c0a3dee3c9a18c9942a71b2d4a670769e470 Mon Sep 17 00:00:00 2001 From: rodley82 Date: Tue, 30 Aug 2022 17:57:43 -0300 Subject: [PATCH] Endpoint basico /cv funcionando renderizando el tex y mostrando un PDF --- .gitignore | 6 ++++++ app/controllers/work_experiences_controller.rb | 11 +++++++++++ .../views/work_experiences/cv.html.erb | 2 +- config/routes.rb | 2 ++ 4 files changed, 20 insertions(+), 1 deletion(-) rename template.tex => app/views/work_experiences/cv.html.erb (98%) diff --git a/.gitignore b/.gitignore index 886f714..b91127c 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,9 @@ # Ignore master key for decrypting credentials and more. /config/master.key + + +*.tex +*.log +*.pdf +*.aux \ No newline at end of file diff --git a/app/controllers/work_experiences_controller.rb b/app/controllers/work_experiences_controller.rb index 469e1a7..e552834 100644 --- a/app/controllers/work_experiences_controller.rb +++ b/app/controllers/work_experiences_controller.rb @@ -1,6 +1,17 @@ class WorkExperiencesController < ApplicationController before_action :set_work_experience, only: %i[ show edit update destroy ] + def cv + @full_name = "Rodolfo Leyes" + # render layout: false, content_type: "application/octet-stream" + tex_content = render_to_string(layout: false) + File.open("./temp.tex", "w") do |f| + f << tex_content + end + `pdflatex -interaction=batchmode temp.tex` + render file: "#{Rails.root}/temp.pdf", layout: false + end + # GET /work_experiences or /work_experiences.json def index @work_experiences = WorkExperience.all diff --git a/template.tex b/app/views/work_experiences/cv.html.erb similarity index 98% rename from template.tex rename to app/views/work_experiences/cv.html.erb index ed6ab76..2ae0128 100644 --- a/template.tex +++ b/app/views/work_experiences/cv.html.erb @@ -56,7 +56,7 @@ % HEADER SECTION %---------------------------------------------------------------------------------------- -{\fontsize{36}{36}\selectfont\scshape\textls[200]{John Smith}} % Your name at the top +{\fontsize{36}{36}\selectfont\scshape\textls[200]{<%= @full_name %>}} % Your name at the top \vspace{1.5cm} % Extra whitespace after the large name at the top diff --git a/config/routes.rb b/config/routes.rb index 6238958..a118f34 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,4 +4,6 @@ Rails.application.routes.draw do # Defines the root path route ("/") # root "articles#index" + + get "cv", to: "work_experiences#cv" end