[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet-scheme] 23/49: examles/web: Add a non-functional form for DHT in
From: |
gnunet |
Subject: |
[gnunet-scheme] 23/49: examles/web: Add a non-functional form for DHT insertions. |
Date: |
Sat, 25 Dec 2021 23:00:00 +0100 |
This is an automated email from the git hooks/post-receive script.
maxime-devos pushed a commit to branch master
in repository gnunet-scheme.
commit ef6d626ab6d5cdc6c59621dd5163aeb1f65e3173
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Sat Sep 25 18:07:06 2021 +0200
examles/web: Add a non-functional form for DHT insertions.
* examples/web.scm
(data-encoding-input, common-get/put-form-parts): New procedures.
(search-form): Use new procedures.
(put-form): New variable.
(url-handler): Use new variable.
---
examples/web.scm | 48 ++++++++++++++++++++++++++++++++++--------------
1 file changed, 34 insertions(+), 14 deletions(-)
diff --git a/examples/web.scm b/examples/web.scm
index 4e8f00f..f51d621 100644
--- a/examples/web.scm
+++ b/examples/web.scm
@@ -36,23 +36,43 @@
port))))
;; TODO: make the form work, defaults, ...
+
+(define (data-encoding-input name id)
+ `(select
+ (@ (name ,name) (id ,id))
+ (option (@ (value "utf-8-text")) "free-form text encoded as UTF-8")
+ (option (@ (value "hexadecimal")) "binary data encoded in hexadecimal")))
+
+(define (common-get/put-form-parts %prefix)
+ (define (prefix id) ; ids must be unique within a document
+ (string-append %prefix id))
+ `((li (label (@ (for "type")) "Type: ")
+ (input (@ (type "number") (id "type") (name "type"))))
+ (li (label (@ (for "replication-level")) "Replication level: ")
+ (input (@ (type "number") (id ,(prefix "replication-level"))
+ (name "replication-level"))))
+ (li (label (@ (for "key-encoding")) "Key encoding: ")
+ ,(data-encoding-input "key-encoding" (prefix "key-encoding")))
+ (li (label (@ (for "key")) "Key: ")
+ (input (@ (type "text") (id ,(prefix "key")) (name "key"))))))
+
(define search-form
- '(form
+ `(form
(@ (action "/search") (method "get"))
- (ul (li (label (@ (for "type")) "Type: ")
- (input (@ (type "number") (id "type") (name "type"))))
- (li (label (@ (for "replication-level")) "Replication level: ")
- (input (@ (type "number") (id "replication-level")
- (name "replication-level"))))
- (li (label (@ (for "key-encoding")) "Key encoding: ")
- (select
- (@ (name "key-encoding") (id "key-encoding"))
- (option (@ (value "utf-8-text")) "free-form text encoded as UTF-8")
- (option (@ (value "hexadecimal")) "binary data encoded in
hexadecimal")))
- (li (label (@ (for "key")) "Key: ")
- (input (@ (type "text") (id "key") (name "key")))))
+ (ul ,@(common-get/put-form-parts "get-"))
(input (@ (type "submit") (value "Search the DHT")))))
+;; TODO: make the form work, defaults, ...
+(define put-form
+ `(form
+ (@ (action "/put") (method "post"))
+ (ul ,@(common-get/put-form-parts "put-")
+ (li (label (@ (for "put-data-encoding")) "Encoding of data: ")
+ ,(data-encoding-input "data-encoding" "put-data-encoding"))
+ (li (label (@ (for "put-data")) "Data to insert: ")
+ (input (@ (type "text") (id "put-data") (name "data")))))
+ (input (@ (type "submit") (value "Put it into the DHT")))))
+
(define (estimate->html estimate)
`(dl (dt "Timestamp")
(dd ,(number->string (nse:estimate:timestamp estimate)))
@@ -67,7 +87,7 @@
(if current-estimate
(estimate->html current-estimate)
'(p "No estimate yet")))
- (respond/html `(div ,estimate-text ,search-form)))
+ (respond/html `(div ,estimate-text ,search-form ,put-form)))
(define (start config)
(define nse-server (nse:connect config))
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [gnunet-scheme] 12/49: dht/client: Send messages for new get operations., (continued)
- [gnunet-scheme] 12/49: dht/client: Send messages for new get operations., gnunet, 2021/12/25
- [gnunet-scheme] 13/49: dht/client: Send PUT messages., gnunet, 2021/12/25
- [gnunet-scheme] 24/49: examples/web: Put different information on separate pages., gnunet, 2021/12/25
- [gnunet-scheme] 20/49: dht/client: Call the callback on the client result., gnunet, 2021/12/25
- [gnunet-scheme] 17/49: dht/struct: Fix typo in synopsis., gnunet, 2021/12/25
- [gnunet-scheme] 14/49: Merge branch 'master' into dht, gnunet, 2021/12/25
- [gnunet-scheme] 22/49: examples/web: Make a non-functional web form for searching the DHT., gnunet, 2021/12/25
- [gnunet-scheme] 27/49: examples/web: Process DHT insertion forms., gnunet, 2021/12/25
- [gnunet-scheme] 40/49: examples/web: Don't hash the data., gnunet, 2021/12/25
- [gnunet-scheme] 35/49: examples/web: Allow module reloading., gnunet, 2021/12/25
- [gnunet-scheme] 23/49: examles/web: Add a non-functional form for DHT insertions.,
gnunet <=
- [gnunet-scheme] 15/49: Update copyright notices, gnunet, 2021/12/25
- [gnunet-scheme] 34/49: crypto: Implement functional variants., gnunet, 2021/12/25
- [gnunet-scheme] 33/49: examples/web: Hash free-form text first., gnunet, 2021/12/25
- [gnunet-scheme] 46/49: Merge branch 'dht'., gnunet, 2021/12/25
- [gnunet-scheme] 11/49: config: Define default UNIXPATH for DHT service., gnunet, 2021/12/25
- [gnunet-scheme] 16/49: Merge branch 'master' into dht, gnunet, 2021/12/25
- [gnunet-scheme] 19/49: dht/client: Recognise client result messages., gnunet, 2021/12/25
- [gnunet-scheme] 38/49: examples/web: Implement searching form., gnunet, 2021/12/25
- [gnunet-scheme] 43/49: examples/web: Display UTF-8 keys and data as text., gnunet, 2021/12/25
- [gnunet-scheme] 32/49: crypto: Implement a wrapper for hashing with bytevector slices., gnunet, 2021/12/25