2013-08-01 10:33:49 +08:00
|
|
|
# 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
|
2014-04-04 21:30:40 +08:00
|
|
|
before_filter :fake, :only => [:index, :course]
|
2014-04-01 16:40:55 +08:00
|
|
|
before_filter :entry_select_course, :entry_select_contest, :entry_select_user, :only => [:index]
|
2013-08-11 15:27:34 +08:00
|
|
|
|
2013-08-01 10:33:49 +08:00
|
|
|
def index
|
2014-04-04 16:59:50 +08:00
|
|
|
projectActive = Project.project_entities.active
|
|
|
|
@projectCount = projectActive.count
|
|
|
|
@projectPublicCount = projectActive.all_public.count
|
|
|
|
@projectHidenCount = @projectCount - @projectPublicCount
|
2013-08-01 10:33:49 +08:00
|
|
|
|
2014-04-04 16:59:50 +08:00
|
|
|
@developerCount = User.developer.count
|
2014-04-18 17:57:11 +08:00
|
|
|
@allUsercount = User.count
|
2013-08-01 10:33:49 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def robots
|
|
|
|
@projects = Project.all_public.active
|
|
|
|
render :layout => false, :content_type => 'text/plain'
|
|
|
|
end
|
2013-09-29 19:46:59 +08:00
|
|
|
|
2014-02-22 09:44:14 +08:00
|
|
|
def course
|
2014-04-04 21:30:40 +08:00
|
|
|
@courseCount = Project.course_entities.count
|
|
|
|
@teacherCount = User.teacher.count
|
|
|
|
@studentCount = User.student.count
|
2014-02-22 09:44:14 +08:00
|
|
|
end
|
2014-03-31 10:56:29 +08:00
|
|
|
|
|
|
|
def contest
|
|
|
|
|
|
|
|
end
|
2014-03-01 10:14:01 +08:00
|
|
|
|
2014-03-25 16:53:11 +08:00
|
|
|
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
|
|
|
|
|
2014-03-01 10:14:01 +08:00
|
|
|
private
|
|
|
|
|
|
|
|
# 判断网站的入口,是课程 course 则跳过index去渲染 course 方法
|
2014-03-31 19:26:07 +08:00
|
|
|
def entry_select_course
|
2014-03-01 10:14:01 +08:00
|
|
|
(course() and render :course and return 0) if request.original_url.match(/course\.trustie\.net/)
|
|
|
|
end
|
2013-09-29 19:46:59 +08:00
|
|
|
|
2014-03-31 10:56:29 +08:00
|
|
|
def entry_select_contest
|
|
|
|
if request.original_url.match(/contest\.trustie\.net/)
|
2014-03-31 19:26:07 +08:00
|
|
|
contest
|
2014-04-03 22:15:19 +08:00
|
|
|
render :contest
|
2014-03-31 10:56:29 +08:00
|
|
|
return 0
|
|
|
|
end
|
|
|
|
end
|
2014-04-01 16:40:55 +08:00
|
|
|
|
|
|
|
def entry_select_user
|
2014-04-04 15:24:42 +08:00
|
|
|
if request.original_url.match(/user\.trustie\.net$/)
|
2014-04-01 16:40:55 +08:00
|
|
|
redirect_to(:controller => "users", :action => "index")
|
|
|
|
return 0
|
|
|
|
end
|
|
|
|
end
|
2014-04-04 21:30:40 +08:00
|
|
|
|
|
|
|
def render(*args)
|
|
|
|
_fake if @fake_filter
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def fake
|
|
|
|
@fake_filter = true
|
|
|
|
end
|
2014-04-08 14:53:11 +08:00
|
|
|
|
|
|
|
# 骗子方法
|
2014-04-04 21:30:40 +08:00
|
|
|
def _fake
|
|
|
|
instance_variables.map { |variable|
|
|
|
|
if variable.to_s =~ /Count$/
|
|
|
|
self.instance_variable_set(variable.to_sym,
|
|
|
|
("1" + (self.instance_variable_get(variable.to_sym).to_s)).to_i)
|
|
|
|
end
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2013-08-01 10:33:49 +08:00
|
|
|
end
|