sdoc_live 0.1.10 → 0.1.12

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: 01316e7563fe0c297ff8ee3304b86fcab074251063ab2c503369a8288362210c
4
- data.tar.gz: d4d839d93250944f290f0157282213c8888daf1c4bfbb2872c17b0ff1034b0b7
3
+ metadata.gz: 4de273e8f014c8b0ef3be552a4966ac2760935d376fcac4501348b1d27768041
4
+ data.tar.gz: bb62b0b50dcaf6c9a73468ca567791507d745af6ba333a586774ec2a4144203d
5
5
  SHA512:
6
- metadata.gz: 0fed3626046989a0448f0368d0d3d65d3889e82ec71cb43775969e832824f156dc773f25b2c9a0e7c92c284f6d76227045fc46e8bbd4e6052f397f99c1cbbf15
7
- data.tar.gz: 7b73e3fe0c6aecc0414120f1af80e4e92ecde9ddc314939ce3165ace61398c31d5a2f85238aec220395b2bd57ed78c4f3e949862eb0d5b85841fd163ead4af75
6
+ metadata.gz: 7728faa3614ae6b99367b2ac776b247d2095d961aec23d5c73fda4b66d9ad74870975aa9530abedfb64b44f24c1575fd12ca533da078b6903cc607d03bb5ddec
7
+ data.tar.gz: c560f5c75b13840d52185b5fcb8a318cef501f05aaf8c44f45914f56a1c80e1f4b72dee07a87f091a7f0bae590f589c44380ceef0ef4c8566dcaec70211971b9
@@ -11,48 +11,14 @@ module SdocLive
11
11
  doc_root = (config.output_dir || Rails.root.join("tmp", "doc")).to_s
12
12
  mount_path = config.mount_path
13
13
 
14
- app.middleware.use(SdocLive::StaticFiles, doc_root, mount_path)
15
- end
16
-
17
- end
18
-
19
- class StaticFiles
20
-
21
- def initialize(app, doc_root, mount_path)
22
- @app = app
23
- @doc_root = doc_root
24
- @mount_path = mount_path.chomp("/")
25
- end
26
-
27
- def call(env)
28
- path_info = env["PATH_INFO"]
29
-
30
- if path_info == @mount_path
31
- query = env["QUERY_STRING"].to_s.empty? ? "" : "?#{ env['QUERY_STRING'] }"
32
- return [301, { "location" => "#{ @mount_path }/#{ query }" }, []]
33
- end
34
-
35
- return @app.call(env) unless path_info.start_with?("#{ @mount_path }/")
36
-
37
- relative_path = path_info.delete_prefix(@mount_path)
38
- relative_path = "/index.html" if relative_path == "/"
39
-
40
- file_path = File.join(@doc_root, relative_path)
41
- file_path = File.join(file_path, "index.html") if File.directory?(file_path)
42
-
43
- if File.file?(file_path)
44
- serve_file(file_path)
45
- else
46
- @app.call(env)
47
- end
48
- end
49
-
50
- private
51
-
52
- def serve_file(path)
53
- content_type = Rack::Mime.mime_type(File.extname(path), "application/octet-stream")
54
- body = File.read(path, mode: "rb")
55
- [200, { "content-type" => content_type, "content-length" => body.bytesize.to_s }, [body]]
14
+ Rails.application.middleware.insert_before(
15
+ Rails::Rack::Logger,
16
+ ActionDispatch::Static,
17
+ doc_root,
18
+ headers: { "cache-control" => "public, max-age=3600" },
19
+ index: "index.html",
20
+ urls: [mount_path]
21
+ )
56
22
  end
57
23
 
58
24
  end
@@ -1,5 +1,5 @@
1
1
  module SdocLive
2
2
 
3
- VERSION = "0.1.10"
3
+ VERSION = "0.1.12"
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.10
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - 16554289+optimuspwnius@users.noreply.github.com