diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d17059231..e7b4bdac6 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -239,7 +239,7 @@ class ApplicationController < ActionController::Base uid_logger("user_setup: " + (User.current.logged? ? "#{User.current.try(:login)} (id=#{User.current.try(:id)})" : "anonymous")) if !User.current.logged? && Rails.env.development? - User.current = User.find 8686 + User.current = User.find 1 end diff --git a/app/controllers/concerns/render_expand.rb b/app/controllers/concerns/render_expand.rb index 4fd77c285..b0f26f43e 100644 --- a/app/controllers/concerns/render_expand.rb +++ b/app/controllers/concerns/render_expand.rb @@ -14,7 +14,7 @@ module RenderExpand kit.stylesheets << Rails.root.join('app/templates', path) end - send_data kit.to_pdf, filename: options[:filename], type: 'application/pdf' + send_data kit.to_pdf, filename: options[:filename], disposition: options[:disposition] || 'attachment', type: 'application/pdf' end end end \ No newline at end of file diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 44a2faa92..781ede214 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1290,20 +1290,8 @@ class ExercisesController < ApplicationController if params[:export].present? && params[:export] normal_status(0,"正在下载中") else - file = File.open(Rails.root.join('exercise_export/blank_exercise.html.erb')) - html = ERB.new(file.read) - - kit = PDFKit.new(html) - base_css = %w(app/templates/exercise_export/exercise_export.css) - base_css.each { |css| kit.stylesheets << Rails.root.join(css) } - # file = Tempfile.new(filename_) - # kit.to_pdf(file.path) - # file - - send_file kit.to_pdf, filename: filename_ ,disposition: 'inline', type:"application/pdf" - - # set_export_cookies - # render pdf: 'exercise_export/blank_exercise', filename: filename_, stylesheets: stylesheets, disposition: 'inline', type:"pdf_attachment.content_type",stream:false + set_export_cookies + render pdf: 'exercise_export/blank_exercise', filename: filename_, stylesheets: stylesheets, disposition: 'inline', type:"pdf_attachment.content_type",stream:false end end diff --git a/app/controllers/student_works_controller.rb b/app/controllers/student_works_controller.rb index 93f0fc586..670e4fb79 100644 --- a/app/controllers/student_works_controller.rb +++ b/app/controllers/student_works_controller.rb @@ -474,7 +474,7 @@ class StudentWorksController < ApplicationController filename_ = "#{@use&.student_id}_#{@use&.real_name}_#{@shixun&.name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}" filename = Base64.urlsafe_encode64(filename_.strip) stylesheets = %w(shixun_work/shixun_work.css shared/codemirror.css) - render pdf: 'shixun_work/shixun_work', filename: filename, stylesheets: stylesheets + render pdf: 'shixun_work/shixun_work', filename: filename, stylesheets: stylesheets, disposition: 'inline', type:"pdf_attachment.content_type",stream:false end # 作品调分