Adds ability to override CSS styles from a foreign repo.

This commit is contained in:
Dominik Picheta 2018-05-22 12:23:43 +01:00
commit 705f212118
9 changed files with 41 additions and 18 deletions

View file

@ -6,6 +6,7 @@ $label-color: #7cd2ff;
$secondary-btn-color: #f1f1f1;
// Define nav bar colours.
$body-bg: #ffffff;
$navbar-color: $body-bg;
$navbar-border-color-dark: $body-bg;
$navbar-primary-color: #e80080;

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -33,7 +33,7 @@ task runbackend, "Runs the forum backend":
exec "./src/forum"
task frontend, "Builds the necessary JS frontend (with CSS)":
exec "nimble c -r src/frontend/buildcss"
exec "nimble c -r src/buildcss"
exec "nimble js -d:release src/frontend/forum.nim"
mkDir "public/js"
cpFile "src/frontend/nimcache/forum.js", "public/js/forum.js"

View file

@ -1,8 +1,8 @@
@import "custom-style";
// Import full Spectre source code
@import "spectre/src/spectre";
@import "custom-style";
// Global styles.
// - TODO: Make these non-global.
.btn, .form-input {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 70 B

Before After
Before After

1
public/images/logo.png Symbolic link
View file

@ -0,0 +1 @@
/Users/dom/projects/nimforum/forum.nim-lang.org/public/images/logo.png

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 70 B

Before After
Before After

35
src/buildcss.nim Normal file
View file

@ -0,0 +1,35 @@
import os, strutils
import sass
import utils
proc buildCSS*(config: Config) =
let publicLoc = "public"
var includePaths: seq[string] = @[]
# Check for a styles override.
var hostname = config.hostname
if not existsDir(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 / "nimforum.scss",
cssLoc / "nimforum.css",
includePaths=includePaths
)
when isMainModule:
let config = loadConfig()
buildCSS(config)
echo("CSS Built successfully")

View file

@ -14,9 +14,7 @@ import
import cgi except setCookie
import options
import sass
import auth, email, utils
import auth, email, utils, buildcss
import frontend/threadlist except User
import frontend/[
@ -245,9 +243,7 @@ proc initialise() =
isFTSAvailable = db.getAllRows(sql("SELECT name FROM sqlite_master WHERE " &
"type='table' AND name='post_fts'")).len == 1
let cssLoc = "public" / "css"
if not existsFile(cssLoc / "nimforum.css"):
sass.compileFile(cssLoc / "nimforum.scss", cssLoc / "nimforum.css")
buildCSS(config)
# Read karax.html and set its properties.
karaxHtml = readFile("public/karax.html") %

View file

@ -1,9 +0,0 @@
import sass, os
when isMainModule:
compileFile(
getCurrentDir() / "public" / "css" / "nimforum.scss",
getCurrentDir() / "public" / "css" / "nimforum.css"
)
echo("Compiled CSS")