Skip to content
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

Added ability to save about: pages. #236

Merged
merged 4 commits into from
May 13, 2021

Conversation

amohamed11
Copy link
Contributor

@amohamed11 amohamed11 commented May 12, 2021

Hi, I've been using Amfora for short-while and wanted to contribute to this awesome project.
Proposed Changes:

  • Extracted the about page check that is in hasContent to its own separate function as that was the only check prohibiting about page saves. Since a page's content has no implication on it being an about page, decoupling these checks seems like a good idea. But do let me know if this change does not make sense for the overall project, and I can look into other fixes.
  • Added a change to downloadNameFromURL so that when it's generating a filename for a saved about page, it uses the entire page url i.e. about:subscriptions as otherwise the filename was simply left blank.

Fixes #210

P.S. I did not locate a contribution guide, so let me know if I went about something the wrong way. If there is such a guide, please do point me towards it.

Copy link
Owner

@makew0rld makew0rld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making this PR!

There is no contribution guide at the moment, although I should definitely make one.

Overall this PR looks good! See my comments below for some small changes.

@@ -576,7 +576,7 @@ func Reload() {
return
}

if !tabs[curTab].hasContent() {
if !tabs[curTab].hasContent() || tabs[curTab].isAnAboutPage() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, reloading about pages should be allowed, so this can be removed.

parsed, _ := url.Parse(u)
if parsed.Path == "" || path.Base(parsed.Path) == "/" {
if strings.HasPrefix(parsed.String(), "about:") {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if strings.HasPrefix(parsed.String(), "about:") {
if strings.HasPrefix(u, "about:") {

Comment on lines 327 to 328
// Is an about page, use the entire page url since there is no hostname
name, err = getSafeDownloadName(dir, parsed.String()+ext, true, 0)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just use the "path" or whatever. Like about:subscriptions should be saved as subscriptions.gmi.

@makew0rld
Copy link
Owner

Thanks for the fix! Note I made a small change in 56b7e4a, because otherwise URLs like about:subscriptions?2 would be saved as subscriptions?2.gmi, and ? is a banned filename character on Windows.

Otherwise looks good, thanks for your work!

@makew0rld makew0rld merged commit a371307 into makew0rld:master May 13, 2021
makew0rld added a commit that referenced this pull request May 13, 2021
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.

Ability to save about: pages
2 participants