forked from huacnlee/personlab
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. 删除了 Shares 表,分享不存数据库里面,改为直接取Google Reader的20条,以集合的方式存 Cache 里面;
2. 当然,就加入了 google_reader_id 到 Settings 表里面; 3. 去除了之前所有 Shares 表由 scaffold 生成的文件; 4. 后面设置里面加入 google_reader_id 的项; 5. HomeController 加入 share,用于分享页面,并且share功能目前已完成; 6. lib/string 里面加入 remove_html_tag 的方法,用于清除所有HTML标签; 7. lib/string 里面加和 html_decode 方法,用于反解 html_encode 格式化的内容;
- Loading branch information
Showing
22 changed files
with
91 additions
and
779 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,6 @@ def success_messages | |
'' | ||
end | ||
end | ||
|
||
|
||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,34 @@ | ||
require "rubygems" | ||
require 'simple-rss' | ||
require 'open-uri' | ||
require "lib/string" | ||
|
||
class Share < ActiveRecord::Base | ||
|
||
def self.api_url(setting) | ||
"http://www.google.com/reader/public/atom/user%2F#{setting.google_reader_id}%2Fstate%2Fcom.google%2Fbroadcast" | ||
end | ||
|
||
def self.find_all(setting) | ||
@expire_minutes = 1.days.minutes | ||
cache_key = "data/shares" | ||
feeds = Rails.cache.read(cache_key) | ||
if not feeds | ||
feeds = [] | ||
feed = SimpleRSS::parse open(api_url(setting)) | ||
if feed != nil | ||
feed.items.each do |item| | ||
feeds << { | ||
"title" => item.title, | ||
"link" => item.link, | ||
"content" => item.content == nil ? item.summary.html_decode.remove_html_tag()[0..500] + '...' : item.content.html_decode.remove_html_tag()[0..500] + '...', | ||
"updated_at" => item.updated, | ||
"author" => item.author, | ||
} | ||
end | ||
end | ||
Rails.cache.write(cache_key,feeds,:expires_in => @expire_minutes) | ||
end | ||
feeds | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.