How to use my own common files in keycloak theme? - keycloak

I would like to use common resources in my keycloak theme but import feature is for extand existing theme but how to use common in my theme ?
I would like to import my own common files but according to the documentation the import only allows to use the common files of another theme but how to use it without extending on another theme ?
My structure
.
├── META-INF/
│ └── keycloak-themes.json
└── theme/
└── my-custom-theme/
├── account/
│ ├── *.ftl
│ └── theme.properties
├── common/
│ └── resources/
│ └── css/
│ └── bootstrap.min.css
└── login
In my theme.properties (login)
locales=en,fr
styles=css/login.css
# which I already tried
# -> by default keycloak use common/keycloak (but how to change to my own common resources ? I tried this import=common/my-custom-theme but I have an error 500)
stylesCommon=css/bootstrap.min.css (it's bootstrap file of keycloak (3.4.1 :/)
Anyone have an idea ?

I solved it by adding the following to my theme.properties:
import=common/my-custom-theme
styles=css/bootstrap.min.css
# stylesCommon=css/bootstrap.min.css <-- not working
Tested it with Keycloak server version 15.0.2

To include in 'stylesCommon', please check if you have following in template.ftl
<#if properties.stylesCommon?has_content>
<#list properties.stylesCommon?split(' ') as style>
<link href="${url.resourcesCommonPath}/${style}" rel="stylesheet" />
</#list>
</#if>

Related

Links to json files

my directory structure is
├── xxx
│   ├── 01.md
| └── 02.md
├── auth
│   ├── j1.json
│   ├── j2.json
│   └── j3.json
└── default.template.html
And I link jsons from markdowns like Auth. It makes sense as we use there files as test scenarios and in json files we have credentials and roles. But if I try to generate html it fails on unresolved internal reference: ../auth/aspect_admin.json. I tried to exclude the link checking but without any help. The best would be to leave it as a link in md file but somehow follow the link and include the json as code block in generated html. Is it possible?
It was a bug and will be fixed in next version https://github.com/planet42/Laika/issues/148

importing style-sheet into app.scss to use throughout project

I want to use a style page across my app.
in the app.scss file I tried using:
#import "../global-scss/html-table-styles.scss";
this does not work.
Pasting the style directly into the app.scss file does work but I would rather not do that.
Is what I'm trying to accomplish possible and if so, what am I doing wrong?
If your file structure is like this:
├── src
│   ├── app
│   │   ├── app.component.ts
│   │   ├── app.module.ts
│   │   ├── app.scss
│   │   └── main.ts
// ... pages, components ...
| └── theme
│   ├── custom-styles.scss
...the import line should be:
#import "../theme/custom-styles.scss";
The problem was due to my poor understanding of style-sheets and because there is an answer already so I am unable to delete.
In the style-sheet I was trying to import I had followed the pattern used for styles local to a page and had a base style tag
eg:
html-table-styles{
//my styles
}
when i imported #import "../global-scss/html-table-styles.scss"; the styles were not being used, removing html-table-styles solved my issue

unresolved import for module imports in Visuial Studio Code

I have opened a folder in VS code and I am trying to set it up.
It's a python project and its directory structure is as:
Project
├── common_features
│ ├── ...
├── core
│ ├── features
│ └── main.py
│ └── tests
├── django project
│ ├── django_app1
│ ├── manage.py
│ ├── ...
└── tests
│ ├── ...
└── runner.py
The project runs as a django project from the django_project dir. It uses modules located in common_features and core. Core is designed such that it could also run on its own. You can also run core from runner.py
The problem is that all our module imports are not being resolved but 3rd party packages work well.
unresolved import 'core.config' Python(unresolved-import)
In PyCharm, I have marked Project, core and django_project as "sources root" and it works like a charm. Not sure how to do that in VS code.
I have tried making some changes in launch.json and settings.json but none are working. I am new to VS code so I'm unable to understand what it is that I'm doing wrong.
Thanks.
Can you try adding the following line to your settings.json file?
{
"python.autoComplete.extraPaths": ["./src"]
}
More info about this here: https://github.com/microsoft/python-language-server/blob/master/TROUBLESHOOTING.md#unresolved-import-warnings

Can I render all partials and their contents on a page with assemble?

I have a bunch of partials in the following directory structure:
src
└── content
├── pages
│ ├── index.hbs
│ └── patterns.hbs
├── partials
│ ├── _footer-subpage.hbs
│ ├── _footer.hbs
│ ├── _head-subpage.hbs
│ ├── _head.hbs
│ └── patterns
│ └── dropdown
│ ├── dropdown.hbs
│ └── dropdown.json
└── templates
├── custom.hbs
└── default.hbs
and I want to be able to loop over all partials within src/content/partials/patterns directory and output their contents on a page. A the moment I am manually including the partials like so:
{{> dropdown }}
{{> another-partial }}
{{> another-partial }}
...
Is it possible to do this dynamically like you can with pages collections?
Edit:
Sorry, I should have been more detailed in what I'm trying to achieve. It's a bit more complex...
This is what I am currently doing in full detail but would like to do programmatically:
<h3>{{dropdown.info.title}}</h3> <-- name
<p>{{dropdown.info.description}}</p> <-- description
{{> dropdown dropdown }}
{{#markdown}}``\{{> dropdown dropdown }}``{{/markdown}} <-- example
<h4>dropdown.hbs</h4>
{{#markdown}}
{{embed 'src/content/partials/patterns/dropdown/dropdown.hbs' 'html'}} <-- source
{{/markdown}}
<h4>dropdown.json</h4>
{{#markdown}}
{{embed 'src/content/partials/patterns/dropdown/dropdown.json' 'json'}} <-- data
{{/markdown}}
The dropdown.info.title is using the .json file within the same directory as the partial for data.
I'm basically replicating functionality from pattern-lab.info to pull in a bunch of components to create a library of "patterns" but don't want to do it manually.
Here's an example of the desired output.
The code I'm using is here https://github.com/sheedy/ux-prototype (the "dev" branch).
Try using the compose helper
You could then do...
{{compose src="src/content/partials/patterns/**/*.hbs"}}
{{#content}}
{{/compose}}

Why is Compass is giving me an import error when trying to import partials

My compass project directory structure looks like this
s3z#s3z:~/Desktop/compass_project$ tree
.
├── basic.html
├── config.rb
├── css
│   ├── ie.css
│   ├── print.css
│   └── screen.css
├── index.html
├── partials
│   └── _normalize.scss
└── sass
├── ie.scss
├── print.scss
└── screen.scss
My screen.scss file looks like this
#import "compass";
#import "partials/normalize";
When I add #import "partials/normalize"; and save it, Compass spits the following error back at me
>>> Compass is watching for changes. Press Ctrl-C to Stop.
>>> Change detected at 22:58:53 to: screen.scss
error sass/screen.scss (Line 2: File to import not found or unreadable: partials/normalize.
Load paths:
/home/max/Desktop/nettut_compass_tut/sass
/home/max/.rvm/gems/ruby-1.9.3-p194/gems/compass-0.12.2/frameworks/blueprint/stylesheets
/home/max/.rvm/gems/ruby-1.9.3-p194/gems/compass-0.12.2/frameworks/compass/stylesheets
Compass::SpriteImporter)
overwrite ./css/screen.css
And just in case it matters my config.rb is
http_path = "/"
css_dir = "css"
sass_dir = "sass"
images_dir = "images"
javascripts_dir = "javascripts"
Any ideas on how to fix this?
You've defined your sass_dir as sass so compass is looking for that reset file in: sass/partials/normalize If you want to import something outside of your sass_dir, you need to use a path relative to the sass file that's doing the importing:
#import "../partials/normalize";
personally, I prefer to put the partial directory in the sass directory, or just let them sort to the top loose.