app/models/feed.rb
# Process atom_reader feed and saves it into db
Process atom_reader feed and saves it into db
Process atom_reader feed and saves it into db
def process_atom_reader(atom_reader)
    time_offset = 1
    site_link =  (atom_reader/:feed).search(:link)[1]['href']
    site_title = (atom_reader/:feed/:title).first.inner_html
    puts "processing atom_reader for #{site_link}"
    (atom_reader/:entry).each do |item|
      link_raw = item.%('feedburner:origLink') || item.%('link')
        link = (item/:link).attr('href').value
      if (Item.find_by_link(link)).blank?
        atom_reader_item = Item.new
        atom_reader_item.feed = self
        atom_reader_item.site_link = site_link
        atom_reader_item.site_title = site_title
        atom_reader_item.title = (item/:title).children[0].text + " - " + (item/:title).children[1].text
        atom_reader_item.link = link
        atom_reader_item.author = (item/:author/:name).inner_html
        begin
          atom_reader_item.content = (item/:content).children[0].text
        rescue
          atom_reader_item.content = (item/:summary).inner_html
        end
        atom_reader_item.published = (item/:published).inner_html
        if atom_reader_item.content.blank?
          atom_reader_item.content =  (item/:summary).inner_html
        end
        if atom_reader_item.published.blank?
          atom_reader_item.published =  (item/:updated).inner_html
        end
        if atom_reader_item.published.blank?
          atom_reader_item.published =  (Time.now - (20*60*60*24) - time_offset.hours).to_s(:db)
          time_offset += 1
        end
        atom_reader_item.title = htmlize(atom_reader_item.title)
        atom_reader_item.content = htmlize(atom_reader_item.content, link)
        atom_reader_item.save!
      end
    end
  end
def process_atom_reader ( atom_reader ) time_offset = 1 site_link = ( atom_reader / :feed ) . search ( :link ) [ 1 ] [ 'href' ] site_title = ( atom_reader / :feed / :title ) . first . inner_html puts "processing atom_reader for #{site_link}" ( atom_reader / :entry ) . each do | item | link_raw = item . % ( 'feedburner:origLink' ) || item . % ( 'link' ) link = ( item / :link ) . attr ( 'href' ) . value if ( Item . find_by_link ( link ) ) . blank? atom_reader_item = Item . new atom_reader_item . feed = self atom_reader_item . site_link = site_link atom_reader_item . site_title = site_title atom_reader_item . title = ( item / :title ) . children [ 0 ] . text + " - " + ( item / :title ) . children [ 1 ] . text atom_reader_item . link = link atom_reader_item . author = ( item / :author / :name ) . inner_html begin atom_reader_item . content = ( item / :content ) . children [ 0 ] . text rescue atom_reader_item . content = ( item / :summary ) . inner_html end atom_reader_item . published = ( item / :published ) . inner_html if atom_reader_item . content . blank? atom_reader_item . content = ( item / :summary ) . inner_html end if atom_reader_item . published . blank? atom_reader_item . published = ( item / :updated ) . inner_html end if atom_reader_item . published . blank? atom_reader_item . published = ( Time . now - ( 20 * 60 * 60 * 24 ) - time_offset . hours ) . to_s ( :db ) time_offset += 1 end atom_reader_item . title = htmlize ( atom_reader_item . title ) atom_reader_item . content = htmlize ( atom_reader_item . content , link ) atom_reader_item . save! end end end
Process atom_reader feed and saves it into db
Process atom_reader feed and saves it into db
# taking out site/blog link and title. # if !link_raw.blank? #   link = (link_raw).inner_html # else # end # taking it 20 days back..
atom_reader