rack-heroku-no-such-app 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7147ca6e94bfd638eeeefbac249528ff88901552
4
+ data.tar.gz: a1daf331e4e3af9e834df5cb0cea747c3895257f
5
+ SHA512:
6
+ metadata.gz: 6e74b1c6b950c21d4dd38a602cf98c895d68ea3c9f0b2928a87fbe88abffd7ff3fef73f4499dd2e86a2ee899ca93e78c5e9b05bbac08e3316b3c557450670336
7
+ data.tar.gz: d080c3ed7d434921203603f62ea5fbba41f436d5a3d24d470f6d08d258581b899afcde1e8aa61a89fa2502b9bbbbafd46a45f2bcbeb44dd462c29575387a260a
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,21 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rack-heroku-no-such-app (0.0.1)
5
+ rack (>= 1.2.0, <= 2.0.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ rack (1.5.2)
11
+ rack-test (0.6.2)
12
+ rack (>= 1.0)
13
+ rake (0.9.6)
14
+
15
+ PLATFORMS
16
+ ruby
17
+
18
+ DEPENDENCIES
19
+ rack-heroku-no-such-app!
20
+ rack-test (~> 0.6)
21
+ rake (~> 0.9)
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2013 Mattt Thompson (http://mattt.me)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -0,0 +1,22 @@
1
+ Rack::HerokuNoSuchApp
2
+ =====================
3
+
4
+ Rack middleware to prevent loading from `*.heroku.com` / `*.herokuapp.com` addresses by serving default Heroku 404 page for "App not found". Use in combination with custom domains.
5
+
6
+ ## Usage
7
+
8
+ ```ruby
9
+ require "rack/heroku/no-such-app"
10
+
11
+ use Rack::Heroku::NoSuchApp
12
+ ```
13
+
14
+ Including this in the `config.ru` file of your Rack application will respond to requests for `*.herokuapp.com` (or redirected from `*.heroku.com`) with the following 404 page:
15
+
16
+ > ## Heroku | No such app
17
+ > There is no app configured at that hostname.
18
+ > Perhaps the app owner has renamed it, or you mistyped the URL.
19
+
20
+ ## License
21
+
22
+ rack-heroku-no-such-app is available under the MIT license. See the LICENSE file for more info.
@@ -0,0 +1,11 @@
1
+ require "bundler"
2
+ Bundler.setup
3
+
4
+ gemspec = eval(File.read("rack-heroku-no-such-app.gemspec"))
5
+
6
+ task :build => "#{gemspec.full_name}.gem"
7
+
8
+ file "#{gemspec.full_name}.gem" => gemspec.files + ["rack-heroku-no-such-app.gemspec"] do
9
+ system "gem build rack-heroku-no-such-app.gemspec"
10
+ system "gem install rack-heroku-no-such-app-#{Rack::Heroku::NoSuchApp::VERSION}.gem"
11
+ end
@@ -0,0 +1,126 @@
1
+ module Rack
2
+ module Heroku
3
+ class NoSuchApp
4
+ VERSION = "0.0.1"
5
+
6
+ HEROKUAPP_DOMAIN_REGEXP = /.+\.heroku(app)?\.com/
7
+
8
+ def initialize(app)
9
+ @app = app
10
+ end
11
+
12
+ def call(env)
13
+ if HEROKUAPP_DOMAIN_REGEXP === (env['HTTP_HOST'] || env['SERVER_NAME'])
14
+ return [404, headers, body]
15
+ end
16
+
17
+ @app.call(env)
18
+ end
19
+
20
+ private
21
+
22
+ def headers
23
+ {
24
+ 'Content-Type' => 'text/html',
25
+ 'Server' => "MochiWeb/1.0 (Any of you quaids got a smint?)"
26
+ }
27
+ end
28
+
29
+ def body
30
+ <<-EOF
31
+ <!DOCTYPE html>
32
+ <html>
33
+ <head>
34
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
35
+ <title>Heroku | No such app</title>
36
+ <style type='text/css'>
37
+ body {
38
+ background-color: white;
39
+ color: #333333;
40
+ font-family: Arial, sans-serif;
41
+ margin: 0;
42
+ padding: 36px;
43
+ line-height: 18px;
44
+ font-size: 14px; }
45
+
46
+ .section {
47
+ margin-bottom: 36px; }
48
+ .section.friendly {
49
+ color: #222222; }
50
+ .section.friendly h1 {
51
+ font-size: 26px;
52
+ background-color: #dad8e4;
53
+ padding: 18px 22px 15px 22px;
54
+ margin: 0;
55
+ overflow: hidden; }
56
+ .section.friendly h1 strong {
57
+ display: inline-block;
58
+ float: left; }
59
+ .section.friendly h1 small {
60
+ display: inline-block;
61
+ float: right;
62
+ text-align: right;
63
+ font-size: 18px;
64
+ padding-top: 4px;
65
+ color: #333333; }
66
+ .section.friendly .article {
67
+ border: 4px solid #dad8e4;
68
+ padding: 24px 18px 18px 18px; }
69
+ .section.friendly .article h3 {
70
+ font-size: 20px;
71
+ margin: 0 0 18px 0; }
72
+ .section.friendly .article a {
73
+ color: #6b6ceb; }
74
+ .section.friendly .article a:visited {
75
+ color: #1d1d3b; }
76
+ .section.friendly .article p {
77
+ font-size: 14px; }
78
+ .section.friendly .article ul {
79
+ list-style-type: square; }
80
+ .section.original {
81
+ background-color: #eeeeee;
82
+ color: #444444; }
83
+ .section.original h2 {
84
+ background-color: #dddddd;
85
+ margin: 0;
86
+ padding: 18px 22px 18px 22px;
87
+ font-size: 20px; }
88
+ .section.original pre {
89
+ margin: 0;
90
+ padding: 18px 22px 18px 22px;
91
+ overflow: auto;
92
+ font-family: monaco, monospaced; }
93
+ .section.original pre code {
94
+ display: block;
95
+ font-size: 11px;
96
+ width: 100%; }
97
+ </style>
98
+ <script type="text/javascript">
99
+ var _gaq = _gaq || [];
100
+ _gaq.push(['_setAccount', 'UA-2989055-7']);
101
+ _gaq.push(['_setDomainName', '.heroku.com']);
102
+ _gaq.push(['_trackPageview']);
103
+ (function() {
104
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
105
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
106
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
107
+ })();
108
+
109
+ </script>
110
+ </head>
111
+ <body>
112
+ <div class='container'>
113
+ <div class='section friendly'>
114
+ <h1><strong>Heroku | No such app</strong></h1>
115
+ <div class='article'>
116
+ <p>There is no app configured at that hostname.<br/>Perhaps the app owner has renamed it, or you mistyped the URL.</p>
117
+ </div>
118
+ </div>
119
+ </div>
120
+ </body>
121
+ </html>
122
+ EOF
123
+ end
124
+ end
125
+ end
126
+ end
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "rack/heroku/no-such-app"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "rack-heroku-no-such-app"
7
+ s.authors = ["Mattt Thompson"]
8
+ s.email = "m@mattt.me"
9
+ s.license = 'MIT'
10
+ s.homepage = "http://github.com/mattt/rack-heroku-no-such-app"
11
+ s.version = Rack::Heroku::NoSuchApp::VERSION
12
+ s.platform = Gem::Platform::RUBY
13
+ s.summary = "rack-heroku-no-such-app"
14
+ s.description = "Rack middleware to prevent loading from `*.heroku.com` / `*.herokuapp.com` addresses by serving default Heroku 404 page for 'App not found'. Use in combination with custom domains."
15
+
16
+ s.add_runtime_dependency "rack", ">= 1.2.0", "<= 2.0.0"
17
+
18
+ s.add_development_dependency "rack-test", "~> 0.6"
19
+ s.add_development_dependency "rake", "~> 0.9"
20
+
21
+ s.files = Dir["./**/*"].reject { |file| file =~ /\.\/(bin|log|pkg|script|spec|test|vendor)/ }
22
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
23
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
24
+ s.require_paths = ["lib"]
25
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rack-heroku-no-such-app
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Mattt Thompson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-03-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 1.2.0
20
+ - - <=
21
+ - !ruby/object:Gem::Version
22
+ version: 2.0.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.2.0
30
+ - - <=
31
+ - !ruby/object:Gem::Version
32
+ version: 2.0.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: rack-test
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ~>
38
+ - !ruby/object:Gem::Version
39
+ version: '0.6'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: '0.6'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '0.9'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ~>
59
+ - !ruby/object:Gem::Version
60
+ version: '0.9'
61
+ description: Rack middleware to prevent loading from `*.heroku.com` / `*.herokuapp.com`
62
+ addresses by serving default Heroku 404 page for 'App not found'. Use in combination
63
+ with custom domains.
64
+ email: m@mattt.me
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - ./Gemfile
70
+ - ./Gemfile.lock
71
+ - ./lib/rack/heroku/no-such-app.rb
72
+ - ./LICENSE
73
+ - ./rack-heroku-no-such-app.gemspec
74
+ - ./Rakefile
75
+ - ./README.md
76
+ homepage: http://github.com/mattt/rack-heroku-no-such-app
77
+ licenses:
78
+ - MIT
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.0.3
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: rack-heroku-no-such-app
100
+ test_files: []