diff --git a/Gemfile b/Gemfile index bfc0b773f..7ff3df60c 100644 --- a/Gemfile +++ b/Gemfile @@ -15,6 +15,18 @@ gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby] gem "builder", "3.0.0" gem 'acts-as-taggable-on' +# Gems used only for assets and not required +# in production environments by default. +group :assets do + gem 'sass-rails', '~> 3.2.3' + gem 'coffee-rails', '~> 3.2.1' + + # See https://github.com/sstephenson/execjs#readme for more supported runtimes + # gem 'therubyracer', :platforms => :ruby + + gem 'uglifier', '>= 1.0.3' +end + # Optional gem for LDAP authentication group :ldap do gem "net-ldap", "~> 0.3.1" diff --git a/Gemfile.lock b/Gemfile.lock index 54d89f381..3486c743b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -40,7 +40,16 @@ GEM arel (3.0.2) builder (3.0.0) coderay (1.0.9) + coffee-rails (3.2.2) + coffee-script (>= 2.2.0) + railties (~> 3.2.0) + coffee-script (2.2.0) + coffee-script-source + execjs + coffee-script-source (1.6.1) erubis (2.7.0) + execjs (1.4.0) + multi_json (~> 1.0) fastercsv (1.5.0) hike (1.2.3) i18n (0.6.1) @@ -86,6 +95,11 @@ GEM rdoc (3.12.2) json (~> 1.4) ruby-openid (2.1.8) + sass (3.2.7) + sass-rails (3.2.6) + railties (~> 3.2.0) + sass (>= 3.1.10) + tilt (~> 1.3) sprockets (2.2.2) hike (~> 1.2) multi_json (~> 1.0) @@ -97,6 +111,9 @@ GEM polyglot polyglot (>= 0.3.1) tzinfo (0.3.37) + uglifier (1.0.3) + execjs (>= 0.3.0) + multi_json (>= 1.0.2) PLATFORMS x86-mingw32 @@ -107,6 +124,7 @@ DEPENDENCIES acts-as-taggable-on builder (= 3.0.0) coderay (~> 1.0.6) + coffee-rails (~> 3.2.1) fastercsv (~> 1.5.0) i18n (~> 0.6.0) jquery-rails (~> 2.0.2) @@ -116,4 +134,6 @@ DEPENDENCIES rails (= 3.2.13) rdoc (>= 2.4.2) ruby-openid (~> 2.1.4) + sass-rails (~> 3.2.3) seems_rateable! + uglifier (>= 1.0.3) diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index f96cf66fb..ab3d7b120 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -23,6 +23,7 @@ class AdminController < ApplicationController before_filter :require_admin helper :sort + helper :Users include SortHelper def index @@ -39,6 +40,121 @@ class AdminController < ApplicationController render :action => "projects", :layout => false if request.xhr? end + def users + @project_type = params[:project_type] + role = params[:role] + + sort_init 'login', 'asc' + sort_update %w(login firstname lastname mail admin created_on last_login_on) + + case params[:format] + when 'xml', 'json' + @offset, @limit = api_offset_and_limit({:limit => 15}) + else + @limit = 15#per_page_option + end + + @status = params[:status] || 1 + has = { + "show_changesets" => true + } + # @count = Redmine::Activity::Fetcher.new(User.current, :author => @user).scope_select {|t| !has["show_#{t}"].nil?}.events(nil, nil).count + + scope = UserStatus.visible + case role + when 'teacher' + scope = UserStatus.teacher + when 'student' + scope = UserStatus.student + else + + end + + scope = scope.in_group(params[:group_id]) if params[:group_id].present? + # scope.each do |user| + # UserStatus.create(:changesets_count => user.changesets.count, :watchers_count => user.watcher_users.count, :user_id => user.id) + # end + @user_count = scope.count + @user_pages = Paginator.new @user_count, @limit, params['page'] + #@offset ||= @user_pages.offset + #@users = scope.order(sort_clause).limit(@limit).offset(@offset).all + @user_base_tag = params[:id] ? 'base_users':'base' + if params[:user_sort_type].present? + case params[:user_sort_type] + when '0' + @offset ||= @user_pages.reverse_offset + unless @offset == 0 + @users_statuses = scope.offset(@offset).limit(@limit).all.reverse + else + limit = @user_count % @limit + if limit == 0 + limit = @limit + end + @users_statuses = scope.offset(@offset).limit(limit).all.reverse + end + @s_type = 0 + # @projects = @projects.sort {|x,y| y.created_on <=> x.created_on } + # @projects = @projects[@offset, @limit] + when '1' + @offset ||= @user_pages.reverse_offset + unless @offset == 0 + @users_statuses = scope.reorder('grade').offset(@offset).limit(@limit).all.reverse + else + limit = @user_count % @limit + if limit == 0 + limit = @limit + end + @users_statuses = scope.reorder('grade').offset(@offset).limit(limit).all.reverse + end + @s_type = 1 + #sort {|x,y| y.user_status.changesets_count <=> x.user_status.changesets_count} + #@users = @users[@offset, @limit] + when '2' + @offset ||= @user_pages.reverse_offset + unless @offset == 0 + @users_statuses = scope.reorder('watchers_count').offset(@offset).limit(@limit).all.reverse + else + limit = @user_count % @limit + if limit == 0 + limit = @limit + end + @users_statuses = scope.reorder('watchers_count').offset(@offset).limit(limit).all.reverse + end + @s_type = 2 + #@users = @users[@offset, @limit] + end + + else + @offset ||= @user_pages.reverse_offset + unless @offset == 0 + @users_statuses = scope.reorder('grade').offset(@offset).limit(@limit).all.reverse + else + limit = @user_count % @limit + if limit == 0 + limit = @limit + end + @users_statuses = scope.reorder('grade').offset(@offset).limit(limit).all.reverse + end + @s_type = 1 + # @projects = @projects.sort {|x,y| y.created_on <=> x.created_on } + # @projects = @projects[@offset, @limit] + end + + @users = [] + @users_statuses.each do |obj| + @users << User.find_by_id("#{obj.user_id}") + end + + + respond_to do |format| + format.html { + @groups = Group.all.sort + render :layout => @user_base_tag + } + format.api + end + end + def plugins @plugins = Redmine::Plugin.all end diff --git a/app/controllers/open_source_projects_controller.rb b/app/controllers/open_source_projects_controller.rb index 1ca7ddcef..ee3af10ce 100644 --- a/app/controllers/open_source_projects_controller.rb +++ b/app/controllers/open_source_projects_controller.rb @@ -1,8 +1,8 @@ class OpenSourceProjectsController < ApplicationController - + before_filter :find_osp, :only => [:master_apply, :accept_master_apply, :refuse_master_apply] before_filter :require_master, :only => [:master_apply, :accept_master_apply, :refuse_master_apply] - + helper :sort include SortHelper helper :apply_project_masters @@ -12,6 +12,7 @@ class OpenSourceProjectsController < ApplicationController # GET /open_source_projects # GET /open_source_projects.json def index + @app_dir = params[:app_dir] @language = params[:language] @created_at = params[:created_at] @@ -22,8 +23,10 @@ class OpenSourceProjectsController < ApplicationController @os_project_count = @open_source_projects.count @os_project_pages = Paginator.new @os_project_count, per_page_option, params['page'] - + @open_source_projects = @open_source_projects.offset(@os_project_pages.offset).limit(@os_project_pages.per_page) + + @bugs = BugToOsp.order('created_at desc').limit(8) # @open_source_projects = OpenSourceProject.all @@ -32,11 +35,11 @@ class OpenSourceProjectsController < ApplicationController format.json { render json: @open_source_projects } end end - + def master_apply @apply = @open_source_project.apply_tips @applicants = @open_source_project.applicants - + respond_to do |format| format.html { render :layout => "base_opensource_p" @@ -49,7 +52,7 @@ class OpenSourceProjectsController < ApplicationController # GET /open_source_projects/1.json def show @open_source_project = OpenSourceProject.find(params[:id]) - + sort_init 'updated_at', 'desc' sort_update 'created_at' => "#{RelativeMemo.table_name}.created_at", 'replies' => "#{RelativeMemo.table_name}.replies_count", @@ -63,9 +66,9 @@ class OpenSourceProjectsController < ApplicationController includes(:last_reply). limit(@topic_pages.per_page). offset(@topic_pages.offset). - order(sort_clause). + order(sort_clause). all - + @bugs = @open_source_project.bugs.limit(6) respond_to do |format| @@ -75,26 +78,64 @@ class OpenSourceProjectsController < ApplicationController format.json { render json: @open_source_project } end end + + def allbug + @bugs = BugToOsp.visible + + @bug_count = @bugs.count + @bug_pages = Paginator.new @bug_count, per_page_option, params['page'] + @bugs = @bugs.includes(:bug).reorder("#{RelativeMemo.table_name}.created_at DESC").limit(@bug_pages.per_page).offset(@bug_pages.offset).all + + respond_to do |format| + format.html + format.json { render json: @open_source_project } + end + end + def search -def search - end + def showbug + @open_source_project = OpenSourceProject.find(params[:id]) + + sort_init 'updated_at', 'desc' + sort_update 'created_at' => "#{RelativeMemo.table_name}.created_at", + 'replies' => "#{RelativeMemo.table_name}.replies_count", + 'updated_at' => "COALESCE (last_replies_relative_memos.created_at, #{RelativeMemo.table_name}.created_at)" -# added by yiang 暴力添加,请绕道 -def showmemo - @open_source_project = OpenSourceProject.find(params[:id]) + @memo = RelativeMemo.new(:open_source_project => @open_source_project) + @topic_count = @open_source_project.bugs.count + @topic_pages = Paginator.new @topic_count, per_page_option, params['page'] + @memos = @open_source_project.bugs. + reorder("#{RelativeMemo.table_name}.sticky DESC"). + includes(:last_reply). + limit(@topic_pages.per_page). + offset(@topic_pages.offset). + order(sort_clause). + all - sort_init 'updated_at', 'desc' - sort_update 'created_at' => "#{RelativeMemo.table_name}.created_at", + respond_to do |format| + format.html { + render :layout => "base_opensource_p" + } + format.json { render json: @open_source_project } + end + end + + # added by yiang 暴力添加,请绕道 + def showmemo + @open_source_project = OpenSourceProject.find(params[:id]) + + sort_init 'updated_at', 'desc' + sort_update 'created_at' => "#{RelativeMemo.table_name}.created_at", 'replies' => "#{RelativeMemo.table_name}.replies_count", 'updated_at' => "COALESCE (last_replies_relative_memos.created_at, #{RelativeMemo.table_name}.created_at)" - @memo = RelativeMemo.new(:open_source_project => @open_source_project) - @topic_count = @open_source_project.topics.count - @topic_pages = Paginator.new @topic_count, per_page_option, params['page'] - @memos = @open_source_project.topics. + @memo = RelativeMemo.new(:open_source_project => @open_source_project) + @topic_count = @open_source_project.topics.count + @topic_pages = Paginator.new @topic_count, per_page_option, params['page'] + @memos = @open_source_project.topics. reorder("#{RelativeMemo.table_name}.sticky DESC"). includes(:last_reply). limit(@topic_pages.per_page). @@ -102,13 +143,14 @@ def showmemo order(sort_clause). all - respond_to do |format| - format.html { - render :layout => "base_opensource_p" - } - format.json { render json: @open_source_project } + respond_to do |format| + format.html { + render :layout => "base_opensource_p" + } + format.json { render json: @open_source_project } + end end -end + # GET /open_source_projects/new # GET /open_source_projects/new.json def new @@ -168,52 +210,51 @@ end format.json { head :no_content } end end - + def remove_condition @app_dir = params[:app_dir] @language = params[:language] @created_at = params[:created_at] redirect_to open_source_projects_path(:app_dir => @app_dir, :language => @language, :created_at => @created_at, :name => params[:name]) end - + def search # per_page_option = 10 -# + # # @open_source_projects = OpenSourceProject.filter(@app_dir, @language, @created_at) # @open_source_projects = @open_source_projects.like(params[:name]) if params[:name].present? -# + # # @os_project_count = @open_source_projects.count # @os_project_pages = Paginator.new @os_project_count, per_page_option, params['page'] -# + # # @open_source_projects = @open_source_projects.offset(@os_project_pages.offset).limit(@os_project_pages.per_page) redirect_to open_source_projects_path(:name => params[:name]) end - + def refuse_master_apply @apply = ApplyProjectMaster.where("user_id = ? and apply_id = ? and apply_type = 'OpenSourceProject'", params[:user_id], @open_source_project.id) @apply.first.destory - + redirect_to master_apply_open_source_project_path end - + def accept_master_apply @apply = ApplyProjectMaster.where("user_id = ? and apply_id = ? and apply_type = 'OpenSourceProject'", params[:user_id], @open_source_project.id) if @apply.count == 1 - @apply.first.update_attributes(:status => 2) + @apply.first.update_attributes(:status => 2) end - + redirect_to master_apply_open_source_project_path end - - + private - + def require_master render_403 unless @open_source_project.admin?(User.current) end - + def find_osp @open_source_project = OpenSourceProject.find(params[:id]) render_404 unless @open_source_project.present? diff --git a/app/controllers/test_controller.rb b/app/controllers/test_controller.rb index 0623dbee2..ec3e5cbdb 100644 --- a/app/controllers/test_controller.rb +++ b/app/controllers/test_controller.rb @@ -1,6 +1,9 @@ class TestController < ApplicationController helper :UserScore + layout 'bootstrap_base' + + def bootstrap; end def zip homeworks_attach_path = [] diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 6174e2124..19c84cc33 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -67,7 +67,7 @@ class UsersController < ApplicationController if User.current.admin? @memberships = @user.memberships.all else - cond = Project.visible_condition(User.current) + "AND projects.project_type <> 1" + cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1" @memberships = @user.memberships.all(:conditions => cond) end events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 20) @@ -565,7 +565,7 @@ class UsersController < ApplicationController end def watch_projects - @watch_projects = Project.joins(:watchers).where("project_type <>? and watchable_type = ? and user_id = ?", '1','Project', @user.id) + @watch_projects = Project.joins(:watchers).where("project_type <>? and watchable_type = ? and watchers.user_id = ?", '1','Project', @user.id) @state = 1 respond_to do |format| format.html { @@ -782,7 +782,7 @@ class UsersController < ApplicationController end def setting_layout(default_base='base_users') - User.current.admin? ? 'base_admin' : default_base + User.current.admin? ? default_base : default_base end # 必填自己的工作单位,其实就是学校 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ca946bf7d..fd1f6f162 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1338,9 +1338,22 @@ module ApplicationHelper def hubspot_head tags = javascript_include_tag('hubspot/messenger.min', 'hubspot/messenger-theme-future') tags << stylesheet_link_tag('hubspot/messenger', 'hubspot/messenger-theme-future', 'hubspot/messenger-theme-flat') - unless User.current.pref.warn_on_leaving_unsaved == '0' - tags << "\n".html_safe + javascript_tag("$(window).load(function(){ warnLeavingUnsaved('#{escape_javascript l(:text_warn_on_leaving_unsaved)}'); });") - end + end + + def bootstrap_head + tags = stylesheet_link_tag('bootstrap/bootstrap.min', 'bootstrap/bootstrap-theme.min') + tags << javascript_include_tag('bootstrap/affix') + tags << javascript_include_tag('bootstrap/alert') + tags << javascript_include_tag('bootstrap/button') + tags << javascript_include_tag('bootstrap/carousel') + tags << javascript_include_tag('bootstrap/collapse') + tags << javascript_include_tag('bootstrap/dropdown') + tags << javascript_include_tag('bootstrap/modal') + tags << javascript_include_tag('bootstrap/popover') + tags << javascript_include_tag('bootstrap/scrollspy') + tags << javascript_include_tag('bootstrap/tab') + tags << javascript_include_tag('bootstrap/tooltip') + tags << javascript_include_tag('bootstrap/transition') tags end @@ -1610,6 +1623,13 @@ module ApplicationHelper def render_dynamic_nav home_link = link_to l(:field_homepage), {:controller => 'welcome', :action => 'index'} + home_link = "
  • " << home_link << "
  • " + bootstrap_render_dynamic_nav + content_tag :ul, (home_link.html_safe+bootstrap_render_dynamic_nav) + end + + def bootstrap_render_dynamic_nav + main_course_link = link_to l(:label_course_practice), {:controller => 'welcome', :action => 'index', :host => Setting.course_domain} main_project_link = link_to l(:label_project_deposit), {:controller => 'welcome', :action => 'index', :host => Setting.project_domain} main_contest_link = link_to l(:label_contest_innovate), {:controller => 'welcome', :action => 'index', :host => Setting.contest_domain} @@ -1630,7 +1650,6 @@ module ApplicationHelper #@nav_dispaly_project_label nav_list = Array.new - nav_list.push(home_link) if !@nav_dispaly_home_path_label nav_list.push(school_all_school_link) if @nav_dispaly_course_all_label nav_list.push(course_all_course_link) if @nav_dispaly_course_all_label nav_list.push(course_teacher_all_link) if @nav_dispaly_teacher_all_label @@ -1651,7 +1670,7 @@ module ApplicationHelper nav_list.collect do |nav_item| content_li << content_tag(:li, nav_item) end - content_tag :ul, content_li.html_safe + content_li.html_safe end def current_user @@ -1666,5 +1685,20 @@ module ApplicationHelper # end # end # end + + def footer_logo(ul_class=nil, li_class=nil) + logos = [] + logos.push(link_to image_tag('/images/footer_logo/nudt.png',:alt=>"nudt"),"http://www.nudt.edu.cn/special.asp?classid=12" ) + logos.push(link_to image_tag('/images/footer_logo/peking_eecs.png', :alt=>"peking_eecs"), "http://eecs.pku.edu.cn" ) + logos.push(link_to image_tag('/images/footer_logo/buaa_scse.png', :alt=>"buaa_scse"), "http://scse.buaa.edu.cn/" ) + logos.push(link_to image_tag('/images/footer_logo/iscas.png', :alt=>"iscas"), "http://www.iscas.ac.cn" ) + logos.push(link_to image_tag('/images/footer_logo/inforbus.png', :alt=>"inforbus"), "http://www.inforbus.com" ) + + logos.collect! { |logo| + content_tag(:li, logo.html_safe, :class => li_class.to_s) + } + + content_tag(:ul, logos.join("").html_safe, :class => ul_class.to_s).html_safe + end end diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 23351d919..5e7f7c18c 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -59,12 +59,11 @@ module IssuesHelper def issue_heading(issue) #h("#{issue.tracker} ##{issue.id}") - #h("#{issue.tracker} #{issue.source_from}") + # h("#{issue.tracker} #{issue.source_from}") s = '' - s << ">>" - s << link_to(@issue.project.name+l(:issue_list), project_issues_path(@issue.project)) - s << " >" - s << @issue.source_from + s << link_to(@issue.project.name, project_issues_path(@issue.project)) + s << " > #" + s << @issue.project_index s.html_safe end diff --git a/app/helpers/open_source_projects_helper.rb b/app/helpers/open_source_projects_helper.rb index f1c1cd35e..dfc7cc8d0 100644 --- a/app/helpers/open_source_projects_helper.rb +++ b/app/helpers/open_source_projects_helper.rb @@ -46,4 +46,12 @@ module OpenSourceProjectsHelper end description end + + def show_description_of_bug(bug) + description = bug.description + if description.nil? || description == '' + description = bug.open_source_project.name + l(:label_bug) + end + description + end end diff --git a/app/models/bug_to_osp.rb b/app/models/bug_to_osp.rb index 5471bd3f9..9cd1d7359 100644 --- a/app/models/bug_to_osp.rb +++ b/app/models/bug_to_osp.rb @@ -5,4 +5,8 @@ class BugToOsp < ActiveRecord::Base validates_presence_of :osp_id, :relative_memo_id + scope :visible, lambda {|*args| + nil + } + end diff --git a/app/models/issue.rb b/app/models/issue.rb index d2332350a..7e899eafc 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -1156,7 +1156,11 @@ class Issue < ActiveRecord::Base # back string obj which is belong to project. def source_from "" << self.project.name.to_s << - "#" << (self.project.issues.index(self).to_i + 1).to_s + "#" << project_index + end + + def project_index + (self.project.issues.index(self).to_i + 1).to_s end private diff --git a/app/models/relative_memo.rb b/app/models/relative_memo.rb index 073d1ca12..f087fce2b 100644 --- a/app/models/relative_memo.rb +++ b/app/models/relative_memo.rb @@ -70,6 +70,11 @@ class RelativeMemo < ActiveRecord::Base def cannot_reply_to_locked_topic errors.add :base, l(:label_memo_locked) if root.locked? && self != root end + + def short_content(length = 25) + str = "^(.{,#{length}})[^\n\r]*.*$" + content.gsub(Regexp.new(str), '\1...').strip if content + end # def update_memos_forum # if forum_id_changed? diff --git a/app/views/admin/users.html.erb b/app/views/admin/users.html.erb new file mode 100644 index 000000000..779316469 --- /dev/null +++ b/app/views/admin/users.html.erb @@ -0,0 +1,69 @@ +<% if User.current.admin? %> +
    + <%= link_to l(:label_user_new), new_user_path, :class => 'icon icon-add' %> +
    + +

    <%= l(:label_user_plural)%>

    + + <%= form_tag(:controller => 'users', :action => 'search', :method => :get) do %> +
    + + <%= l(:label_filter_plural) %> + + + <%= select_tag 'status', users_status_options_for_select(@status), :class => "small", :onchange => "this.form.submit(); return false;" %> + + <% if @groups.present? %> + + <%= select_tag 'group_id', content_tag('option') + options_from_collection_for_select(@groups, :id, :name, params[:group_id].to_i), :onchange => "this.form.submit(); return false;" %> + <% end %> + + + <%= text_field_tag 'name', params[:name], :size => 30 %> + <%= submit_tag l(:label_search), :class => "small", :name => nil %> +
    + <% end %> +   + +
    + + + + <%= sort_header_tag('login', :caption => l(:field_login)) %> + <%= sort_header_tag('firstname', :caption => l(:field_firstname)) %> + <%= sort_header_tag('lastname', :caption => l(:field_lastname)) %> + <%= sort_header_tag('mail', :caption => l(:field_mail)) %> + + <%= sort_header_tag('admin', :caption => l(:field_admin), :default_order => 'desc') %> + <%= sort_header_tag('created_on', :caption => l(:field_created_on), :default_order => 'desc') %> + <%= sort_header_tag('last_login_on', :caption => l(:field_last_login_on), :default_order => 'desc') %> + + + + + <% for user in @users -%> + "> + + + + + + + + + + <% end -%> + +
    <%= avatar(user, :size => "14") %><%= link_to h(user.login), edit_user_path(user) %><%= h(user.firstname) %><%= h(user.lastname) %><%= checked_image user.admin? %><%= format_time(user.created_on) %> <%= change_status_link(user) %> + <%= delete_link user_path(user, :back_url => users_path(params)) unless User.current == user %>
    +
    + + + <% html_title(l(:label_user_plural)) -%> +<%else %> + +<% end%> \ No newline at end of file diff --git a/app/views/attachments/_form.html.erb b/app/views/attachments/_form.html.erb index bdf65a96f..d568dd63c 100644 --- a/app/views/attachments/_form.html.erb +++ b/app/views/attachments/_form.html.erb @@ -6,7 +6,7 @@ <%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 255, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") + link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') %> - <%= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %> + <%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %> <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> <% end %> diff --git a/app/views/layouts/_bootstrap_base_footer.html.erb b/app/views/layouts/_bootstrap_base_footer.html.erb new file mode 100644 index 000000000..2bda28bdd --- /dev/null +++ b/app/views/layouts/_bootstrap_base_footer.html.erb @@ -0,0 +1,20 @@ +
    + \ No newline at end of file diff --git a/app/views/layouts/_bootstrap_base_header.html.erb b/app/views/layouts/_bootstrap_base_header.html.erb new file mode 100644 index 000000000..8c2d26c54 --- /dev/null +++ b/app/views/layouts/_bootstrap_base_header.html.erb @@ -0,0 +1,82 @@ +<% +request.headers['REQUEST_URI'] = "" if request.headers['REQUEST_URI'].nil? +realUrl = request.original_url +if (realUrl.match(/forge\.trustie\.net\/*/)) + @nav_dispaly_project_label = 1 + @nav_dispaly_forum_label = 1 +elsif (realUrl.match(/course\.trustie\.net\/*/)) + @nav_dispaly_course_all_label = 1 + @nav_dispaly_forum_label = 1 + @nav_dispaly_course_label = nil + @nav_dispaly_store_all_label = 1 +elsif (realUrl.match(/user\.trustie\.net\/*/)) + @nav_dispaly_home_path_label = 1 + @nav_dispaly_main_course_label = 1 + @nav_dispaly_main_project_label = 1 + @nav_dispaly_main_contest_label = 1 +elsif (realUrl.match(/contest\.trustie\.net\/*/)) + @nav_dispaly_contest_label = 1 + @nav_dispaly_store_all_label = 1 +else + @nav_dispaly_project_all_label = 1 + @nav_dispaly_course_all_label = 1 + @nav_dispaly_forum_label = 1 + @nav_dispaly_bid_label = 1 + @nav_dispaly_contest_label = 1 + @nav_dispaly_store_all_label = 1 +end +%> + + + diff --git a/app/views/layouts/bootstrap_base.html.erb b/app/views/layouts/bootstrap_base.html.erb new file mode 100644 index 000000000..040857df4 --- /dev/null +++ b/app/views/layouts/bootstrap_base.html.erb @@ -0,0 +1,34 @@ + + + + + <%= h html_title %> + + + + <%= csrf_meta_tag %> + <%= favicon %> + <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'bootstrap_custom.css', :media => 'all' %> + <%= javascript_heads %> + <%#= javascript_include_tag "jquery.leanModal.min" %> + <%= bootstrap_head %> + <%= javascript_include_tag 'gas' %> + <%= yield :header_tags -%> + + + <%= render :partial => 'layouts/bootstrap_base_header' %> +
    + <%= render_flash_messages %> + <%= yield %> +
    + + + + + + + + + <%= render :partial => 'layouts/bootstrap_base_footer' %> + + diff --git a/app/views/open_source_projects/_show_bug.html.erb b/app/views/open_source_projects/_show_bug.html.erb new file mode 100644 index 000000000..43ea2eac7 --- /dev/null +++ b/app/views/open_source_projects/_show_bug.html.erb @@ -0,0 +1,80 @@ + + + +
    + 共有 <%= link_to @topic_count %> 个贴子 +
    +
    + <% if memos.any? %> + <% memos.each do |topic| %> + + + + + + +
    <%= link_to image_tag(url_to_avatar(topic.author), :class => "avatar"), user_path(topic.author) if topic.author%> + <%= image_tag('../images/avatars/User/0', :class => "avatar") unless topic.author%> + + + + + + + + + + + + + + + + + + + +
    + <% if topic.url.nil? || topic.url == '' %> + <%= link_to h(topic.subject), open_source_project_relative_memo_path(open_source_project, topic) %> + <% else %> + <%= link_to h(topic.subject), topic.url, :target => '_blank' %> + <% end %> + + + + + + + +
    <%= link_to (topic.replies_count), topic.url, :target => '_blank' %>
    回帖
    + + + + + + + +
    <%= link_to (topic.viewed_count_crawl+topic.viewed_count_local), topic.url, :target => '_blank' %>
    关注
    + + + + + + + +
    <%= link_to (topic.viewed_count_crawl+topic.viewed_count_local), topic.url, :target => '_blank' %>
    浏览
    <%= topic.short_content(70) %>
    <%= user_url_and_time topic.username, topic.userhomeurl, topic.created_at %> +
    +
    帖子来源:<%=link_to topic.topic_resource, topic.url, :target => '_blank' %> + <%= no_use_link(topic, User.current) %>
    + + <% end %> + + <% else %> +

    + <%= l(:label_no_data) %> +

    + <% end %> +
    \ No newline at end of file diff --git a/app/views/open_source_projects/_show_memo.html.erb b/app/views/open_source_projects/_show_memo.html.erb index 63de42132..6633ccd75 100644 --- a/app/views/open_source_projects/_show_memo.html.erb +++ b/app/views/open_source_projects/_show_memo.html.erb @@ -2,7 +2,7 @@
    - 共有 <%= link_to memos.count %> 个贴子 共有 <%= link_to @topic_count %> 个贴子
    <% if memos.any? %> @@ -18,12 +18,12 @@ <% if topic.url.nil? || topic.url == '' %> <%= link_to h(topic.subject), open_source_project_relative_memo_path(open_source_project, topic) %> <% else %> - <%= link_to h(topic.subject), topic.url %> + <%= link_to h(topic.subject), topic.url, :target => '_blank' %> <% end %> - + @@ -33,7 +33,7 @@
    <%= link_to (topic.replies_count), open_source_project_relative_memo_path(open_source_project, topic) %><%= link_to (topic.replies_count), topic.url, :target => '_blank' %>
    回帖 - + @@ -43,7 +43,7 @@ - + - - - diff --git a/app/views/open_source_projects/_show_topics.html.erb b/app/views/open_source_projects/_show_topics.html.erb index 3ba463944..38f689244 100644 --- a/app/views/open_source_projects/_show_topics.html.erb +++ b/app/views/open_source_projects/_show_topics.html.erb @@ -5,12 +5,13 @@ - + <%= javascript_include_tag "ichart.1.2.min" %> <%= stylesheet_link_tag "sec-analysis.css" %> <%= stylesheet_link_tag "buglist-ichart.css" %> <%= stylesheet_link_tag "buglist.css" %> +
    @@ -20,33 +21,63 @@
    -

    项目安全态势

    <%= link_to "更多 >>", :controller => "open_source_projects",:action => "showmemo", :id => @open_source_project.id %>
    -
    -
    -
      - <% @bugs.each do |bug| %> -
    • >[<%= show_description(bug, open_source_project) %>]<%= link_to bug.subject, bug.url %>
    • - <% end %> +

      项目安全态势

      <%= link_to "更多 >>", :controller => "open_source_projects",:action => "showbug", :id => @open_source_project.id %>
      - +<% if @open_source_project.id ==42 then %> + +
      + +Tags + +聚焦: +
      栈溢出
      +
      远程权限
      +
      框架安全
      - +
      - +<% elsif @open_source_project.id ==70 then %> - +
      + +Tags + +聚焦: +
      Kernel安全
      +
      函数漏洞
      +
      ping_init_sock()
      +
      - +<% elsif @open_source_project.id ==17 then %> - +
      + +Tags + +聚焦: +
      Heartbleed
      +
      致命漏洞
      +
      - +<% elsif @open_source_project.id ==55 then %> - +
      + +Tags + +聚焦: +
      DDos攻击
      +
      信息泄露
      +
      - +<%end%> - +
      +
      +
        + <% @bugs.each do |bug| %> +
      • >[<%= show_description(bug, open_source_project) %>]<%= link_to bug.subject, bug.url, :target => '_blank' %>
      • + <% end %>
    @@ -61,8 +92,6 @@ // t.push(Math.floor(Math.random()*(30+((i%12)*5)))+10); } - - var data = [ { name :'', @@ -127,7 +156,7 @@ parseText:function(tip,name,value,text,i){ return name+"漏洞数:"+value; } - } , + } }, tipMocker:function(tips,i){ @@ -143,18 +172,7 @@ labels[index]+" "+//日期 ((i%12)==0?"1 月":((i%12+1))+"月")+ //时间 "
    "+tips.join("
    "); - }, - - // legend : { - // enable : true, - // row:1,//设置在一行上显示,与column配合使用 - // column : 'max', - // valign:'top', - // sign:'bar', - // background_color:null,//设置透明背景 - // offsetx:-80,//设置x轴偏移,满足位置需要 - // border : true - // }, + }, crosshair:{ enable:true, //十字交叉线 line_color:'#62bce9' @@ -194,8 +212,7 @@ start_scale:0, scale_space:50, end_scale:70, - scale_color:'#9f9f9f', - // label : {color:'#ffffff',fontsize:11}, + scale_color:'#9f9f9f' },{ position:'bottom', @@ -203,35 +220,10 @@ }] } }); - //开始画图 - /** -*自定义组件,画平均线。 -*/ -// line.plugin(new iChart.Custom({ -// drawFn:function(){ -// /** -// *计算平均值的高度(坐标Y值) -// *计算高度还不会! 会划线了! -// */ -// // var avg = line.total/5, -// // coo = line.getCoordinate(), -// // x = coo.get('originx'), -// // W = coo.width, -// // S = coo.getScale('left'), -// // H = coo.height, -// // h = (avg - S.start) * H / S.distance, -// // y = line.y + H - h; -// line.target.line(28,97,400,97,2,'#b32c0d') -// .textAlign('start') -// .textBaseline('middle') -// .textFont('600 12px Verdana'); -// } -// })); line.draw(); }); - //]]> @@ -282,10 +274,7 @@ // t.push(Math.floor(Math.random()*(30+((i%12)*5)))+10); } - - - - var data = [ + var data = [ { name : '', value:flow, @@ -297,16 +286,9 @@ //创建x轴标签文本 var date = new Date() - var labels = []; - /* labels.push(date.getFullYear()-2); - labels.push(date.getFullYear()-1); - labels.push(date.getFullYear()); - labels.push(date.getFullYear()+1);*/ labels=["2012","","","","","","","","","","","","2013","","","","","","","","","","","","2014","","","",""]; - - var line = new iChart.LineBasic2D({ render : 'canvasDiv2', data: data, @@ -352,7 +334,7 @@ parseText:function(tip,name,value,text,i){ return name+"帖子数:"+value+"万"; } - } , + } }, tipMocker:function(tips,i){ @@ -378,10 +360,9 @@ label:false, //是否显示数值 // hollow_inside:false, smooth : true,//平滑曲线 - point_size:2, // 焦点大小 + point_size:2 // 焦点大小 // point_hollow : true, - - + }, coordinate:{ width:225, // 图表大小 @@ -404,7 +385,7 @@ start_scale:0, scale_space:50, end_scale:70, - scale_color:'#9f9f9f', + scale_color:'#9f9f9f' // label : {color:'#ffffff',fontsize:11}, },{ @@ -435,11 +416,11 @@
    <%= link_to (topic.viewed_count_crawl+topic.viewed_count_local), open_source_project_relative_memo_path(open_source_project, topic) %><%= link_to (topic.viewed_count_crawl+topic.viewed_count_local), topic.url, :target => '_blank' %>
    关注 - + @@ -51,17 +51,16 @@
    <%= link_to (topic.viewed_count_crawl+topic.viewed_count_local), open_source_project_relative_memo_path(open_source_project, topic) %><%= link_to (topic.viewed_count_crawl+topic.viewed_count_local), topic.url, :target => '_blank' %>
    浏览
    <%= user_url_and_time topic.username, topic.userhomeurl, topic.created_at %> + <%= user_url_and_time topic.username, topic.userhomeurl, topic.created_at %>
    帖子来源:<%=link_to 'OSChina', topic.url %> + 帖子来源:<%=link_to 'OSChina', topic.url %> <%= no_use_link(topic, User.current) %>
    - +
    <%= link_to h(topic.subject), topic.url %><%= link_to h(topic.subject), topic.url, :target => '_blank' %> - + @@ -449,7 +430,7 @@ diff --git a/app/views/open_source_projects/allbug.html.erb b/app/views/open_source_projects/allbug.html.erb new file mode 100644 index 000000000..d5c0c2e55 --- /dev/null +++ b/app/views/open_source_projects/allbug.html.erb @@ -0,0 +1,89 @@ + + + + +
    + +
    + 共有 <%= link_to @bug_count %> 个安全贴子 +
    +
    + <% if @bugs.any? %> + <% @bugs.each do |bug| %> + <% topic = bug.bug %> +
    <%= link_to (topic.replies_count), open_source_project_relative_memo_path(open_source_project, topic) %><%= link_to (topic.replies_count), topic.url, :target => '_blank' %>
    回帖 - + @@ -459,7 +440,7 @@ - + - + - -
    <%= link_to (topic.viewed_count_crawl+topic.viewed_count_local), open_source_project_relative_memo_path(open_source_project, topic) %><%= link_to (topic.viewed_count_crawl+topic.viewed_count_local), topic.url, :target => '_blank' %>
    关注 - + @@ -467,17 +448,16 @@
    <%= link_to (topic.viewed_count_crawl+topic.viewed_count_local), open_source_project_relative_memo_path(open_source_project, topic) %><%= link_to (topic.viewed_count_crawl+topic.viewed_count_local), topic.url, :target => '_blank' %>
    浏览
    帖子来源:<%=link_to 'OSChina', topic.url %> + 帖子来源:<%=link_to 'OSChina', topic.url %> <%= no_use_link(topic, User.current) %>
    + + + + + +
    <%= link_to image_tag(url_to_avatar(topic.author), :class => "avatar"), user_path(topic.author) if topic.author%> + <%= image_tag('../images/avatars/User/0', :class => "avatar") unless topic.author%> + + + + + + + + + + + + + + + + + + + + + +
    + <% if topic.url.nil? || topic.url == '' %> + <%= link_to h(topic.subject), open_source_project_relative_memo_path(bug.open_source_project, topic) %> + <% else %> + <%= link_to h(topic.subject), topic.url, :target => '_blank' %> + <% end %> + + + + + + + +
    <%= link_to (topic.replies_count), topic.url, :target => '_blank' %>
    回帖
    + + + + + + + +
    <%= link_to (topic.viewed_count_crawl+topic.viewed_count_local), topic.url, :target => '_blank' %>
    关注
    + + + + + + + +
    <%= link_to (topic.viewed_count_crawl+topic.viewed_count_local), topic.url, :target => '_blank' %>
    浏览
    <%= topic.short_content(100) %>
    <%= user_url_and_time topic.username, topic.userhomeurl, topic.created_at %> +
    +
    帖子来源:<%=link_to topic.topic_resource, topic.url, :target => '_blank' %> +
    + + <% end %> + + <% else %> +

    + <%= l(:label_no_data) %> +

    + <% end %> + + +<%#= render :partial => 'open_source_projects/show_memo', :locals => {:memos => @memos, :open_source_project => @open_source_project} %> + \ No newline at end of file diff --git a/app/views/open_source_projects/index.html.erb b/app/views/open_source_projects/index.html.erb index e51ef4fc1..99e34333f 100644 --- a/app/views/open_source_projects/index.html.erb +++ b/app/views/open_source_projects/index.html.erb @@ -48,7 +48,7 @@ background-position: -266px 3px; } .navigation .icon-search, .navigation .nav-pill-cancle, .navigation .nav-switch-icon, .navigation .nav-topbar .topbar-search .topbar-submit, .navigation .nav-topbar-arror { - background: url(); + /*background: url()*/ } .nav-switch-icon { width: 15px; @@ -129,8 +129,6 @@ li { .nav-search-con{ padding-top: 7px; } - - <%= javascript_include_tag "ichart.1.2.min" %> <%= stylesheet_link_tag "buglist-div-use.css" %> @@ -146,29 +144,13 @@ li {
    -

    软件安全漏洞

    More >>
    +

    软件安全态势

    <%= link_to '更多 >>', allbug_open_source_projects_path %>
    -
    +
    @@ -236,7 +218,7 @@ li { parseText:function(tip,name,value,text,i){ return name+"漏洞数:"+value; } - } , + } }, tipMocker:function(tips,i){ var index; @@ -272,7 +254,7 @@ li { label:false, //是否显示数值 // hollow_inside:false, smooth : true,//平滑曲线 - point_size:2, // 焦点大小 + point_size:2 // 焦点大小 // point_hollow : true, @@ -298,7 +280,7 @@ li { start_scale:0, scale_space:50, end_scale:70, - scale_color:'#9f9f9f', + scale_color:'#9f9f9f' // label : {color:'#ffffff',fontsize:11}, },{ @@ -417,7 +399,7 @@ line.target.line(28,97,400,97,2,'#b32c0d')
    \ No newline at end of file diff --git a/app/views/open_source_projects/showmemo.html.erb b/app/views/open_source_projects/showmemo.html.erb index 387237113..7c3bd5c31 100644 --- a/app/views/open_source_projects/showmemo.html.erb +++ b/app/views/open_source_projects/showmemo.html.erb @@ -51,5 +51,6 @@ :title => l(:button_delete) ) if @forum.destroyable_by?(User.current) %> +
    <%= render :partial => 'open_source_projects/show_memo', :locals => {:memos => @memos, :open_source_project => @open_source_project} %>
    \ No newline at end of file diff --git a/app/views/tags/_tag_name.html.erb b/app/views/tags/_tag_name.html.erb index 297f813df..4891cc233 100644 --- a/app/views/tags/_tag_name.html.erb +++ b/app/views/tags/_tag_name.html.erb @@ -1,100 +1,100 @@ <% @tags = obj.reload.tag_list %> <% if non_list_all and (@tags.size > 0) %> - -<% if @tags.size > Setting.show_tags_length.to_i then %> -<% i = 0 %> + + <% if @tags.size > Setting.show_tags_length.to_i then %> + <% i = 0 %> -<% until i>Setting.show_tags_length.to_i do %> -
    - <%= link_to @tags[i], :controller => "tags",:action => "index",:q => @tags[i],:object_flag => object_flag,:obj_id => obj.id %> -
    -<% i += 1%> -<% end %> + <% until i>Setting.show_tags_length.to_i do %> +
    + <%= link_to @tags[i], :controller => "tags", :action => "index", :q => @tags[i], :object_flag => object_flag, :obj_id => obj.id %> +
    + <% i += 1 %> + <% end %> -<%= link_to l(:label_more_tags),:action => "show",:id => obj.id %> + <%= link_to l(:label_more_tags), :action => "show", :id => obj.id %> -<% else %> + <% else %> -<% @tags.each do |tag| %> -
    - <%= link_to tag,:controller => "tags",:action => "index",:q=>tag,:object_flag => object_flag,:obj_id => obj.id %> -
    -<% end %> + <% @tags.each do |tag| %> +
    + <%= link_to tag, :controller => "tags", :action => "index", :q => tag, :object_flag => object_flag, :obj_id => obj.id %> +
    + <% end %> -<% end %> + <% end %> <% else %> - -<% if @tags.size > 0 %> -<% @tags.each do |tag| %> -
    - <%= link_to tag,:controller => "tags",:action => "index",:q=>tag ,:object_flag => object_flag,:obj_id => obj.id %> - - <% case object_flag %> - <% when '1'%> + + <% if @tags.size > 0 %> + <% @tags.each do |tag| %> +
    + <%= link_to tag, :controller => "tags", :action => "index", :q => tag, :object_flag => object_flag, :obj_id => obj.id %> + + <% case object_flag %> + <% when '1' %> <% if User.current.eql?(obj) %> - <%= link_to 'x',:controller => "tags",:action => "remove_tag",:remote => true,:tag_name => tag, - :taggable_id => obj.id,:taggable_type => object_flag %> + <%= link_to 'x', :controller => "tags", :action => "remove_tag", :remote => true, :tag_name => tag, + :taggable_id => obj.id, :taggable_type => object_flag %> <% end %> <% when '2' %> <% if (ProjectInfo.find_by_project_id(obj.id)).user_id == User.current.id %> - <%= link_to 'x',:controller => "tags",:action => "remove_tag",:remote => true,:tag_name => tag, - :taggable_id => obj.id,:taggable_type => object_flag %> + <%= link_to 'x', :controller => "tags", :action => "remove_tag", :remote => true, :tag_name => tag, + :taggable_id => obj.id, :taggable_type => object_flag %> <% end %> <% when '3' %> <% if (ProjectInfo.find_by_project_id(obj.project_id)).user_id == User.current.id %> - <%= link_to 'x',:controller => "tags",:action => "remove_tag",:remote => true,:tag_name => tag, - :taggable_id => obj.id,:taggable_type => object_flag %> + <%= link_to 'x', :controller => "tags", :action => "remove_tag", :remote => true, :tag_name => tag, + :taggable_id => obj.id, :taggable_type => object_flag %> <% end %> - <% when '4'%> + <% when '4' %> <% if obj.author_id == User.current.id %> - <%= link_to 'x',:controller => "tags",:action => "remove_tag",:remote => true,:tag_name => tag, - :taggable_id => obj.id,:taggable_type => object_flag %> + <%= link_to 'x', :controller => "tags", :action => "remove_tag", :remote => true, :tag_name => tag, + :taggable_id => obj.id, :taggable_type => object_flag %> <% end %> - <% when '6'%> - <% if ( User.current.logged? && - User.current.admin? - # && (@project && User.current.member_of?(@project)) - ) - %> - <%= link_to 'x',:controller => "tags",:action => "remove_tag",:remote => true,:tag_name => tag, - :taggable_id => obj.id,:taggable_type => object_flag %> + <% when '6' %> + <% if (User.current.logged? && + User.current.admin? + # && (@project && User.current.member_of?(@project)) + ) + %> + <%= link_to 'x', :controller => "tags", :action => "remove_tag", :remote => true, :tag_name => tag, + :taggable_id => obj.id, :taggable_type => object_flag %> <% end %> - <% when '7'%> + <% when '7' %> <% if obj.author_id == User.current.id %> - <%= link_to 'x',:controller => "tags",:action => "remove_tag",:remote => true,:tag_name => tag, - :taggable_id => obj.id,:taggable_type => object_flag %> + <%= link_to 'x', :controller => "tags", :action => "remove_tag", :remote => true, :tag_name => tag, + :taggable_id => obj.id, :taggable_type => object_flag %> <% end %> <% end %> -
    -<% end %> -<% else %> - +
    + <% end %> + <% else %> +    <%= l(:label_tags_no) %> -<% end %> + <% end %> <% end %> \ No newline at end of file diff --git a/app/views/test/bootstrap.html.erb b/app/views/test/bootstrap.html.erb new file mode 100644 index 000000000..56c1d11bf --- /dev/null +++ b/app/views/test/bootstrap.html.erb @@ -0,0 +1 @@ +<%= image_tag "http://image227.poco.cn/mypoco/myphoto/20140516/17/5527437020140516173219035.png", class: "img-responsive" %> \ No newline at end of file diff --git a/app/views/test/courselist.html.erb b/app/views/test/courselist.html.erb index 959d6a4be..e11c16fad 100644 --- a/app/views/test/courselist.html.erb +++ b/app/views/test/courselist.html.erb @@ -1,42 +1,54 @@ - -<% @courses.each do |course| %> -
    - <%= course.name %> +
    + Well done! You successfully read this important alert message. +
    +
    + Heads up! This alert needs your attention, but it's not super important. +
    +
    + Warning! Best check yo self, you're not looking too good. +
    +
    + Oh snap! Change a few things up and try submitting again. +
    + +