Commit 2c2741c2 authored by Ozoux's avatar Ozoux
Browse files

Merge branch 'package' into 'master'

Package

See merge request !6
parents 88a827db 1af30363
Pipeline #688 passed with stages
in 14 seconds
.DS_Store
.db
liiibre.jar
build
\ No newline at end of file
stages:
- build
- package
build:
stage: build
image:
name: python:3-alpine
script: python compile.py
artifacts:
paths:
- build
package:
stage: package
image:
name: openjdk:15
script: jar -cf liiibre.jar -C build/ .
artifacts:
paths:
- liiibre.jar
## Keycloak Themes
## Development
To start the project :
```
docker-compose up -d
```
To stop the project :
```
docker-compose down
```
To create a new theme :
1. Add the a new folder under `theme/`
2. Declare it in `META-INF/keycloak-themes.json`
3. Add a volume bind in `docker-compose.yml`
## Deployment
1. Download the [latest package](https://git.indie.host/indiehost/tech/keycloak-themes/-/jobs/artifacts/master/raw/liiibre.jar?job=build)
2. Copy it in the folder `/opt/jboss/keycloak/standalone/deployments/`
\ No newline at end of file
import os
import json
import shutil
import hashlib
import pathlib
import re
srcDir = "src"
buildDir = "build"
baseTheme = "liiibre"
def geThemes():
themes = []
for name in os.listdir(srcDir):
types = os.listdir(os.path.join(srcDir, name))
themes.append({"name": name, "types": types})
return themes
def clearBuildDir():
if os.path.exists(buildDir):
shutil.rmtree(buildDir)
os.mkdir(buildDir)
def generateManifest(themes):
manifestDir = os.path.join(buildDir, "META-INF")
os.mkdir(manifestDir)
with open(os.path.join(manifestDir, "keycloak-themes.json"), "w+") as manifest:
manifest.write(json.dumps({"themes": themes}))
def copyTheme(theme):
src = os.path.join(srcDir, theme["name"])
dest = os.path.join(buildDir, "theme", theme["name"])
shutil.copytree(src, dest)
def hashResources(theme):
hashedRessources = {}
for themeType in theme["types"]:
hashedRessources[themeType] = []
currentDir = os.path.join(buildDir, "theme", theme["name"], themeType)
for dirpath, _, files in os.walk(currentDir):
for file in files:
path = pathlib.Path(os.path.join(dirpath, file))
if re.search(".*\.(js|css)", path.as_posix()):
fileHash = getFileHash(path)
hashedPath = suffixFile(path, fileHash)
convertedPaths = convertPaths(
currentDir, path.as_posix(), hashedPath.as_posix())
hashedRessources[themeType].append(convertedPaths)
return hashedRessources
def getFileHash(path):
with open(path, "rb") as f:
file_hash = hashlib.md5()
while chunk := f.read(8192):
file_hash.update(chunk)
return file_hash.hexdigest()
def suffixFile(path, suffix):
suffixedPath = path.with_stem(
path.stem + "." + suffix)
os.rename(path, suffixedPath)
return suffixedPath
def convertPaths(dir, *paths):
return [path.replace(os.path.join(dir, "resources/"), "") for path in paths]
def updateProperties(theme, hashDic):
for themeType in theme["types"]:
if theme["name"] == baseTheme:
toReplace = [*hashDic[baseTheme][themeType]]
else:
toReplace = [*hashDic[baseTheme][themeType],
*hashDic[theme["name"]][themeType]]
with open(os.path.join(buildDir, "theme", theme["name"], themeType, "theme.properties"), 'r+') as f:
content = f.read()
for replaceArgs in toReplace:
content = content.replace(*replaceArgs)
f.seek(0)
f.write(content)
if __name__ == "__main__":
clearBuildDir()
themes = geThemes()
generateManifest(themes)
hashDic = {}
for theme in themes:
copyTheme(theme)
hashDic[theme["name"]] = hashResources(theme)
for theme in themes:
updateProperties(theme, hashDic)
embed-server --std-out=echo --server-config=standalone.xml
/subsystem=keycloak-server/theme=defaults/:write-attribute(name=cacheThemes,value=false)
/subsystem=keycloak-server/theme=defaults/:write-attribute(name=cacheTemplates,value=false)
/subsystem=keycloak-server/theme=defaults/:write-attribute(name=staticMaxAge,value=-1)
stop-embedded-server
\ No newline at end of file
......@@ -4,15 +4,20 @@ services:
postgres:
image: postgres
volumes:
- ./.db:/var/lib/postgresql/data
- db:/var/lib/postgresql/data
environment:
POSTGRES_DB: keycloak
POSTGRES_USER: keycloak
POSTGRES_PASSWORD: password
keycloak:
image: jboss/keycloak
image: quay.io/keycloak/keycloak
volumes:
- ./themes:/opt/jboss/keycloak/themes/
- ./src/cfamederic:/opt/jboss/keycloak/themes/cfamederic
- ./src/liiibre:/opt/jboss/keycloak/themes/liiibre
- ./src/liiibrelite:/opt/jboss/keycloak/themes/liiibrelite
- ./src/smart:/opt/jboss/keycloak/themes/smart
- ./src/zwo:/opt/jboss/keycloak/themes/zwo
- ./disable-theme-cache.cli:/opt/jboss/startup-scripts/disable-theme-cache.cli
environment:
DB_VENDOR: POSTGRES
DB_ADDR: postgres
......@@ -26,3 +31,6 @@ services:
- 8080:8080
depends_on:
- postgres
volumes:
db:
locales=en,fr
parent=base
\ No newline at end of file
parent=liiibre
\ No newline at end of file
cgu=By clicking on Login, you agree to <a href="https://www.cfamederic.com/charte-usage-tic/">the Digital Tools Usage Policy</a> et the <a href="https://www.cfamederic.com/politique-confidentialite/">Privacy Policy</a>.
\ No newline at end of file
cgu=En cliquant sur Connexion, vous acceptez <a href="https://www.cfamederic.com/charte-usage-tic/">la charte d&#39;usages des Outils num&eacute;riques</a> et la <a href="https://www.cfamederic.com/politique-confidentialite/">politique de confidentialit&eacute;</a>.
\ No newline at end of file
:root {
--main-color: #3f6f9a; /* zwo dark blue */
--second-color: #000; /* zwo orange */
--third-color: #5db9d3; /* zwo ligther blue */
--hover-color: #0f4c81; /* zwo blue green */
--grey: #72767b;
}
.login-pf {
background-image: url("../img/backgroud.jpg");
background-color: #f2f2f2;
background-repeat: repeat;
}
#kc-header-wrapper {
margin-bottom: -2rem;
}
#kc-header-wrapper img {
height: 300px;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment