~singpolyma/jabber-iq-gateway-web

1a4ff87ff675c7d3b941f418ecfb897ac79663e5 — Stephen Paul Weber 2 years ago 168db81
Add tiny nip of CSS
1 files changed, 9 insertions(+), 4 deletions(-)

M jabber-iq-gateway-web.hs
M jabber-iq-gateway-web.hs => jabber-iq-gateway-web.hs +9 -4
@@ 56,6 56,9 @@ webPost sendIQ toJid req = (>>=) $ do
xmppURI :: Text -> URI.URI
xmppURI jid = (URI.URI "xmpp:" Nothing (textToString jid) "" "")

css :: Text
css = s"<style>body { font-family: sans-serif; }</style>"

webGetPrompt :: (XMPP.IQ -> IO (Maybe XMPP.IQ)) -> XMPP.JID -> IO Wai.Response
webGetPrompt sendIQ toJid = do
	result <- sendIQ $ (XMPP.emptyIQ XMPP.IQGet) {


@@ 75,10 78,11 @@ webGetPrompt sendIQ toJid = do
				Wai.text HTTP.status200 (Wai.stringHeaders' [
					("Content-Type",
					"text/html; charset=utf-8")
				]) $ s"<form method=\"post\" action=\"\">\
				]) $ css ++ s"<form method=\"post\" action=\"\">\
				\<p>" ++ escapeXML desc ++ s"</p>\
				\<input type=\"text\" name=\"prompt\" \
				\placeholder=\"" ++ escapeXML prompt ++ s"\" />\
				\ <button type=\"submit\">Add Contact</button>\
				\</form>"
		_ -> Wai.string HTTP.status400 []
		     "No jabber:iq:gateway available."


@@ 90,14 94,15 @@ web sendIQ req
	| method == HTTP.methodGet, Just toJid <- to =
		(>>=) $ webGetPrompt sendIQ toJid
	| otherwise = (>>=) $
		Wai.string HTTP.status200
		Wai.text HTTP.status200
		(Wai.stringHeaders' [
			("Content-Type", "text/html; charset=utf-8")
		])
		"<form method=\"get\" action=\"\">\
		(css ++ s"<form method=\"get\" action=\"\">\
		\<input type=\"text\" name=\"to\"\
			\placeholder=\"JabberID to query\" />\
		\</form>"
		\ <button type=\"submit\">Begin</button>\
		\</form>")

	where
	method = Wai.requestMethod req