diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
index 152fb059e..d87644e43 100644
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -238,9 +238,9 @@ class AdminController < ApplicationController
#首页定制
def first_page_made
if request.get?
- @first_page = FirstPage.all.first
+ @first_page = FirstPage.where("page_type = 'project'").first
elsif request.post?
- @first_page = FirstPage.all.first
+ @first_page = FirstPage.where("page_type = 'project'").first
@first_page.web_title = params[:web_title]
@first_page.description = params[:description]
@first_page.title = params[:title]
@@ -262,6 +262,68 @@ class AdminController < ApplicationController
end
end
end
+ end
+
+ def course_page_made
+ if request.get?
+ @course_page = FirstPage.where("page_type = 'course'").first
+ @first_page = FirstPage.where("page_type = 'project'").first
+ elsif request.post?
+ @first_page = FirstPage.where("page_type = 'project'").first
+ @course_page = FirstPage.where("page_type = 'course'").first
+ @first_page.web_title = params[:web_title]
+ @course_page.title = params[:course_title]
+ @course_page.description = params[:course_description]
+ if @first_page.save && @course_page.save
+ respond_to do |format|
+ format.html {
+ flash[:notice] = l(:notice_successful_update)
+ redirect_to admin_course_page_made_path
+ }
+ format.api { render_api_ok }
+ end
+ else
+ respond_to do |format|
+ format.html {
+ course_page_made
+ render :action => 'course_page_made'
+ }
+ format.api { render_validation_errors(@first_page) }
+ format.api { render_validation_errors(@course_page) }
+ end
+ end
+ end
+ end
+ def contest_page_made
+ if request.get?
+ @contest_page = FirstPage.where("page_type = 'contest'").first
+ @first_page = FirstPage.where("page_type = 'project'").first
+ elsif request.post?
+ @first_page = FirstPage.where("page_type = 'project'").first
+ @contest_page = FirstPage.where("page_type = 'contest'").first
+ @first_page.web_title = params[:web_title]
+ @contest_page.title = params[:contest_title]
+ @contest_page.description = params[:contest_description]
+ if @first_page.save && @contest_page.save
+ respond_to do |format|
+ format.html {
+ flash[:notice] = l(:notice_successful_update)
+ redirect_to admin_contest_page_made_path
+ }
+ format.api { render_api_ok }
+ end
+ else
+ respond_to do |format|
+ format.html {
+ contest_page_made
+ render :action => 'contest_page_made'
+ }
+ format.api { render_validation_errors(@first_page) }
+ format.api { render_validation_errors(@contest_page) }
+ end
+ end
+ end
end
+
end
diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb
index 0920d2e42..03bca6162 100644
--- a/app/controllers/welcome_controller.rb
+++ b/app/controllers/welcome_controller.rb
@@ -16,12 +16,13 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class WelcomeController < ApplicationController
+ include ApplicationHelper
caches_action :robots
# before_filter :fake, :only => [:index, :course]
before_filter :entry_select, :only => [:index]
def index
- @first_page = FirstPage.all.first
+ @first_page = FirstPage.where("page_type = 'project'").first
end
def robots
@@ -30,6 +31,7 @@ class WelcomeController < ApplicationController
end
def course
+ @course_page = FirstPage.where("page_type = 'course'").first
if params[:school_id]
@school_id = params[:school_id]
elsif User.current.logged? && User.current.user_extensions.school
@@ -41,13 +43,24 @@ class WelcomeController < ApplicationController
def logolink()
+ @course_page = FirstPage.where("page_type = 'course'").first
+ logo = get_avatar?(@course_page)
id = params[:school_id]
logo_link = ""
- if id.nil? and User.current.user_extensions.school.nil?
- logo_link = '/images/transparent.png'
+ if id.nil? && User.current.user_extensions.school.nil?
+ if logo
+ logo_link = url_to_avatar(@course_page)
+ else
+ logo_link = '/images/transparent.png'
+ end
+
else
if id == "0"
- logo_link = '/images/transparent.png'
+ if logo
+ logo_link = url_to_avatar(@course_page)
+ else
+ logo_link = '/images/transparent.png'
+ end
else
if id.nil?
if School.find(User.current.user_extensions.school.id).logo_link.nil?
@@ -66,7 +79,7 @@ class WelcomeController < ApplicationController
def contest
-
+ @contest_page = FirstPage.where("page_type = 'contest'").first
end
def search
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 3f873a64d..b63381903 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -625,7 +625,7 @@ module ApplicationHelper
end
def html_title(*args)
- first_page = FirstPage.all.first
+ first_page = FirstPage.where("page_type = 'project'").first
if args.empty?
title = @html_title || []
title << @project.name if @project
diff --git a/app/views/admin/contest_page_made.html.erb b/app/views/admin/contest_page_made.html.erb
new file mode 100644
index 000000000..b8a86fa4d
--- /dev/null
+++ b/app/views/admin/contest_page_made.html.erb
@@ -0,0 +1,39 @@
+
<%=l(:label_first_page_made)%>
+
+<%= form_tag(:controller => 'admin', :action => 'contest_page_made') do %>
+
+ <%= l(:label_web_title) %>:
+ <%= text_field_tag 'web_title', params[:wbe_title],:value => @first_page.web_title, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
+
+
+
+ <%= link_to l(:label_project_first_page), {:action => 'first_page_made'} %>
+ <%= link_to l(:label_course_first_page), {:action => 'course_page_made'} %>
+ <%= link_to l(:label_contest_first_page), {:action => 'contest_page_made'} , :class => 'selected'%>
+
+
+
+ <%=l(:label_contest_first_page)%>
+
+ <%= l(:label_site_image) %>:
+
+
+ <%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@contest_page} %>
+
+
+ <%= l(:label_site_title) %>:
+ <%= text_field_tag 'contest_title', params[:label_site_title], :value => @contest_page.title,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
+
+
+
+ <%= l(:label_site_description)%>:
+ <%= text_area_tag 'contest_description',@contest_page.description,:rows => 8, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
+
+
+ <%= submit_tag l(:button_save), :class => "small", :name => nil %>
+<% end %>
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/admin/course_page_made.html.erb b/app/views/admin/course_page_made.html.erb
new file mode 100644
index 000000000..4554fb8e0
--- /dev/null
+++ b/app/views/admin/course_page_made.html.erb
@@ -0,0 +1,37 @@
+<%=l(:label_first_page_made)%>
+
+<%= form_tag(:controller => 'admin', :action => 'course_page_made') do %>
+
+ <%= l(:label_web_title) %>:
+ <%= text_field_tag 'web_title', params[:wbe_title],:value => @first_page.web_title, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
+
+
+
+ <%= link_to l(:label_project_first_page), {:action => 'first_page_made'} %>
+ <%= link_to l(:label_course_first_page), {:action => 'course_page_made'}, :class => 'selected' %>
+ <%= link_to l(:label_contest_first_page), {:action => 'contest_page_made'} %>
+
+
+ <%=l(:label_course_first_page)%>
+
+ <%= l(:label_site_image) %>:
+
+
+ <%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@course_page} %>
+
+
+ <%= l(:label_site_title) %>:
+ <%= text_field_tag 'course_title', params[:label_site_title], :value => @course_page.title,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
+
+
+ <%= l(:label_site_description)%>:
+ <%= text_area_tag 'course_description',@course_page.description,:rows => 8, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
+
+
+ <%= submit_tag l(:button_save), :class => "small", :name => nil %>
+<% end %>
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/admin/first_page_made.html.erb b/app/views/admin/first_page_made.html.erb
index 9e863d813..a64bbb443 100644
--- a/app/views/admin/first_page_made.html.erb
+++ b/app/views/admin/first_page_made.html.erb
@@ -1,16 +1,25 @@
<%=l(:label_first_page_made)%>
<%= form_tag(:controller => 'admin', :action => 'first_page_made') do %>
+
+ <%= l(:label_web_title) %>:
+ <%= text_field_tag 'web_title', params[:wbe_title],:value => @first_page.web_title, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
+
+
+
+ <%= link_to l(:label_project_first_page), {:action => 'first_page_made'}, :class => 'selected' %>
+ <%= link_to l(:label_course_first_page), {:action => 'course_page_made'} %>
+ <%= link_to l(:label_contest_first_page), {:action => 'contest_page_made'} %>
+
+
+ <%=l(:label_project_first_page)%>
<%= l(:label_site_image) %>:
<%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@first_page} %>
-
- <%= l(:label_web_title) %>:
- <%= text_field_tag 'web_title', params[:wbe_title],:value => @first_page.web_title, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
-
+
<%= l(:label_site_title) %>:
<%= text_field_tag 'title', params[:label_site_title], :value => @first_page.title,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
@@ -19,6 +28,7 @@
<%= l(:label_site_description)%>:
<%= text_area_tag 'description',@first_page.description,:rows => 8, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
+
<%= submit_tag l(:button_save), :class => "small", :name => nil %>
<% end %>
diff --git a/app/views/admin/project_page_made.html.erb b/app/views/admin/project_page_made.html.erb
new file mode 100644
index 000000000..e338c21a9
--- /dev/null
+++ b/app/views/admin/project_page_made.html.erb
@@ -0,0 +1,31 @@
+
<%=l(:label_first_page_made)%>
+
+<%= form_tag(:controller => 'admin', :action => 'first_page_made') do %>
+
+ <%= l(:label_web_title) %>:
+ <%= text_field_tag 'web_title', params[:wbe_title],:value => @first_page.web_title, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
+
+
<%=l(:label_project_first_page)%>
+
+ <%= l(:label_site_image) %>:
+
+
+ <%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@first_page} %>
+
+
+
+ <%= l(:label_site_title) %>:
+ <%= text_field_tag 'title', params[:label_site_title], :value => @first_page.title,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
+
+
+ <%= l(:label_site_description)%>:
+ <%= text_area_tag 'description',@first_page.description,:rows => 8, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
+
+
+ <%= submit_tag l(:button_save), :class => "small", :name => nil %>
+<% end %>
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/welcome/contest.html.erb b/app/views/welcome/contest.html.erb
index c87cc13e1..c3bd120da 100644
--- a/app/views/welcome/contest.html.erb
+++ b/app/views/welcome/contest.html.erb
@@ -114,12 +114,17 @@
- <%= image_tag '/images/transparent.png', size: "75x75" %>
+ <% if get_avatar?(@contest_page) %>
+ <%= image_tag(url_to_avatar(@contest_page), size: "75x75") %>
+ <% else %>
+ <%= image_tag '/images/transparent.png', size: "75x75" %>
+ <% end %>
-
- <%= l(:label_welcome_trustie) %> <%= l(:label_welcome_trustie_contest) %> , <%= l(:label_welcome_trustie_contest_description) %>
-
+ <% unless @contest_page.nil? %>
+
<%= @contest_page.title %> , <%= @contest_page.description %>
+ <% end %>
+
diff --git a/app/views/welcome/course.html.erb b/app/views/welcome/course.html.erb
index cfde8fca4..f6bffe51c 100644
--- a/app/views/welcome/course.html.erb
+++ b/app/views/welcome/course.html.erb
@@ -51,14 +51,17 @@
<% end %>
<% end %>
<% end %>
- <%= l(:label_welcome_trustie) %><%= l(:label_welcome_trustie_course) %>
+ <% unless @course_page.nil? %>
+ <%= @course_page.title %>
+
<% if @school_id.nil? and User.current.user_extensions.school.nil? %>
- , <%= l(:label_welcome_trustie_course_description) %>
+ , <%= @course_page.description %>
<% else %>
<% if @school_id == "0" %>
- , <%= l(:label_welcome_trustie_course_description) %>
+ , <%= @course_page.description %>
<% end %>
<% end %>
+ <% end %>
<%= render :partial => "search_course", :locals => {:project_type => Project::ProjectType_course} %>
diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb
index ffc9706e9..d1d807207 100644
--- a/app/views/welcome/index.html.erb
+++ b/app/views/welcome/index.html.erb
@@ -42,7 +42,9 @@
+ <% unless @first_page.nil? %>
<%= @first_page.title %> , <%= @first_page.description %>
+ <% end %>
<%= render :partial => "search_project", :locals => {:project_type => 0}%>
diff --git a/config/locales/zh.yml b/config/locales/zh.yml
index 11c9e054a..69af5cd2a 100644
--- a/config/locales/zh.yml
+++ b/config/locales/zh.yml
@@ -516,6 +516,9 @@ zh:
label_project_plural: 项目列表
label_project_score: 项目评分
label_first_page_made: 首页定制
+ label_project_first_page: 项目托管平台首页
+ label_course_first_page: 课程实践平台首页
+ label_contest_first_page: 竞赛实战平台首页
label_x_projects:
zero: 无项目
one: 1 个项目
diff --git a/config/routes.rb b/config/routes.rb
index 7c5f878eb..f6b391108 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -559,6 +559,8 @@ RedmineApp::Application.routes.draw do
match 'admin/projects', :controller => 'admin', :action => 'projects', :via => :get
match 'admin/users', :controller => 'admin', :action => 'users', :via => :get
match 'admin/first_page_made',:controller => 'admin',:action => 'first_page_made',:via => [:get,:post]
+ match 'admin/course_page_made',:controller => 'admin',:action => 'course_page_made',:via => [:get,:post]
+ match 'admin/contest_page_made',:controller => 'admin',:action => 'contest_page_made',:via => [:get,:post]
match 'admin/search', :controller => 'admin', :action => 'search', :via => [:get, :post]
match 'admin/plugins', :controller => 'admin', :action => 'plugins', :via => :get
match 'admin/info', :controller => 'admin', :action => 'info', :via => :get
diff --git a/db/migrate/20140710095123_add_cloumn_to_first_page.rb b/db/migrate/20140710095123_add_cloumn_to_first_page.rb
new file mode 100644
index 000000000..6720a8aa4
--- /dev/null
+++ b/db/migrate/20140710095123_add_cloumn_to_first_page.rb
@@ -0,0 +1,9 @@
+class AddCloumnToFirstPage < ActiveRecord::Migration
+ def change
+ add_column :first_pages,:type,:string
+
+ fr = FirstPage.all.first
+ fr.type = "project"
+ fr.save
+ end
+end
diff --git a/db/migrate/20140711010124_alt_column_name.rb b/db/migrate/20140711010124_alt_column_name.rb
new file mode 100644
index 000000000..24b784765
--- /dev/null
+++ b/db/migrate/20140711010124_alt_column_name.rb
@@ -0,0 +1,5 @@
+class AltColumnName < ActiveRecord::Migration
+ def change
+ rename_column :first_pages,:type,:page_type
+ end
+end
diff --git a/db/migrate/20140711012924_add_contest_and_course_first_page.rb b/db/migrate/20140711012924_add_contest_and_course_first_page.rb
new file mode 100644
index 000000000..801219bd5
--- /dev/null
+++ b/db/migrate/20140711012924_add_contest_and_course_first_page.rb
@@ -0,0 +1,17 @@
+# -*coding:utf-8 -*-
+class AddContestAndCourseFirstPage < ActiveRecord::Migration
+ def change
+ fp = FirstPage.new
+ fp.web_title = ""
+ fp.title = "Trustie在线课程实践平台"
+ fp.description = "面向中国高校教师与大学生,提供社交化的课程管理、资源共享、合作实验、协同研究。"
+ fp.page_type = "course"
+ fp.save
+ fp1 = FirstPage.new
+ fp1.web_title = ""
+ fp1.title = "Trustie在线竞赛实战平台"
+ fp1.description = "面向中国大学生与编程爱好者,提供社交化的竞赛管理、应用管理、代码托管、合作交流。"
+ fp1.page_type = "contest"
+ fp1.save
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index d84c30f9a..8123e15de 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20140710071720) do
+ActiveRecord::Schema.define(:version => 20140711012924) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@@ -412,6 +412,7 @@ ActiveRecord::Schema.define(:version => 20140710071720) do
t.string "description"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
+ t.string "page_type"
end
create_table "forums", :force => true do |t|