Serve homepage from local .md using --alias=/ and dynamic sync from r/gnoland/home
Note: I remember writing about a similar issue, but I can't find it anymore. If anyone finds it, please feel free to share the link.
Use --alias=/=./home.md (feature by @aeddi) for the homepage, synced from r/gnoland/home.
This avoids bricked contracts, supports overrides, and makes updates safer.
Plan
- write this script
# misc/deployments/update-home.sh
# if this file exists, it means we want to bypass the script behavior and just manage the homepage manually.
if [ -f home-override.md ]; then
cp home-override.md home.md
exit 0
fi
# tries to query r/gnoland/home.
if gnokey query ... > out.md; then
# eventually patch the page to add things like the newsletter html form
echo "<!-- extra blocks -->" >> out.md
mv out.md home.md
else
echo "warn: failed to update"
fi
-
configure docker-compose/kube to periodically run this script
-
configure docker-compose/kube to use the
--alias=/:./home.md
Refers to https://github.com/gnolang/gno/pull/4252
@moul
- where are
home.mdorhome-override.mdsupposed to be located?- Are they provided externally from the binary or included in the binary itself (like examples/ folder)
- how are the things to be patched defined, is it another text file?
- script is to be published on the monorepo
- home.md is to be generated by the script on the server
- home.override.md to be manually added on the server
script is to be published on the monorepo
home.md is to be generated by the script on the server
home.override.md to be manually added on the server
I have one last doubt.
Can we bundle echo "<!-- extra blocks --> into another file that is eventually present in the FS (as it may be for home-override.md).
Or in order to add this, we should each time push an edit to the script itself?
We should focus on a script on the monorepo. This script may (or not) look for files on the FS.
@moul
I am currently having this scripting issue. If we want to add extra blocks, using this
# tries to query r/gnoland/home.
if gnokey query ... > out.md; then
will it work if gnoweb is running with --aliases=/=static:<path to home.md> already (forget home-override for now)?
Because gnokey would query the RPC directly and skip the aliased home.
So extra block will be applied to the original home rather than the aliased_home.
Is that the behavior we want?
It should be fine because the alias is for /, and the query targets /r/gnoland/home. Even if the alias for / is set up, /r/gnoland/home should not be replaced by the static file.
It should be fine because the alias is for /, and the query targets /r/gnoland/home. Even if the alias for / is set up, /r/gnoland/home should not be replaced by the static file.
I think I understand correctly then