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

[WIP] Dev server mode, base.js refactor #135

Merged
merged 9 commits into from
Sep 9, 2022

Conversation

pascalopitz
Copy link
Collaborator

@pascalopitz pascalopitz commented Sep 9, 2022

  • Adds -dev flag so dev on JS files can happen with just a reload, instead of re-building artifact
  • Rips out JQuery and moment from base.js
  • Fixes nil pointer exception in template
  • Fixes wrong type exception in template

@pascalopitz pascalopitz changed the title Dev server mode, base.js refactor [WIP] [WIP] Dev server mode, base.js refactor Sep 9, 2022
@pascalopitz
Copy link
Collaborator Author

@buro9 I added a dev mode toggle in this to enable faster process when editing JS files. What do you think?

{ amount: 60, name: 'minutes' },
{ amount: 24, name: 'hours' },
{ amount: 7, name: 'days' },
{ amount: 4.34524, name: 'weeks' },
Copy link
Owner

Choose a reason for hiding this comment

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

Where did 4.34524 come from?

It looks like (((365*3+366)/4)/12) / (((365*3+366)/4)/52) to determine weeks in a month over a year but it's not quite, as that produces 4.3 recurring.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Literally from the article I linked in the comment.
Googling, the same factor for month to week conversion seems to be widely used, i.e.:

https://w3percentagecalculator.com/how-many-weeks-in-a-month/
https://www.checkyourmath.com/convert/time/weeks_months.php
https://www.asknumbers.com/DateTimeConversion.aspx

I have no idea where they get the number from and if it's more or less accurate than your formula.

Copy link
Owner

Choose a reason for hiding this comment

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

LOL, I should read the comment :)

I'm happy to trust the number if the entire world does... I just pause when I see a magic number and see if I can understand it. I think it's roughly what my formula was but probably accounts for it better (i.e. the 4.3 recurring is likely too approximate and someone's stabbed around at the decimal places to make it "good enough" without being too approximate). I cannot find the source of the number used, but hey it works for me.

router.Mount(`/`,
http.FileServer(http.FS(inlinedFiles)),
)
if *opts.IsDevelopment {
Copy link
Owner

Choose a reason for hiding this comment

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

This is nice... I like this for the simplicity of it.

Copy link
Owner

@buro9 buro9 left a comment

Choose a reason for hiding this comment

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

I'm happy to merge... it works right?

I've approved, you can hit merge I believe.

@pascalopitz pascalopitz merged commit 2304a34 into buro9:main Sep 9, 2022
@pascalopitz pascalopitz deleted the dev-server-js branch September 9, 2022 22:36
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