opengraph

This commit is contained in:
Andreas Stephanides
2015-02-14 18:24:46 +01:00
parent 195b982ef4
commit ebe8d1f8df
2 changed files with 14 additions and 0 deletions

View File

@@ -117,6 +117,8 @@ gem 'whenever'
gem 'yaml_db' gem 'yaml_db'
gem 'etherpad-lite' gem 'etherpad-lite'
gem 'opengraph_parser'
# Image gallery # Image gallery
gem 'blueimp-gallery' gem 'blueimp-gallery'
gem 'blueimp-gallery-rails' gem 'blueimp-gallery-rails'

View File

@@ -64,6 +64,18 @@ class Neuigkeit < ActiveRecord::Base
def name def name
self.title self.title
end end
def load_from_facebook(link)
event=FbGraph::Event.new(link).fetch(:access_token=>"CAABtfB8SO7kBADyHVHnWHqsxsU1bqqmeDdZCp7V1KF9G4o3oFHcZBq0IB8X3ird4muVIPuWKZB8jL1o9JCON60Lmnvk8rkZA2dyZAuU95dC0SWzOEnhtAEkyzZCN6hkKXdl87o38OloLBivc2kjJYmpUVKzdZAD5ywxKG7Hv5FWxXf6amWA782JSmcxgWsRDH4ZAZBXsUrhpnILNOVoKSBf1mGyfrFiPvA3QZD")
self.title=event.name
self.text=event.description
unless event.start_time.nil?
ce=Calentry.new(:start=>event.start_time, :ende=>event.end_time , :typ=>1)
ce.ende=ce.start if ce.ende.nil?
self.calentries<< ce
ce.save
end
end
def text_first_words def text_first_words
md = /<p>(?<text>[^\<\>]*)/.match Sanitize.clean(self.text,:elements=>['p']) md = /<p>(?<text>[^\<\>]*)/.match Sanitize.clean(self.text,:elements=>['p'])
words=md[:text].split(" ") unless md.nil? words=md[:text].split(" ") unless md.nil?