diff --git a/app/models/share.rb b/app/models/share.rb
index 9fb2c82..8fb6612 100644
--- a/app/models/share.rb
+++ b/app/models/share.rb
@@ -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
diff --git a/app/views/cpanel/settings/index.html.erb b/app/views/cpanel/settings/index.html.erb
index 56f1266..5f33523 100644
--- a/app/views/cpanel/settings/index.html.erb
+++ b/app/views/cpanel/settings/index.html.erb
@@ -23,6 +23,10 @@
饭否ID
<%= f.text_field :fanfou_id, :class => "text middle" %>
+
+ Google Reader
+ http://www.google.com/reader/shared/<%= f.text_field :google_reader_id, :class => "text short" %>
+
Meta Keywords
<%= f.text_field :meta_keywords, :class => "text long" %>
diff --git a/app/views/shares/edit.html.erb b/app/views/shares/edit.html.erb
deleted file mode 100644
index ec9fdbf..0000000
--- a/app/views/shares/edit.html.erb
+++ /dev/null
@@ -1,32 +0,0 @@
-Editing share
-
-<% form_for(@share) do |f| %>
- <%= f.error_messages %>
-
-
- <%= f.label :title %>
- <%= f.text_field :title %>
-
-
- <%= f.label :summary %>
- <%= f.text_field :summary %>
-
-
- <%= f.label :from %>
- <%= f.text_field :from %>
-
-
- <%= f.label :cover %>
- <%= f.text_field :cover %>
-
-
- <%= f.label :url %>
- <%= f.text_field :url %>
-
-
- <%= f.submit 'Update' %>
-
-<% end %>
-
-<%= link_to 'Show', @share %> |
-<%= link_to 'Back', shares_path %>
\ No newline at end of file
diff --git a/app/views/shares/index.html.erb b/app/views/shares/index.html.erb
deleted file mode 100644
index 0ff1fb3..0000000
--- a/app/views/shares/index.html.erb
+++ /dev/null
@@ -1,28 +0,0 @@
-Listing shares
-
-
-
- Title
- Summary
- From
- Cover
- Url
-
-
-<% @shares.each do |share| %>
-
- <%=h share.title %>
- <%=h share.summary %>
- <%=h share.from %>
- <%=h share.cover %>
- <%=h share.url %>
- <%= link_to 'Show', share %>
- <%= link_to 'Edit', edit_share_path(share) %>
- <%= link_to 'Destroy', share, :confirm => 'Are you sure?', :method => :delete %>
-
-<% end %>
-
-
-
-
-<%= link_to 'New share', new_share_path %>
\ No newline at end of file
diff --git a/app/views/shares/new.html.erb b/app/views/shares/new.html.erb
deleted file mode 100644
index d148e8b..0000000
--- a/app/views/shares/new.html.erb
+++ /dev/null
@@ -1,31 +0,0 @@
-New share
-
-<% form_for(@share) do |f| %>
- <%= f.error_messages %>
-
-
- <%= f.label :title %>
- <%= f.text_field :title %>
-
-
- <%= f.label :summary %>
- <%= f.text_field :summary %>
-
-
- <%= f.label :from %>
- <%= f.text_field :from %>
-
-
- <%= f.label :cover %>
- <%= f.text_field :cover %>
-
-
- <%= f.label :url %>
- <%= f.text_field :url %>
-
-
- <%= f.submit 'Create' %>
-
-<% end %>
-
-<%= link_to 'Back', shares_path %>
\ No newline at end of file
diff --git a/app/views/shares/show.html.erb b/app/views/shares/show.html.erb
deleted file mode 100644
index 98cbc25..0000000
--- a/app/views/shares/show.html.erb
+++ /dev/null
@@ -1,28 +0,0 @@
-
- Title:
- <%=h @share.title %>
-
-
-
- Summary:
- <%=h @share.summary %>
-
-
-
- From:
- <%=h @share.from %>
-
-
-
- Cover:
- <%=h @share.cover %>
-
-
-
- Url:
- <%=h @share.url %>
-
-
-
-<%= link_to 'Edit', edit_share_path(@share) %> |
-<%= link_to 'Back', shares_path %>
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 998bcbb..9dd0f40 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -12,8 +12,7 @@
end
# Share
- map.resources :controller => "shares", :as => "share"
-
+
# Blog
map.purchase "blog", :controller => "posts"
map.purchase "blog", :controller => "posts", :action => "index"
@@ -21,6 +20,8 @@
map.purchase "blog/page/:page", :controller => "posts", :action => "index", :requirements => { :page => /[\d]+/ }
map.purchase "blog/:slug", :controller => "posts", :action => "show", :requirements => { :slug => /[a-z0-9A-Z\-\_\.]+/ }
+ map.purchase "share", :controller => "home", :action => "share"
+
# Pages (This well be stay last line)
map.purchase ":slug", :controller => "home", :action => "show", :requirements => { :slug => /[a-z0-9A-Z\-\_\.]+/ }
diff --git a/db/development.sqlite3 b/db/development.sqlite3
index 25ba0a9..456536e 100644
Binary files a/db/development.sqlite3 and b/db/development.sqlite3 differ
diff --git a/db/schema.rb b/db/schema.rb
index 1262d65..0decc20 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20090517034648) do
+ActiveRecord::Schema.define(:version => 20090517064606) do
create_table "comments", :force => true do |t|
t.integer "post_id", :null => false
@@ -71,16 +71,7 @@
t.datetime "updated_at"
t.string "fanfou_id"
t.string "blog_feed_html"
- end
-
- create_table "shares", :force => true do |t|
- t.string "title", :null => false
- t.string "summary", :null => false
- t.string "from"
- t.string "cover"
- t.string "url", :null => false
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.string "google_reader_id"
end
create_table "tags", :force => true do |t|
diff --git a/lib/string.rb b/lib/string.rb
index 142876f..77c4b86 100644
--- a/lib/string.rb
+++ b/lib/string.rb
@@ -28,6 +28,15 @@ def truncate_html(len = 30, ellipsis = "...")
(results + ellipsis)
end
+ def remove_html_tag()
+ self.gsub(/<.+?>/, "")
+ end
+
+ def html_decode
+ es = {'&' => '&', '>' => '>', '<' => '<', '"' => '"'}
+ self.gsub(/&|>|<|"/) { |s| es[s] }
+ end
+
# clear unsafe char with url slug
def safe_slug(spliter = '-')
@slug = self
diff --git a/personlab.tmproj b/personlab.tmproj
index ddb8803..90d1f43 100644
--- a/personlab.tmproj
+++ b/personlab.tmproj
@@ -2,8 +2,6 @@
- currentDocument
- app/controllers/application_controller.rb
documents
@@ -20,363 +18,10 @@
fileHierarchyDrawerWidth
259
metaData
-
- app/controllers/application_controller.rb
-
- caret
-
- column
- 21
- line
- 7
-
- firstVisibleColumn
- 0
- firstVisibleLine
- 0
-
- app/controllers/cpanel/comments_controller.rb
-
- caret
-
- column
- 0
- line
- 9
-
- firstVisibleColumn
- 0
- firstVisibleLine
- 0
-
- app/controllers/cpanel/posts_controller.rb
-
- caret
-
- column
- 65
- line
- 1
-
- firstVisibleColumn
- 0
- firstVisibleLine
- 0
-
- app/controllers/posts_controller.rb
-
- caret
-
- column
- 50
- line
- 71
-
- firstVisibleColumn
- 0
- firstVisibleLine
- 60
-
- app/models/comment.rb
-
- caret
-
- column
- 20
- line
- 12
-
- firstVisibleColumn
- 0
- firstVisibleLine
- 0
-
- app/models/comment_observer.rb
-
- caret
-
- column
- 27
- line
- 25
-
- firstVisibleColumn
- 0
- firstVisibleLine
- 0
-
- app/sweepers/comment_sweeper.rb
-
- caret
-
- column
- 34
- line
- 19
-
- firstVisibleColumn
- 0
- firstVisibleLine
- 0
-
- app/sweepers/menu_sweeper.rb
-
- caret
-
- column
- 36
- line
- 12
-
- firstVisibleColumn
- 0
- firstVisibleLine
- 0
-
- app/sweepers/page_sweeper.rb
-
- caret
-
- column
- 26
- line
- 4
-
- firstVisibleColumn
- 0
- firstVisibleLine
- 0
-
- app/sweepers/post_sweeper.rb
-
- caret
-
- column
- 25
- line
- 11
-
- firstVisibleColumn
- 0
- firstVisibleLine
- 0
-
- app/views/cpanel/menus/edit.html.erb
-
- caret
-
- column
- 24
- line
- 7
-
- firstVisibleColumn
- 0
- firstVisibleLine
- 0
-
- app/views/cpanel/menus/index.html.erb
-
- caret
-
- column
- 23
- line
- 5
-
- firstVisibleColumn
- 0
- firstVisibleLine
- 0
-
- app/views/cpanel/pages/edit.html.erb
-
- caret
-
- column
- 0
- line
- 9
-
- columnSelection
-
- firstVisibleColumn
- 0
- firstVisibleLine
- 0
- selectFrom
-
- column
- 23
- line
- 9
-
- selectTo
-
- column
- 0
- line
- 9
-
-
- app/views/cpanel/pages/index.html.erb
-
- caret
-
- column
- 0
- line
- 5
-
- columnSelection
-
- firstVisibleColumn
- 0
- firstVisibleLine
- 0
- selectFrom
-
- column
- 23
- line
- 5
-
- selectTo
-
- column
- 0
- line
- 5
-
-
- app/views/cpanel/posts/edit.html.erb
-
- caret
-
- column
- 25
- line
- 16
-
- firstVisibleColumn
- 0
- firstVisibleLine
- 0
-
- app/views/posts/_posts.html.erb
-
- caret
-
- column
- 4
- line
- 5
-
- columnSelection
-
- firstVisibleColumn
- 0
- firstVisibleLine
- 0
- selectFrom
-
- column
- 95
- line
- 5
-
- selectTo
-
- column
- 4
- line
- 5
-
-
- app/views/posts/show.html.erb
-
- caret
-
- column
- 15
- line
- 14
-
- firstVisibleColumn
- 0
- firstVisibleLine
- 14
-
- config/environment.rb
-
- caret
-
- column
- 0
- line
- 52
-
- firstVisibleColumn
- 0
- firstVisibleLine
- 25
-
- config/environments/development.rb
-
- caret
-
- column
- 11
- line
- 8
-
- columnSelection
-
- firstVisibleColumn
- 0
- firstVisibleLine
- 0
- selectFrom
-
- column
- 7
- line
- 8
-
- selectTo
-
- column
- 17
- line
- 8
-
-
-
- openDocuments
-
- app/views/posts/show.html.erb
- app/sweepers/comment_sweeper.rb
- config/environments/development.rb
- app/sweepers/page_sweeper.rb
- app/views/cpanel/menus/index.html.erb
- app/models/comment.rb
- app/models/comment_observer.rb
- app/sweepers/post_sweeper.rb
- app/controllers/cpanel/posts_controller.rb
- app/controllers/cpanel/comments_controller.rb
- app/sweepers/menu_sweeper.rb
- app/views/cpanel/pages/index.html.erb
- app/views/cpanel/menus/edit.html.erb
- app/views/cpanel/posts/edit.html.erb
- app/views/cpanel/pages/edit.html.erb
- app/views/posts/_posts.html.erb
- app/controllers/application_controller.rb
- app/controllers/posts_controller.rb
- config/environment.rb
-
+
showFileHierarchyDrawer
windowFrame
- {{289, 146}, {871, 595}}
+ {{590, 92}, {871, 595}}
diff --git a/public/about.html b/public/about.html
index ee67be1..80f7c23 100644
--- a/public/about.html
+++ b/public/about.html
@@ -3,22 +3,22 @@
- 关于我 - Jason Lee
+ 关于我 - 李华顺
-
+
-
+