danirus / django-comments-xtd

A pluggable Django comments application with thread support, follow-up notifications, mail confirmation, like/dislike flags, moderation, a ReactJS plugin and Bootstrap 5.3.
https://django-comments-xtd.readthedocs.io
BSD 2-Clause "Simplified" License
594 stars 157 forks source link

Buid javascript library #139

Closed sandeepbalagopal09 closed 3 years ago

sandeepbalagopal09 commented 4 years ago

The tutorial shows how the javascript plugin can be integrated to a project. But when i try to do that getting an error from the console 'django is not defined'. I followed the doc, cloned the django-comments-xtd.git to my project folder. then did the build. After that copied the entire django_comments_xtd folder with the static assets to my project folder for django to recognise it as an app and load the static js. plugin-2.3.0.js and vendor~plugin-2.3.0.js. js files are load to my template but getting this error. How can i properly configure ?

danirus commented 4 years ago

Do you have the virtualenv active? The virtualenv where you did install Django?

sandeepbalagopal09 commented 4 years ago

Its fixed now @danirus. I had to put the i18n urls and call the JavaScriptCatalog view.

sandeepbalagopal09 commented 4 years ago

Sorry for repopening, this is working but My server is taking lot of hits from the url jsi18n/ because the comments plugin is calling this url. Is it possible to not to get it from a url ? since the call is happening in my article detail page, whenever someone access the page, the url is called.So just one day I get around 30k+ hit on this url.

can i just include the response of JavaScriptCatalog as a script in my html ? but that would nullify changes if django changes something in JavaScriptCatalog view.

danirus commented 4 years ago

Does anyhow the solution for #144 fix this issue?

sandeepbalagopal09 commented 4 years ago

Not actually.The call to django's javascript catalogue is still there. <script type="text/javascript" src="{% url 'javascript-catalog' %}">

I happen to copy this javascript to into one of my common js file and fixed temporarily in my project.

danirus commented 4 years ago

I will follow the note on performance to fix this issue.

danirus commented 4 years ago

Hi @sandeepbalagopal09, the last part of this issue is not a problem that can be fixed from within a Django application. Serving the JavaScript catalog is the responsibility of the Django project in which you integrate the application.

Check the link above, note on performance, and follow any of the recommendations. It seems the best one is based on django-statici18n.

danirus commented 3 years ago

My last answer pointed in the direction to solve this issue. Given that it's over 5 months since then I'm closing the issue. Please, don't hesitate to use the Discussions if you need more help. Thanks!