Skip to content

Instantly share code, notes, and snippets.

@berkes
Created December 21, 2010 12:04
Show Gist options
  • Save berkes/749847 to your computer and use it in GitHub Desktop.
Save berkes/749847 to your computer and use it in GitHub Desktop.
git diff 61b2bbb..HEAD
diff --git a/app/models/service.rb b/app/models/service.rb
index eb0d48a..e0234b0 100644
--- a/app/models/service.rb
+++ b/app/models/service.rb
@@ -26,3 +26,4 @@ class Service
end
require File.join(Rails.root, 'app/models/services/facebook')
require File.join(Rails.root, 'app/models/services/twitter')
+require File.join(Rails.root, 'app/models/services/identica')
diff --git a/app/models/services/identica.rb b/app/models/services/identica.rb
new file mode 100644
index 0000000..5905481
--- /dev/null
+++ b/app/models/services/identica.rb
@@ -0,0 +1,34 @@
+class Services::Identica < Service
+ MAX_CHARACTERS = 140
+
+ def post(post, url='')
+ Rails.logger.debug("event=post_to_service type=Ostatus sender_id=#{self.use
+ message = public_message(post, url)
+
+ identica_key = SERVICES['identica']['consumer_key']
+ identica_consumer_secret = SERVICES['identica']['consumer_secret']
+ identica_endpoint = SERVICES['identica']['endpoint']
+
+ if identica_consumer_secret.blank? || identica_consumer_secret.blank?
+ Rails.logger.info "you have a blank identica key or secret.... you should
+ end
+
+ Twitter.configure do |config|
+ config.consumer_key = identica_key
+ config.consumer_secret = identica_consumer_secret
+ config.oauth_token = self.access_token
+ config.oauth_token_secret = self.access_secret
+ config.endpoint = identica_endpoint
+ end
+
+ begin
+ Twitter.update(message)
+ rescue Exception => e
+ Rails.logger.info e.message
+ end
+ end
+
+ def public_message(post, url)
+ super(post, MAX_CHARACTERS, url)
+ end
+end
diff --git a/app/views/shared/_add_remove_services.haml b/app/views/shared/_add_
index fe28614..c2cac89 100644
--- a/app/views/shared/_add_remove_services.haml
+++ b/app/views/shared/_add_remove_services.haml
@@ -16,3 +16,6 @@
- unless @services.any?{|x| x.provider == 'facebook'}
%h4= link_to t('services.index.connect_to_facebook'), "/auth/facebook" if SER
+
+- unless @services.any?{|x| x.provider == 'identica'}
+ %h4= link_to t('services.index.connect_to_identica'), "/auth/identica" if SER
diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb
index 9789fee..3363fe6 100644
--- a/config/initializers/omniauth.rb
+++ b/config/initializers/omniauth.rb
@@ -5,5 +5,6 @@
Rails.application.config.middleware.use OmniAuth::Builder do
provider :twitter, SERVICES['twitter']['consumer_key'], SERVICES['twitter']['
provider :facebook, SERVICES['facebook']['app_id'], SERVICES['facebook']['app
+ provider :identica, SERVICES['identica']['consumer_key'], SERVICES['identica'
end
diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml
index 6b18977..63bce2a 100644
--- a/config/locales/diaspora/en.yml
+++ b/config/locales/diaspora/en.yml
@@ -388,6 +388,7 @@ en:
really_disconnect: "disconnect %{service}?"
connect_to_twitter: "Connect to twitter"
connect_to_facebook: "Connect to facebook"
+ connect_to_identica: "Connect to identi.ca"
edit_services: "Edit services"
create:
success: "Authentication successful."
diff --git a/config/oauth_keys.yml.example b/config/oauth_keys.yml.example
index 8e1db63..174da63 100644
--- a/config/oauth_keys.yml.example
+++ b/config/oauth_keys.yml.example
@@ -4,3 +4,6 @@ twitter:
facebook:
app_id: ""
app_secret: ""
+identica:
+ consumer_key: ""
+ consumer_secret: ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment