fix onebox for your own site

This commit is contained in:
Sam Saffron
2013-02-06 16:22:11 +11:00
parent d237e3bf3b
commit 0f88947279
9 changed files with 58 additions and 12 deletions

View File

@@ -19,7 +19,6 @@ module Oneboxer
result['description'] = node['content'] if node
end
result
end
end

View File

@@ -8,8 +8,8 @@ module Oneboxer
attr_accessor :regexp
attr_accessor :favicon_file
def matcher(regexp)
self.regexp = regexp
def matcher(regexp=nil,&blk)
self.regexp = regexp || blk
end
def favicon(favicon_file)

View File

@@ -5,8 +5,9 @@ module Oneboxer
class DiscourseOnebox < BaseOnebox
include ActionView::Helpers::DateHelper
# TODO: we need to remove these hardcoded urls ASAP
matcher /^https?\:\/\/(dev.discourse.org|localhost\:3000|l.discourse|discuss.emberjs.com)\/.*$/
matcher do
Regexp.new "^#{Discourse.base_url.gsub(".","\\.")}.*$", true
end
def onebox
uri = URI::parse(@url)