Skip to content
This repository was archived by the owner on May 3, 2021. It is now read-only.

Switch to go modules, remove some code duplication#25

Merged
skx merged 2 commits intoskx:masterfrom
MFAshby:various_improvements
Nov 7, 2020
Merged

Switch to go modules, remove some code duplication#25
skx merged 2 commits intoskx:masterfrom
MFAshby:various_improvements

Conversation

@MFAshby
Copy link
Copy Markdown
Contributor

@MFAshby MFAshby commented Nov 6, 2020

Hi, I'm thinking about using your project (I've been thinking about writing a go-based webmail for a year! just didn't start it yet...), and noted that you still need sending capability for this to be a fully functional webmail. If it's OK, I'd like to help with that!

While taking a look around the code you have so far, I noted a couple of suggestions that might help make it easier to work on in future, in particular:

  1. Using go modules for dependency management, also lets you clone and build the project outside of your GOPATH.
  2. Using go:generate annotation to invoke implant, this approach means that your build instructions don't have to change if you change the embedding tool (or indeed if you want to execute several external code generation tools). The build process then simply looks like:
go generate
go build
  1. Starting to break down the HTML files into reusable sections, starting with the Javascript portion which was copied into each HTML file separately. A component or snippet-based approach like this can help keep concerns separated, and ensure that pages don't get out of sync (e.g. missing a page when you update the script to fix a bug)

Feel free to close this PR if you aren't working on this project any more and don't have time to review,
Thanks for writing this piece of software, it makes a nice change from all the PHP based webmails out there!

the go source tree, and dependencies pinned.

Use go:generate annotation to generate the static resources go file, and
add it to gitignore (generated stuff can be left out of source
control to prevent stale builds)
included as a sub-template.

Parse all the templates upfront on server start, and look them up
when needed. This
1. Reduces code duplication loading templates from
resources and
2. Saves re-parsing templates on every page load

More work can be done removing duplication from the HTML files and
stylesheets. Componentizing the HTML like this should eventually allow
composite views for different sized screens: e.g. including the message
view and message list on the same page in wide screen formats.
@skx
Copy link
Copy Markdown
Owner

skx commented Nov 7, 2020

I admit I've not even built this project for some time, since I switched from my own self-hosted IMAP/SMTP server to paying for gsuite. That said if the project is useful to others I'm certainly willing and able to review/accept changes.

I have no objection to anything you've committed - only the minor comment that the CI is now broken, as the implant tool is missing (as a guess). I'm happy to accept this and merge then fixup shortly afterward.

I expect that when we have go 1.16 I'd be moving over to using the go embed support. I made a quick hack to test that out for another project and it was pretty simple:

So while the change to go generate isn't a bad one I would regard that as being temporary!

@skx skx merged commit 0cb65ad into skx:master Nov 7, 2020
@MFAshby MFAshby deleted the various_improvements branch November 7, 2020 12:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants