-
-
Notifications
You must be signed in to change notification settings - Fork 67
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
Custom new tab page #83
Conversation
It makes it possible to store other kinds of configuration files in it, such as a custom new tab page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this! I have some comments.
- Don't export
configDir
, but instead have a new exported variable calledNewTabPath
. The config package can do thefilepath.Join(config.ConfigDir, "new_tab.gmi")
work. - Use
newtab.gmi
, notnew_tab.gmi
I didn't make the new tab file location configurable.
All good with me.
I didn't implement the reload yet because it will require some special cases and I'm not sure where best to add them,
Reload()
, orhasContent()
andhandleURL()
?
I would add a config boolean called CustomNewTab
, set on startup. Then in Reload
, I would add code like this:
func Reload() {
if tabs[curTab].page.URL == "about:newtab" && config.CustomNewTab {
// Re-render new tab, similar to Init()
newTabContent := getNewTabContent()
tmpTermW := termW
renderedNewTabContent, newTabLinks = renderer.RenderGemini(newTabContent, textWidth(), leftMargin())
newTabPage = structs.Page{
Raw: newTabContent,
Content: renderedNewTabContent,
Links: newTabLinks,
URL: "about:newtab",
Width: tmpTermW, // Note this line is different than from Init(), since the terminal width is known
Mediatype: structs.TextGemini,
}
}
if !tabs[curTab].hasContent() {
return
}
// Reload func continues...
}
Done! I didn't add the |
Thanks! The problem with not having
I'm okay with this, because of the performance gain. Once this is added, I will be happy to merge. |
Fair point, done. If a custom new tab page is present on startup, then the new tab page will always be reloaded. Otherwise it will never be reloaded, even if a custom new tab page appears later. Should I squash my commits before merging? |
Thanks for all your work! Merged. And no, you don't have to squash, I can do that with the "Squash and merge" button. |
Got it. Thanks for merging and making amfora! |
The new tab page can now be loaded from
$XDG_CONFIG_HOME/amfora/new_tab.gmi
. This is documented in the default tab page. This implements what was suggested in issue #67 except for the ability to reload the new tab page, it is loaded once on startup.~
in the config option and possibly environment variables in order to honorXDG_CONFIG_HOME
so I opted for a hardcoded path like the config file. If it is deemed necessary I can implement it.config.ConfigDir
was exported to allow accessingXDG_CONFIG_HOME
from outsideconfig
.Reload()
, orhasContent()
andhandleURL()
?