sdoc_live 0.1.12 → 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4de273e8f014c8b0ef3be552a4966ac2760935d376fcac4501348b1d27768041
4
- data.tar.gz: bb62b0b50dcaf6c9a73468ca567791507d745af6ba333a586774ec2a4144203d
3
+ metadata.gz: 5650fe4d2019c3e87194df2b3991e1353be042296fb48d4d6401832981aae200
4
+ data.tar.gz: 0a2aa835270a49e4e053e7c6e43de03cab05c335ce1bf3f28633d7db82bf7ce1
5
5
  SHA512:
6
- metadata.gz: 7728faa3614ae6b99367b2ac776b247d2095d961aec23d5c73fda4b66d9ad74870975aa9530abedfb64b44f24c1575fd12ca533da078b6903cc607d03bb5ddec
7
- data.tar.gz: c560f5c75b13840d52185b5fcb8a318cef501f05aaf8c44f45914f56a1c80e1f4b72dee07a87f091a7f0bae590f589c44380ceef0ef4c8566dcaec70211971b9
6
+ metadata.gz: d3370cd47fb6b9c436cf25f4b2da691c6da616bc225039393887be61133b8e20a7ca00b3bc107eba25fff09d906e8e164c0f859668fc29457141fada77960cf5
7
+ data.tar.gz: 0aee08711b0940fe269167b1e583b4578884d25c72b596cd7810be10e1bdcf4daeede3bed516bf033fccb4e805c548d8227409a1a2daf20afbbe7ef2e88f9a34
@@ -13,14 +13,43 @@ module SdocLive
13
13
 
14
14
  Rails.application.middleware.insert_before(
15
15
  Rails::Rack::Logger,
16
- ActionDispatch::Static,
16
+ SdocLive::StaticFiles,
17
17
  doc_root,
18
- headers: { "cache-control" => "public, max-age=3600" },
19
- index: "index.html",
20
- urls: [mount_path]
18
+ mount_path
21
19
  )
22
20
  end
23
21
 
24
22
  end
25
23
 
26
- end
24
+ class StaticFiles
25
+
26
+ def initialize(app, doc_root, mount_path)
27
+ @app = app
28
+ @mount_path = mount_path.chomp("/")
29
+ @file_handler = ActionDispatch::FileHandler.new(
30
+ doc_root,
31
+ headers: { "cache-control" => "public, max-age=3600" }
32
+ )
33
+ end
34
+
35
+ def call(env)
36
+ path_info = env["PATH_INFO"]
37
+
38
+ if path_info == @mount_path
39
+ query = env["QUERY_STRING"].to_s.empty? ? "" : "?#{env['QUERY_STRING']}"
40
+ return [301, { "location" => "#{@mount_path}/#{query}" }, []]
41
+ end
42
+
43
+ if path_info.start_with?("#{@mount_path}/")
44
+ env["PATH_INFO"] = path_info.delete_prefix(@mount_path)
45
+ response = @file_handler.attempt(env)
46
+ env["PATH_INFO"] = path_info
47
+ return response if response
48
+ end
49
+
50
+ @app.call(env)
51
+ end
52
+
53
+ end
54
+
55
+ end
@@ -1,5 +1,5 @@
1
1
  module SdocLive
2
2
 
3
- VERSION = "0.1.12"
3
+ VERSION = "0.1.13"
4
4
 
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sdoc_live
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - 16554289+optimuspwnius@users.noreply.github.com