-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
230 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,7 @@ | ||
dist | ||
dist-newstyle | ||
dist-ghcjs | ||
cabal-dev | ||
*.o | ||
*.hi | ||
*.chi | ||
*.chs.h | ||
*.dyn_hi | ||
*.dyn_o | ||
*.p_hi | ||
*.p_o | ||
*.js_dyn_hi | ||
*.js_dyn_o | ||
*.js_p_hi | ||
*.js_p_o | ||
*.js_o | ||
*.js_hi | ||
.virthualenv | ||
.hsenv* | ||
*.*~ | ||
*.swp | ||
.DS_Store | ||
backend.pid | ||
backend.out | ||
.shelly | ||
TAGS | ||
tags | ||
*~ | ||
*.orig | ||
hsenv.log | ||
\#*# | ||
.#* | ||
src/Main | ||
*.jsexe | ||
result | ||
result-android | ||
result-ios | ||
result-exe | ||
.attr-cache | ||
ghcid-output.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# DO NOT HAND-EDIT THIS FILE | ||
import ((import <nixpkgs> {}).fetchFromGitHub ( | ||
let json = builtins.fromJSON (builtins.readFile ./github.json); | ||
in { inherit (json) owner repo rev sha256; | ||
private = json.private or false; | ||
} | ||
)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"owner": "obsidiansystems", | ||
"repo": "obelisk", | ||
"branch": "master", | ||
"rev": "59456f318f9618ce12e78f5937a968c58071b686", | ||
"sha256": "06y25i3s0daa417j7j2if3k8y66wb8zgszhlclw4nq0427jf3d2y" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: backend | ||
version: 0.1 | ||
cabal-version: >= 1.8 | ||
build-type: Simple | ||
|
||
library | ||
hs-source-dirs: src | ||
if impl(ghcjs) | ||
buildable: False | ||
build-depends: base | ||
, common | ||
, frontend | ||
, obelisk-backend | ||
, obelisk-route | ||
exposed-modules: | ||
Backend | ||
ghc-options: -Wall | ||
|
||
executable backend | ||
main-is: main.hs | ||
hs-source-dirs: src-bin | ||
if impl(ghcjs) | ||
buildable: False | ||
build-depends: base | ||
, backend | ||
, common | ||
, frontend | ||
, obelisk-backend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../frontend-js/bin/frontend.jsexe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../frontend-js/bin/frontend.jsexe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import Backend | ||
import Frontend | ||
import Obelisk.Backend | ||
|
||
main :: IO () | ||
main = runBackend backend frontend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{-# LANGUAGE EmptyCase #-} | ||
{-# LANGUAGE FlexibleContexts #-} | ||
{-# LANGUAGE LambdaCase #-} | ||
{-# LANGUAGE RankNTypes #-} | ||
{-# LANGUAGE TypeFamilies #-} | ||
module Backend where | ||
|
||
import Common.Route | ||
import Obelisk.Backend | ||
|
||
backend :: Backend BackendRoute FrontendRoute | ||
backend = Backend | ||
{ _backend_run = \serve -> serve $ const $ return () | ||
, _backend_routeEncoder = backendRouteEncoder | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../static |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
optional-packages: | ||
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: common | ||
version: 0.1 | ||
cabal-version: >= 1.2 | ||
build-type: Simple | ||
|
||
library | ||
hs-source-dirs: src | ||
build-depends: base | ||
, obelisk-route | ||
, mtl | ||
, text | ||
|
||
exposed-modules: | ||
Common.Api | ||
Common.Route |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module Common.Api where | ||
|
||
commonStuff :: String | ||
commonStuff = "Here is a string defined in code common to the frontend and backend." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{-# LANGUAGE EmptyCase #-} | ||
{-# LANGUAGE FlexibleContexts #-} | ||
{-# LANGUAGE GADTs #-} | ||
{-# LANGUAGE LambdaCase #-} | ||
{-# LANGUAGE RankNTypes #-} | ||
{-# LANGUAGE TemplateHaskell #-} | ||
{-# LANGUAGE KindSignatures #-} | ||
{-# LANGUAGE EmptyCase #-} | ||
{-# LANGUAGE MultiParamTypeClasses #-} | ||
{-# LANGUAGE FlexibleInstances #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module Common.Route where | ||
|
||
{- -- You will probably want these imports for composing Encoders. | ||
import Prelude hiding (id, (.)) | ||
import Control.Category | ||
-} | ||
|
||
import Data.Text (Text) | ||
import Data.Functor.Identity | ||
import Data.Functor.Sum | ||
|
||
import Obelisk.Route | ||
import Obelisk.Route.TH | ||
|
||
data BackendRoute :: * -> * where | ||
-- | Used to handle unparseable routes. | ||
BackendRoute_Missing :: BackendRoute () | ||
-- You can define any routes that will be handled specially by the backend here. | ||
-- i.e. These do not serve the frontend, but do something different, such as serving static files. | ||
|
||
data FrontendRoute :: * -> * where | ||
FrontendRoute_Main :: FrontendRoute () | ||
-- This type is used to define frontend routes, i.e. ones for which the backend will serve the frontend. | ||
|
||
backendRouteEncoder | ||
:: Encoder (Either Text) Identity (R (Sum BackendRoute (ObeliskRoute FrontendRoute))) PageName | ||
backendRouteEncoder = handleEncoder (const (InL BackendRoute_Missing :/ ())) $ | ||
pathComponentEncoder $ \case | ||
InL backendRoute -> case backendRoute of | ||
BackendRoute_Missing -> PathSegment "missing" $ unitEncoder mempty | ||
InR obeliskRoute -> obeliskRouteSegment obeliskRoute $ \case | ||
-- The encoder given to PathEnd determines how to parse query parameters, | ||
-- in this example, we have none, so we insist on it. | ||
FrontendRoute_Main -> PathEnd $ unitEncoder mempty | ||
|
||
|
||
concat <$> mapM deriveRouteComponent | ||
[ ''BackendRoute | ||
, ''FrontendRoute | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
http://localhost:8000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
### Config | ||
|
||
Obelisk projects should contain a config folder with the following subfolders: common, frontend, and backend. | ||
|
||
Things that should never be transmitted to the frontend belong in backend/ (e.g., email credentials) | ||
|
||
Frontend-only configuration belongs in frontend/. | ||
|
||
Shared configuration files (e.g., the route config) belong in common/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ system ? builtins.currentSystem # TODO: Get rid of this system cruft | ||
, iosSdkVersion ? "10.2" | ||
}: | ||
with import ./.obelisk/impl { inherit system iosSdkVersion; }; | ||
project ./. ({ ... }: { | ||
android.applicationId = "systems.obsidian.obelisk.examples.minimal"; | ||
android.displayName = "Obelisk Minimal Example"; | ||
ios.bundleIdentifier = "systems.obsidian.obelisk.examples.minimal"; | ||
ios.bundleName = "Obelisk Minimal Example"; | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: frontend | ||
version: 0.1 | ||
cabal-version: >= 1.8 | ||
build-type: Simple | ||
|
||
library | ||
hs-source-dirs: src | ||
build-depends: base | ||
, common | ||
, obelisk-frontend | ||
, obelisk-route | ||
, reflex-dom | ||
, obelisk-generated-static | ||
, text | ||
exposed-modules: | ||
Frontend | ||
ghc-options: -Wall | ||
|
||
executable frontend | ||
main-is: main.hs | ||
hs-source-dirs: src-bin | ||
build-depends: base | ||
, common | ||
, obelisk-frontend | ||
, obelisk-route | ||
, reflex-dom | ||
, obelisk-generated-static | ||
, frontend | ||
--TODO: Make these ghc-options optional | ||
ghc-options: -threaded | ||
if os(darwin) | ||
ghc-options: -dynamic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import Frontend | ||
import Common.Route | ||
import Obelisk.Frontend | ||
import Obelisk.Route.Frontend | ||
import Reflex.Dom | ||
|
||
main :: IO () | ||
main = do | ||
let Right validFullEncoder = checkEncoder backendRouteEncoder | ||
run $ runFrontend validFullEncoder frontend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
module Frontend where | ||
|
||
import qualified Data.Text as T | ||
import Obelisk.Frontend | ||
import Obelisk.Route | ||
import Reflex.Dom.Core | ||
|
||
import Common.Api | ||
import Common.Route | ||
import Obelisk.Generated.Static | ||
|
||
|
||
frontend :: Frontend (R FrontendRoute) | ||
frontend = Frontend | ||
{ _frontend_head = el "title" $ text "Obelisk Minimal Example" | ||
, _frontend_body = do | ||
text "Welcome to Obelisk!" | ||
el "p" $ text $ T.pack commonStuff | ||
elAttr "img" ("src" =: static @"obelisk.jpg") blank | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.