diaspora_federation-rails-0.0.8/ 0000755 0000041 0000041 00000000000 12604274230 016661 5 ustar www-data www-data diaspora_federation-rails-0.0.8/lib/ 0000755 0000041 0000041 00000000000 12604274230 017427 5 ustar www-data www-data diaspora_federation-rails-0.0.8/lib/diaspora_federation/ 0000755 0000041 0000041 00000000000 12604274230 023431 5 ustar www-data www-data diaspora_federation-rails-0.0.8/lib/diaspora_federation/engine.rb 0000644 0000041 0000041 00000000451 12604274230 025223 0 ustar www-data www-data module DiasporaFederation
# diaspora* federation rails engine
class Engine < ::Rails::Engine
isolate_namespace DiasporaFederation
config.generators do |g|
g.test_framework :rspec
end
config.after_initialize do
DiasporaFederation.validate_config
end
end
end
diaspora_federation-rails-0.0.8/lib/diaspora_federation/rails.rb 0000644 0000041 0000041 00000000236 12604274230 025071 0 ustar www-data www-data require "diaspora_federation/engine"
require "diaspora_federation"
module DiasporaFederation
# diaspora* federation rails engine
module Rails
end
end
diaspora_federation-rails-0.0.8/metadata.yml 0000644 0000041 0000041 00000004151 12604274230 021165 0 ustar www-data www-data --- !ruby/object:Gem::Specification
name: diaspora_federation-rails
version: !ruby/object:Gem::Version
version: 0.0.8
platform: ruby
authors:
- Benjamin Neff
autorequire:
bindir: bin
cert_chain: []
date: 2015-09-19 00:00:00.000000000 Z
dependencies:
- !ruby/object:Gem::Dependency
name: rails
requirement: !ruby/object:Gem::Requirement
requirements:
- - "~>"
- !ruby/object:Gem::Version
version: '4.2'
type: :runtime
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - "~>"
- !ruby/object:Gem::Version
version: '4.2'
- !ruby/object:Gem::Dependency
name: diaspora_federation
requirement: !ruby/object:Gem::Requirement
requirements:
- - '='
- !ruby/object:Gem::Version
version: 0.0.8
type: :runtime
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - '='
- !ruby/object:Gem::Version
version: 0.0.8
description: A rails engine that adds the diaspora* federation protocol to a rails
app
email:
- benjamin@coding4.coffee
executables: []
extensions: []
extra_rdoc_files: []
files:
- LICENSE
- README.md
- app/controllers/diaspora_federation/application_controller.rb
- app/controllers/diaspora_federation/h_card_controller.rb
- app/controllers/diaspora_federation/receive_controller.rb
- app/controllers/diaspora_federation/webfinger_controller.rb
- config/routes.rb
- lib/diaspora_federation/engine.rb
- lib/diaspora_federation/rails.rb
homepage: https://github.com/SuperTux88/diaspora_federation
licenses:
- AGPL 3.0 - http://www.gnu.org/licenses/agpl-3.0.html
metadata: {}
post_install_message:
rdoc_options: []
require_paths:
- lib
required_ruby_version: !ruby/object:Gem::Requirement
requirements:
- - "~>"
- !ruby/object:Gem::Version
version: '2.0'
required_rubygems_version: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
version: '0'
requirements: []
rubyforge_project:
rubygems_version: 2.4.6
signing_key:
specification_version: 4
summary: diaspora* federation rails engine
test_files: []
has_rdoc:
diaspora_federation-rails-0.0.8/config/ 0000755 0000041 0000041 00000000000 12604274230 020126 5 ustar www-data www-data diaspora_federation-rails-0.0.8/config/routes.rb 0000644 0000041 0000041 00000000756 12604274230 022004 0 ustar www-data www-data DiasporaFederation::Engine.routes.draw do
controller :receive do
post "receive-new/public" => :public, :as => "receive_public"
post "receive-new/users/:guid" => :private, :as => "receive_private"
end
controller :webfinger do
get ".well-known/host-meta" => :host_meta, :as => "host_meta"
get "webfinger" => :legacy_webfinger, :as => "legacy_webfinger"
end
controller :h_card do
get "hcard/users/:guid" => :hcard, :as => "hcard"
end
end
diaspora_federation-rails-0.0.8/LICENSE 0000644 0000041 0000041 00000001466 12604274230 017675 0 ustar www-data www-data Diaspora Federation Rails Engine
Copyright (C) 2015 Benjamin Neff
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
Some parts are based on an older federation gem from Florian Staudacher:
https://github.com/Raven24/diaspora-federation
diaspora_federation-rails-0.0.8/app/ 0000755 0000041 0000041 00000000000 12604274230 017441 5 ustar www-data www-data diaspora_federation-rails-0.0.8/app/controllers/ 0000755 0000041 0000041 00000000000 12604274230 022007 5 ustar www-data www-data diaspora_federation-rails-0.0.8/app/controllers/diaspora_federation/ 0000755 0000041 0000041 00000000000 12604274230 026011 5 ustar www-data www-data diaspora_federation-rails-0.0.8/app/controllers/diaspora_federation/receive_controller.rb 0000644 0000041 0000041 00000001462 12604274230 032226 0 ustar www-data www-data require_dependency "diaspora_federation/application_controller"
module DiasporaFederation
# this controller processes receiving messages
class ReceiveController < ApplicationController
before_action :check_for_xml
# receives public messages
#
# POST /receive/public
def public
logger.info "received a public message"
logger.debug CGI.unescape(params[:xml])
render nothing: true, status: :ok
end
# receives private messages for a user
#
# POST /receive/users/:guid
def private
logger.info "received a private message for #{params[:guid]}"
logger.debug CGI.unescape(params[:xml])
render nothing: true, status: :ok
end
private
def check_for_xml
render nothing: true, status: 422 if params[:xml].nil?
end
end
end
diaspora_federation-rails-0.0.8/app/controllers/diaspora_federation/application_controller.rb 0000644 0000041 0000041 00000000225 12604274230 033103 0 ustar www-data www-data module DiasporaFederation
# Base-Controller for all DiasporaFederation-Controller
class ApplicationController < ActionController::Base
end
end
diaspora_federation-rails-0.0.8/app/controllers/diaspora_federation/webfinger_controller.rb 0000644 0000041 0000041 00000005115 12604274230 032553 0 ustar www-data www-data require_dependency "diaspora_federation/application_controller"
module DiasporaFederation
# this controller handles all webfinger-specific requests
class WebfingerController < ApplicationController
# returns the host-meta xml
#
# example:
#
#
#
#
#
# GET /.well-known/host-meta
def host_meta
render body: WebfingerController.host_meta_xml, content_type: "application/xrd+xml"
end
# @deprecated this is the pre RFC 7033 webfinger
#
# example:
#
#
# acct:alice@localhost:3000
# http://localhost:3000/people/c8e87290f6a20132963908fbffceb188
#
#
#
#
#
#
#
#
# GET /webfinger?q=
def legacy_webfinger
person_wf = find_person_webfinger(params[:q]) if params[:q]
if person_wf.nil?
render nothing: true, status: 404
else
logger.info "webfinger profile request for: #{person_wf.acct_uri}"
render body: person_wf.to_xml, content_type: "application/xrd+xml"
end
end
private
# creates the host-meta xml with the configured server_uri and caches it
# @return [String] XML string
def self.host_meta_xml
@host_meta_xml ||= Discovery::HostMeta.from_base_url(DiasporaFederation.server_uri.to_s).to_xml
end
def find_person_webfinger(query)
DiasporaFederation.callbacks.trigger(:fetch_person_for_webfinger, query.strip.downcase.sub("acct:", ""))
end
end
end
diaspora_federation-rails-0.0.8/app/controllers/diaspora_federation/h_card_controller.rb 0000644 0000041 0000041 00000001152 12604274230 032020 0 ustar www-data www-data require_dependency "diaspora_federation/application_controller"
module DiasporaFederation
# this controller generates the hcard
class HCardController < ApplicationController
# returns the hcard of the user
#
# GET /hcard/users/:guid
def hcard
person_hcard = DiasporaFederation.callbacks.trigger(:fetch_person_for_hcard, params[:guid])
if person_hcard.nil?
render nothing: true, status: 404
else
logger.info "hcard profile request for: #{person_hcard.nickname}:#{person_hcard.guid}"
render html: person_hcard.to_html.html_safe
end
end
end
end
diaspora_federation-rails-0.0.8/README.md 0000644 0000041 0000041 00000005370 12604274230 020145 0 ustar www-data www-data # diaspora* federation library
**A library that provides functionalities needed for the diaspora* federation protocol**
[](https://travis-ci.org/SuperTux88/diaspora_federation)
[](https://codeclimate.com/github/SuperTux88/diaspora_federation)
[](https://codeclimate.com/github/SuperTux88/diaspora_federation/coverage)
[](https://gemnasium.com/SuperTux88/diaspora_federation)
[](https://inch-ci.org/github/SuperTux88/diaspora_federation)
[](https://badge.fury.io/rb/diaspora_federation)
[Documentation](http://www.rubydoc.info/gems/diaspora_federation/) |
[Bugtracker](https://github.com/SuperTux88/diaspora_federation/issues)
## Library
The ```diaspora_federation``` gem provides the functionality for de-/serialization and de-/encryption of Entities
in the protocols used for communication among the various installations of Diaspora*
## Rails Engine
The ```diaspora_federation-rails``` gem is a rails engine that adds the diaspora* federation protocol to a rails app.
### Usage
Add the gem to your ```Gemfile```:
```ruby
gem "diaspora_federation-rails"
```
Mount the routes in your ```config/routes.rb```:
```ruby
mount DiasporaFederation::Engine => "/"
```
Configure the engine in ```config/initializers/diaspora_federation.rb```:
```ruby
DiasporaFederation.configure do |config|
# the pod url
config.server_uri = AppConfig.pod_uri
config.define_callbacks do
on :fetch_person_for_webfinger do |diaspora_id|
person = Person.find_local_by_diaspora_id(diaspora_id)
if person
DiasporaFederation::Discovery::WebFinger.new(
# ...
)
end
end
on :fetch_person_for_hcard do |guid|
# ...
end
end
end
```
## Development
**!!! This gem is currently under heavy development, so every release can contain breaking changes !!!**
If you want to help, please contact me, help is welcome.
After the first stable release, this repo will be moved to the [diaspora organization](https://github.com/diaspora/).
## Diaspora
A privacy-aware, distributed, open source social network
Links:
[Project site](https://diasporafoundation.org) |
[Wiki](https://wiki.diasporafoundation.org)
## License
This gem is published under the terms of the "GNU Affero General Public License". See the LICENSE file for the exact wording.