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

Render stdin text as Gemtext (#205) #242

Merged
merged 6 commits into from
Jun 25, 2021
Merged

Conversation

dvejmz
Copy link
Contributor

@dvejmz dvejmz commented Jun 11, 2021

This allows amfora to accept content via stdin and render it as Gemtext. The main use case this fulfils is the rendering of Gemtext files via stdin (see #205) but plaintext is also handled.

makew0rld
makew0rld previously approved these changes Jun 24, 2021
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 creating this PR! Works well for me, just see my comments below. And please fix the linting errors.

Comment on lines +84 to +85
stat, _ := os.Stdin.Stat()
return (stat.Mode() & os.ModeCharDevice) != 0
Copy link
Owner

Choose a reason for hiding this comment

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

Is this check portable across OSes? Where did you find this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This check leverages the Go standard library so I'd have thought it would be. I haven't tested this outside of my Fedora Linux installation so I wouldn't be able to say for sure though.

I got the idea from here. This article explains the approach in a bit more detail.

Copy link
Owner

Choose a reason for hiding this comment

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

Seems good. This answer mentions the same solution working on macOS too. And I guess pipes don't really apply to Windows.

amfora.go Show resolved Hide resolved
amfora.go Outdated
}

stdinText := stdinTextBuilder.String()
if len(strings.TrimSpace(stdinText)) > 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 don't think this check is necessary. Nothing wrong with displaying some spaces or just nothing at all. Would be useful if part of some longer pipeline, where returning nothing is possible but not certain. Much better to get an empty page than be confused by the new tab page.

Other than this I think we're good to go!

@makew0rld makew0rld merged commit 4480e2d into makew0rld:master Jun 25, 2021
@makew0rld
Copy link
Owner

Thanks for adding this!

makew0rld added a commit that referenced this pull request Jun 25, 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.

2 participants