{"id":19319703,"url":"https://github.com/hyperoslo/feeder","last_synced_at":"2025-04-22T17:32:06.161Z","repository":{"id":15100481,"uuid":"17827215","full_name":"hyperoslo/feeder","owner":"hyperoslo","description":"Provides simple feed functionality through an engine","archived":false,"fork":false,"pushed_at":"2015-01-15T12:18:29.000Z","size":797,"stargazers_count":6,"open_issues_count":2,"forks_count":1,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-04-14T08:51:00.147Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://rubygems.org/gems/feeder","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hyperoslo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-03-17T12:30:12.000Z","updated_at":"2019-08-13T15:37:49.000Z","dependencies_parsed_at":"2022-09-08T16:41:40.600Z","dependency_job_id":null,"html_url":"https://github.com/hyperoslo/feeder","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperoslo%2Ffeeder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperoslo%2Ffeeder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperoslo%2Ffeeder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperoslo%2Ffeeder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hyperoslo","download_url":"https://codeload.github.com/hyperoslo/feeder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250287676,"owners_count":21405659,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T01:24:53.851Z","updated_at":"2025-04-22T17:32:05.749Z","avatar_url":"https://github.com/hyperoslo.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Feeder\n\n[![Gem Version](https://img.shields.io/gem/v/feeder.svg?style=flat)](https://rubygems.org/gems/feeder)\n[![Build Status](https://img.shields.io/travis/hyperoslo/feeder.svg?style=flat)](https://travis-ci.org/hyperoslo/feeder)\n[![Dependency Status](https://img.shields.io/gemnasium/hyperoslo/feeder.svg?style=flat)](https://gemnasium.com/hyperoslo/feeder)\n[![Code Climate](https://img.shields.io/codeclimate/github/hyperoslo/feeder.svg?style=flat)](https://codeclimate.com/github/hyperoslo/feeder)\n[![Coverage Status](https://img.shields.io/coveralls/hyperoslo/feeder.svg?style=flat)](https://coveralls.io/r/hyperoslo/feeder)\n\nFeeder gives you a mountable engine that provides a route to a feed page in your\nRuby on Rails application.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'feeder'\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install feeder\n\nInstall the migrations:\n\n    rake feeder:install:migrations\n\nRun the migrations:\n\n    rake db:migrate\n\nInclude the helpers in your controllers:\n\n    # app/controllers/application_controller.rb\n    class ApplicationController \u003c ActionController::Base\n      helper Feeder::AuthorizationHelper\n      helper Feeder::LikeHelper\n    end\n\n## Usage\n\nTo make Feeder available, mount it to a route by adding the following somewhere\nin your _config/routes.rb_:\n\n```ruby\nmount Feeder::Engine =\u003e \"/feed\"\n```\n\nYou will now be able to display a feed on _/feed_ in your application. In order\nfor Feeder to display anything in your feed, however, you will need to make\nviews per item type in the feed. Feeder looks up these views in\n_app/views/feeder/types_ by default, and then checks for a partial with the same\nname as your item type. As an example, if you have a `Message` model that you\nwish to list out on your feed, you would make a file called *_message.html.erb*\nin _app/views/feeder/types_.\n\nThen, all you need to do is to declare that your `Message` model is feedable:\n\n```ruby\nclass Message \u003c ActiveRecord::Base\n  # If you don't want to publish every message in the feed,\n  # you can provide an option: `if: -\u003e message { message.show_in_feed? }`\n  feedable\nend\n```\n\n### Filtering\n\nWant to filter out what feedables to display in your feed? We've got you covered\nthrough the all-powerful `filter` scope! Give it a scope or model class, \nand Feeder makes sure to only return feed items with the specified feedables.\nFor example: say you have the following feedables:\n- `ShortMessage`\n- `Tweet`\n- `NewsArticle`\n\nTo get `Feeder::Item`s with news articles having IDs `[1, 2, 3, 4, 5]`, tweets\nfrom `featured` scope and all short message, you could do like this:\n\n```ruby\nFeeder::Item.filter(\n  NewsArticle.where(id: [1, 2, 3, 4, 5]),\n  Tweet.featured,\n  ShortMessage,\n)\n```\n\n**NOTE:** The `filter` scope is _exclusive_, meaning that anything you _do not_\npass in to it will also not be brought back. With the above feedables, if you\nonly want short messages `[1, 3, 4]`, but all of the tweets and news articles,\nyou would have to specify them as well, like this:\n\n```ruby\nFeeder::Item.filter(\n  ShortMessage.where(id: [1, 3, 4]),\n  Tweet,\n  NewsArticle\n)\n```\n\nThe following would only return feed items with short messages:\n\n```ruby\nFeeder::Item.filter(ShortMessage)\n```\n\n### Configuration\n\n```ruby\nFeeder.configure do |config|\n  # A list of scopes that will be applied to the feed items in the controller.\n  config.scopes \u003c\u003c proc { limit 5 }\nend\n```\n\nYou have access to the controller in the scope, which enables you to do cool\nstuff like this:\n\n```ruby\nFeeder.configure do |config|\n  # A list of scopes that will be applied to the feed items in the controller.\n  config.scopes \u003c\u003c proc { |ctrl| limit ctrl.params[:limit] }\nend\n```\n\nIf your scope evaluates to `nil` it will not be applied to prevent it from\nbreaking the scope chain. This enables optional paramaters by doing something\nlike this:\n\n```ruby\nFeeder.configure do |config|\n  # A list of scopes that will be applied to the feed items in the controller.\n  config.scopes \u003c\u003c proc { |ctrl| ctrl.params.has_key?(:limit) limit(ctrl.params[:limit]) : nil }\nend\n```\n\nAdd this to your `spec/spec_helper.rb` if you don't want to create\n`Feeder::Item` during the tests:\n```ruby\nFeeder.configure do |config|\n  config.test_mode = true\nend\n```\n\n### Stickies\n\nYou can \"sticky\" items in your feed so they're pinned at the top regardless of when\nthey were created. Just set the `sticky` attribute and Feeder will take care of the rest.\n\n### Recommendations\n\nYou can appoint moderators to recommend exemplary items to your feed. You can configure the\nconditions upon which a user is allowed to recommend items by creating an authorization adapter.\n\n```ruby\nFeeder.configure do |config|\n  config.authorization_adapter = MyAuthorizationAdapter\nend\n```\n\nAn authorization adapter is just a class that can be initialized with a user and responds to\n`authorized?` (see `Feeder::AuthorizationAdapters::Base`).\n\nFeeder ships with an authorization adapter for CanCan. To use it, just set the `authorization_adapter`\nconfiguration to `Feeder::AuthorizationAdapter::CanCanAdapter`. If your ability is called something\nother than `Ability`, you will also want to configure `cancan_ability_class` to refer to it. If the method\nto derive the current user is called something other than `current_user`, you will also want to configure\n`current_user_method`.\n\n```ruby\nFeeder.configure do |config|\n  config.authorization_adapter = Feeder::AuthorizationAdapters::CanCanAdapter\n  config.authorization_adapter.cancan_ability_class  = 'Permission'\n  config.current_user_method = 'current_author'\nend\n```\n\n### Likes\n\nYou can let users like items in your feed. As with recommendations you can configure the\nconditions upon which users is allowed to recommend items by creating an authorization adapter.\n\nYou can also configure feeder to enable the use of multiple kinds of \"likes\" by setting the\n`like_scopes` configuration variable.\n\n```ruby\nFeeder.configure do |config|\n  config.like_scopes = [:cred, :kudos]\nend\n```\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n\n## Credits\n\nHyper made this. We're a digital communications agency with a passion for good code,\nand if you're using this library we probably want to hire you.\n\n\n## License\n\nFeeder is available under the MIT license. See the MIT-LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperoslo%2Ffeeder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhyperoslo%2Ffeeder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperoslo%2Ffeeder/lists"}