You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

welcome_controller.rb 4.2 kB

13 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
12 years ago
12 years ago
13 years ago
13 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
12 years ago
​
​
12 years ago
12 years ago
​
​
​
​
​
​
​
​
​
​
​
​
12 years ago
12 years ago
​
​
​
12 years ago
​
​
​
12 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
13 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. # Redmine - project management software
  2. # Copyright (C) 2006-2013 Jean-Philippe Lang
  3. #
  4. # This program is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU General Public License
  6. # as published by the Free Software Foundation; either version 2
  7. # of the License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. class WelcomeController < ApplicationController
  18. caches_action :robots
  19. # before_filter :fake, :only => [:index, :course]
  20. before_filter :entry_select, :only => [:index]
  21. def index
  22. end
  23. def robots
  24. @projects = Project.all_public.active
  25. render :layout => false, :content_type => 'text/plain'
  26. end
  27. def course
  28. @logoLink ||= logolink()
  29. end
  30. def logolink()
  31. id = params[:school_id]
  32. logo_link = ""
  33. if id.nil? and User.current.user_extensions.school.nil?
  34. logo_link = '/images/transparent.png'
  35. else
  36. if id == "0"
  37. logo_link = '/images/transparent.png'
  38. else
  39. if id.nil?
  40. if School.find(User.current.user_extensions.school.id).logo_link.nil?
  41. logo_link = '/images/transparent.png'
  42. else
  43. logo_link = School.find(User.current.user_extensions.school.id).logo_link
  44. end
  45. else
  46. logo_link = School.find(id).logo_link
  47. end
  48. end
  49. end
  50. return logo_link
  51. end
  52. def contest
  53. end
  54. def search
  55. search_condition = params[:q]
  56. search_type = params[:search_type].to_sym unless search_condition.blank?
  57. respond_to do |format|
  58. format.html{
  59. case search_type
  60. when :projects
  61. redirect_to projects_search_path(:name => search_condition,
  62. :project_type => Project::ProjectType_project)
  63. when :courses
  64. redirect_to projects_search_path(:name => search_condition,
  65. :project_type => Project::ProjectType_course)
  66. when :users
  67. redirect_to users_search_path(:name => search_condition)
  68. when :users_teacher
  69. redirect_to users_search_path(:name => search_condition, :role => :teacher)
  70. when :users_student
  71. redirect_to users_search_path(:name => search_condition, :role => :student)
  72. else
  73. redirect_to home_path, :alert => l(:label_sumbit_empty)
  74. end
  75. }
  76. end
  77. end
  78. private
  79. def entry_select
  80. url = request.original_url
  81. if url.include?("course.trustie.net")
  82. course
  83. render :course
  84. return 0
  85. elsif url.include?("contest.trustie.net")
  86. contest
  87. render :contest
  88. return 0
  89. elsif url.include?("user.trustie.net")
  90. redirect_to(:controller => "users", :action => "index")
  91. end
  92. end
  93. # 判断网站的入口,是课程 course 则跳过index去渲染 course 方法
  94. def entry_select_course
  95. if request.original_url.match(/course\.trustie\.net/)
  96. (course() and render :course and return 0)
  97. end
  98. end
  99. def entry_select_contest
  100. if request.original_url.match(/contest\.trustie\.net/)
  101. contest
  102. render :contest
  103. return 0
  104. end
  105. end
  106. def entry_select_user
  107. if request.original_url.match(/user\.trustie\.net$/)
  108. redirect_to(:controller => "users", :action => "index")
  109. return 0
  110. end
  111. end
  112. # def render(*args)
  113. # _fake if @fake_filter
  114. # super
  115. # end
  116. # private
  117. # def fake
  118. # @fake_filter = true
  119. # end
  120. # # 骗子方法
  121. # def _fake
  122. # instance_variables.map { |variable|
  123. # if variable.to_s =~ /Count$/
  124. # self.instance_variable_set(variable.to_sym,
  125. # ("1" + (self.instance_variable_get(variable.to_sym).to_s)).to_i)
  126. # end
  127. # }
  128. # end
  129. end

软件技术创新是当今国家整体创新能力的重要基础和发展引擎。近年来,大众参与的软件创新与创业活动已经成为网络时代软件开发和应用的新形态,正在快速改变着全球软件创新模式和软件产业格局。 ...