@crazycells, Thanks. I need to look if all of the plugins I use are from GitHub. Definitely I’ll fork those.
rod
Posts
-
Saving Plugins Locally? -
Saving Plugins Locally?I am running an old version of NodeBB. I’ve tried to upgrade a few times but a few of the plugins I use don’t work as expected in the newer versions.
To protect myself from a problem if old versions of plugins are removed from the npm repositories is there a way to save the plugins locally? I ran into this problem when I moved my forum to a new hosting server, one of the plugins I use couldn’t find a specific version my forum previously had installed. Fortunately a slightly newer yet still old version did work successfully.
Thank you.
-
How to trigger an action after a post is madeI would like to trigger a specific action after a user submits a post. How would you recommend I do this?
I found an old post that references "fireHook", how could I use that to my advantage?
plugins.fireHook('action:post.purge', pid, function () { // all plugins are done });
In my case I don't want to purge a post but rather do something else.
Where would I even put the code chunk?
Thanks.
-
In which version did Custom Javascript show up?Well I am embarrassed, I figured out the problem! There is no problem with custom javascript or the custom header information. It turns out the nodebb-plugin-ns-twitch-monitor was the problem! The plugin does not seem to work after a certain version of NodeBB and where I had it placed in my widgets must have been causing the custom header code to not load or run properly.
I am still running
v1.4.5
but am moving over to a new server, yes after all of these years. In doing so I have been incrementally stepping through upgrades, 1.4.5 -> 1.5.x -> 1.6.x -> 1.7.x... It was there at the 1.7.x that my custom Piwik (Matomo) code stopped working. I put NodeBB into "dev" mode and saw a number of errors related to the Twitch plugin. I removed the plugin and my analytics code now works fine.It is bittersweet as I really like the Twitch plugin on my forum but the plugin stopped working quite some time ago. Twitch changed how their API works and the plugin was never updated to keep up.
Shouting out to a list of people for closure on this, in case you were all losing sleep on this since May of last year! @baris @julian @Nicolas
-
In which version did Custom Javascript show up?@baris Thanks for all of the pointers. The javascript does not seem to work in a Widget, as you deduced, either.
I'm at a loss as I'm not a JS programmer. I'll just stick with
v1.4.5
for a while longer for my production forum. Possibly I will figure something else out. -
In which version did Custom Javascript show up?@baris Still no success. I am watching the web server logs of the Piwik server and I see a hit for the loading of "/piwik.js" (as I should as you call the URL in your first script tag but I don't see any further web server entries after that.
I switch over to the my production NodeBB forum and while watching the Piwik web server log files I see all of the action I expect to see.
Is there any sort of special widget or plugin I could install in which I could put this javascript and have it run as it should. I wonder what in NodeBB is stomping on it?
I do see
true
in my browser console, fromconsole.log(window.hasOwnProperty('_paq'))
-
In which version did Custom Javascript show up?@baris. I reverted my dev site back to my production '1.4.5' version and it logged properly to Piwik (Matomo.). I upgraded to
v1.6.1
and that version worked fine also, reporting to Piwik.I upgrade to
v1.7.5
and voila reporting to Piwik no longer works. The1.7.x
branch is the one in which the Custom Javascript was broken out from Custom Header. I truly believe this is the root of the problem.Has anyone else reported oddities with custom javascript after the introduction of the 1.7 branch?
Thank you.
-
In which version did Custom Javascript show up?@baris I cannot get this to work. My new plan is to destroy my
1.12.1
version and install1.6.x
and test. If that works do the same going to version1.7.x
and test, and keep jumping forward until it doesn’t work and then report back.Thank you for all of your help thus far.
-
In which version did Custom Javascript show up?@baris You lost me on that last post. What section do I wrap in window.addEventListener('load', function ()?
-
In which version did Custom Javascript show up?@baris The odd thing is that it works in
1.4.5
. Should it work if I move it toCustom Header
with the script tags around it? Because when I try that I do get an error in the console and do NOT get any of that data form the console.log output.The error I get when it is in
Custom Header
isReferenceError: Can't find variable: ajaxify
-
In which version did Custom Javascript show up?@baris I added that to the function, I see data being displayed. Is there anything specific I should be looking for? I could give you access to the forum (it is a dev forum not prod) if you wanted to poke on it directly.
-
In which version did Custom Javascript show up?@baris said in In which version did Custom Javascript show up?:
firePiwik(ajaxify.data);
This has not solved the problem. Possibly closer, but not solved. I have my code back in
Custom Javascript
. I am not seeing errors for that in my browser console.It now behaves like it just doesn't execute
firePiwik(data);
in the "$(window)" area. This is all so strange.Thanks.
-
In which version did Custom Javascript show up?@baris @julian That didn't help. My code snippet was just a piece of the javascript. Here is all of it, maybe that will help figuring out why the $(window)... bit no longer works since upgrading from
1.4.5
var _paq = _paq || []; (function () { var u = "//your.piwikurlhere.com/"; function firePiwik (data) { if (app.user && app.user.uid > 0) { _paq.push(['setUserId', app.user.uid.toString()]); _paq.push(['setCustomVariable', 1, "appUserUsername", app.user.username, "visit"]); } _paq.push(['setDocumentTitle', document.title]); _paq.push(['setCustomUrl', location.href]); _paq.push(['enableHeartBeatTimer']); _paq.push(['appendToTrackingUrl', 'bots=1']); if (data.tpl === 'search') { _paq.push(['trackSiteSearch', ajaxify.data.search_query,, ajaxify.data.matchCount]); } else { _paq.push(['trackPageView']); } _paq.push(['enableLinkTracking']); _paq.push(['setTrackerUrl', u+'piwik.php']); _paq.push(['setSiteId', 1]); } var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); $(window).on('action:ajaxify.end', function(ev, data) { firePiwik(data); }); })();
The problem is that pesky
$(window)
area. I tried to replace it with the suggestion you made but that also didn't work and spewed number of other console errors.I think you could just drop this whole code bit into your Custom Javascript area and see it in action. The URL won't be correct but that shouldn't matter.
I really want to get this working so I can stay current with my NodeBB versions. I really do.
Thanks!
-
In which version did Custom Javascript show up? -
In which version did Custom Javascript show up?@baris I moved my javascript from
Custom Javascript
toCustom Header
but now I get an error (in my browser javascript console) that a variable cannot be found. Do you have a suggestion on what I should look at to resolve this?Can't find variable: $
And this is the code snippet:
$(window).on('action:ajaxify.end', function(ev, data) { firePiwik(data); console.log('in ajaxify.end area') });
Thank you.
-
In which version did Custom Javascript show up?Between version
1.4.5
and1.12.1
when did theCustom Javascript
area show up in addition to theCustom CSS/LESS
andCustom Header
areas?I ask because now with the
Custom Javascript
area I can no longer include the<script type="text/javascript">
and</script>
tags which I believe is why my custom javascript no longer works.When looking at my browser's console don't see my code snippet being parsed as javascript.
-
Getting an error with my Custom Javascript@PitaJ Thank you. How about this error that I am seeing in my browser console:
-
Getting an error with my Custom JavascriptI am seeing this error in my
Custom Javascript
. Any clues as to why it is complaining?Thanks.
-
Forum completely gone@Annihil Could this be contributing to the problem, no up address is attached to the port to listen on?
info: NodeBB is now listening on: 0.0.0.0:4567