Skip to content

Commit

Permalink
hellow world
Browse files Browse the repository at this point in the history
  • Loading branch information
SaadiaM1346 committed Sep 25, 2024
1 parent 80b81b1 commit bb93f2f
Show file tree
Hide file tree
Showing 10 changed files with 191 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 _ = []
Expand Down
13 changes: 13 additions & 0 deletions Web/Controller/Prelude.hs
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions Web/Controller/Static.hs
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions Web/FrontController.hs
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions Web/Routes.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Web.Routes where
import IHP.RouterPrelude
import Generated.Types
import Web.Types

-- Generator Marker
instance AutoRoute StaticController
10 changes: 10 additions & 0 deletions Web/Types.hs
Original file line number Diff line number Diff line change
@@ -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)
74 changes: 74 additions & 0 deletions Web/View/Layout.hs
Original file line number Diff line number Diff line change
@@ -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|
<!DOCTYPE html>
<html lang="en">
<head>
{metaTags}

{stylesheets}
{scripts}

<title>{pageTitleOrDefault "App"}</title>
</head>
<body>
<div class="container mt-4">
{renderFlashMessages}
{inner}
</div>
</body>
</html>
|]

-- 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|
<link rel="stylesheet" href={assetPath "/vendor/bootstrap-5.2.1/bootstrap.min.css"}/>
<link rel="stylesheet" href={assetPath "/vendor/flatpickr.min.css"}/>
<link rel="stylesheet" href={assetPath "/app.css"}/>
|]

scripts :: Html
scripts = [hsx|
{when isDevelopment devScripts}
<script src={assetPath "/vendor/jquery-3.6.0.slim.min.js"}></script>
<script src={assetPath "/vendor/timeago.js"}></script>
<script src={assetPath "/vendor/popper-2.11.6.min.js"}></script>
<script src={assetPath "/vendor/bootstrap-5.2.1/bootstrap.min.js"}></script>
<script src={assetPath "/vendor/flatpickr.js"}></script>
<script src={assetPath "/vendor/morphdom-umd.min.js"}></script>
<script src={assetPath "/vendor/turbolinks.js"}></script>
<script src={assetPath "/vendor/turbolinksInstantClick.js"}></script>
<script src={assetPath "/vendor/turbolinksMorphdom.js"}></script>
<script src={assetPath "/helpers.js"}></script>
<script src={assetPath "/ihp-auto-refresh.js"}></script>
<script src={assetPath "/app.js"}></script>
|]

devScripts :: Html
devScripts = [hsx|
<script id="livereload-script" src={assetPath "/livereload.js"} data-ws={liveReloadWebsocketUrl}></script>
|]

metaTags :: Html
metaTags = [hsx|
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
<meta property="og:title" content="App"/>
<meta property="og:type" content="website"/>
<meta property="og:url" content="TODO"/>
<meta property="og:description" content="TODO"/>
{autoRefreshMeta}
|]
14 changes: 14 additions & 0 deletions Web/View/Prelude.hs
Original file line number Diff line number Diff line change
@@ -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
42 changes: 42 additions & 0 deletions Web/View/Static/Welcome.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
module Web.View.Static.Welcome where
import Web.View.Prelude

data WelcomeView = WelcomeView

instance View WelcomeView where
html WelcomeView = [hsx|
<div style="background-color: #657b83; padding: 2rem; color:hsla(196, 13%, 96%, 1); border-radius: 4px">
<div style="max-width: 800px; margin-left: auto; margin-right: auto">
<h1 style="margin-bottom: 2rem; font-size: 2rem; font-weight: 300; border-bottom: 1px solid white; padding-bottom: 0.25rem; border-color: hsla(196, 13%, 60%, 1)">
IHP
</h1>

<h2 style="margin-top: 0; margin-bottom: 0rem; font-weight: 900; font-size: 3rem">
It's working! Hello World!
</h2>

<p style="margin-top: 1rem; font-size: 1.75rem; font-weight: 600; color:hsla(196, 13%, 80%, 1)">
Your new application is up and running.
</p>

<p>
<a
href="https://ihp.digitallyinduced.com/Slack"
style="margin-top: 2rem; background-color: #268bd2; padding: 1rem; border-radius: 3px; color: hsla(205, 69%, 98%, 1); text-decoration: none; font-weight: bold; display: inline-block; box-shadow: 0 4px 6px hsla(205, 69%, 0%, 0.08); transition: box-shadow 0.2s; transition: transform 0.2s;"
target="_blank"
>Join our community on Slack!</a>
</p>

<a href="https://ihp.digitallyinduced.com/Guide/your-first-project.html" style="margin-top: 2rem; background-color: #268bd2; padding: 1rem; border-radius: 3px; color: hsla(205, 69%, 98%, 1); text-decoration: none; font-weight: bold; display: inline-block; box-shadow: 0 4px 6px hsla(205, 69%, 0%, 0.08); transition: box-shadow 0.2s; transition: transform 0.2s;" target="_blank">
Learn the Next Steps in the Documentation
</a>
</div>
</div>

<div style="max-width: 800px; margin-left: auto; margin-right: auto; margin-top: 4rem">
<img src="/ihp-welcome-icon.svg" alt="/ihp-welcome-icon" style="width:100%;">
<p style="color: hsla(196, 13%, 50%, 1); margin-top: 4rem">
You can modify this start page by making changes to "./Web/View/Static/Welcome.hs".
</p>
</div>
|]
1 change: 1 addition & 0 deletions blog
Submodule blog added at cb2a54

0 comments on commit bb93f2f

Please sign in to comment.