rack-rscript 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e2ae444c177f0c9d60fe675075fd1800e9124c81
4
- data.tar.gz: e40f6ad9a8580c0d2eaa713d59592edeb2cc7948
3
+ metadata.gz: 67eaf987c95218ab325c90f6cdc5950a91d83ec4
4
+ data.tar.gz: b351e24514900fd5f9d9ac6db045e69799af0c75
5
5
  SHA512:
6
- metadata.gz: 7e09e5713f0e25eefb0b087d8b546b8014615f665ad147b8293fa271c4303f301a1bb84e07f4df8fc3e272d07c3080a2e02c238a8d77904143203188ecfc490f
7
- data.tar.gz: 632512b0a99b3a16e7901cbab78026aaa96bc7df7c980b755395384ce7c0c9c0850de07902275b10662b6924ae0c15daa12d82461f7ed913376f8aaa66703aec
6
+ metadata.gz: 90139ab92d16f29258861fc9cfc11df3126aa4a59d41e511bcb5c9dd5fec15231dde62b287210a213da8452dd50604e4544727cb1772758274093f253c43fb7c
7
+ data.tar.gz: d220fbc8ee425c9e93bb61176eea4a51b5eb8176e5507e89559ff7df9deece05e90d32beacded05365e7a6bcebb86c253e86eff864802aa9313f9790d30cd67d
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/rack-rscript.rb CHANGED
@@ -31,17 +31,22 @@ class RackRscript
31
31
 
32
32
 
33
33
  def initialize(log: nil, pkg_src: '', cache: 5, rsc_host: 'rse',
34
- rsc_package_src: nil, pxlinks: nil, debug: false)
34
+ rsc_package_src: nil, pxlinks: nil, debug: false,
35
+ root: 'www', static: [])
36
+
37
+ @log, @debug, @static = log, debug, static
38
+
39
+ puts '@app_root: ' + @app_root.inspect if @debug
40
+ puts 'root: ' + root.inspect if @debug
35
41
 
36
42
  @params = {}
43
+
37
44
  @templates = {}
38
45
 
39
46
  @rrscript = RScript.new log: log, pkg_src: pkg_src, cache: cache
40
47
 
41
48
  @url_base = pkg_src # web server serving the RSF files
42
- @url_base += '/' unless @url_base[-1] == '/'
43
-
44
- @log, @debug = log, debug
49
+ @url_base += '/' unless @url_base[-1] == '/'
45
50
 
46
51
  if pxlinks then
47
52
 
@@ -65,6 +70,12 @@ class RackRscript
65
70
 
66
71
  @rsc = nil
67
72
  @rsc = RSC.new rsc_host, rsc_package_src if rsc_package_src
73
+
74
+ @filetype = {xml: 'application/xml', html: 'text/html', png: 'image/png',
75
+ jpg: 'image/jpeg', txt: 'text/plain', css: 'text/css',
76
+ xsl: 'application/xml', svg: 'image/svg+xml'}
77
+
78
+ @root, @static = root, static
68
79
 
69
80
  end
70
81
 
@@ -130,7 +141,7 @@ class RackRscript
130
141
  'application/json' => passthru_proc,
131
142
  'image/png' => passthru_proc,
132
143
  'image/jpeg' => passthru_proc,
133
- 'image/svg+xml' => passthru_proc
144
+ 'image/svg+xml' => passthru_proc
134
145
  }
135
146
 
136
147
  content_type ||= 'text/html'
@@ -263,7 +274,37 @@ class RackRscript
263
274
  'application/json']
264
275
 
265
276
  end
266
-
277
+
278
+ get /^(\/(?:#{@static.join('|')}).*)/ do |path|
279
+
280
+ puts 'path: ' + path.inspect if @debug
281
+ filepath = File.join(@app_root, @root, path )
282
+
283
+ if @log then
284
+ @log.info 'DandelionS1/default_routes: ' +
285
+ "root: %s path: %s" % [@root, path]
286
+ end
287
+
288
+ if path.length < 1 or path[-1] == '/' then
289
+ path += 'index.html'
290
+ File.read filepath
291
+ elsif File.directory? filepath then
292
+ Redirect.new (path + '/')
293
+ elsif File.exists? filepath then
294
+
295
+ content_type = @filetype[filepath[/\w+$/].to_sym]
296
+ [File.read(filepath), content_type || 'text/plain']
297
+ else
298
+ 'oops, file ' + filepath + ' not found'
299
+ end
300
+
301
+ end
302
+
303
+ get /^\/$/ do
304
+
305
+ file = File.join(@root, 'index.html')
306
+ File.read file
307
+ end
267
308
 
268
309
  end
269
310
 
data.tar.gz.sig CHANGED
@@ -1,2 +1,5 @@
1
- +t0z3v���T\�65Uv����z 6�;�4T�������f��1ǘ�W�&MU�زc��EN��° HQ ��&p���^�
2
- #��%ֵ��2��>��=�$�� YW Q�Zu@����b�c� ���+��e���~��� � ��1V�ݰ-����@̈́�������i;��ASL��8���lzw�Ol|׻��}`�����O^'�'���b���=��N=��$ �����9���5r�
1
+ [��MKP�zM4b*���YY)n%A �<��S��i4Y��̇�vx��3xTeF��6�F<|
2
+ ��r!-GcWe 0�/Mb��=(Ft����q��qN���#�P|��s��-��,v�2�O��o}
3
+ �˞��
4
+ ^�w��%D�#��
5
+ ��� sp���у ����}Ge�o�喘}�V�s%�eEB#;����������=r
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-rscript
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  vvLi4Y0qQy/Uz/kHVXzfeLcG657aNIu8ogA1I3Xnlz0sqlNoDhk5sSBd2BsfkVFS
32
32
  sTo/69YTrLx1zw==
33
33
  -----END CERTIFICATE-----
34
- date: 2018-06-18 00:00:00.000000000 Z
34
+ date: 2018-07-22 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rack
metadata.gz.sig CHANGED
@@ -1 +1 @@
1
- R<�Á���@wj��(�@��SO�e�%���?n�lǓ�}��;/�$�Wf76�4�i�� dN4p<�9ꡓ(5�� b[+7W��>�z_���kC��_�$!�U 2+a+�qiƩ���hsK�O���]����_���D+N���BJr׾L��z�_pTpu0d�U:V Y�(��+�~mR&Ґρ���CL�Z�5�.�Y�<",D�����f���*�h��/�G��۶���.�:�5@��=a@'}uɉ#���H
1
+ T��ѝ`�G��g�.�PŦâ(e,�k^U U/L/���F�~`>�@@��4��h=[ad��|�YGCc`li',U�חM��ؾ+(j�xF ��=qvM"sss O�:���.dpg�~10u+ #�:K�="����3�*�4YH��F����qv؜T�"fL�G�'�� RqW �cj��&f��;�OD���1<����ok�����v����ܧF%|��ܷX9P�%�>C*THt;`L