Skip to content
Snippets Groups Projects
Commit a0669e77 authored by Jean-Paul Calderone's avatar Jean-Paul Calderone
Browse files

Merge branch '10.initial-obelisk-project' into 'main'

Create initial Obelisk project

Closes #10

See merge request !6
parents 213fd6c0 e769ed26
Branches
Tags
1 merge request!6Create initial Obelisk project
Pipeline #3213 passed
Showing
with 235 additions and 0 deletions
build-android:
stage: build
tags:
- nix
- linux
script:
- cd obelisk
- nix-build -A android.frontend -o result-android
artifacts:
paths:
- obelisk/result-android/android-app-debug.apk
.attr-cache
.cabal-sandbox
*.hi
*.o
cabal.project.local
cabal.sandbox.config
ctags
dist-newstyle/
dist/
ghcid-output.txt
profile/
result
result-*
tags
TAGS
static.out
# DO NOT HAND-EDIT THIS FILE
import (import ./thunk.nix)
\ No newline at end of file
{
"owner": "obsidiansystems",
"repo": "obelisk",
"branch": "master",
"private": false,
"rev": "41f97410cfa2e22a4ed9e9344abcd58bbe0f3287",
"sha256": "04bpzji7y3nz573ib3g6icb56s5zbj4zxpakhqaql33v2v77hi9g"
}
# DO NOT HAND-EDIT THIS FILE
let fetch = { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256, ... }:
if !fetchSubmodules && !private then builtins.fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; inherit sha256;
} else (import <nixpkgs> {}).fetchFromGitHub {
inherit owner repo rev sha256 fetchSubmodules private;
};
json = builtins.fromJSON (builtins.readFile ./github.json);
in fetch json
\ No newline at end of file
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 -Wredundant-constraints -Wincomplete-uni-patterns -Wincomplete-record-updates -O -fno-show-valid-hole-fits
executable backend
main-is: main.hs
hs-source-dirs: src-bin
ghc-options: -Wall -Wredundant-constraints -Wincomplete-uni-patterns -Wincomplete-record-updates -O -threaded -fno-show-valid-hole-fits
if impl(ghcjs)
buildable: False
build-depends: base
, backend
, common
, frontend
, obelisk-backend
../frontend-js/bin/frontend.jsexe
\ No newline at end of file
../../frontend-js/bin/frontend.jsexe
\ No newline at end of file
import Backend
import Frontend
import Obelisk.Backend
main :: IO ()
main = runBackend backend frontend
module Backend where
import Common.Route
import Obelisk.Backend
backend :: Backend BackendRoute FrontendRoute
backend = Backend
{ _backend_run = \serve -> serve $ const $ return ()
, _backend_routeEncoder = fullRouteEncoder
}
../static
\ No newline at end of file
optional-packages:
*
write-ghc-environment-files: never
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
ghc-options: -Wall -Wredundant-constraints -Wincomplete-uni-patterns -Wincomplete-record-updates -O -fno-show-valid-hole-fits
module Common.Api where
commonStuff :: String
commonStuff = "Here is a string defined in Common.Api"
{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
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 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.
fullRouteEncoder
:: Encoder (Either Text) Identity (R (FullRoute BackendRoute FrontendRoute)) PageName
fullRouteEncoder = mkFullRouteEncoder
(FullRoute_Backend BackendRoute_Missing :/ ())
(\case
BackendRoute_Missing -> PathSegment "missing" $ unitEncoder mempty)
(\case
FrontendRoute_Main -> PathEnd $ unitEncoder mempty)
concat <$> mapM deriveRouteComponent
[ ''BackendRoute
, ''FrontendRoute
]
This string comes from config/common/example
\ No newline at end of file
http://localhost:8000
\ No newline at end of file
### 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/
{ system ? builtins.currentSystem
, obelisk ? import ./.obelisk/impl {
inherit system;
iosSdkVersion = "13.2";
# You must accept the Android Software Development Kit License Agreement at
# https://developer.android.com/studio/terms in order to build Android apps.
# Uncomment and set this to `true` to indicate your acceptance:
config.android_sdk.accept_license = true;
# In order to use Let's Encrypt for HTTPS deployments you must accept
# their terms of service at https://letsencrypt.org/repository/.
# Uncomment and set this to `true` to indicate your acceptance:
# terms.security.acme.acceptTerms = false;
}
}:
with obelisk;
project ./. ({ ... }: {
# Not using "storage.private" (our newer domain name) since that makes the build
# fail: "[...] is not a valid Java package name as 'private' is a Java keyword."
android.applicationId = "io.privatestorage.privatestoragemobile";
android.displayName = "Private Storage Mobile";
ios.bundleIdentifier = "systems.obsidian.obelisk.examples.minimal";
ios.bundleName = "Obelisk Minimal Example";
})
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
, jsaddle
, reflex-dom-core
, obelisk-executable-config-lookup
, obelisk-generated-static
, text
exposed-modules:
Frontend
ghc-options: -Wall -Wredundant-constraints -Wincomplete-uni-patterns -Wincomplete-record-updates -O -fno-show-valid-hole-fits
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
ghc-options: -threaded -O -Wall -Wredundant-constraints -Wincomplete-uni-patterns -Wincomplete-record-updates -fno-show-valid-hole-fits
if impl(ghcjs)
ghc-options: -dedupe
cpp-options: -DGHCJS_BROWSER
if os(darwin)
ghc-options: -dynamic
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment