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 %>

- +
@@ -76,6 +76,10 @@
<%= content_tag "span", "#{l(:label_course_brief_introduction)}:", :class => "course-font" %> + <%# desc = course.short_description.nil? ? "" : course.short_description%> + <%= content_tag "div", course.short_description, :class => "brief_introduction", :title => course.short_description %>
diff --git a/app/views/courses/index.html.erb b/app/views/courses/index.html.erb index db94cf6c5..0586262e9 100644 --- a/app/views/courses/index.html.erb +++ b/app/views/courses/index.html.erb @@ -35,6 +35,8 @@
<%if @courses%> <%= render_course_hierarchy(@courses)%> + <%#= render :partial => 'course', :locals => {:course => @courses.first}%> + <%#= "hello".html_safe %> <%end%>
diff --git a/app/views/issues/_list.html.erb b/app/views/issues/_list.html.erb index b36c4b57d..57d8a60cb 100644 --- a/app/views/issues/_list.html.erb +++ b/app/views/issues/_list.html.erb @@ -38,7 +38,7 @@ <% 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 %>