fix_microsoft_links 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'fix_microsoft_links'
@@ -0,0 +1,7 @@
1
+ module FixMicrosoftLinks
2
+ class Railtie < Rails::Railtie
3
+ initializer 'fix_microsoft_links.register_middleware' do |app|
4
+ app.config.middleware.insert_after ::Rack::Lock, FixMicrosoftLinks::Rack::Response
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,26 @@
1
+ module FixMicrosoftLinks
2
+ module Rack
3
+ class Response
4
+ def initialize(app)
5
+ @app = app
6
+ end
7
+
8
+ def call(env)
9
+ # Clicking a URL from Microsoft apps will redirect you to login to already authenticated sites otherwise :(
10
+ # http://support.microsoft.com/kb/899927
11
+ if env["HTTP_USER_AGENT"] =~ /[^\w](Word|Excel|PowerPoint|Outlook)[^\w]/
12
+ body = StringIO.new("<html><head><meta http-equiv='refresh' content='0'/></head><body></body></html>")
13
+ return [200, {"Content-Type" => "text/html"}, body]
14
+ end
15
+ @app.call(env)
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+ # For rails 3 and greater, this will tie the fix into your middleware
22
+ require 'fix_microsoft_links/railtie' if defined?(Rails) && defined?(Rails::Railtie)
23
+
24
+ # If you are running a pre-rails 3 app you will need to do something like the following in your environment.rb:
25
+ # require 'fix_microsoft_links'
26
+ # config.middleware.insert_after Rack::Lock, FixMicrosoftLinks::Rack::Response
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fix_microsoft_links
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Zachary Kloepping
9
+ - Jon Bell
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2012-05-08 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rack
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: 1.1.1
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: 1.1.1
31
+ description:
32
+ email:
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - init.rb
38
+ - lib/fix_microsoft_links.rb
39
+ - lib/fix_microsoft_links/railtie.rb
40
+ homepage: https://github.com/spilliton/fix_microsoft_links
41
+ licenses: []
42
+ post_install_message:
43
+ rdoc_options: []
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ! '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ requirements: []
59
+ rubyforge_project:
60
+ rubygems_version: 1.8.24
61
+ signing_key:
62
+ specification_version: 3
63
+ summary: Fixes redirects to login pages when a user clicks a link to your site from
64
+ a Microsoft application like Word or Excel
65
+ test_files: []