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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support theme and image directory #12

Merged
merged 7 commits into from
Sep 17, 2019
Merged

Conversation

tobynet
Copy link
Contributor

@tobynet tobynet commented Sep 15, 2019

Motivation

馃惗馃殏 We need to support more animals like "longdog" and "locomotive", etc.

  • Add -t option for themes. (embedded only)
  • Add -d option for image directory.
  • The default theme is longcat, the current 馃悎.
  • Add a bonus theme tacgnol.

Example

image

Comming soon...

The dark-mode is already available. ( tobynet@bc3cc62 )

main.go Show resolved Hide resolved
main.go Outdated
func loadImage(fs http.FileSystem, n string) (image.Image, error) {
f, err := fs.Open(n)
if err != nil {
log.Fatal(err)
log.Fatal(fmt.Errorf("theme file does not open: %s", n))
Copy link
Owner

Choose a reason for hiding this comment

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

Thanks. please fix this part too. (Yes, I know this part never passed)

return nil, fmt.Errorf("theme file does not open: %s", n)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to fix it ( tobynet/longcat@8c8f2c4 )

Copy link
Contributor Author

@tobynet tobynet Sep 16, 2019

Choose a reason for hiding this comment

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

I consider necessary for error handlings in loadImage too.

e.g. -t wlongcat (/themes/wlongcat/ may not exist in statik.go)

Before:

$ go run main.go -n 2 -H -t wlongcat
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x鈻堚枅鈻堚枅鈻堚枅鈻堚枅]

goroutine 1 [running]:
main.main()
        鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅longcat/main.go:151 +0x4d5
exit status 2

After: (little readable)

$ go run main.go -n 2 -H -t wlongcat
2019/鈻堚枅/鈻堚枅 鈻堚枅鈻堚枅鈻堚枅 theme file does not open: /themes/wlongcat/data01.png
exit status 1

main.go Show resolved Hide resolved
@mattn
Copy link
Owner

mattn commented Sep 16, 2019

Totally LGTM except I pointed.

@tobynet tobynet mentioned this pull request Sep 16, 2019
7 tasks
@mattn
Copy link
Owner

mattn commented Sep 17, 2019

Good to merge for me. Do you have something else to do?

@mattn mattn merged commit fb86005 into mattn:master Sep 17, 2019
@mattn
Copy link
Owner

mattn commented Sep 17, 2019

Thank you.

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.

None yet

2 participants