diff --git a/Main.hs b/Main.hs index 81d4d95..be5faf8 100644 --- a/Main.hs +++ b/Main.hs @@ -6,9 +6,13 @@ import qualified IHP.Server import IHP.RouterSupport import IHP.FrameworkConfig import IHP.Job.Types +import Web.FrontController +import Web.Types instance FrontController RootApplication where - controllers = [] + controllers = [ + mountFrontController WebApplication + ] instance Worker RootApplication where workers _ = [] diff --git a/Web/Controller/Prelude.hs b/Web/Controller/Prelude.hs new file mode 100644 index 0000000..106e039 --- /dev/null +++ b/Web/Controller/Prelude.hs @@ -0,0 +1,13 @@ +module Web.Controller.Prelude +( module Web.Types +, module Application.Helper.Controller +, module IHP.ControllerPrelude +, module Generated.Types +) +where + +import Web.Types +import Application.Helper.Controller +import IHP.ControllerPrelude +import Generated.Types +import Web.Routes diff --git a/Web/Controller/Static.hs b/Web/Controller/Static.hs new file mode 100644 index 0000000..0296557 --- /dev/null +++ b/Web/Controller/Static.hs @@ -0,0 +1,6 @@ +module Web.Controller.Static where +import Web.Controller.Prelude +import Web.View.Static.Welcome + +instance Controller StaticController where + action WelcomeAction = render WelcomeView diff --git a/Web/FrontController.hs b/Web/FrontController.hs new file mode 100644 index 0000000..e1fb78a --- /dev/null +++ b/Web/FrontController.hs @@ -0,0 +1,19 @@ +module Web.FrontController where + +import IHP.RouterPrelude +import Web.Controller.Prelude +import Web.View.Layout (defaultLayout) + +-- Controller Imports +import Web.Controller.Static + +instance FrontController WebApplication where + controllers = + [ startPage WelcomeAction + -- Generator Marker + ] + +instance InitControllerContext WebApplication where + initContext = do + setLayout defaultLayout + initAutoRefresh diff --git a/Web/Routes.hs b/Web/Routes.hs new file mode 100644 index 0000000..98b0b2b --- /dev/null +++ b/Web/Routes.hs @@ -0,0 +1,7 @@ +module Web.Routes where +import IHP.RouterPrelude +import Generated.Types +import Web.Types + +-- Generator Marker +instance AutoRoute StaticController \ No newline at end of file diff --git a/Web/Types.hs b/Web/Types.hs new file mode 100644 index 0000000..d48bddd --- /dev/null +++ b/Web/Types.hs @@ -0,0 +1,10 @@ +module Web.Types where + +import IHP.Prelude +import IHP.ModelSupport +import Generated.Types + +data WebApplication = WebApplication deriving (Eq, Show) + + +data StaticController = WelcomeAction deriving (Eq, Show, Data) diff --git a/Web/View/Layout.hs b/Web/View/Layout.hs new file mode 100644 index 0000000..891047b --- /dev/null +++ b/Web/View/Layout.hs @@ -0,0 +1,74 @@ +module Web.View.Layout (defaultLayout, Html) where + +import IHP.ViewPrelude +import IHP.Environment +import Generated.Types +import IHP.Controller.RequestContext +import Web.Types +import Web.Routes +import Application.Helper.View + +defaultLayout :: Html -> Html +defaultLayout inner = [hsx| + + +
+ {metaTags} + + {stylesheets} + {scripts} + ++ Your new application is up and running. +
+ ++ Join our community on Slack! +
+ + + Learn the Next Steps in the Documentation + ++ You can modify this start page by making changes to "./Web/View/Static/Welcome.hs". +
+