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} + + {pageTitleOrDefault "App"} + + +
+ {renderFlashMessages} + {inner} +
+ + +|] + +-- The 'assetPath' function used below appends a `?v=SOME_VERSION` to the static assets in production +-- This is useful to avoid users having old CSS and JS files in their browser cache once a new version is deployed +-- See https://ihp.digitallyinduced.com/Guide/assets.html for more details + +stylesheets :: Html +stylesheets = [hsx| + + + + |] + +scripts :: Html +scripts = [hsx| + {when isDevelopment devScripts} + + + + + + + + + + + + + |] + +devScripts :: Html +devScripts = [hsx| + + |] + +metaTags :: Html +metaTags = [hsx| + + + + + + + {autoRefreshMeta} +|] diff --git a/Web/View/Prelude.hs b/Web/View/Prelude.hs new file mode 100644 index 0000000..86a2e47 --- /dev/null +++ b/Web/View/Prelude.hs @@ -0,0 +1,14 @@ +module Web.View.Prelude +( module IHP.ViewPrelude +, module Web.View.Layout +, module Generated.Types +, module Web.Types +, module Application.Helper.View +) where + +import IHP.ViewPrelude +import Web.View.Layout +import Generated.Types +import Web.Types +import Web.Routes () +import Application.Helper.View diff --git a/Web/View/Static/Welcome.hs b/Web/View/Static/Welcome.hs new file mode 100644 index 0000000..08f094b --- /dev/null +++ b/Web/View/Static/Welcome.hs @@ -0,0 +1,42 @@ +module Web.View.Static.Welcome where +import Web.View.Prelude + +data WelcomeView = WelcomeView + +instance View WelcomeView where + html WelcomeView = [hsx| +
+
+

+ IHP +

+ +

+ It's working! Hello World! +

+ +

+ Your new application is up and running. +

+ +

+ Join our community on Slack! +

+ + + Learn the Next Steps in the Documentation + +
+
+ +
+ /ihp-welcome-icon +

+ You can modify this start page by making changes to "./Web/View/Static/Welcome.hs". +

+
+|] \ No newline at end of file diff --git a/blog b/blog new file mode 160000 index 0000000..cb2a544 --- /dev/null +++ b/blog @@ -0,0 +1 @@ +Subproject commit cb2a5444fbc8613fe6c3ff135f105cc13a2ac357