gnunet-svn
[Top][All Lists]
Advanced

[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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]