From 8724b79296a8dc766536bcdb404ce0713474fe4f Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Mon, 11 Aug 2014 13:37:54 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E7=90=86=E9=A1=B5=E9=9D=A2=E4=BB=A3?=
=?UTF-8?q?=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/welcome/_course_list.html.erb | 28 ++++
app/views/welcome/_no_course_title.html.erb | 5 +
app/views/welcome/course.html.erb | 141 +-------------------
3 files changed, 39 insertions(+), 135 deletions(-)
create mode 100644 app/views/welcome/_course_list.html.erb
create mode 100644 app/views/welcome/_no_course_title.html.erb
diff --git a/app/views/welcome/_course_list.html.erb b/app/views/welcome/_course_list.html.erb
new file mode 100644
index 000000000..a72ed1764
--- /dev/null
+++ b/app/views/welcome/_course_list.html.erb
@@ -0,0 +1,28 @@
+<% course_list.map do |course| %>
+
/,"") %>>
+
+ <%= image_tag(get_course_avatar(course), :class => "avatar-4") %>
+
+
+
+
+ <% if (course.school == nil) %>
+
+ <% else %>
+ <%= link_to course.school.name.try(:gsub, /(.+)$/, '\1:'), options={:action => 'course', :school_id => course.school.id}, html_options={:method => 'get'} %>
+ <% end %>
+
+
+ <%= link_to(course.try(:teacher).try(:realname), user_path(course.teacher)) %>
+ <%#=course.try(:teacher).try(:name)%>
+
+
+
+ [<%= get_course_term course %>]
+ <%= link_to(course.name.truncate(30, omission: '...'), course_path(course.id), :class => "d-g-blue d-p-project-name", :title => "#{course.name}") %>
+ (<%= "#{memberCount(course)}人" %>)
+ <% files_count = course.attachments.count.to_s %>
+ (<%= link_to "#{files_count}份", course_files_path(course) %>资料)
+
+
+<% end %>
diff --git a/app/views/welcome/_no_course_title.html.erb b/app/views/welcome/_no_course_title.html.erb
new file mode 100644
index 000000000..7e6e09520
--- /dev/null
+++ b/app/views/welcome/_no_course_title.html.erb
@@ -0,0 +1,5 @@
+
+
+ 该学校未开设任何课程,您可以查看其他学校课程
+
+
\ No newline at end of file
diff --git a/app/views/welcome/course.html.erb b/app/views/welcome/course.html.erb
index c33f846e7..5fa76174c 100644
--- a/app/views/welcome/course.html.erb
+++ b/app/views/welcome/course.html.erb
@@ -88,74 +88,13 @@
<%= link_to "更多>>", {:controller => 'courses', :action => 'index', :school_id => nil} %>
-
<% if User.current.logged? %>
-
-
- 该学校未开设任何课程,您可以查看其他学校课程
-
-
- <% find_all_new_hot_course(9, @school_id).map do |course| %>
- - /,"") %>>
-
- <%= image_tag(get_course_avatar(course), :class => "avatar-4") %>
-
-
-
-
- <% if (course.school == nil) %>
-
- <% else %>
- <%= link_to course.school.name.try(:gsub, /(.+)$/, '\1:'), options={:action => 'course', :school_id => course.school.id}, html_options={:method => 'get'} %>
- <% end %>
-
-
- <%= link_to(course.try(:teacher).try(:realname), user_path(course.teacher)) %>
- <%#=course.try(:teacher).try(:name)%>
-
-
-
- [<%= get_course_term course %>]
- <%= link_to(course.name.truncate(30, omission: '...'), course_path(course.id), :class => "d-g-blue d-p-project-name", :title => "#{course.name}") %>
- (<%= "#{memberCount(course)}人" %>)
- <% files_count = course.attachments.count.to_s %>
- (<%= link_to "#{files_count}份", course_files_path(course) %>资料)
-
-
- <% end %>
+ <%= render "welcome/no_course_title"%>
+ <%= render :partial => 'course_list', :locals => {:course_list => find_all_new_hot_course(9, @school_id)} %>
<% else %>
- <% find_all_new_hot_course(10, @school_id).map do |course| %>
- - /,"") %>>
-
- <%= image_tag(get_course_avatar(course), :class => "avatar-4") %>
-
-
-
-
- <% if (course.school == nil) %>
-
- <% else %>
- <%= link_to course.school.name.try(:gsub, /(.+)$/, '\1:'), options={:action => 'course', :school_id => course.school.id}, html_options={:method => 'get'} %>
- <% end %>
-
-
- <%= link_to(course.try(:teacher).try(:realname), user_path(course.teacher)) %>
- <%#=course.try(:teacher).try(:name)%>
-
-
-
- [<%= get_course_term course %>]
- <%= link_to(course.name.truncate(30, omission: '...'), course_path(course.id), :class => "d-g-blue d-p-project-name", :title => "#{course.name}") %>
- (<%= "#{memberCount(course)}人" %>)
- <% files_count = course.attachments.count.to_s %>
- (<%= link_to "#{files_count}份", course_files_path(course) %>资料)
-
-
- <% end %>
+ <%= render :partial => 'course_list', :locals => {:course_list => find_all_new_hot_course(10, @school_id)} %>
<% end %>
@@ -171,80 +110,12 @@
<% end %>
-
- <% school_course.map do |course| %>
- <% if course.school%>
- - /,"") %>>
-
- <%= image_tag(get_course_avatar(course), :class => "avatar-4") %>
-
-
-
-
- <%= link_to course.school.name.try(:gsub, /(.+)$/, '\1:'), options={:action => 'course', :school_id => course.school.id}, html_options={:method => 'get'} %>
-
-
- <%= link_to(course.try(:teacher).try(:realname), user_path(course.teacher)) %>
-
-
-
- [<%= get_course_term course %>]
- <%= link_to(course.name.truncate(30, omission: '...'), course_path(course.id), :class => "d-g-blue d-p-project-name", :title => "#{course.name}") %>
- (<%= "#{memberCount(course)}人" %>)
- <% files_count = course.attachments.count.to_s %>
- (<%= link_to "#{files_count}份", course_files_path(course) %>资料)
-
-
-
-
- <%end%>
- <% end; reset_cycle %>
+ <%= render :partial => 'course_list', :locals => {:course_list => school_course} %>
<% if school_course.count < 10 %>
-
-
-
-
- 该学校开设课程较少,您可以查看其他学校课程
-
+ <%= render "welcome/no_course_title"%>
- <% find_all_new_hot_course(10 - school_course.count, @school_id).map do |course| %>
- - /,"") %>>
-
- <%= image_tag(get_course_avatar(course), :class => "avatar-4") %>
-
-
-
-
- <% if (course.school == nil) %>
-
- <% else %>
-
- <%= link_to course.school.name.try(:gsub, /(.+)$/, '\1:'), options={:action => 'course', :school_id => course.school.id}, html_options={:method => 'get'} %>
- <% end %>
-
-
- <%= link_to(course.try(:teacher).try(:name), user_path(course.teacher)) %>
-
-
-
- [<%= get_course_term course %>]
- <%= link_to(course.name.truncate(30, omission: '...'), course_path(course.id), :class => "d-g-blue d-p-project-name", :title => "#{course.name}") %>
- (<%= "#{memberCount(course)}人" %> )
- <% files_count = course.attachments.count.to_i.to_s %>
- (<%= link_to "#{files_count}份", course_files_path(course) %>资料)
-
-
- <% end %>
+ <%= render :partial => 'course_list', :locals => {:course_list => find_all_new_hot_course(10 - school_course.count - 1, @school_id)} %>
<% end %>