# Redmine - project management software # Copyright (C) 2006-2013 Jean-Philippe Lang # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class WelcomeController < ApplicationController caches_action :robots before_filter :entry_select_course, :entry_select_contest, :entry_select_user, :only => [:index] def index projectActive = Project.project_entities.active @projectCount = projectActive.count @projectPublicCount = projectActive.all_public.count @projectHidenCount = @projectCount - @projectPublicCount @developerCount = User.developer.count end def robots @projects = Project.all_public.active render :layout => false, :content_type => 'text/plain' end def course @course = Project.course_entities @teacher = User.teacher @student = User.student end def contest end def search search_condition = params[:q] search_type = params[:search_type].to_sym unless search_condition.blank? respond_to do |format| format.html{ case search_type when :projects redirect_to projects_search_path(:name => search_condition, :project_type => Project::ProjectType_project) when :courses redirect_to projects_search_path(:name => search_condition, :project_type => Project::ProjectType_course) when :users redirect_to users_search_path(:name => search_condition) when :users_teacher redirect_to users_search_path(:name => search_condition, :role => :teacher) when :users_student redirect_to users_search_path(:name => search_condition, :role => :student) else redirect_to home_path, :alert => l(:label_sumbit_empty) end } end end private # 判断网站的入口,是课程 course 则跳过index去渲染 course 方法 def entry_select_course (course() and render :course and return 0) if request.original_url.match(/course\.trustie\.net/) end def entry_select_contest if request.original_url.match(/contest\.trustie\.net/) contest render :contest, layout: false return 0 end end def entry_select_user if request.original_url.match(/user\.trustie\.net$/) redirect_to(:controller => "users", :action => "index") return 0 end end end