Skip to content

Implement #317 (Show forum version on webpages) #377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

penguinite
Copy link
Contributor

This commit allows nimforum to embed the version and the specific commit of a particular build into its webpages.
The version info is added at compile-time, through the use of the {.strdefine.} pragma. We do need git for the commit hash, but it's not a requirement for compiling nimforum, since it will just default to "" if git doesn't exist or if git returns an error.

The embedded version info is present through this meta tag:

  <meta name="generator" content="Nimforum $version - $commit">

Edit: Should've added that this implements #317 (I forgot that GitHub doesn't add links to the titles)

@PMunch
Copy link
Collaborator

PMunch commented Mar 20, 2025

There is a bit of disagreement on whether or not putting version number information on websites is a good idea. On the one hand your users can alert you if the version you're using is old, or use the information to understand what's possible across versions. On the other hand vulnerability scanning becomes much easier as you can simply load the page and check the version number against known issues.

For this reason I think this feature should at least be toggle-able. I guess it would be possible to override the Commit and Version numbers to hide the true version, but it'd be nicer to have a way to remove the <meta> tag completely.

Another thing I noticed while reviewing the code, you pass the Commit and Version flags to both the backend and front-end compilation, yet you still bake this information in during runtime. Not quite sure how these templates work, but wouldn't it be possible to bake this information into the file during compilation instead?

@penguinite
Copy link
Contributor Author

penguinite commented Mar 22, 2025

Hello and thanks for the feedback!

The "embed info" feature is available as a compile-time toggle for the backend nimble task now. So, to enable this feature, you'd run nimble -d:embedInfo backend instead of nimble backend

If this flag is given at compile-time, a script (src/embedinfo.nim) will be ran, which bakes the version info into the template file itself.

But the problem with this approach is that karax.html becomes polluted with meaningless info, so instead, the script saves the new html file as karax.ver.html (which has a .gitignore rule)
And we simply instruct the backend to use that file instead of karax.html

Let me know if there are any problems with this approach!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants