kennygrant / gohackernews

Golang News - curated links about the Go programming language
https://golangnews.com
MIT License
282 stars 42 forks source link

Error reading template "root_url" not defined #19

Closed gnoirzox closed 7 years ago

gnoirzox commented 7 years ago

After fetching the latests changes, I am getting the following error:

Error reading templates template: stories/views/sitemap.xml.got:4: function "root_url" not defined

Do I miss anything ? What is the purpose of root_url ?

kennygrant commented 7 years ago

For this particular problem, the definition of the function is just this:

view.Helpers["root_url"] = func() string {
        return server.Config("root_url")
    }

So you need this key in your fragmenta.json file, and you need this helper defined (I think it is currently in app/setup.go - just add it with the url you want to use for the server and it should work fine.

The purpose of this is to remove hard-coded refs to Golang News or related urls from the code so that the software can be used for other sites. If you're actively using it, it might be best to lock to a slightly earlier version and upgrade once v2 comes out (I'd also be interested to hear what you're using it for).

I'm in the middle of a large change to the project to move it to a newer router (most of those changes are not yet checked in to master, but they're coming soon in a v2.0). That will include breaking changes to handlers (new handler signature), and extensive tests which are long overdue. It will have breaking changes though as it's a move to a version 2 of the forum, and will include a few other improvements.

gnoirzox commented 7 years ago

Ok, thanks, I fixed it.

That is a great idea and I cannot wait for the v2! I am not using it actively yet. I just have a project which is simply a social news aggregator website targeted to the startup ecosystem in London. I was planning to deploy it soon, but as you are thinking about releasing some breaking changes, I may postpone it (again..) until the release of the v2.