-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
120 lines (104 loc) · 3.01 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
require(File.join(File.dirname(__FILE__), 'lib', 'aggir'))
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
task :default => ["feeds:update"]
URLS = %w(http://feeds2.feedburner.com/GeekingWithGreg
http://feeds.feedburner.com/daniel-lemire/atom
http://www.searchenginecaffe.com/feeds/posts/default
http://thenoisychannel.com/feed/
http://irgupf.com/feed/
http://windowoffice.tumblr.com/rss
http://feeds.feedburner.com/stanfordinfoblog
http://musicmachinery.com/feed/
http://blogs.sun.com/searchguy/feed/entries/atom)
namespace :feeds do
desc "Update feeds..."
task :update do
Aggir::Feed.all.each do |f|
f.update_entries
end
Aggir::Feed.sort_entries
end
task :add do
url = ENV['url']
raise StandardError.new("You must give a URL...") if url.blank?
Aggir::Feed.create_or_update(url)
end
desc "Creating default feeds..."
task :create do
URLS.each do |url|
f = Aggir::Feed.create_or_update(url)
unless f.nil?
f.update_entries
else
puts "URL: #{url} came back as nil!"
end
end
Aggir::Feed.sort_entries
end
desc "Grab latest 15 headlines..."
task :latest do
latest = Aggir::Entry.latest
latest.each do |l|
puts "#{l.feed.title} - #{l.title}"
end
end
desc "Sending all entries to Solr..."
task :update_search do
require 'cgi'
latest = Aggir::Entry.all
puts "Sending #{latest.size} entries to Solr..."
#posts = []
latest.each do |l|
posts = []
stripped_content = l.content.gsub(/<\/?[^>]*>/, "")
stripped_content = CGI.escapeHTML(stripped_content)
keywords = l.find_keywords
posts << {:id => l.hashed_guid, :title => l.title,
:post => stripped_content, :link => l.link, :keywords => keywords.join(" ")}
Aggir::Solr.new.update(posts)
end
#Aggir::Solr.new.update(posts)
end
desc "Find Entry keywords from Delicious"
task :find_keywords do
Aggir::Entry.latest.each do |e|
puts e.find_keywords.inspect
end
end
desc "Show Last 10 Feeds"
task :latest_feeds do
Aggir::Feed.most_recent.each do |f|
puts "#{f.title} - #{f.entries.size} Posts"
end
end
desc "Show Number of posts for all feeds"
task :all_feeds do
Aggir::Feed.all.each do |f|
puts "#{f.title} - #{f.entries.size} Posts"
end
end
end
namespace :pdf do
desc "Download All PDFs"
task :download_all do
download_dir = File.join(File.dirname(__FILE__), 'downloads')
FileUtils.mkdir(download_dir) unless File.exists?(download_dir)
pdfs = Aggir::Link.all
pdfs.each do |pdf|
puts "Downloading #{pdf.link}..."
pdf.download(download_dir)
end
end
desc "Download Latest PDFs"
task :download do
download_dir = File.join(File.dirname(__FILE__), 'downloads')
FileUtils.mkdir(download_dir) unless File.exists?(download_dir)
pdfs = Aggir::Link.latest
pdfs.each do |pdf|
puts "Downloading #{pdf.link}..."
pdf.download(download_dir)
end
end
end