1

Get Started with Rails

Social Stream is an engine for Ruby on Rails, the popular web development framework. You need to know Rails before developing with Social Stream. There is a nice guide at Getting Started with Rails that you should read first.

Once you have created your Rails application, you can add the Social Stream engine. Social Stream is quite modular, you are able to use only the functionalities you need in your application. Before installing Social Stream, you have to decide which components you are using in your new social network.

2

Social Stream’s components

Social Stream is splitted into components to provide developers with the precise functionality you need for their social network website. Every component is packaged as a Ruby Gem which is the standard packaging in Ruby. Ruby on Rails itself is also packaged as a gem.

Current available components in Social Stream are:

The social_stream-base gem provides your application with the core social network functionality. It supports users and groups, profile pages, activity streams, private messages and notifications, text posts and comments. Everything you need to start your social network.

The social_stream-documents gem adds the core support for file uploads. Besides, it adds some nice features to certain kind of files, such as image thumbnails, audio and video with an HTML5 player.

social_stream-events provides your social network with support for scheduled events, along with a nice full-screen calendar.

social_stream-linkser adds advanced management of links to other webpages. These are quite popular in leisure social networks where people share a lot of Youtube videos, for instance.

The social_stream-presence gem provides your social network with chat and videoconference support.

social_stream-ostatus lets your social network website federate with other social networks using the popular OStatus protocol.

The social_stream-oauth2_server gem turns your site into an OAuth2 provider, letting third party applications to access authentication and protected services in your social network.

4

Customize your application

Now you have your own social network! But we are sure you want to customize it. Now you will learn how to quickly change its appearance. All the examples are demonstrated in the social_stream-started application. You can download it and follow all the examples.

Quickly change the branding of your social network

Change the color using Bootstrap’s variables

Social Stream is built in the top of Bootstrap, the popular and powerful front-end framework. You can use Bootstrap’s variables to customize your social network! For example, you can easily change the color of your social network. Just add the following to the top of app/assets/stylesheets /social_stream.css.sass See example

// Must go before social_stream-base is loaded
@import variables

@import social_stream-base
...

Then, create a file in app/assets/stylesheets/_variables.scss with the changes you want. See example:

$orange:                #f89406 !default;
$principalColor:       $orange !default;
$linkColor:             $principalColor !default;

All the assets (images, javascripts, stylesheets) in your application have the highest priority over the ones in Social Stream. You can easily change the social network logo placing an image at app/assets/images/header-logo-index.png See example. It will be choosen by the server before Social Stream’s header-logo-index.png

Change the views

Where are the views? you will probably ask. Social Stream is Rails Engine. Everything (images, javascripts, css, views, models, controllers, etc.) is packaged within the gem, in an obscure place in your computer. But do not desperate! You still have full control on them and can change them in two ways, with Deface or overwriting them.

Defacing views

Using Spree’s Deface to change the views is the recomended way to go. Why? Because you will benefit from bug fixes and new features in new versions of Social Stream. If you just overwrite the views, these changes won’t be propagated to your final application.

See an example on how easy is to replace the contents of the footer

Overwriting views

The other option is completely overwrite the view. This makes change when the view is significantly different from the one in Social Stream. To achieve this, just place a view with the same path in your application. As in the case of the assets explained above, Rails will pick your application’s view before Social Stream’s. The social_stream-started application contains an example on how to completely overwrite the frontpage’s presentation partial.

Customize models and controllers

You can also customize any model or controller provided by Social Streams though the rails_engine_decorators gem. For example, if you want to add functionality to users, just create a file app/decorators/social_stream/ base/user_decorator.rb that reopens the class to include your functionality. See example.

User.class_eval do
  def decorator_test
    "test"
  end
end

5

More

Need more? Try this: