{"id":13483187,"url":"https://github.com/joshfrench/rakismet","last_synced_at":"2025-05-16T06:07:20.520Z","repository":{"id":393585,"uuid":"11432","full_name":"joshfrench/rakismet","owner":"joshfrench","description":"Easy Akismet and TypePad AntiSpam integration for Rails","archived":false,"fork":false,"pushed_at":"2017-11-16T06:17:33.000Z","size":135,"stargazers_count":355,"open_issues_count":7,"forks_count":45,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-05-13T12:18:09.777Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"beberlei/DoctrineExtensions","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joshfrench.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2008-04-21T00:09:57.000Z","updated_at":"2024-09-21T18:20:29.000Z","dependencies_parsed_at":"2022-07-18T08:49:07.450Z","dependency_job_id":null,"html_url":"https://github.com/joshfrench/rakismet","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshfrench%2Frakismet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshfrench%2Frakismet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshfrench%2Frakismet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshfrench%2Frakismet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joshfrench","download_url":"https://codeload.github.com/joshfrench/rakismet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254478190,"owners_count":22077676,"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-07-31T17:01:08.922Z","updated_at":"2025-05-16T06:07:15.506Z","avatar_url":"https://github.com/joshfrench.png","language":"Ruby","funding_links":[],"categories":["Captchas and anti-spam"],"sub_categories":[],"readme":"Rakismet\n========\n\n**Akismet** (\u003chttp://akismet.com/\u003e) is a collaborative spam filtering service.\n**Rakismet** is easy Akismet integration with Rails and rack apps. TypePad's\nAntiSpam service and generic Akismet endpoints are supported.\n\nCompatibility\n=============\n\n**Rakismet \u003e= 1.0.0** work with Rails 3 and other Rack-based frameworks.\n\n**Rakismet \u003c= 0.4.2** is compatible with Rails 2.\n\nGetting Started\n===============\n\nAdd the Rakismet gem to your Gemfile\n\n```ruby\ngem 'rakismet'\n```\n\nOnce you've added the Rakismet gem to your Gemfile and installed it with ``bundle install``,\nyou'll need an API key. Head on over to http://akismet.com/signup/ and sign up\nfor a new username.\n\nConfigure the Rakismet key and the URL of your application by setting the following\nin application.rb:\n\n```ruby\nconfig.rakismet.key = 'your wordpress key'\nconfig.rakismet.url = 'http://yourdomain.com/'\n```\n\nor an initializer, for example `config/initializers/rakismet.rb`:\n\n```ruby\nYourApp::Application.config.rakismet.key = 'your wordpress key'\nYourApp::Application.config.rakismet.url = 'http://yourdomain.com/'\n```\n\nIf you wish to use another Akismet-compatible API provider such as TypePad's\nantispam service, you'll also need to set `config.rakismet.host` to your service\nprovider's endpoint.\n\nIf you want to use a proxy to access akismet (i.e. your application is behind a\nfirewall), set the proxy_host and proxy_port option.\n\n```ruby\nconfig.rakismet.proxy_host = 'http://yourdomain.com/'\nconfig.rakismet.proxy_port = '8080'\n```\n\nIf your Rails app is a multitenant application, you can specify your Rakismet url as a proc:\n\n```ruby\nconfig.rakismet.url = Proc.new { ApplicationController.current_tenant.url }\n```\n\nChecking For Spam\n-----------------\n\nFirst, introduce Rakismet to your model:\n\n```ruby\nclass Comment\n  include Rakismet::Model\nend\n```\n\nWith Rakismet mixed in to your model, you'll get three instance methods for interacting with\nAkismet:\n\n * `spam?` submits the comment to Akismet and returns true if Akismet thinks the comment is spam, false if not.\n * `ham!` resubmits a valid comment that Akismet erroneously marked as spam (marks it as a false positive.)\n * `spam!` resubmits a spammy comment that Akismet missed (marks it as a false negative.)\n\nThe `ham!` and `spam!` methods will change the value of `spam?` but their\nprimary purpose is to send feedback to Akismet. The service works best when you\nhelp correct the rare mistake; please consider using these methods if you're\nmoderating comments or otherwise reviewing the Akismet responses.\n\nConfiguring Your Model\n----------------------\n\nRakismet sends the following information to the spam-hungry robots at Akismet:\n\n    author        : name submitted with the comment\n    author_url    : URL submitted with the comment\n    author_email  : email submitted with the comment\n    comment_type  : Defaults to comment but you can set it to trackback, pingback, or something more appropriate\n    content       : the content submitted\n    permalink     : the permanent URL for the entry the comment belongs to\n    user_ip       : IP address used to submit this comment\n    user_agent    : user agent string\n    referrer      : referring URL (note the spelling)\n\nBy default, Rakismet just looks for attributes or methods on your class that\nmatch these names. You don't have to have accessors that match these exactly,\nhowever. If yours differ, just tell Rakismet what to call them:\n\n```ruby\nclass Comment\n  include Rakismet::Model\n  attr_accessor :commenter_name, :commenter_email\n  rakismet_attrs :author =\u003e :commenter_name, :author_email =\u003e :commenter_email\nend\n```\n\nOr you can pass in a proc, to access associations:\n\n```ruby\nclass Comment \u003c ActiveRecord::Base\n  include Rakismet::Model\n  belongs_to :author\n  rakismet_attrs  :author =\u003e proc { author.name },\n                  :author_email =\u003e proc { author.email }\nend\n```\n\nYou can even hard-code specific fields:\n\n```ruby\nclass Trackback\n  include Rakismet::Model\n  rakismet_attrs :comment_type =\u003e \"trackback\"\nend\n```\n\nOptional Request Variables\n--------------------------\n\nAkismet wants certain information about the request environment: remote IP, the\nuser agent string, and the HTTP referer when available. Normally, Rakismet\nasks your model for these. Storing this information on your model allows you to\ncall the `spam?` method at a later time. For instance, maybe you're storing your\ncomments in an administrative queue or processing them with a background job.\n\nYou don't need to have these three attributes on your model, however. If you\nchoose to omit them, Rakismet will instead look at the current request (if one\nexists) and take the values from the request object instead.\n\nThis means that if you are **not storing the request variables**, you must call\n`spam?` from within the controller action that handles comment submissions. That\nway the IP, user agent, and referer will belong to the person submitting the\ncomment. If you're not storing the request variables and you call `spam?` at a\nlater time, the request information will be missing or invalid and Akismet won't\nbe able to do its job properly.\n\nIf you've decided to handle the request variables yourself, you can disable the\nmiddleware responsible for tracking the request information by adding this to\nyour app initialization:\n\n```ruby\nconfig.rakismet.use_middleware = false\n```\n\nAdditionally, the middleware will send along additional env variables starting with \nHTTP_ to Akismet. If you wish to block any sensitive user information, use:\n\n```ruby\nconfig.rakismet.excluded_headers = ['HTTP_COOKIE','HTTP_SENSITIVE']\n```\n\nexcluded_headers will default to ['HTTP_COOKIE']\n\nTesting\n-------\n\nRakismet can be configued to tell Akismet that it should operate in test mode -\nso Akismet will not change its behavior based on any test API calls, meaning\nthey will have no training effect. That means your tests can be somewhat\nrepeatable in the sense that one test won't influence subsequent calls.\n\nYou can configure Rakismet for test mode via application.rb:\n\n```ruby\nconfig.rakismet.test = false # \u003c- default\nconfig.rakismet.test = true\n```\n\nOr via an initializer:\n\n```ruby\nYourApp::Application.config.rakismet.test = false # \u003c- default\nYourApp::Application.config.rakismet.test = true\n```\n\n**NOTE**: When running in Rails, Rakismet will run in test mode when your Rails\nenvironment is `test` or `development`, unless explictly configured otherwise.\nOutside of Rails Rakismet defaults to test mode turned **off**.\n\n\nVerifying Responses\n-------------------\n\nIf you want to see what's happening behind the scenes, after you call one of\n`@comment.spam?`, `@comment.spam!` or `@comment.ham!` you can check\n`@comment.akismet_response`.\n\nThis will contain the last response from the Akismet server. In the case of\n`spam?` it should be `true` or `false.` For `spam!` and `ham!` it should be\n`Feedback received.` If Akismet returned an error instead (e.g. if you left out\nsome required information) this will contain the error message.\n\nFAQ\n===\n\nWhy does Akismet think all of my test data is spam?\n---------------------------------------------------\n\nAkismet needs enough information to decide if your test data is spam or not.\nTry to supply as much as possible, especially the author name and request\nvariables.\n\nHow can I simulate a spam submission?\n-------------------------------------\n\nMost people have the opposite problem, where Akismet doesn't think anything is\nspam. The only guaranteed way to trigger a positive spam response is to set the\ncomment author to \"viagra-test-123\".\nTo simulate a negative (not spam) result, set user_role to administrator, and all\nother required fields populated with typical values. The Akismet API will always\nreturn a false response.\n\nIf you've done this and `spam?` is still returning false, you're probably\nmissing the user IP or one of the key/url config variables. One way to check is\nto call `@comment.akismet_response`. If you are missing a required field or\nthere was another error, this will hold the Akismet error message. If your comment\nwas processed normally, this value will simply be `true` or `false`.\n\nCan I use Rakismet with a different ORM or framework?\n-----------------------------------------------------\n\nSure. Rakismet doesn't care what your persistence layer is. It will work with\nDatamapper, a NoSQL store, or whatever next month's DB flavor is.\n\nRakismet also has no dependencies on Rails or any of its components, and only\nuses a small Rack middleware object to do some of its magic. Depending on your\nframework, you may have to modify this slightly and/or manually place it in your\nstack.\n\nYou'll also need to set a few config variables by hand. Instead of\n`config.rakismet.key`, `config.rakismet.url`, and `config.rakismet.host`, set\nthese values directly with `Rakismet.key`, `Rakismet.url`, and `Rakismet.host`.\n\n---------------------------------------------------------------------------\n\nIf you have any implementation or usage questions, don't hesitate to get in\ntouch: josh@vitamin-j.com.\n\nCopyright (c) 2008 Josh French, released under the MIT license\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoshfrench%2Frakismet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoshfrench%2Frakismet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoshfrench%2Frakismet/lists"}