Skip to content

amerine/rack_konami

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rack::Konami

Rack::Konami is a Rack middleware that injects a hidden snippet into your pages. When a user enters the Konami Code (↑ ↑ ↓ ↓ ← → ← → B A ↵), the snippet fades in and then disappears after a configurable delay.

Features

  • Works with jQuery 1.4 or later, falling back to vanilla JavaScript if jQuery isn't present.
  • Supports both keyboard and touch devices.
  • Configurable HTML snippet and fade-out delay.
  • Automatically updates the Content-Length header when injecting content.
  • Compatible with Ruby 3 and Rack 3.

Installation

gem install rack_konami

Basic Usage

require 'rack_konami'

use Rack::Konami, html: "<img src='/images/rails.png'>", delay: 1500

app = lambda do |env|
  [200, { 'Content-Type' => 'text/html' }, '<html><body><p>Awesome Body</p></body></html>']
end

run app

Rails and Sinatra

Rails 2.3.x

Add to config/environment.rb:

config.gem 'rack_konami'
config.middleware.use Rack::Konami, html: "<img src='/images/rails.png'>", delay: 1500

Rails 3.x / Sinatra

Add to your Gemfile:

gem 'rack_konami'

Then in config.ru:

use Rack::Konami, html: "<img src='/images/rails.png'>", delay: 1500

Rails 6.0 – 7.1

Add the gem to your Gemfile and install:

gem 'rack_konami'

Then configure middleware in config/application.rb (or an initializer):

config.middleware.use Rack::Konami, html: "<img src='/images/rails.png'>", delay: 1500

Open your browser and type ↑ ↑ ↓ ↓ ← → ← → B A ↵.

Running Tests

bundle install
bundle exec rake test

Contributing

  1. Fork the project.
  2. Make your feature addition or bug fix.
  3. Add tests so future changes don't break your code.
  4. Commit without modifying the Rakefile, version, or history.
  5. Send a pull request (topic branches are appreciated).

License

Copyright (c) 2010-2025 Mark Turner. See LICENSE for details.

About

Rack middlware that embeds the Konami code in your apps

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages