From bc3df8161084b8b5e185c81168b502b6e889f5ab Mon Sep 17 00:00:00 2001 From: Z Date: Mon, 2 Mar 2020 18:16:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9jump=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/about_controller.rb | 5 +++++ app/controllers/jump_controller.rb | 8 -------- app/views/about/jump.html.haml | 11 +++++++++++ config/routes.rb | 2 +- 4 files changed, 17 insertions(+), 9 deletions(-) delete mode 100644 app/controllers/jump_controller.rb create mode 100644 app/views/about/jump.html.haml diff --git a/app/controllers/about_controller.rb b/app/controllers/about_controller.rb index 10fb4ffb6..fb9eb9f56 100644 --- a/app/controllers/about_controller.rb +++ b/app/controllers/about_controller.rb @@ -7,6 +7,7 @@ class AboutController < ApplicationController before_action :set_body_classes, only: :show before_action :set_instance_presenter before_action :set_expires_in, only: [:show, :more, :terms] + before_action :authenticate_user!, only: :jump skip_before_action :require_functional!, only: [:more, :terms] @@ -24,6 +25,10 @@ class AboutController < ApplicationController def terms; end + def jump + @jump_url = "https://#{params[:destin]}/#{params[:path]}" + end + helper_method :display_blocks? helper_method :display_blocks_rationale? helper_method :public_fetch_mode? diff --git a/app/controllers/jump_controller.rb b/app/controllers/jump_controller.rb deleted file mode 100644 index 37061c98e..000000000 --- a/app/controllers/jump_controller.rb +++ /dev/null @@ -1,8 +0,0 @@ - -class JumpController < ApplicationController - before_action :authenticate_user! - - def index - redirect_to("//#{params[:destin]}/#{params[:path]}") - end -end diff --git a/app/views/about/jump.html.haml b/app/views/about/jump.html.haml new file mode 100644 index 000000000..f26e410ba --- /dev/null +++ b/app/views/about/jump.html.haml @@ -0,0 +1,11 @@ +- content_for :page_title do + = @jump_url + +.grid + .column-0 + .box-widget + .rich-formatting + %h2= '将前往:' + %h4= link_to @jump_url, @jump_url + .column-1 + = render 'application/sidebar' diff --git a/config/routes.rb b/config/routes.rb index 4264947dc..e71ffa1a0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -451,7 +451,7 @@ Rails.application.routes.draw do get '/about/more', to: 'about#more' get '/terms', to: 'about#terms' - get '/jump/:destin/(*path)', to: 'jump#index', :constraints => { :destin => /[0-z\.]+/ } + get '/jump/:destin/(*path)', to: 'about#jump', :constraints => { :destin => /[0-z\.]+/ } match '/', via: [:post, :put, :patch, :delete], to: 'application#raise_not_found', format: false match '*unmatched_route', via: :all, to: 'application#raise_not_found', format: false