This repository has been archived by the owner on Mar 6, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Rakefile
67 lines (60 loc) · 1.75 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
require 'rake'
Personlab::Application.load_tasks
# Twitter
namespace :tweet do
desc "Twitter reload."
task :update => :environment do
setting = Setting.find_create
if !setting.fanfou_id.blank?
puts "#{Time.now}"
puts 'Load tweets from twitter.com...'
items = Tweet.get_home_messages(setting.fanfou_id,5,true)
if items.blank?
puts "Not found or get error."
else
puts "Done. there have #{items.count} tweet."
end
end
end
end
# Google Reader
namespace :reader_share do
desc "Google Reader reload shere items."
task :update => :environment do
setting = Setting.find_create
puts "#{Time.now}"
puts 'Load Google Reader share articles...'
items = Share.find_all(setting,true)
puts "Done. there got #{items.count} articles from Google Reader."
end
end
# Google Reader
namespace :markdown do
desc "Google Reader reload shere items."
task :export => :environment do
Post.all(:include => [:category]).each do |post|
print "post: <#{post.slug}>"
categories = ""
if not post.tags.blank?
categories = "\n- #{post.tags.join("\n- ")}"
end
file_name = "#{Rails.root}/_posts/#{post.created_at.strftime('%Y-%m-%d')}-#{post.slug}.markdown"
summary = %(---
layout: post
title: "#{post.title}"
date: #{post.created_at.strftime("%Y-%m-%d %H:%M")}
comments: true
categories: #{categories}
---
)
File.open(file_name,"w+") do |f|
f.puts summary
f.puts post.body
end
puts "[done]"
end
end
end