public
Description: This contains various plugins for Feather
Clone URL: git://github.com/eldiablo/feather-plugins.git
Search Repo:
Click here to lend your support to: feather-plugins and make a donation at www.pledgie.com !
updated importer with better error handling, and also fixed an issue with 
dates for imported articles
eldiablo (author)
Tue Apr 08 12:05:18 -0700 2008
commit  22d563e2c1b5721028199a6f48e0d23d8b282399
tree    95f998080ede87fda9325839ca4e3802cb901ec9
parent  30d103d9868603e39700eaf3bc655b19a218a6ff
...
6
7
8
9
 
10
11
12
...
6
7
8
 
9
10
11
12
0
@@ -6,7 +6,7 @@ class Comment < DataMapper::Base
0
   property :created_at, :datetime
0
   property :email_address, :string
0
   
0
- validates_presence_of :name, :comment
0
+ validates_presence_of :name, :comment, :article_id
0
   
0
   def self.all_for_post(article_id, method = :all)
0
     self.send(method, {:article_id => article_id, :order => "created_at"})
...
30
31
32
33
34
 
 
35
36
37
...
42
43
44
45
 
46
47
48
...
59
60
61
62
63
 
 
 
64
65
66
...
30
31
32
 
 
33
34
35
36
37
...
42
43
44
 
45
46
47
48
...
59
60
61
 
 
62
63
64
65
66
67
0
@@ -30,8 +30,8 @@ module Admin
0
           # Grab the information from the article feed item
0
           article.title = (a/"title").text
0
           article.content = (a/"description").text
0
- article.published = true
0
- article.published_at = (a/"pubdate").text
0
+ article.published = "1"
0
+ article.published_at = DateTime.parse((a/"pubdate").text)
0
           article.permalink = URI.parse((a/"guid").text).request_uri
0
           article.user_id = self.current_user.id
0
           # Save the article
0
@@ -42,7 +42,7 @@ module Admin
0
         # Return the list of processed articles
0
         processed
0
       end
0
-
0
+
0
       ##
0
       # This processes the comments feed url
0
       def process_comments(url)
0
@@ -59,8 +59,9 @@ module Admin
0
           # Grab the information from the comment feed item
0
           comment.comment = (c/"description").text
0
           comment.name = (c/"dc:creator").text
0
- comment.created_at = (c/"pubdate").text
0
- comment.article_id = Article.first(:title => (c/"title").text.gsub("Re: ", "")).id
0
+ comment.created_at = DateTime.parse((c/"pubdate").text)
0
+ a = Article.first(:title => (c/"title").text.gsub("Re: ", ""))
0
+ comment.article_id = a.id unless a.nil?
0
           # Save the comment
0
           comment.save
0
           # Add it to the list of processed comments
...
4
5
6
7
8
9
10
11
12
13
 
14
15
 
16
17
18
...
22
23
24
25
26
27
28
29
30
31
 
32
33
 
34
35
36
...
4
5
6
 
 
 
 
 
 
 
7
8
 
9
10
11
12
...
16
17
18
 
 
 
 
 
 
 
19
20
 
21
22
23
24
0
@@ -4,15 +4,9 @@
0
   <% @articles.each do |article| %>
0
     <p>
0
     <% if article.new_record? %>
0
- <%= article.title %> : unable to save!
0
- <br />
0
- <ul>
0
- <% article.errors.collect { |e| e[1][0] }.each do |e| %>
0
- <li><%= e %></li>
0
- <% end %>
0
- </ul>
0
+ <%= error_messages_for(article, lambda{|error| "<li>#{error[1]}</li>"}) {|errors| "Unable to save article #{article.title}!<br />" } %>
0
     <% else %>
0
- <%= article.title %> : saved as article <%= article.id %>, available at <%= link_to article.permalink, article.permalink %>
0
+ Saved article <%= article.title %> as <%= article.id %>, available <%= link_to "here", article.permalink %>.
0
     <% end %>
0
     </p>
0
   <% end %>
0
@@ -22,15 +16,9 @@
0
   <% @comments.each do |comment| %>
0
     <p>
0
     <% if comment.new_record? %>
0
- Comment by <%= comment.name %> : unable to save!
0
- <br />
0
- <ul>
0
- <% comment.errors.collect { |e| e[1][0] }.each do |e| %>
0
- <li><%= e %></li>
0
- <% end %>
0
- </ul>
0
+ <%= error_messages_for(comment, lambda{|error| "<li>#{error[1]}</li>"}) {|errors| "Unable to save comment by #{comment.name}!<br />" } %>
0
     <% else %>
0
- Comment by <%= comment.name %> : saved as <%= comment.id %>
0
+ Saved comment by <%= comment.name %> as <%= comment.id %>.
0
     <% end %>
0
     </p>
0
   <% end %>

Comments

    No one has commented yet.