summaryrefslogtreecommitdiff
path: root/lisp/webapps/dns-admin/site.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/webapps/dns-admin/site.lisp')
-rw-r--r--lisp/webapps/dns-admin/site.lisp103
1 files changed, 103 insertions, 0 deletions
diff --git a/lisp/webapps/dns-admin/site.lisp b/lisp/webapps/dns-admin/site.lisp
new file mode 100644
index 0000000..996eeea
--- /dev/null
+++ b/lisp/webapps/dns-admin/site.lisp
@@ -0,0 +1,103 @@
+;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
+(declaim (optimize (speed 0) (safety 3) (debug 3)))
+
+(in-package #:dns-admin)
+
+(defmacro .base (&optional (onload-fn "goto_location('/dns')"))
+ `(html5
+ `(html
+ (head
+ ((meta :name "viewport" :content "width=device-width, initial-scale=1"))
+ ((meta :charset "utf-8"))
+ ((title) ,(title *webapp*))
+ ,@(mapcar (lambda (css)
+ `((link :rel "stylesheet" :href ,(getf css :href) :integrity ,(getf css :integrity) :crossorigin ,(getf css :crossorigin))))
+ '((:href "https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" :integrity "sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" :crossorigin "anonymous")))
+ ,@(mapcar (lambda (js)
+ `((script :type "text/javascript" :src ,(getf js :src) :integrity ,(getf js :integrity) :crossorigin ,(getf js :crossorigin))))
+ '((:src "https://code.jquery.com/jquery-3.2.1.slim.min.js" :integrity "sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" :crossorigin "anonymous")
+ (:src "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" :integrity "sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" :crossorigin "anonymous")
+ (:src "https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" :integrity "sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" :crossorigin "anonymous")))
+ ((script :type "text/javascript" :src "/static/js/cljs/main.js")))
+ ((body :onload ,(format nil "dnsadmin.core.~a" ,onload-fn))
+ ((div :class "container-fluid")
+ ((div :class "row" :style "padding: 20px")
+ ((div :class "col")
+ ((div :class "page-header")
+ ((h2 :align "center") ,(title *webapp*))))))
+ ((div :id "location" :style "display: none"))
+ ((div :id "authmsg"))
+ ((div :id "errormsg"))
+ ((div :id "message"))
+ ((div :id "body"))
+ ((div :id "infoblox-creds" :class "modal fade" :role "dialog")
+ ((div :class "modal-dialog modal-lg")
+ ((div :class "modal-content")
+ ((div :class "modal-header")
+ ((h5 :class "modal-title") "Infoblox - Connection Parameters")
+ ((button :type "button" :class "close" :data-dismiss "modal") "×"))
+ ((div :id "infoblox-creds-body" :class "modal-body" :style "height: 460px;"))
+ ((div :class "modal-footer")
+ ((button :type "submit" :class "btn btn-danger btn-default" :data-dismiss "modal")
+ ((span :class "glyphicon glyphicon-remove") "Cancel"))))))))))
+
+(defmacro .location ()
+ `(handle-location location))
+
+(defmacro .dns ()
+ `(handle-dns))
+
+(defmacro .dns-headers ()
+ `(handle-dns-headers recordtype))
+
+(defmacro .dns-login-get ()
+ `(handle-dns-login-get))
+
+(defmacro .dns-login-post ()
+ `(handle-dns-login-post username pwd keypath))
+
+(defmacro .dns-api-search-get ()
+ `(handle-dns-api-search-get recordtype))
+
+(defmacro .dns-api-search-post ()
+ `(handle-dns-api-search-post recordtype ref name ipv4addr ipv6addr canonical ptrdname))
+
+(defmacro .dns-api-add-get ()
+ `(handle-dns-api-add-get recordtype))
+
+(defmacro .dns-api-add-post ()
+ `(handle-dns-api-add-post recordtype name ipv4addr ipv6addr canonical ptrdname))
+
+(defmacro .dns-api-modify-get ()
+ `(handle-dns-api-modify-get recordtype ref name ipv4addr ipv6addr canonical ptrdname))
+
+(defmacro .dns-api-modify-post ()
+ `(handle-dns-api-modify-post recordtype ref name ipv4addr ipv6addr canonical ptrdname))
+
+(defmacro .dns-api-delete-post ()
+ `(handle-dns-api-delete-post recordtype ref))
+
+(defmacro .dns-api-ttl-get ()
+ `(handle-dns-api-ttl-get recordtype ref name))
+
+(defmacro .dns-api-ttl-post ()
+ `(handle-dns-api-ttl-post recordtype ref ttl))
+
+;; hunchentoot fails to differentiate between :get and :post to the
+;; same URL. So we work around it in the URLs but fix it in the
+;; downstream macro and function names.
+(define-endpoint :get "/" () .base)
+(define-endpoint :post "/location" ((location :parameter-type 'string)) .location)
+(define-endpoint :get "/dns" () .dns)
+(define-endpoint :post "/dns/headers" ((recordtype :parameter-type 'string)) .dns-headers)
+(define-endpoint :get "/dns/login" () .dns-login-get)
+(define-endpoint :post "/dns/login/post" ((username :parameter-type 'string) (pwd :parameter-type 'string) (keypath :parameter-type 'string)) .dns-login-post)
+(define-endpoint :post "/dns/api/search" ((recordtype :parameter-type 'string)) .dns-api-search-get)
+(define-endpoint :post "/dns/api/search/post" ((recordtype :parameter-type 'string) (ref :parameter-type 'string) (name :parameter-type 'string) (ipv4addr :parameter-type 'string) (ipv6addr :parameter-type 'string) (canonical :parameter-type 'string) (ptrdname :parameter-type 'string)) .dns-api-search-post)
+(define-endpoint :post "/dns/api/add" ((recordtype :parameter-type 'string)) .dns-api-add-get)
+(define-endpoint :post "/dns/api/add/post" ((recordtype :parameter-type 'string) (name :parameter-type 'string) (ipv4addr :parameter-type 'string) (ipv6addr :parameter-type 'string) (canonical :parameter-type 'string) (ptrdname :parameter-type 'string)) .dns-api-add-post)
+(define-endpoint :post "/dns/api/modify" ((recordtype :parameter-type 'string) (ref :parameter-type 'string) (name :parameter-type 'string) (ipv4addr :parameter-type 'string) (ipv6addr :parameter-type 'string) (canonical :parameter-type 'string) (ptrdname :parameter-type 'string)) .dns-api-modify-get)
+(define-endpoint :post "/dns/api/modify/post" ((recordtype :parameter-type 'string) (ref :parameter-type 'string) (name :parameter-type 'string) (ipv4addr :parameter-type 'string) (ipv6addr :parameter-type 'string) (canonical :parameter-type 'string) (ptrdname :parameter-type 'string)) .dns-api-modify-post)
+(define-endpoint :post "/dns/api/delete/post" ((recordtype :parameter-type 'string) (ref :parameter-type 'string)) .dns-api-delete-post)
+(define-endpoint :post "/dns/api/ttl" ((recordtype :parameter-type 'string) (ref :parameter-type 'string) (name :parameter-type 'string)) .dns-api-ttl-get)
+(define-endpoint :post "/dns/api/ttl/post" ((recordtype :parameter-type 'string) (ref :parameter-type 'string) (ttl :parameter-type 'string)) .dns-api-ttl-post)