Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def process_articles(mephisto_articles, permalink_format)
- # Create an array to store the processed articles
- processed = []
- # Loop through them
- mephisto_articles.each do |a|
- # Find the article, or create a new one
- article = Article.new
- # Grab the information from the article feed item
- article.title = a.title
- article.content = a.body
- article.formatter = formatter(a.filter)
- article.published = "1"
- article.published_at = DateTime.now
- article.permalink = format_permalink(permalink_format,DateTime.now,a.title)
- article.user_id = self.current_user.id
- # Add the tags, if present in the feed, and if the tagging plugin is active
- if is_plugin_active("feather-tagging") && defined?(Tag) && defined?(Tagging) && article.respond_to?("tag_list=")
- tags = []
- sections = []
- DataMapper.repository(:mephisto_database) do
- taggings = MephistoTagging.all(:taggable_id => a.id)
- tags = MephistoTag.all(:id => taggings.collect{|tg| tg.tag_id}.join(',')) unless taggings.empty?
- assigned_sections = MephistoAssignedSection.all(:article_id => a.id)
- sections = MephistoSection.all(:sections => assigned_sections.collect{|as| as.section_id}.join(',')) unless assigned_sections.empty?
- end
- article.tag_list = (tags.collect{|tag| tag.name} + sections.collect{|section| section.name}).compact.join(",")
- end
- # Save the article
- Merb.logger.debug!(article.inspect)
- #
- article.save
- @article_map[a.id] = article.id
- # Add it to the list of processed articles
- processed << article
- end
- # Return the list of processed articles
- processed
- end
Add Comment
Please, Sign In to add comment