Start using GenericParser.
parent
b4d80d2c71
commit
f579353d11
2
makefile
2
makefile
|
@ -1,7 +1,7 @@
|
|||
all: build
|
||||
|
||||
clone-generic-parser:
|
||||
[ -d ../parser ] || cd .. && git clone ssh://_gitea@git.baguette.netlib.re:2299/Baguette/parser.git
|
||||
[ ! -d ../parser ] && cd .. && git clone ssh://_gitea@git.baguette.netlib.re:2299/Baguette/parser.git || :
|
||||
|
||||
build: clone-generic-parser
|
||||
spago build
|
||||
|
|
|
@ -29,8 +29,9 @@ import Web.Event.Event (Event)
|
|||
import Bulma as Bulma
|
||||
import CSSClasses as C
|
||||
|
||||
import Parsing (runParser)
|
||||
import DomainParser as DomainParser
|
||||
import GenericParser (DomainError(..), parse)
|
||||
import GenericParser.DomainParserRFC1035 as RFC1035
|
||||
--import GenericParser.DomainParser as DomainParser
|
||||
import App.LogMessage
|
||||
import App.Messages.DNSManagerDaemon as DNSManager
|
||||
|
||||
|
@ -264,8 +265,11 @@ handleAction = case _ of
|
|||
H.modify_ _ { newDomainForm { new_domain = v } }
|
||||
case v of
|
||||
"" -> H.modify_ _ { newDomainForm { error_string = Nothing } }
|
||||
_ -> case runParser v DomainParser.domain of
|
||||
Left error_string -> H.modify_ _ { newDomainForm { error_string = Just $ show error_string } }
|
||||
_ -> case parse RFC1035.label { string: v, position: 0 } of
|
||||
Left { position, error } ->
|
||||
let error_string = "error " <> (show_error error)
|
||||
<> " at position: " <> show position
|
||||
in H.modify_ _ { newDomainForm { error_string = Just error_string } }
|
||||
Right _ -> H.modify_ _ { newDomainForm { error_string = Nothing } }
|
||||
UpdateSelectedDomain domain -> H.modify_ _ { newDomainForm { selected_domain = domain } }
|
||||
|
||||
|
@ -299,6 +303,13 @@ handleAction = case _ of
|
|||
H.raise $ MessageToSend message
|
||||
H.raise $ Log $ SimpleLog $ "[😇] Trying to add a new domain (" <> new_domain <> ")"
|
||||
handleAction $ HandleNewDomainInput $ INP_newdomain ""
|
||||
where
|
||||
show_error :: Maybe DomainError -> String
|
||||
show_error Nothing = "no specific error"
|
||||
show_error (Just (LabelTooLarge size)) = "LabelTooLarge (size: " <> show size <> ")"
|
||||
show_error (Just (DomainTooLarge size)) = "DomainTooLarge (size: " <> show size <> ")"
|
||||
show_error (Just (InvalidCharacter)) = "InvalidCharacter"
|
||||
show_error (Just (EOFExpected)) = "EOFExpected"
|
||||
|
||||
handleQuery :: forall a m. MonadAff m => Query a -> H.HalogenM State Action () Output m (Maybe a)
|
||||
handleQuery = case _ of
|
||||
|
|
Loading…
Reference in New Issue