From d4dfa38bd99afe9bbc9b5a40b975e2baf887a0e5 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 13 Oct 2017 14:16:14 +0800 Subject: [PATCH] =?UTF-8?q?PHP/Web=E5=AE=9E=E8=AE=AD=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/games_controller.rb | 16 +++++++++++++++- app/views/games/_code_actions.html.erb | 3 +++ app/views/games/web_display.html.erb | 2 ++ config/routes.rb | 1 + 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 app/views/games/web_display.html.erb diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index d5522b898..c027dcafe 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -3,7 +3,7 @@ class GamesController < ApplicationController layout "base_myshixun" skip_before_filter :verify_authenticity_token, :only => [:file_update] before_filter :find_myshixun, :only => [:index] - before_filter :find_game, :only => [:show, :game_build, :entry,:next_step, :prev_step,:outputs_show, :file_edit, :file_update, :get_waiting_time, + before_filter :find_game, :only => [:show, :game_build, :entry,:next_step, :prev_step,:outputs_show, :file_edit, :file_update, :get_waiting_time, :web_display, :game_status, :change_status, :answer, :minus_score, :refresh_game_list, :reset_original_code, :reset_new_code, :evaluating_choice, :sync_codes] before_filter :find_repository, :only => [:show, :entry, :file_edit, :file_update, :reset_original_code, :reset_new_code, :html_show] before_filter :allowd_manager @@ -496,6 +496,20 @@ class GamesController < ApplicationController end end + # web渲染 + def web_display + path = @game.challenge.path.strip + port = (50000 + @game.id).to_s + # 测试 + #path = "src/step1/Helloworld.php" + #port = (50000+4116).to_s + @url = "http://106.75.96.108:" + port + '/' + path + + respond_to do |format| + format.html{render :layout => false} + end + end + def minus_score @game_challenge = @game.challenge user = User.current diff --git a/app/views/games/_code_actions.html.erb b/app/views/games/_code_actions.html.erb index 9d026ad1a..9cc6647b6 100644 --- a/app/views/games/_code_actions.html.erb +++ b/app/views/games/_code_actions.html.erb @@ -1,5 +1,8 @@ +<% if @myshixun.shixun.try(:language) == "PHP/Web" %> + 查看网页效果 +<% end %> <% if @st == 0 %>
"> 加载上次通过的代码 diff --git a/app/views/games/web_display.html.erb b/app/views/games/web_display.html.erb new file mode 100644 index 000000000..97b28adbe --- /dev/null +++ b/app/views/games/web_display.html.erb @@ -0,0 +1,2 @@ + diff --git a/config/routes.rb b/config/routes.rb index f772ec526..f879b4ac6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -157,6 +157,7 @@ RedmineApp::Application.routes.draw do match 'prev_step', :via => [:get, :post] match 'reset_original_code', :via => [:get, :post] match 'reset_new_code', :via => [:get, :post] + match 'web_display', :via => [:get, :post] get 'entry' get 'outputs_show' get 'game_status'