app/models/feed.rb
def process_atom(atom)
    # taking out site/blog link and title.
    site_link =  (atom/:feed/:id).first.inner_html
    site_title = (atom/:feed/:title).first.inner_html

    puts "processing atom for #{site_link}"

    (atom/:entry).each do |item|
      link = (item/:link).first.attr('href')

      if (Item.find_by_link(link)).blank?
        atom_item = Item.new
        atom_item.feed = self
        atom_item.site_link = site_link
        atom_item.site_title = site_title
        atom_item.title = (item/:title).inner_html
        atom_item.link = link
        atom_item.author = (item/:author/:name).inner_html

        atom_item.content = (item/:content).inner_html
        if atom_item.content.blank?
          atom_item.content = (item/:summary).inner_html
        end

        atom_item.published = (item/:published).inner_html
        if atom_item.published.blank?
          atom_item.published = (item/:updated).inner_html
        end

        atom_item.title = htmlize(atom_item.title)
        atom_item.content = htmlize(atom_item.content, link)

        atom_item.save!
      end
    end
  end
# Process atom feed and saves it into db
Process atom feed and saves it into db
Process atom feed and saves it into db
def process_atom(atom)
    site_link =  (atom/:feed/:id).first.inner_html
    site_title = (atom/:feed/:title).first.inner_html
    puts "processing atom for #{site_link}"
    (atom/:entry).each do |item|
      link = (item/:link).first.attr('href')
      if (Item.find_by_link(link)).blank?
        atom_item = Item.new
        atom_item.feed = self
        atom_item.site_link = site_link
        atom_item.site_title = site_title
        atom_item.title = (item/:title).inner_html
        atom_item.link = link
        atom_item.author = (item/:author/:name).inner_html
        atom_item.content = (item/:content).inner_html
        if atom_item.content.blank?
          atom_item.content = (item/:summary).inner_html
        end
        atom_item.published = (item/:published).inner_html
        if atom_item.published.blank?
          atom_item.published = (item/:updated).inner_html
        end
        atom_item.title = htmlize(atom_item.title)
        atom_item.content = htmlize(atom_item.content, link)
        atom_item.save!
      end
    end
  end
def process_atom ( atom ) site_link = ( atom / :feed / :id ) . first . inner_html site_title = ( atom / :feed / :title ) . first . inner_html puts "processing atom for #{site_link}" ( atom / :entry ) . each do | item | link = ( item / :link ) . first . attr ( 'href' ) if ( Item . find_by_link ( link ) ) . blank? atom_item = Item . new atom_item . feed = self atom_item . site_link = site_link atom_item . site_title = site_title atom_item . title = ( item / :title ) . inner_html atom_item . link = link atom_item . author = ( item / :author / :name ) . inner_html atom_item . content = ( item / :content ) . inner_html if atom_item . content . blank? atom_item . content = ( item / :summary ) . inner_html end atom_item . published = ( item / :published ) . inner_html if atom_item . published . blank? atom_item . published = ( item / :updated ) . inner_html end atom_item . title = htmlize ( atom_item . title ) atom_item . content = htmlize ( atom_item . content , link ) atom_item . save! end end end
Process atom feed and saves it into db
Process atom feed and saves it into db
# taking out site/blog link and title.
atom