diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index 0f16a81c6..14395ac0b 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -34,20 +34,20 @@ class ContestsController < ApplicationController case params[:contest_sort_type] when '0' unless @offset == 0 - @contests = @contests.offset(@offset).limit(@limit).all.reverse + @contests = @contests.reorder('contests.commit').offset(@offset).limit(@limit).all.reverse else limit = @contest_count % @limit limit = @limit if limit == 0 - @contests = @contests.offset(@offset).limit(limit).all.reverse + @contests = @contests.reorder('contests.commit').offset(@offset).limit(limit).all.reverse end @s_state = 0 when '1' unless @offset == 0 - @contests = @contests.reorder('contests.commit').offset(@offset).limit(@limit).all.reverse + @contests = @contests.reorder('contests.created_on').offset(@offset).limit(@limit).all.reverse else limit = @contest_count % @limit limit = @limit if limit == 0 - @contests = @contests.reorder('contests.commit').offset(@offset).limit(limit).all.reverse + @contests = @contests.reorder('contests.created_on').offset(@offset).limit(limit).all.reverse end @s_state = 1 when '2' @@ -62,11 +62,11 @@ class ContestsController < ApplicationController end else unless @offset == 0 - @contests = @contests.reorder('contests.commit').offset(@offset).limit(@limit).all.reverse + @contests = @contests.reorder('contests.created_on').offset(@offset).limit(@limit).all.reverse else limit = @contest_count % @limit limit = @limit if limit == 0 - @contests = @contests.reorder('contests.commit').offset(@offset).limit(limit).all.reverse + @contests = @contests.reorder('contests.created_on').offset(@offset).limit(limit).all.reverse end @s_state = 1 end diff --git a/app/controllers/school_controller.rb b/app/controllers/school_controller.rb index 9ef935cf7..5ba6d836b 100644 --- a/app/controllers/school_controller.rb +++ b/app/controllers/school_controller.rb @@ -2,8 +2,30 @@ class SchoolController < ApplicationController before_filter :require_admin, :only => :upload_logo - def upload_logo + def upload + uploaded_io = params[:logo] + school_id = 0 + schools = School.where("name = ?", params[:school]) + + schools.each do |s| + school_id = s.id + end + unless uploaded_io.nil? + File.open(Rails.root.join('public', 'images', 'school', school_id.to_s+'.png'), 'wb') do |file| + file.write(uploaded_io.read) + end + + s1 = School.find(school_id) + s1.logo_link = '/images/school/'+school_id.to_s+'.png' + s1.save + + + end + end + + def upload_logo + end diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 5e8eef074..710b73194 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -39,8 +39,35 @@ class WelcomeController < ApplicationController @courseCount = Project.course_entities.count @teacherCount = User.teacher.count @studentCount = User.student.count + @logoLink = logolink(params[:school_id]) end + + + def logolink(id) + logo_link = "" + if id.nil? and User.current.user_extensions.school.nil? + logo_link = '/images/transparent.png' + else + if id.to_i == 0 + logo_link = '/images/transparent.png' + else + if id.nil? + if School.find(User.current.user_extensions.school.id).logo_link.nil? + logo_link = '/images/transparent.png' + else + logo_link = School.find(User.current.user_extensions.school.id).logo_link + end + else + logo_link = School.find(id).logo_link + + end + end + end + return logo_link + end + + def contest end diff --git a/app/helpers/contests_helper.rb b/app/helpers/contests_helper.rb index cb4d6a0f7..36f2351cb 100644 --- a/app/helpers/contests_helper.rb +++ b/app/helpers/contests_helper.rb @@ -62,12 +62,12 @@ module ContestsHelper content = ''.html_safe case state when 0 - content << content_tag('li', link_to(l(:label_sort_by_active), {controller: 'contests', action: 'index' ,:contest_sort_type => '1'})) - content << content_tag('li', link_to(l(:label_sort_by_time), {controller: 'contests', action: 'index' ,:contest_sort_type => '0'}, :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_time), {controller: 'contests', action: 'index' ,:contest_sort_type => '1'})) + content << content_tag('li', link_to(l(:label_sort_by_active), {controller: 'contests', action: 'index' ,:contest_sort_type => '0'}, :class=>"selected"), :class=>"selected") when 1 - content << content_tag('li', link_to(l(:label_sort_by_active), {controller: 'contests', action: 'index' ,:contest_sort_type => '1'}, :class=>"selected"), :class=>"selected") - content << content_tag('li', link_to(l(:label_sort_by_time), {controller: 'contests', action: 'index' ,:contest_sort_type => '0'})) + content << content_tag('li', link_to(l(:label_sort_by_time), {controller: 'contests', action: 'index' ,:contest_sort_type => '1'}, :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_active), {controller: 'contests', action: 'index' ,:contest_sort_type => '0'})) end content = content_tag('ul', content) content_tag('div', content, :class => "tabs") diff --git a/app/views/contests/_contest_list.html.erb b/app/views/contests/_contest_list.html.erb index fb3ddd115..6ffac831e 100644 --- a/app/views/contests/_contest_list.html.erb +++ b/app/views/contests/_contest_list.html.erb @@ -13,7 +13,7 @@ diff --git a/app/views/layouts/_base_footer.html.erb b/app/views/layouts/_base_footer.html.erb index 5ef65ed72..9df56ee2f 100644 --- a/app/views/layouts/_base_footer.html.erb +++ b/app/views/layouts/_base_footer.html.erb @@ -1,31 +1,31 @@
-
diff --git a/app/views/school/upload_logo.html.erb b/app/views/school/upload_logo.html.erb index ecad26f59..97a3f171c 100644 --- a/app/views/school/upload_logo.html.erb +++ b/app/views/school/upload_logo.html.erb @@ -1 +1,5 @@ - +<%= form_tag({action: :upload},method: "post", multipart: true) do %> + <%= text_field_tag 'school'%> + <%= file_field_tag 'logo' %> + <%= submit_tag('Upload') %> +<% end %> diff --git a/app/views/welcome/course.html.erb b/app/views/welcome/course.html.erb index c91b3e453..8ad0cd6bf 100644 --- a/app/views/welcome/course.html.erb +++ b/app/views/welcome/course.html.erb @@ -1,22 +1,11 @@ <%= stylesheet_link_tag 'welcome' %> - - -
+ <%= image_tag(@logoLink, size:'75x75') %> - - <% if params[:school_id].nil? and User.current.user_extensions.school.nil? %> - <%= image_tag '/images/transparent.png', size: "75x75" %> - <% else%> - <% if params[:school_id] == "0" %> - <%= image_tag '/images/transparent.png', size: "75x75" %> - <% else %> - <% if params[:school_id].nil? %> - <% if School.find(User.current.user_extensions.school.id).logo_link.nil? %> - <%= image_tag '/images/transparent.png', size: "75x75" %> - <% else %> - <%= image_tag(School.find(User.current.user_extensions.school.id).logo_link, size: "75x75") %> - <% end %> -
- <% else %> - <%= image_tag(School.find(params[:school_id]).logo_link, size: "75x75") %> -
- <% end %> - <% end %> - <% end %>
@@ -201,31 +104,6 @@
-
- <%= l(:label_contests_reward_method) %><%= contest.budget%> + <%= l(:label_contests_reward_method) %>:  <%= contest.budget%>
- - - - - - - - - - - - - - -
课程总量: <%#=@course.count%>教师数量: <%#=@teacher.count%>
用户总量: <%#=User.count%>学生数量: <%#=@student.count%>
资源总量: <%#=Attachment.count%> 
- - -

