Permalink
Browse files

实现通讯功能

  • Loading branch information...
1 parent 8825d9e commit 00341b5edd29b6e19465020e4559fb976bb00232 @ranxian committed Oct 28, 2012
Showing with 27 additions and 10 deletions.
  1. +20 −0 app/models/news.rb
  2. +7 −10 app/views/home/index.html.slim
View
@@ -7,4 +7,24 @@ class News
default_scope desc(:created_at)
has_many :comments
+
+ def self.reports
+ reports = []
+ cnt = 0
+ self.all.each do |news|
+ if not news.images.empty?
+ cnt += 1
+ reports << news
+ end
+ break if cnt >= 2
+ end
+
+ reports
+ end
+
+ def images
+ imgs = []
+ imgs << self.content.scan(/src="(.*?)"/)
+ return imgs.compact.flatten
+ end
end
@@ -141,17 +141,14 @@
.yellow-block
.yellow-ribbon
- / h4: a href="#" 通讯
+ h4: a href="#" 通讯
ul.unstyled.broadcast
- li
- a href="#"
- | “CMRC中国经济观察”第30次季度报告会特别专场快报通稿
- img src="http://www.nsd.edu.cn/cn/userfiles/Image/2012-07/20120722150205541253291.JPG"
- li
- a href="#"
- | “CMRC中国经济观察”第30次季度报告会特别专场快报通稿
- img src="http://www.nsd.edu.cn/cn/userfiles/Image/2012-07/20120722150205541253291.JPG"
- .yellow-block
+ - News.reports.each do |press|
+ li
+ a href="#"
+ = press.title
+ = image_tag(press.images.first)
+
.yellow-ribbon
h4 相关链接
.relative-link

0 comments on commit 00341b5

Please sign in to comment.