#27 Should get page title even if post is a page.

This commit is contained in:
2015-11-12 21:51:17 +08:00
parent 0e0090ed0b
commit 6e48e3d151
2 changed files with 5 additions and 5 deletions
+1 -1
View File
@@ -87,7 +87,7 @@ class Api::V1::PostsController < Api::V1::ApplicationController
end
def process_post
if !@post.processed && @post.type != 'WebPage'
if !@post.processed
ProcessPostWorker.perform_async @post.url
end
end
+4 -4
View File
@@ -13,14 +13,13 @@ class ProcessPostWorker
if page.images.best.present?
post.create_thumbnail file: URI.parse(page.images.best)
end
post.save
rescue SocketError => e
Rails.logger.error "出错了: #{e}"
ensure
readability_extract_content post
end
post.save
readability_extract_content post
end
private
@@ -31,8 +30,9 @@ class ProcessPostWorker
response = RestClient.get "https://readability.com/api/content/v1/parser?token=#{token}&url=#{post.url}"
if response.code == 200
post_json = JSON.parse response.body
post.content = HTMLEntities.new.decode post_json['content']
post.good_format = true
post.good_format = true if post.type != 'WebPage'
post.title = post_json['title']
post.save
end