Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fluther

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fluther

  • 1.0.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

h1. Fluther Ruby Client

h2. Introduction

This gem provides an interface to the "Fluther discussion service":http://www.fluther.com/. It is implemented as a piece of Rack middleware which handles proxying requests to Fluther and returning the response so that it can be included in your web application. While it should be usable with any Rack-based application, these docs assume you are embedding Fluther in a Rails 2.x application.

Requirements:

  • Rack
  • Warden
  • Thin (optional)

h2. Installation

  • Add the @fluther@ gem to your application (i.e. in @Gemfile@ or @environment.rb@).

  • Create an initializer (e.g. @config/initializers/fluther.rb@) that inserts the Fluther proxy after the Warden module, mounting it on the appropriate path:

Rails.configuration.after_initialize  do
  Rails.configuration.middleware.insert_after Warden::Manager, Fluther::Proxy, '/qna'
end
  • In the environment or initializer, add the Fluther configuration:
class Fluther::Config
  # hostname of the Fluther server for this environment (provided by Fluther)
  fluther_host 'fstage.fluther.com'

  # federated API key (provided by Fluther)
  app_key '2b6a0009c414c53e3d4fa8f8c3134d59'

  # mapping of attributes in the User model to the Fluther user
  user_fields :id => :id, :name => :name, :email => :email  # (defaults)
end

h2. Rails Integration

The proxy provides three Rack variables that include the Fluther response: @fluther.header@, @fluther.title@, and @fluther.response@. The first two (may) contain HTML blocks which should be inserted into the page @@ and @@ blocks, respectively, and the third is the HTML for the Fluther widget itself.

To integrate the response into your application, you should add an action which is routed from the same path as the Fluther proxy. For this example, we assume the controller is @MainController@, the action is @fluther@, and as above, it is mounted at @/qna@. Also, we assume that the application layout includes @yield(:head)@ in the @<head>@ block:

# config/routes.rb
map.fluther '/qna/*_', :controller => 'main', :action => 'fluther'
# app/views/main/fluther.html.erb
<%
  if (header = request.env['fluther.header']).present?
    content_for :head, header
  end
  if (title = request.env['fluther.title']).present?
    content_for :head, content_tag(:title, title)
  end
%>
<%= request.env['fluther.response'] -%>

You should now be able to start your application, navigate to http://localhost:300/qna and see the Fluther page.

h2. Thin Integration

The Fluther gem uses "EventMachine":http://github.com/igrigorik/em-http-request to perform the HTTP request. When running under a non-EventMachine web server, the proxy request will be performed synchronously. However, when running under the "Thin":http://code.macournoyer.com/thin/ web server, the proxy can take advantage of the presense of EventMachine to perform the request asynchronously, i.e. without blocking the web server process. This does require some additional setup:

  • Add the @async-rack@ gem to your application.
  • Add the following Rails code (v2 specific) to the block in the initializer you created above:
...
Rails.configuration.threadsafe!
Rails.configuration.dependency_loading = true
class AsyncRack::Lock  # kludge to disable error on async response in Rack::Lock
  def async_callback(result)
    super
  end
end
  • To run your application: @script/server thin@

h2. Credits

Special thanks to Andrew and Ben at Fluther for all their help with integration and testing.

  • Author: "Steve Sloan":mailto:steve@conceivian.com
  • Copyright: (c) 2010 Conceivian Corporation
  • License: MIT

FAQs

Package last updated on 11 Aug 2010

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc