gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet-scheme] 22/49: examples/web: Make a non-functional web form for


From: gnunet
Subject: [gnunet-scheme] 22/49: examples/web: Make a non-functional web form for searching the DHT.
Date: Sat, 25 Dec 2021 22:59:59 +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 f66adf06f910f2289f740c503e049e6ba1369a7b
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Sat Sep 25 16:51:52 2021 +0200

    examples/web: Make a non-functional web form for searching the DHT.
    
    * examples/web.scm
      (search-form): New variable.
      (url-handler)[body]: Rename to ...
      (url-handler)[estimate-text]: ... this.
      (url-handler): Include the search form.
---
 examples/web.scm | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/examples/web.scm b/examples/web.scm
index b39cdba..4e8f00f 100644
--- a/examples/web.scm
+++ b/examples/web.scm
@@ -35,6 +35,24 @@
                              (body ,body))
                       port))))
 
+;; TODO: make the form work, defaults, ...
+(define search-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")))))
+    (input (@ (type "submit") (value "Search the DHT")))))
+
 (define (estimate->html estimate)
   `(dl (dt "Timestamp")
        (dd ,(number->string (nse:estimate:timestamp estimate)))
@@ -45,11 +63,11 @@
 
 (define (url-handler server request body)
   (define current-estimate (nse:estimate server))
-  (define body
+  (define estimate-text
     (if current-estimate
        (estimate->html current-estimate)
        '(p "No estimate yet")))
-  (respond/html body))
+  (respond/html `(div ,estimate-text ,search-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]