ThomasTJdev / nim_websitecreator

Nim fullstack website framework - deploy a website within minutes
https://nimwc.org
MIT License
176 stars 7 forks source link

Bug: `title*` is a const, but should be defined in `config.cfg` #127

Open ThomasTJdev opened 4 years ago

ThomasTJdev commented 4 years ago

title* is defined in the const-file for strings, but the title* should be updated with the value specified by the user in config.cfg. Otherwise title will always be "Nim Website Creator". The plugins needs to be able to use title to represent the user defined title.

https://github.com/ThomasTJdev/nim_websitecreator/blob/d22fc86aa934ee3286b8fa5c4c046f3c90fc4bbe/nimwcpkg/constants/_strings.nim#L48

juancarlospaco commented 4 years ago

I was thinking a lot about the config in general, I think this can be changed from INI to JSON Pretty-Printed.

JSON

INI

How to Validate config as-you-type on the fly?.

Note

ThomasTJdev commented 4 years ago

Hi @juancarlospaco

At compile-time

Of course it would benefit performance and security by doing it on compile-time, but it would also limit the users possibility to do quick adjustments. If they get a new mail server, they then need to change the config and re-compile NimWC. I do have have NimWC running on devices, where Nim is not installed. I would like to keep main options as runtime. If we have static elements in the config, a simple macro looping through could do the job:

macro genConfigItems(): void =
  var heading: string
  loop through config file:
    if line.substr(0, 0) == "[":
      heading = line
      conintue
    if heading in ["static", "config", "nochange"]:
      source &= "const cfg" & itemName & " = " & itemValue
    else:
      source &= "let " & itemName & " = dict.getSectionValue(\"" & heading & "\",\"" & itemValue & "\")\n"

  result = parseStmt(source)

JSON vs INI

I get the point and I see the benefits. But I'm in doubt about "benefit vs time-to-change"...

Types in config

As you say, the INI does not support types such as bool and int, so it would ease our job as developers to use JSON. But I think our main purpose is to ensure the ease for the end-user.

juancarlospaco commented 4 years ago

So I am kinda using webgui as a Mine Field for cool new ideas, and I think people like them, so maybe in the future stuff from webgui can be steal to here, so few destacable mentions can be:

But I wait to see how Fusion evolves, maybe cool stuff can be sent there, and only depend on Fusion and the rest just move it inside NimWC, maybe Fusion becomes a frequently installed package and lots of people will have it installed, looks like a nice idea.

Also: https://github.com/juancarlospaco/nim_packages_security_audit#fully-automated-nim-packages-security-audit :slightly_smiling_face: