Skip to content

Commit

Permalink
- Adding sass and spectre
Browse files Browse the repository at this point in the history
- Config -> config.kdl
  • Loading branch information
Patitotective committed Jul 12, 2024
1 parent bb4c952 commit cc6f750
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 15 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "public/css/spectre"]
path = public/css/spectre
url = https://github.com/picturepan2/spectre
3 changes: 3 additions & 0 deletions grado.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ bin = @["app"]
requires "nim >= 2.0.0"
requires "karax >= 1.2.2"
requires "prologue >= 0.6.4"
requires "sass >= 0.2.0"
requires "kdl >= 2.0.1"

task frontend, "Compiles the frontend to JavaScript":
exec "nimble c -r --mm:refc src/buildcss"
exec "nim js --outdir:public/js src/frontend"

1 change: 1 addition & 0 deletions public/css/spectre
Submodule spectre added at 884725
10 changes: 0 additions & 10 deletions public/css/style.css

This file was deleted.

14 changes: 14 additions & 0 deletions public/css/style.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// @import "custom-style"
// Import full Spectre source code
@import "spectre/src/spectre"

body
margin: 0
background:#0C0D11
color: white


html, body, #ROOT
height: 100%
/* width: 100%;*/
33 changes: 33 additions & 0 deletions src/buildcss.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import std/os
import sass

import config as _

proc buildCSS*(cssFilename = "style") =
let publicLoc = "public"
var includePaths: seq[string] = @[]
# Check for a styles override.
var hostname = config.hostname
if not dirExists(hostname):
hostname = "localhost.local"

let dir = getCurrentDir() / hostname / "public"
includePaths.add(dir / "css")
createDir(publicLoc / "images")
let logo = publicLoc / "images" / "logo.png"
removeFile(logo)
createSymlink(
dir / "images" / "logo.png",
logo
)

let cssLoc = publicLoc / "css"
sass.compileFile(
cssLoc / (cssFilename & ".sass"),
cssLoc / (cssFilename & ".css"),
includePaths=includePaths
)

when isMainModule:
buildCSS()
echo("CSS Built successfully")
4 changes: 4 additions & 0 deletions src/config.kdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
title "Grado"
appPath "/"
port 8081
hostname "hostname.com"
15 changes: 11 additions & 4 deletions src/config.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
const
title* {.define.} = "Grado"
appPath* {.define.} = "/" # Path where the app is: https://www.example.com/ or https://www.example.com/app
port* {.define.} = 8081
import std/os
import kdl, kdl/[decoder]

type
Config* = object
title*: string
appPath*: string # Path where the app is: https://www.example.com/ or https://www.example.com/app
port*: int
hostname*: string

const configPath* {.define.} = currentSourcePath.parentDir() / "config.kdl"
const config* = configPath.parseKdlFile().decodeKdl(Config)
2 changes: 1 addition & 1 deletion src/frontend/routes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import std/[tables, uri, dom]
import karax/[karaxdsl, vdom]

import patterns, utils
from ../config import nil
import ../config as _

type
Params* = Table[string, string]
Expand Down

0 comments on commit cc6f750

Please sign in to comment.