• Stars
    star
    132
  • Rank 265,790 (Top 6 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 11 years ago
  • Updated about 10 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Generate a social feed in javascript.

SocialFeed.js

Easily create a feed with your latest interactions on different social media. SocialFeed.js was inspired by the compiled feed on http://gnab.org/, and was designed to be very modular and plugable.

SocialFeed.js

At this moment the following features are implemented:

  • Github
  • Vimeo
  • Youtube Video Uploads
  • Disqus
  • RSS Feeds
  • Delicious

However, extending SocialFeed.js is a simple task. See Extending SocialFeed.js for more information.

See SocialFeed.js in use at my personal site. For a complete example two SocialFeeds, Require.JS, extending modules, using with Handlebar, etc see the source code for http://mikaelb.net/ at https://github.com/mikaelbr/mikaelbr.github.io.

Installation & Usage

Requirements

Install

Manually Download

Installing SocialFeed.js is simple. Just download the raw JavaScript file and optionally the CSS file.

Using Bower

bower install socialfeed

Import all dependancies and the SocialFeed.js code.

<html>
  <head>
    <title>SocialFeed.js</title>
    <link rel="stylesheet" type="text/css" href="socialfeed.min.css">
  </head>
  <body>
    <div id="socialfeed"></div>
    <!-- Import Scripts -->
    <script src="components/jquery/jquery.js"></script>
    <script src="components/socialfeed/socialfeed.min.js"></script>
  </body>
</html>

Usage

SocialFeed.js is very modular, and every different social site is implemented as it's own module. By default, no social site is added, you have to explicitly add every social function. This to be as customizable as possible.

SocialFeed has a simple constructor. If you only pass it a jQuery event, all module items will be rendered, but you can restrict this by passing the count-option. Even if count is 5, all module items are fetched from the different APIs, but only the first 5 are rendered.

Constructor:

new SocialFeed({
    el: '#foo' // selector or jQuery object for wrapper element.
  , count: 10 // defaults to 1000
  , offset: 10 // defaults to 0. Start rendering from offset.
});

If you set offset to N, the first N items won't show.

Shortcut:

new SocialFeed('#foo');

Let's see how we can add Github and Delicious as a part of the feed (using the template as defined above.):

var sfeed = new SocialFeed({
                el: $("#socialfeed")
              , count: 10
            })
            .addModule(new SocialFeed.Modules.Github('mikaelbr')) // argument: username
            .addModule(new SocialFeed.Modules.Delicious('mikaelbr')) // argument: username
            .start();

This will populate the #socialfeed element when data from both of the social sites are loaded.

Note, if you omit the start(). Nothing will happen. SocialFeed() waits until explicitly told to initiate.

Disqus requires a public API key to access data, so we have an extra argument when adding the module:

var sfeed = new SocialFeed($("#socialfeed"))
                  .addModule(new SocialFeed.Modules.Disqus('mikaelbr', 'OEMdBc63xd0MZGKiVV5JgExTqdO7OSYkjgv613LJ8Py89y44pcoSKeBrelZjepVS'))
                  .start();

Built in Modules

Every built in module is under the namespace SocialFeed.Modules.

Module Description
Github(username[, hideEvents = None]) Shows all your events on github, including create repositories, starring, forking, pull requesting, pushing.
Vimeo(username[, hideEvents = None]) Shows your activity on Vimeo, including like, add comment and upload.
YouTubeUploads(username[, count = 10]) Shows uploaded YouTube videos. Sorted by updated time, not published.
Disqus(username, public_api_key) Show your public comments made on Disqus.
Delicious(username) Shows your shared bookmarks.
RSS(rssUrl, count) Fetches the count number of posts from your RSS feed at rssUrl

API

SocialFeed exposes several functions and events.

Methods

Method Description
.start() Initiate SocialFeed.js.
.reload() Reload content. Fetch new data from social channels.
.loadNumEntries(number) Load the next number items, if more to load.
.nextBulk() Loads the next bulk of items. If constructor initiated with count 10, load next 10.
.addModule(Module) Add a new module to the feed.
.on(eventType, callback) Listen for an event on the feed. See Events

Events

To listen for a event use:

var sfeed = new SocialFeed($("#socialfeed"));
sfeed.on('eventName', function() { /* body */ });

or for Modules:

var mod = new SocialFeed.Modules.Github('mikaelbr');
mod.on('eventName', function() { /* body */ });

Events for a feed

Event Type Passed arguments Description
start None Triggered when .start() is called
reload None Triggered when .reload() is called
addModule Module Triggered when module is added
moduleAdded Module Triggered when module is added and fetched
preFetch None Triggered before fetching data from modules.
postFetch AllModules[] Triggered when all modules are fetched
dataReady SortedHTMLList, AllModules[] Triggered when all data is generated as HTML.
rendered SortedHTMLList{from _offset, to count} Triggered when rendering new items. Passes the sorted HTML list with the rendered entities.
nextBulk None Triggered when .nextBulk() is called.
loadNumEntries Number Triggered when .loadNumEntries() is called.
error Module, jqXHR, AjaxOptions Triggered when error fetching some module data.

Events for a module

Event Type Passed arguments Description
error Module, jqXHR, AjaxOptions Triggered on error fetching module data.
fetched Module, jqXHR, AjaxOptions Triggered when data for module is fetched.

Extending SocialFeed.js

Adding new Social sites.

You can easily add new modules to SocialFeed.js. See code for example:

var NewModule = SocialFeed.Modules.extend({
  init: function(ident, count) {
    // Constructor. Omit to use default one with only "ident".
    this.ident = ident;
    this.count = count;
  }

  , url: function () {
    // URL can also be a string, but having it as a function
    // allows us to pass the ident value. ident is the first argument
    // to the module constructor.
    return 'http://path.to.some/document.json?user=' + this.ident + '&count=' + this.count;
  }

  , parse: function (resp) {
    // resp is the response from the AJAX call. Return a list of entities.
    return resp.result;
  }

  , orderBy: function (item) {
    // orderBy must be implemented. Return a numeric value to sort by.
    // item is an entity from the results.
    return -(new Date(item.created_at)).getTime();
  }

  , render: function (item) {
    // Return HTML representation of an entity.
    return '<p>' + item.message + '</p>';
  }
});

var sfeed = new SocialFeed($("#socialfeed"))
                  .addModule(new NewModule('mikaelbr', 10))
                  .start();

Extend/Alter behaviour of existing module

You can change original behaviour of the pre-defined modules by extending them and overwriting their methods.

Example:

var Disqus = SocialFeed.Modules.Disqus.extend({
  render: function (item) {
    return '<p>Allways show this message!</p>';
  }
});

var sfeed = new SocialFeed($("#socialfeed"))
                  .addModule(new Disqus('mikaelbr', 'OEMdBc63xd0MZGKiVV5JgExTqdO7OSYkjgv613LJ8Py89y44pcoSKeBrelZjepVS'))
                  .start();

Examples

See examples for more code snippets and help.

Changelog

  • v0.3.7: Added Vimeo as a module.
  • v0.3.6-2: Simplified the constructor, to take a element selector instead of jQuery element.
  • v0.3.6-1: Event type clean up.
  • v0.3.6: Added AMD definition.
  • v0.3.5: Major bugfix: Browserify now wraps scripts in a SIAF. SocialFeed.js no longer destroys everything it touches.
  • v0.3.4:
    • Added RSS Module
    • Added ES5 Shims
    • Bugfix: Reloading fixed.

Contribute

SocialFeed.js is very open for contributions. If you have built a module you think should be built in or find a bug, please send a pull request.

Also feel free to post issues at https://github.com/mikaelbr/SocialFeed.js/issues.

Contribution guide

To set-up SocialFeed.js to run locally, do the following:

$ git clone git://github.com/mikaelbr/SocialFeed.js.git
$ cd SocialFeed.js/

Install dependencies

$ make deps

This will install both the client side deps and browser side.

Build

After making your changes, bundle a new version of SocialFeed.js.

From root, run

make bundle

This will build the JavaScript, compile LESS files and minify both. You can find the bundled files in the root directory.

More Repositories

1

node-notifier

A Node.js module for sending notifications on native Mac, Windows and Linux (or Growl as fallback)
JavaScript
5,711
star
2

awesome-es2015-proxy

For learning how to use JavaScript Proxy, or just to see what is possible
JavaScript
600
star
3

gulp-notify

gulp plugin to send messages based on Vinyl Files or Errors to Mac OS X, Linux or Windows using the node-notifier module. Fallbacks to Growl or simply logging
JavaScript
592
star
4

marked-terminal

A Renderer for the marked project. Allowing you to render Markdown to print to your Terminal
JavaScript
405
star
5

mversion

A cross packaging module version bumper. CLI or API for bumping versions of package.json, bower.json, *.jquery.json etc.
JavaScript
199
star
6

node-notifier-cli

CLI API for node-notifier as separate package.
JavaScript
142
star
7

metatune

PHP Wrapper for the Spotify Metadata API and the Spotify Play Button
PHP
55
star
8

node-osascript

A stream for Apple Open Scripting Architecture (OSA) through AppleScript or Javascript
JavaScript
50
star
9

bacon-love

A Nodeschool type workshop for Functional Reactive Programming and Bacon.js
JavaScript
48
star
10

fp-react

Functional tools for React components
JavaScript
41
star
11

vscodemod

VSCode extension for doing codemod on selected text
JavaScript
30
star
12

did-i-do-that

A debug tool based on JavaScript Proxy to track surprising/unwanted mutation of objects.
JavaScript
26
star
13

gulp-gitmodified

A plugin for Gulp to get an object stream of modified files on git.
JavaScript
22
star
14

frp-piano

An example of Functional Reactive Programming, by implementing a simple collaborative piano.
CSS
19
star
15

node-heartrate

A Bluethooth Low Energy heart rate stream
JavaScript
15
star
16

babel-plugin-transform-react-require

Transform files using JSX to implicitly require React (or other implementations).
JavaScript
15
star
17

gulp-gitshasuffix

A plugin for Gulp to suffix files with latest commit sha.
JavaScript
11
star
18

chrome-github-packages

Enhance Package.json on Github by linking up modules to NPM
JavaScript
11
star
19

mrun

mrun - A npm module for setting npm run properties to build/watch less and browserify code
JavaScript
10
star
20

lastfm-spotify-urilist

A Node.js module for an easy way of getting a list of Spotify URIs based on Last.fm data.
JavaScript
10
star
21

markdowner

Markdowner is a cloud based application for writing and sharing Markdown documents.
JavaScript
9
star
22

cli-usage

Easily show the usage of your CLI tool from a Markdown string or file
JavaScript
9
star
23

AI-Poker-Player

NTNU Project for AI Programming
Python
8
star
24

metabrag

A jQuery plugin for showing off your GitHub and Coderwall stats.
JavaScript
7
star
25

kodesnutt

Kode brukt i episoder av Kodesnutt.io
JavaScript
5
star
26

simplify-playbutton

Automated service for generating Spotify Play Button for your Last.fm scrobbled tracks. Using Node.js and running on Heroku.
JavaScript
5
star
27

kakle

If Commit, Then Do. Kakle helps you remember when you should run commands after pulling external changes
JavaScript
5
star
28

clapper

Do actions on applause and listen on claps on browser usermedia
JavaScript
4
star
29

node-csstats

Parse AMX Mod X Stats File. A result of procrastinating during a Master's thesis and nostalgia.
JavaScript
4
star
30

SwarmWebots

Project 4 - Artificial Swarm Behavior
Python
4
star
31

record-access

Property accessors as functions similar to .property in elm-lang.
JavaScript
4
star
32

traceur-cli

Wraps traceur cli to add REPL and string eval
JavaScript
4
star
33

didt

Did I do that?
JavaScript
3
star
34

bacon.decorate

Unify your API and abstract time using Functional Reactive Programming and Bacon.js
JavaScript
3
star
35

json-ast

OCaml JSON AST generator. Work in progress
OCaml
3
star
36

phpcoderwall

PHP library for fetching Coderwall data
PHP
3
star
37

presentations

A collection of presentations
JavaScript
3
star
38

graphql-node-import

Import `.graphql` and `.gql` files directly in Node, accessing queries and fragments
TypeScript
3
star
39

nextjs-css-relative-assets-bug-repro

JavaScript
2
star
40

standalone-unrar

A standalone unrar library without any need for external dependencies.
JavaScript
2
star
41

diy-nextjs-server-actions

Example code from presentation "DIY Nextjs Server Actions"
TypeScript
2
star
42

node-repo-github

A very simple node.js wrapper to get Github Repo Information.
JavaScript
2
star
43

twit-stream

Streaming Twitter data with proper Node.JS streams2 with a simple API
JavaScript
2
star
44

rm-debugger

Simplest codemod you can think of, but is still handy: Remove all `debugger;` statements from your code.
JavaScript
2
star
45

react-formdata

A library for generating an object of values from a set of inputs in React
JavaScript
2
star
46

mikaelbr

My special repository
2
star
47

twitscraper

A binary used for scraping the Twitter site for tweets and generate a .tsv file for output
JavaScript
2
star
48

release-actions-demo

JavaScript
1
star
49

bekk-open-source

Repo brukt for planlegging av faggruppearbeid ifm. Open Source
1
star
50

Basic-Evolutionary-Programming

The code for a University project
Python
1
star
51

metaenter

A simple jQuery plugin for simulating a facebook-like text input.
JavaScript
1
star
52

dotfiles

My dotfiles used for importing to new systems and backup
Shell
1
star
53

simplserv

A simple HTTP server using Python. For web development and testing AJAX calls.
Python
1
star
54

aoc22

Advent of Code solutions for 2022 in OCaml
OCaml
1
star
55

lsystem-reasonml

ReasonML experimentation implementing Lindenmayer system
OCaml
1
star
56

AnnWebots

Project 3 - Webots with Generic Anns
Python
1
star
57

stringywingy

Check if a sentence or a word is an anagram or a palindrome.
JavaScript
1
star
58

kodesnutt.io

Kodesnutt.io homepage
HTML
1
star
59

tweetsa

Python
1
star
60

bekk-trhfrontend-prosjektoppsett

Oppsett av nye frontendprosjekter med transpilering og LESS. Stegvis guide til hvordan det kan gjรธres.
JavaScript
1
star
61

podcast-player

CLI tool for listening to podcasts.
JavaScript
1
star
62

webkom-kurs2015

Kurs for Webkom Kickoff 2015.
JavaScript
1
star
63

tdcinfographic-raspberry

Server component to the tdcinfographic application. Connecting to the tdcinfographic Node.js app through WebSockets.
Python
1
star
64

asyncjs.kodesnutt.io-source

Source for asyncjs.kodesnutt.io
CSS
1
star
65

async-kodesnutt

CSS
1
star
66

simplify-zones

Simplify geometry of tariff zones from Entur
JavaScript
1
star
67

webkom-kurs2015-webpack

Kurs for Webkom Kickoff 2015 - WebPack versjon
JavaScript
1
star
68

gifme

gifme client for posting gifs to Slack
OCaml
1
star
69

ndc

My talk for NDC2014: Functional Reactive Programming and Bacon
JavaScript
1
star
70

tweetannotator

A web tool for annotating sentiment on random tweets. Can be used to generate data sets for machine learning algorithms
JavaScript
1
star
71

CP-Sudoku

Constraint based sudoku solver
Java
1
star
72

immutable-memo

Memoization with immutable data structures for React.memo
JavaScript
1
star
73

textareaAutoHeight

Create a Facebook like input box in seconds. A text area will automaticly set height according to content, and submit on enter, but give new line at shift + enter.
JavaScript
1
star
74

auto-unrar

Automatic unpack all recursive rar-files from a directory
JavaScript
1
star
75

azure-ml-text-analysis

API Wrapper for doing text analysis on Azure Machine Learning Platform
JavaScript
1
star
76

cheerful.dev

Test site for Svelte, Sapper and Now.sh
Svelte
1
star
77

Coding-Dojo-Counter

A web application for selecting sparrers and keeping time in Coding Dojos. Integration with Facebook Events
JavaScript
1
star