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.
pgfqe6ch8/app/controllers/iframes_controller.rb

48 lines
1.5 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

class IframesController < ApplicationController
layout false
skip_before_filter :verify_authenticity_token, :only => [:html_content]
include ApplicationHelper
def show
render :layout => false
end
# 渲染实训代码
# educodercss: 字符串以 分隔存储的是版本库css的路径
# educoderscript: 字符串以 分隔存储的是版本库js的路径
# contents html实训的整体内容
def html_content
@contents = params[:contents] || ""
gpid = params[:gpid]
edu_css = params[:educodercss]
edu_js = params[:educoderscript]
@g = Gitlab.client
@rev = "master"
if @contents.present?
@contents = @contents.gsub("w3equalsign", "=").gsub("w3scrw3ipttag", "script").gsub("edulink", "link").html_safe
end
# css
if edu_css.present?
css_path = edu_css.split(",")
css_path.each do |path|
file_content = @g.files(gpid, path, @rev).content
file_content = tran_base64_decode64(file_content) unless file_content.blank?
@contents = @contents.sub(/EDUCODERCSS/, "<style>#{file_content}</style>")
end
end
# js
if edu_js.present?
js_path = edu_js.split(",")
js_path.each do |path|
file_content = @g.files(gpid, path, @rev).content
file_content = tran_base64_decode64(file_content) unless file_content.blank?
@contents = @contents.sub(/EDUCODERJS/, "<script>#{file_content}</script>")
end
end
respond_to do |format|
format.js
format.html
end
end
end