bgeminiserver 1.0.0 → 1.0.2
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 +4 -4
- data/lib/geminiserver.rb +10 -20
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11ece503be3e6903fb2f59e49994bbc7a73612247063f3769d8628d03308d54b
|
4
|
+
data.tar.gz: d47146808a64104e457618c6b9df1376ab135c1bf3737234f6f1c57804027b58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87df4dd3a6a0f399d15ccf431eaf37d56624fd2a53f34784edced5f02ca67890c40792643a717e398bd6b15da7e3160c7221896739c43185e1cbb70f4ef6948c
|
7
|
+
data.tar.gz: 04d384a26126a4453f16a92f3cc12108b49fa1d8dacd3ac5ae739d6f93cce61da903966400fc70fbb883c7c46dd9ebf0e1fd42fe45831e9cbee3e03b476ca5ef
|
data/lib/geminiserver.rb
CHANGED
@@ -5,20 +5,16 @@ require "uri"
|
|
5
5
|
|
6
6
|
module GeminiPage
|
7
7
|
|
8
|
-
# Indexes a path of the file sysem (with folders) and creates corresponding
|
9
|
-
# handlers. There is no caching.
|
8
|
+
# Indexes a path of the file sysem (with folders) and creates corresponding handlers. There is no caching.
|
10
9
|
# All files which do not have a mimetype with text/ are read binary.
|
11
10
|
#
|
12
|
-
# @param serv [GeminiServer] The server object on which the handlers should be
|
13
|
-
# registered.
|
11
|
+
# @param serv [GeminiServer] The server object on which the handlers should be registered.
|
14
12
|
# @param dir_path [String] Path to be indexed.
|
15
13
|
# @param prefix [String] Prefix on the server.
|
16
14
|
# @param extensions [Hash] List of file extensions and corresponding mimetypes.
|
17
15
|
# @param default [String] Default mimetype
|
18
|
-
# @param file_prefix [String] Internal use. Path from the file system which
|
19
|
-
#
|
20
|
-
# @example Indexes the downloads folder of the user "user" and makes the files
|
21
|
-
# available under "/computer/Downloads/".
|
16
|
+
# @param file_prefix [String] Internal use. Path from the file system which should not be used as a prefix on the server.
|
17
|
+
# @example Indexes the downloads folder of the user "user" and makes the files available under "/computer/Downloads/".
|
22
18
|
# GeminiPage.index_dir serv, "/home/user/Downloads/", "/computer/Downloads/"
|
23
19
|
def self.index_dir serv, dir_path, prefix = "/", extensions = {"gmi" => "text/gemini"}, default = "application/octet-stream", file_prefix = nil
|
24
20
|
file_prefix = dir_path if ! file_prefix
|
@@ -66,8 +62,7 @@ module GeminiPage
|
|
66
62
|
#
|
67
63
|
# @param func [Proc] Function which is called.
|
68
64
|
# @param input_prompt [String] Prompt to be sent to the client.
|
69
|
-
# @param secret [String] True if the input contains sensitive data such as a
|
70
|
-
# password, false otherwise.
|
65
|
+
# @param secret [String] True if the input contains sensitive data such as a password, false otherwise.
|
71
66
|
# @return [Proc]
|
72
67
|
# @example A simple page in Gemini format, which has "Hello World!" as its headline.
|
73
68
|
# GeminiPage.require_input(->(conn, cert, input) {
|
@@ -228,10 +223,8 @@ class GeminiServer
|
|
228
223
|
|
229
224
|
# Starts the server. However, the server does not yet respond to requests.
|
230
225
|
#
|
231
|
-
# Registers a handler for a specific path. The handler is a function (Proc),
|
232
|
-
#
|
233
|
-
# * The current connection to the client. Through this the function can return
|
234
|
-
# content to the client. Can be handled similar to a stream.
|
226
|
+
# Registers a handler for a specific path. The handler is a function (Proc), which gets three parameters:
|
227
|
+
# * The current connection to the client. Through this the function can return content to the client. Can be handled similar to a stream.
|
235
228
|
# * The (if available) certificate sent by the client.
|
236
229
|
# * The input (if any) sent by the client.
|
237
230
|
#
|
@@ -246,8 +239,7 @@ class GeminiServer
|
|
246
239
|
@handlers[path] = func
|
247
240
|
end
|
248
241
|
|
249
|
-
# Copies a handler for another path. If the original handler is edited, the
|
250
|
-
# new one is not edited.
|
242
|
+
# Copies a handler for another path. If the original handler is edited, the new one is not edited.
|
251
243
|
#
|
252
244
|
# @param path [String]
|
253
245
|
# @param copy_path [String]
|
@@ -264,11 +256,9 @@ class GeminiServer
|
|
264
256
|
@handlers.delete path
|
265
257
|
end
|
266
258
|
|
267
|
-
# Enables the server so that it responds to requests. This blocks the rest of
|
268
|
-
# the program.
|
259
|
+
# Enables the server so that it responds to requests. This blocks the rest of the program.
|
269
260
|
#
|
270
|
-
# @param log [TrueClass, FalseClass] If enabled, successful requests from
|
271
|
-
# clients are output.
|
261
|
+
# @param log [TrueClass, FalseClass] If enabled, successful requests from clients are output.
|
272
262
|
# @example
|
273
263
|
# serv.listen
|
274
264
|
def listen log = false
|