问题和反馈动态 diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index 7a241981a..e41260de1 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -1,22 +1,11 @@ <%= stylesheet_link_tag 'welcome' %> - - -
-
- - - - - - - - -






- -
-
- -
+

diff --git a/config/routes.rb b/config/routes.rb index 3c4510be9..00b2df32f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -588,6 +588,8 @@ RedmineApp::Application.routes.draw do post 'school/search_school/', :to => 'school#search_school' get 'school/search_school/', :to => 'school#search_school' + post 'school/upload', :to => 'school#upload' + ######added by nie match 'tags/show_projects_tags',:to => 'tags#show_projects_tags' ########### added by liuping diff --git a/db/migrate/20140428013546_change_default_logo_for_school.rb b/db/migrate/20140428013546_change_default_logo_for_school.rb new file mode 100644 index 000000000..e3abe0c18 --- /dev/null +++ b/db/migrate/20140428013546_change_default_logo_for_school.rb @@ -0,0 +1,15 @@ +class ChangeDefaultLogoForSchool < ActiveRecord::Migration + def up + execute <<-SQL + UPDATE schools SET logo_link = '/images/school/default.png' + WHERE id <> 117 + SQL + end + + def down + execute <<-SQL + UPDATE schools SET logo_link = '/images/transparent.png' + WHERE id <> 117 + SQL + end +end diff --git a/db/schema.rb b/db/schema.rb index 2f88265cd..fe23a1caa 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 => 20140424072458) do +ActiveRecord::Schema.define(:version => 20140428013546) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -23,15 +23,6 @@ ActiveRecord::Schema.define(:version => 20140424072458) do add_index "activities", ["user_id", "act_type"], :name => "index_activities_on_user_id_and_act_type" add_index "activities", ["user_id"], :name => "index_activities_on_user_id" - create_table "apply_project_masters", :force => true do |t| - t.integer "user_id" - t.string "apply_type" - t.integer "apply_id" - t.integer "status" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - create_table "attachments", :force => true do |t| t.integer "container_id" t.string "container_type", :limit => 30 @@ -71,20 +62,6 @@ ActiveRecord::Schema.define(:version => 20140424072458) do add_index "auth_sources", ["id", "type"], :name => "index_auth_sources_on_id_and_type" - create_table "bak_mentioned", :primary_key => "Id", :force => true do |t| - t.string "this_real_name", :limit => 1000 - t.integer "is_mentioned_in" - t.string "context", :limit => 2000 - end - - add_index "bak_mentioned", ["this_real_name", "is_mentioned_in"], :name => "name_mention", :length => {"this_real_name"=>900, "is_mentioned_in"=>nil} - add_index "bak_mentioned", ["this_real_name"], :name => "this_real_name" - add_index "bak_mentioned", ["this_real_name"], :name => "this_real_name_2" - add_index "bak_mentioned", ["this_real_name"], :name => "this_real_name_3", :length => {"this_real_name"=>900} - add_index "bak_mentioned", ["this_real_name"], :name => "this_real_name_4" - add_index "bak_mentioned", ["this_real_name"], :name => "this_real_name_5" - add_index "bak_mentioned", ["this_real_name"], :name => "this_real_name_6" - create_table "biding_projects", :force => true do |t| t.integer "project_id" t.integer "bid_id" @@ -124,11 +101,6 @@ ActiveRecord::Schema.define(:version => 20140424072458) do add_index "boards", ["last_message_id"], :name => "index_boards_on_last_message_id" add_index "boards", ["project_id"], :name => "boards_project_id" - create_table "categories", :primary_key => "Id", :force => true do |t| - t.integer "proj_id", :default => 0, :null => false - t.text "proj_categories" - end - create_table "changes", :force => true do |t| t.integer "changeset_id", :null => false t.string "action", :limit => 1, :default => "", :null => false @@ -293,14 +265,6 @@ ActiveRecord::Schema.define(:version => 20140424072458) do add_index "documents", ["created_on"], :name => "index_documents_on_created_on" add_index "documents", ["project_id"], :name => "documents_project_id" - create_table "eco_projects", :force => true do |t| - t.integer "proj_id", :default => 0, :null => false - t.integer "eco_proj_id" - t.datetime "date_collected" - end - - add_index "eco_projects", ["proj_id"], :name => "proj_id" - create_table "enabled_modules", :force => true do |t| t.integer "project_id" t.string "name", :null => false @@ -322,137 +286,6 @@ ActiveRecord::Schema.define(:version => 20140424072458) do add_index "enumerations", ["id", "type"], :name => "index_enumerations_on_id_and_type" add_index "enumerations", ["project_id"], :name => "index_enumerations_on_project_id" - create_table "events", :primary_key => "event_id", :force => true do |t| - t.string "job_name" - t.datetime "event_time" - t.string "event_type", :limit => 20 - end - - create_table "fm_article", :force => true do |t| - t.integer "proj_id", :default => 0, :null => false - t.text "article_title", :limit => 16777215 - t.text "article_link", :limit => 16777215 - t.text "article_time", :limit => 16777215 - t.datetime "date_collected" - end - - add_index "fm_article", ["proj_id"], :name => "proj_id" - - create_table "fm_bugtracker_link", :force => true do |t| - t.integer "proj_id", :default => 0, :null => false - t.text "description", :limit => 16777215 - t.datetime "date_collected" - end - - add_index "fm_bugtracker_link", ["proj_id"], :name => "proj_id" - - create_table "fm_datametric_link", :force => true do |t| - t.integer "proj_id", :default => 0, :null => false - t.text "description", :limit => 16777215 - t.datetime "date_collected" - end - - add_index "fm_datametric_link", ["proj_id"], :name => "proj_id" - - create_table "fm_dependency_link", :force => true do |t| - t.integer "proj_id", :default => 0, :null => false - t.text "description", :limit => 16777215 - t.datetime "date_collected" - end - - add_index "fm_dependency_link", ["proj_id"], :name => "proj_id" - - create_table "fm_download_link", :force => true do |t| - t.integer "proj_id", :default => 0, :null => false - t.text "download_link", :limit => 16777215 - t.datetime "date_collected" - end - - add_index "fm_download_link", ["proj_id"], :name => "proj_id" - - create_table "fm_heartbeat", :force => true do |t| - t.integer "proj_id", :default => 0, :null => false - t.float "popularity_score", :limit => 12 - t.float "vitality_score", :limit => 12 - t.integer "subscription" - t.integer "voting_score" - t.integer "voting_count" - t.datetime "date_collected" - end - - add_index "fm_heartbeat", ["proj_id"], :name => "proj_id" - - create_table "fm_license", :force => true do |t| - t.integer "proj_id", :default => 0, :null => false - t.text "description", :limit => 16777215 - t.datetime "date_collected" - end - - add_index "fm_license", ["proj_id"], :name => "proj_id" - - create_table "fm_mailinglist_link", :force => true do |t| - t.integer "proj_id", :default => 0, :null => false - t.text "description", :limit => 16777215 - t.datetime "date_collected" - end - - add_index "fm_mailinglist_link", ["proj_id"], :name => "proj_id" - - create_table "fm_operating_system", :force => true do |t| - t.integer "proj_id", :default => 0, :null => false - t.text "description", :limit => 16777215 - t.datetime "date_collected" - end - - add_index "fm_operating_system", ["proj_id"], :name => "proj_id" - - create_table "fm_programming_language", :force => true do |t| - t.integer "proj_id", :default => 0, :null => false - t.text "description", :limit => 16777215 - t.datetime "date_collected" - end - - add_index "fm_programming_language", ["proj_id"], :name => "proj_id" - - create_table "fm_project_spotlight", :force => true do |t| - t.integer "proj_id", :default => 0, :null => false - t.text "description", :limit => 16777215 - t.text "project_name", :limit => 16777215 - t.text "project_spotlight_link", :limit => 16777215 - t.datetime "date_collected" - end - - add_index "fm_project_spotlight", ["proj_id"], :name => "proj_id" - - create_table "fm_release", :force => true do |t| - t.integer "proj_id", :default => 0, :null => false - t.text "description", :limit => 16777215 - t.text "release_version", :limit => 16777215 - t.text "release_time", :limit => 16777215 - t.text "release_tag", :limit => 16777215 - t.datetime "date_collected" - end - - add_index "fm_release", ["proj_id"], :name => "proj_id" - - create_table "fm_submit", :force => true do |t| - t.integer "proj_id", :default => 0, :null => false - t.text "submitter", :limit => 16777215 - t.text "submitter_link", :limit => 16777215 - t.text "submit_time", :limit => 16777215 - t.datetime "date_collected" - end - - add_index "fm_submit", ["proj_id"], :name => "proj_id" - - create_table "fm_summary", :force => true do |t| - t.integer "proj_id", :default => 0, :null => false - t.text "description", :limit => 16777215 - t.datetime "date_collected" - end - - add_index "fm_summary", ["proj_id"], :name => "proj_id" - create_table "forums", :force => true do |t| t.string "name", :null => false t.string "description", :default => "" @@ -685,22 +518,6 @@ ActiveRecord::Schema.define(:version => 20140424072458) do add_index "news", ["created_on"], :name => "index_news_on_created_on" add_index "news", ["project_id"], :name => "news_project_id" - create_table "no_uses", :force => true do |t| - t.integer "user_id", :null => false - t.string "no_use_type" - t.integer "no_use_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "ohloh_tagged", :force => true do |t| - t.integer "proj_id", :default => 0, :null => false - t.string "description", :limit => 100, :null => false - t.datetime "date_collected" - end - - add_index "ohloh_tagged", ["proj_id"], :name => "proj_id" - create_table "open_id_authentication_associations", :force => true do |t| t.integer "issued" t.integer "lifetime" @@ -716,19 +533,6 @@ ActiveRecord::Schema.define(:version => 20140424072458) do t.string "salt", :null => false end - create_table "open_source_projects", :force => true do |t| - t.string "name" - t.text "description" - t.integer "commit_count", :default => 0 - t.integer "code_line", :default => 0 - t.integer "users_count", :default => 0 - t.date "last_commit_time" - t.string "url" - t.date "date_collected" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - create_table "praise_tread_caches", :force => true do |t| t.integer "object_id", :null => false t.string "object_type" @@ -808,23 +612,6 @@ ActiveRecord::Schema.define(:version => 20140424072458) do add_index "queries", ["project_id"], :name => "index_queries_on_project_id" add_index "queries", ["user_id"], :name => "index_queries_on_user_id" - create_table "relative_memos", :force => true do |t| - t.integer "osp_id", :null => false - t.integer "parent_id" - t.string "subject", :null => false - t.text "content", :null => false - t.integer "author_id" - t.integer "replies_count", :default => 0 - t.integer "last_reply_id" - t.boolean "lock", :default => false - t.boolean "sticky", :default => false - t.boolean "is_quote", :default => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "viewed_count_crawl", :default => 0 - t.integer "viewed_count_local", :default => 0 - end - create_table "repositories", :force => true do |t| t.integer "project_id", :default => 0, :null => false t.string "url", :default => "", :null => false @@ -983,22 +770,6 @@ ActiveRecord::Schema.define(:version => 20140424072458) do add_index "tokens", ["user_id"], :name => "index_tokens_on_user_id" add_index "tokens", ["value"], :name => "tokens_value", :unique => true - create_table "tprojects", :force => true do |t| - t.string "name", :limit => 1000, :default => "0" - t.text "description", :limit => 16777215 - t.string "commit_count", :limit => 100, :default => "0" - t.string "code_line", :limit => 100 - t.string "last_commit_time", :limit => 100 - t.string "url", :limit => 1000 - t.datetime "date_collected" - t.string "created_at", :limit => 100 - t.string "updated_at", :limit => 100 - t.integer "proj_id", :null => false - t.string "user_count", :limit => 100 - end - - add_index "tprojects", ["proj_id"], :name => "proj_id" - create_table "trackers", :force => true do |t| t.string "name", :limit => 30, :default => "", :null => false t.boolean "is_in_chlog", :default => false, :null => false diff --git a/public/images/school/1578.png b/public/images/school/1578.png new file mode 100644 index 000000000..84340ace5 Binary files /dev/null and b/public/images/school/1578.png differ diff --git a/public/images/school/default.png b/public/images/school/default.png new file mode 100644 index 000000000..a6475f70d Binary files /dev/null and b/public/images/school/default.png differ diff --git a/public/javascripts/welcome.js b/public/javascripts/welcome.js new file mode 100644 index 000000000..a0166bb3f --- /dev/null +++ b/public/javascripts/welcome.js @@ -0,0 +1,64 @@ +(function () { + window.onload = function(){ + function fixedBar(id, options){ + var ele = document.getElementById(id); + if(!ele) return; + if(/msie (\d+\.\d+)/i.test(navigator.userAgent)){ + var pageHeight=window.innerHeight; + var d=document; + if(typeof pageHeight!="number"){ + if(document.compatMode=="CSS1Compat"){ + pageHeight=document.documentElement.clientHeight; + }else{ + pageHeight=document.body.clientHeight; + } + } + var ieScrollTop=window.pageYOffset || d.documentElement.scrollTop || d.body.scrollTop; + if(options.addclass) ele.className = options.addclass; + ele.style.position= 'absolute'; + + if(options.show){ + ele.style.top = 0 + "px"; + ele.style.display= 'block'; + } + + window.attachEvent('onscroll' , function (){ + + var ieScrollTop=window.pageYOffset || d.documentElement.scrollTop || d.body.scrollTop; + + ele.style.top = 0 + "px"; + if(options.autoHidden){ + if(ieScrollTop==0){ + ele.style.display="none"; + }else{ + ele.style.display="block"; + } + } + }); + }else{ + var ele = document.getElementById(id); + if(typeof pageHeight!="number"){ + if(document.compatMode=="CSS1Compat"){ + pageHeight=document.documentElement.clientHeight; + }else{ + pageHeight=document.body.clientHeight; + } + } + if(options.show) ele.style.display= 'block'; + ele.style.top = 0 +'px'; + window.addEventListener('scroll',function (){ + if(options.autoHidden){ + if(baidu.page.getScrollTop()==0){ + ele.style.display="none"; + }else{ + ele.style.display="block"; + } + } + },false); + } + } + + fixedBar('backTopBtn' , {autoHidden: true, top : 186}); + fixedBar('identifier-pannel' , {autoHidden: false , top : 956 , show : true}); + } +})(); \ No newline at end of file diff --git a/public/stylesheets/nyan.css b/public/stylesheets/nyan.css index 6ac1966a4..62c47abb2 100644 --- a/public/stylesheets/nyan.css +++ b/public/stylesheets/nyan.css @@ -227,12 +227,14 @@ body { display: none; padding-bottom: 2px; width: 1000px; + height: 500px; z-index: 100; left: 50%; margin-left: -202px; opacity: 1; position: fixed; top: 200px; + overflow: scroll; } #WOpenWindow .school_list{ width:1000px;