diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb
index a728ee6e2..b9f9245c8 100644
--- a/app/controllers/bids_controller.rb
+++ b/app/controllers/bids_controller.rb
@@ -449,7 +449,7 @@ class BidsController < ApplicationController
# 显示作业课程
# add by nwb
def show_courseEx
- if (User.current.logged? && User.current.member_of_course?(@bid.courses.first))
+ if (User.current.logged? && (User.current.member_of_course?(@bid.courses.first) || User.current.admin?))
# flash[:notice] = ""
@membership = User.current.coursememberships.all(:conditions => Course.visible_condition(User.current))
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index daaebe3ca..4f6cb3e95 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -256,8 +256,8 @@ module ApplicationHelper
end
def format_activity_description(text)
- h(truncate(text.to_s, :length => 120).gsub(%r{[\r\n]*<(pre|code)>.*$}m, '...')
- ).gsub(/[\r\n]+/, "
").html_safe
+ h(truncate(text.to_s, :length => 120).gsub(%r{[\r\n]*<(pre|code)>.*$}m, '...')).gsub(/[\r\n]+/, "
").html_safe
+ #h(truncate(text.to_s, :length => 120).gsub(/<\/?.*?>/,"")).html_safe
end
def format_version_name(version)
diff --git a/app/models/course.rb b/app/models/course.rb
index b6974eed0..248f80e0b 100644
--- a/app/models/course.rb
+++ b/app/models/course.rb
@@ -104,7 +104,19 @@ class Course < ActiveRecord::Base
# 课程的短描述信息
def short_description(length = 255)
- description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
+ description.gsub(/<\/?.*?>/,"").html_safe if description
+ #description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
+ end
+
+ def strip_html(html)
+ return html if html.empty? || !html.include?('<')
+ output = ""
+ tokenizer = HTML::Tokenizer.new(html)
+ while token = tokenizer.next
+ node = HTML::Node.parse(nil, 0, 0, token, false)
+ output += token unless (node.kind_of? HTML::Tag) or (token =~ /^/,"").html_safe if description
+ #description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
+ end
+
private :workflow_rule_by_attribute
def done_ratio
@@ -1513,4 +1519,6 @@ class Issue < ActiveRecord::Base
def be_user_score_new_issue
UserScore.project(:post_issue, User.current,self, { issue_id: self.id })
end
+
+
end
diff --git a/app/models/news.rb b/app/models/news.rb
index 9a0f8b75c..66e339291 100644
--- a/app/models/news.rb
+++ b/app/models/news.rb
@@ -74,6 +74,12 @@ class News < ActiveRecord::Base
visible(user).includes([:author, :project]).order("#{News.table_name}.created_on DESC").limit(count).all
end
+ # 新闻的短描述信息
+ def short_description(length = 255)
+ description.gsub(/<\/?.*?>/,"").html_safe if description
+ #description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
+ end
+
private
def add_author_as_watcher
diff --git a/app/models/open_source_project.rb b/app/models/open_source_project.rb
index e3556ce55..2de5966bb 100644
--- a/app/models/open_source_project.rb
+++ b/app/models/open_source_project.rb
@@ -84,7 +84,8 @@ class OpenSourceProject < ActiveRecord::Base
# end
def short_description(length = 255)
- description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
+ #description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
+ description.gsub(/<\/?.*?>/,"").html_safe if description
end
def applied_by?(user)
diff --git a/app/models/project.rb b/app/models/project.rb
index 37ca8f20b..698b1f26a 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -629,7 +629,8 @@ class Project < ActiveRecord::Base
# Returns a short description of the projects (first lines)
def short_description(length = 255)
- description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
+ #description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
+ description.gsub(/<\/?.*?>/,"").html_safe if description
end
def css_classes
diff --git a/app/views/courses/_course.html.erb b/app/views/courses/_course.html.erb
index ef8f37566..6b720229a 100644
--- a/app/views/courses/_course.html.erb
+++ b/app/views/courses/_course.html.erb
@@ -16,7 +16,7 @@
<%= content_tag('span', "#{l(:label_institution_name)}:", :class => "course-font")%>
<% @admin = @course.course_infos%>
<%if @admin&&@admin.first&&@admin.first.user&&@admin.first.user.user_extensions%>
-
+
<% unless @course.teacher.user_extensions.school.nil? %>
<%= link_to @course.teacher.user_extensions.school.try(:name), school_course_list_path(@course.teacher.user_extensions.school) %>
<% end %>
@@ -28,7 +28,7 @@
<%= content_tag('a', @admin.collect{|u| link_to(u.user.lastname+u.user.firstname, user_path(u.user_id))}.join(", ").html_safe) %>
<% end %>
-
+
diff --git a/app/views/school/index.html.erb b/app/views/school/index.html.erb
index a42844ffb..8a5aa5f49 100644
--- a/app/views/school/index.html.erb
+++ b/app/views/school/index.html.erb
@@ -71,7 +71,9 @@
<%= link_to "全部学校",school_index_path %>
- 我的学校
+ <% if User.current.logged? %>
+ 我的学校
+ <% end %>
- 请选择省份:
diff --git a/app/views/users/_course_form.html.erb b/app/views/users/_course_form.html.erb
index f5cada9a8..4d9c58392 100644
--- a/app/views/users/_course_form.html.erb
+++ b/app/views/users/_course_form.html.erb
@@ -32,7 +32,7 @@
- <%= membership.course.description %>
+ <%= membership.course.short_description %>
|
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb
index ec469a5b9..f2fa522cd 100644
--- a/app/views/users/show.html.erb
+++ b/app/views/users/show.html.erb
@@ -26,7 +26,7 @@
<%= text_field_tag 'user', params[:user], :size => 30 %>
- <%= submit_tag l(:label_search_by_user), :class => "small", :name => nil %>
+ <%= submit_tag l(:label_search_by_user), :class => "small", :name => nil %>
|
@@ -51,31 +51,31 @@
<% case e.act_type %>
<% when 'JournalsForMessage' %>
<% if User.current.login == e.user.try(:login) %>
- <%# if e.user_id == act.jour.id %>
- <%= link_to("#{l(:label_i)}", user_path(e.user_id)) %> <%= l(:label_have_feedback) %><%=
- link_to("#{e.act.user.name}", user_path(e.act.user.id)) %><%= l(:label_of_feedback) + l(:label_layouts_feedback) %> |
+ <%# if e.user_id == act.jour.id %>
+ <%= link_to("#{l(:label_i)}", user_path(e.user_id)) %> <%= l(:label_have_feedback) %>
+ <%= link_to("#{e.act.user.name}", user_path(e.act.user.id)) %><%= l(:label_of_feedback) + l(:label_layouts_feedback) %> |
<%# else %>
<%# end %>
<% else %>
- <%= link_to("#{e.user.name}", user_path(e.user_id)) %> <%= l(:label_have_feedback) %><%=
- link_to("#{e.act.user.name}", user_path(e.act.user.id)) %><%= l(:label_of_feedback) + l(:label_layouts_feedback) %> |
+ <%= link_to("#{e.user.name}", user_path(e.user_id)) %> <%= l(:label_have_feedback) %><%=
+ link_to("#{e.act.user.name}", user_path(e.act.user.id)) %><%= l(:label_of_feedback) + l(:label_layouts_feedback) %> |
<% end %>
-
- <%= textilizable act.notes %>
- <%= link_to(l(:label_goto), user_newfeedback_user_path(e.user_id)) %>
-
- |
-
+
+ <%= textilizable act.notes %>
+ <%= link_to(l(:label_goto), user_newfeedback_user_path(e.user_id)) %>
+
+ |
+
-
-
-
- <%=(l(:label_update_time).to_s << ':' << format_time(e.act.created_on)).to_s %>
-
-
- |
-
+
+
+
+ <%=(l(:label_update_time).to_s << ':' << format_time(e.act.created_on)).to_s %>
+
+
+ |
+
<% when 'Bid' %>
<% if act.reward_type ==3 %>
@@ -92,7 +92,7 @@
<% end %>
<% end %>
- <%= h act.description %> |
+ <%= act.description.html_safe %> |
@@ -109,7 +109,7 @@
| <%= link_to(h(e.user), user_path(e.user_id)) %> <%= l(:label_new_activity) %> <%= link_to( l(:label_activity_project)+act.issue.project.name, project_path(act.issue.project.identifier))%> <%= link_to format_activity_title("#{act.issue.tracker} ##{act.issue.id}: #{act.issue.subject}"), {:controller => 'issues', :action => 'show', :id => act.issue.id, :anchor => "change-#{act.id}"} %> |
<% end %>
- <%= h act.notes %> |
+ <%= act.notes.html_safe %> |
@@ -126,7 +126,7 @@
| <%= link_to(h(e.user), user_path(e.user_id)) %> <%= l(:label_new_activity) %> <%= link_to format_activity_title(act.title), {:controller => 'repositories', :action => 'revision', :id => act.repository.project, :repository_id => act.repository.identifier_param, :rev => act.identifier} %> |
<% end %>
- <%= h act.long_comments %> |
+ <%= act.long_comments.html_safe %> |
@@ -145,11 +145,11 @@
|
<%= h act.content.truncate(240, omission: '...') %> |
-
+ |
<%= (l(:label_update_time).to_s << ':' << format_time(e.act.created_on)).to_s %>
-
+
|
<% when 'Principal' %>
@@ -161,8 +161,8 @@
<% end %>
|
-
-
+ |
+
<%= (l(:label_update_time).to_s << ':' << format_time(e.act.created_on)).to_s %>
@@ -177,7 +177,7 @@
| <%= link_to(h(e.user), user_path(e.user_id)) %> <%= l(:label_new_activity) %> <%= link_to format_activity_title("#{l(:label_news)}: #{act.title}"), {:controller => 'news', :action => 'show', :id => act.id} %> |
<% end %>
- <%= h act.description %> |
+ <%= act.description.html_safe %> |
@@ -193,7 +193,7 @@
| <%= link_to(h(e.user), user_path(e.user_id)) %> <%= l(:label_new_activity) %> <%= link_to format_activity_title("#{act.source_from} (#{act.status}): #{act.tracker.name} #{act.subject}"), {:controller => 'issues', :action => 'show', :id => act.id} %> |
<% end %>
- <%= textilizable act.description %> |
+ <%= textilizable(act.description) %> |
@@ -251,7 +251,7 @@
- <%= link_to(h(e.user), user_path(e.user)) %>
+ | <%= link_to(h(e.user), user_path(e.user)) %>
<% if e.instance_of?(JournalsForMessage)%>
<% if e.reply_id == User.current.id%>
<%if e.jour_type == 'Bid'%>
diff --git a/app/views/users/user_activities.html.erb b/app/views/users/user_activities.html.erb
index faea90fd3..2b4cf8819 100644
--- a/app/views/users/user_activities.html.erb
+++ b/app/views/users/user_activities.html.erb
@@ -39,8 +39,9 @@
|
|
- |
+
+
<% end %>
-<% end %>
+<% end %>
<% end %>
diff --git a/app/views/users/user_projects.html.erb b/app/views/users/user_projects.html.erb
index e16700cd1..66ddcaae2 100644
--- a/app/views/users/user_projects.html.erb
+++ b/app/views/users/user_projects.html.erb
@@ -30,7 +30,7 @@
- <%= membership.project.description%>
+ <%= membership.project.short_description%>
|
diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb
index d1d807207..0cc5c5e2a 100644
--- a/app/views/welcome/index.html.erb
+++ b/app/views/welcome/index.html.erb
@@ -62,7 +62,7 @@
<% projects = find_miracle_project(10, 3) %>
<% projects.map do |project| %>
-
+
-
<%= image_tag(get_project_avatar(project), :class => "avatar-4") %>
@@ -73,43 +73,43 @@
(<%= link_to "#{projectCount(project)}人", project_member_path(project) ,:course =>'0' %>)
- ><%=project.description.truncate(50, omission: '...')%>
+ ><%=project.short_description.truncate(50, omission: '...')%>
- <% issue_count = project.issues.count %>
- <% issue_journal_count = project.issue_changes.count %>
- <% issue_score = issue_count * 0.2 %>
- <% issue_journal_score = issue_journal_count * 0.1 %>
- <% finall_issue_score = issue_score + issue_journal_score %>
+ <%# issue_count = project.issues.count %>
+ <%# issue_journal_count = project.issue_changes.count %>
+ <%# issue_score = issue_count * 0.2 %>
+ <%# issue_journal_score = issue_journal_count * 0.1 %>
+ <%# finall_issue_score = issue_score + issue_journal_score %>
- <% new_count = project.news.count %>
- <% new_score = new_count * 0.1 %>
- <% finall_new_score = new_score %>
+ <%# new_count = project.news.count %>
+ <%# new_score = new_count * 0.1 %>
+ <%# finall_new_score = new_score %>
- <% document_count = project.documents.count %>
- <% file_score = document_count * 0.1 %>
- <% finall_file_score = file_score %>
+ <%# document_count = project.documents.count %>
+ <%# file_score = document_count * 0.1 %>
+ <%# finall_file_score = file_score %>
- <% changeset_count = project.changesets.count %>
- <% code_submit_score = changeset_count * 0.3 %>
- <% finall_code_submit_score = code_submit_score %>
+ <%# changeset_count = project.changesets.count %>
+ <%# code_submit_score = changeset_count * 0.3 %>
+ <%# finall_code_submit_score = code_submit_score %>
- <% board_message_count = 0 %>
- <% project.boards.each do |board| %>
- <% board_message_count += board.messages_count %>
- <% end %>
- <% topic_score = board_message_count * 0.1 %>
- <% finall_topic_score = topic_score %>
+ <%# board_message_count = 0 %>
+ <%# project.boards.each do |board| %>
+ <%# board_message_count += board.messages_count %>
+ <%# end %>
+ <%# topic_score = board_message_count * 0.1 %>
+ <%# finall_topic_score = topic_score %>
- <% finall_project_score = finall_issue_score + finall_new_score + finall_file_score + finall_code_submit_score + topic_score %>
- <%= content_tag "span", l(:label_project_score)+ ":" + format("%.2f" , finall_project_score ),
+ <%# finall_project_score = finall_issue_score + finall_new_score + finall_file_score + finall_code_submit_score + topic_score %>
+ <%= content_tag "span", l(:label_project_score)+ ":" + project_score(project),
:style => "cursor: pointer; display: inline-block; float: right; color: #ec6300; ",
:title => "项目得分,综合考虑了项目的各项活动,反映了该项目的活跃程度",
:class => "tooltip",
:id => "tooltip-#{project.id}" %>
-
+
<% end; reset_cycle %>
@@ -122,7 +122,7 @@
<%activities = find_all_activities%>
<% activities.each do |event| %>
-
+
-
<%= image_tag url_to_avatar(event.event_author), :class => "avatar-3" %>
@@ -133,7 +133,7 @@
<%= l(:field_updated_on) %><%= time_tag_welcome event.event_datetime %>前 <%= show_event_reply event %>
-
+
<% end %>