Using gin with pongo2/v4 or v5 and embedded templates

You’d like to use pongo2/v4 with gin and embed templates with go:embed.

I’m using cobra for my cli parsing and commands.
So

edit cmd/ui.go

ui/templates.go

ui/templates/base.html.twig

ui/templates/layout.html.twig

ui/templates/index.html.twig

and finally run

to download packages

Any questions -> leave a comment

Go/Golang Run embedded bash script or node/js,python,php,ruby etc

Since Go v1.16 there’s the embed package, a simple tool to embed files as filesystems of simple strings or []bytes.

While it has its downsides, I was recently met with a challenge. I’d like to run bash scripts I wrote because it’s more efficient to just run a bash script than breaking my fingers writing os/exec stuff.

Anyhow it’s pretty simple really. Any shell command has a standard input and output. You just assign the file pointer (aka the Reader) to the os.Command’s Stdin.
Continue reading “Go/Golang Run embedded bash script or node/js,python,php,ruby etc”

Watch out! It’s the Angular Thought Police!

So, yesterday I was visiting Angular’s discord server, because after a little over a month with Vue I was missing Angular’s components and way to express event listeners and 2-way binding of variables as well as the class based approach.
Vue2 is a simple, super productive framework, especially with Quasar, with a rich ecosystem and excellent libraries like vuex-orm, which is really fantastic, mind blowing.
It’s not perfect, nothing in this world is. The same way that Angular isn’t perfect or React or Svelte.
The worst part of Angular is the forced rxjs, if you’re doing anything more complex than a Hello World application anyway.
Continue reading “Watch out! It’s the Angular Thought Police!”

Keycloak-js client with Quasar (now updated for v2)

So you’d like to use openid-connect (oidc), especially keycloak (kc) in your Quasar app.

There’s a package, @dsb-norge/vue-keycloak-js . I’d recommend you fork it and create your own version with the keycloak-js version that matches your Keycloak server. However it also works with just the version used in this git repository.

The git repository is available at
https://github.com/dsb-norge/vue-keycloak-js

This is for Quasar v1

Alright let’s get started.

1. Create a file named silent-check-sso.html with the following content:

Put that file in the public directory as its path is
public/silent-check-sso.html.

2. Create boot/keycloak.js

3. Reference the created boot file in quasar.conf.js

And that’s really all there is to it.

After this is done you can access the keycloak object via $keycloak in your template.

This is for Qusasar v2:

Thanks a bunch to Excel1 and yusufkandemir for figuring it out.

First you have to upgrade or use the v2 branch of @dsb-norge/vue-keycloak-js.
e.g. npm i @dsb-norge/vue-keycloak-js@2
or use your own fork

But essentially you do whatever you would do for v1 only the boot/keycloak.js file is different

The boot/keycloak.js file

and of course don’t forget to add it to the boot array in quasar.conf.js

vue dev server with nginx

The Nginx conf is the same for any sock-js site. It can be used for Vue and Angular and Svelte, not sure about React but I’d guess it uses sock-js as well.

My dev domain is qxdsladmin.local in this example.

/etc/nginx/conf.d/qxdsladmin.local.conf

This location ~ ^/api/v1/.* is a mountpoint for the backend http api, which in my case is a RESTful Go API.

The vue part, create a file named vue.config.js in the project’s root dir.
So if you used vue create vxdsladmin it’s the directory you go to when doing cd vxdsladmin.

This works for me, but maybe it can be improved. Let me know if that’s the case.