Uncaught ReferenceError: moment is not defined

171 views
Skip to first unread message

Detlev Zundel

unread,
Aug 12, 2022, 10:51:19 AM8/12/22
to nikola-...@googlegroups.com
Hi,

my personal blog is using the "zen" theme for quite some time now, but
as it is hosted in Germany I now risk being sued because of using the
Google fonts API[1]. Trying to fix this, I came up with a pull request
on the nikola-themes repository[2]. In order to test this, I recreated
the whole site from scratch which I have not done for some time now.
Looking at the development console on the new site I get the error
mentioned in the subject. The error is in the index.html file around
this location:

#+begin_src html
</section><script src="assets/js/all-nocdn.js"></script><!-- fancy dates --><script>
moment.locale("en");
fancydates(0, "YYYY-MM-DD HH:mm");
</script><!-- end fancy dates --><script>
#+end_src

Trying to find out, why this is an error, I followed the trail of
breadcrumbs to the "bundles" file in the zen theme, which looks like
this:

#+begin_src
assets/css/all-nocdn.css=rst_base.css,nikola_rst.css,code.css,baguetteBox.min.css,theme.css,custom.css
assets/css/all.css=rst_base.css,nikola_rst.css,code.css,baguetteBox.min.css,theme.css,custom.css
assets/js/all-nocdn.js=baguetteBox.min.js,moment-with-locales.min.js,fancydates.min.js
assets/js/all.js=fancydates.min.js
#+end_src

As I did not modify "USE_CDN", it should be false and thus
"all-nocdn.js" is relevant for my site. So if I am not mistaken, the
code should be in "moment-with-locales.min.js". Unfortunatly I cannot
find this file in the theme, so I believe it should be in the main
Nikola code. Checking the git repo, I can find this commit:

https://github.com/getnikola/nikola/commit/9a226dcf399dc698f2142ebdf3b222b9b476ac46

If I am not mistaken again, then this commit removed a file
"moment-with-locales.min.js" and may be the reason why the created
bundle does not include the "moment" code required by the index.html
file.

So can someone tell me if this reasoning is correct and how to correctly
fix this?

Thanks in advance
Detlev

[1] https://www.theregister.com/2022/01/31/website_fine_google_fonts_gdpr/
[2] https://github.com/getnikola/nikola-themes/pull/208


Detlev Zundel

unread,
Aug 16, 2022, 10:56:34 AM8/16/22
to nikola-...@googlegroups.com
I wrote:

[...]

> If I am not mistaken again, then this commit removed a file
> "moment-with-locales.min.js" and may be the reason why the created
> bundle does not include the "moment" code required by the index.html
> file.
>
> So can someone tell me if this reasoning is correct and how to correctly
> fix this?

So I think I have found the core problem. Commit f1d480d8 (Fix #3232 —
switch to Luxon for fancy dates, 2020-04-15) in Nikola switched to a
different handling of fancy dates altogether and the zen theme missed
out on this change. The fact that nobody complained may point to the
fact that I am the only user of this theme :|

I'll try to come up with a proper fix for this soon.

Best wishes
Detlev

--
Never confuse education with intelligence, you can have a PhD and
still be an idiot.
-- Richard Feynman

Detlev Zundel

unread,
Aug 22, 2022, 11:04:17 AM8/22/22
to nikola-...@googlegroups.com
It seems I am mostly talking to myself here ;)

> I wrote:
>
> [...]
>
>> If I am not mistaken again, then this commit removed a file
>> "moment-with-locales.min.js" and may be the reason why the created
>> bundle does not include the "moment" code required by the index.html
>> file.
>>
>> So can someone tell me if this reasoning is correct and how to correctly
>> fix this?
>
> So I think I have found the core problem. Commit f1d480d8 (Fix #3232 —
> switch to Luxon for fancy dates, 2020-04-15) in Nikola switched to a
> different handling of fancy dates altogether and the zen theme missed
> out on this change. The fact that nobody complained may point to the
> fact that I am the only user of this theme :|
>
> I'll try to come up with a proper fix for this soon.

To properly document the problem, I opened an issue it github:

https://github.com/getnikola/nikola-themes/issues/211

And a pull-request including a fix for this issue:

https://github.com/getnikola/nikola-themes/pull/209

In my local repository I do have some more enhancements on top of this
(update of fontaweseom and forkawesome and adding 'updated' handling)
and once the base goes in, I can open subsequent pull requests. Or
is it better to put all the new stuff into one pull-request? I did not
do this yet as my experience shows that people like to deal with smaller
units that are more clearly separated, but maybe this depends on the
project.

Any comment greatly appreciated!

Best wishes
Detlev

--
Referee's report: This paper contains much that is new and much that
is true. Unfortunately, that which is true is not new and that which
is new is not true.

Michael Ghens

unread,
Aug 22, 2022, 11:37:17 AM8/22/22
to nikola-...@googlegroups.com
It is interesting. It does not apply to me so I am just lurking.

--
You received this message because you are subscribed to the Google Groups "nikola-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nikola-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nikola-discuss/87czcs2uc7.fsf%40member.fsf.org.

Detlev Zundel

unread,
Aug 22, 2022, 1:56:50 PM8/22/22
to nikola-...@googlegroups.com
Hi Michael,

> It is interesting. It does not apply to me so I am just lurking.

Thanks for acknowledging that my posts at least are visible in the group
:)

Cheers
Detlev

--
error compiling committee.c: too many arguments to function

Reply all
Reply to author
Forward
0 new messages