rbeer / nodebb-plugin-smoothshorts

Seamless short URLs for topic and post links in NodeBB.
MIT License
5 stars 2 forks source link

Categories not loading without a browser refresh after upgrading to 0.3.2 #15

Open GitPuffy opened 8 years ago

GitPuffy commented 8 years ago

I am seeing odd behavior in my test/dev environment with a clean clone of my production forum then removing nodebb-plugin-smoothshorts directory from node_modules and then git cloning from github (in essence getting your most recent work).

The behavior is when I periodically visit one of the "primary categories" that has sub categories the primary category never fully loads. it is opaque during the load (Lavender theme) and then never goes to fully visible. The progress bar moves along the top of the forum but never fully disappears. If I hard refresh my browser the subcategory will then load.

Nothing seems to get logged as an error. I also started the test/dev forum in ./nodebb dev startup mode but it too did not display anything odd. You may need to visit my test/dev forum to see the behavior.

Thanks.

rbeer commented 8 years ago

Hi @GitPuffy

Just read your mail; thanks.

Well, I get plenty of errors in the browser console. Seems I messed up good there. ^_^

Let's see...

rbeer commented 8 years ago

I see the error in your dev instance, but can't reproduce it. You have another error before the one coming from the plugin.

// Place this code snippet near the footer of your page before the close of the /body tag
// LEGAL NOTICE: The content of this website and all associated program code are protected under the Digital Millennium Copyright Act. Intentionally circumventing this code may constitute a violation of the DMCA.

eval(function(p, a, c, k, e, d) {
  e = function(c) {
    return (c < a ? '' : e(parseInt(c / a))) + ((c = c % a) > 35 ? String.fromCharCode(c + 29) : c.toString(36))
  }
  ;
  if (!''.replace(/^/, String)) {
    while (c--) {
      d[e(c)] = k[c] || e(c)
    }
...

This one produces a SyntaxError: Unexpected token }. Syntax Errors tend to mess up all following scripts; I think that's what happens here. I don't think the source of the problem is in the plugin.

Do you have the same problem when in dev mode?

GitPuffy commented 8 years ago

I made a fresh clone of my PRD to DEV and now the only thing I have done is delete the nodebb-plugin-smoothshorts directory from node_modules and then did a git clone of your current master.

Unfortunately now I cannot get NodeBB to start without errors. I think you must be working on a new set of code bits. I'll check for your next commits to master and try then.

This is the error I get now when starting up NodeBB:

/home/centos/nodebb_installation/DEVpath/node_modules/nodebb-plugin-smoothshorts/lib/hashing.js:70
    let type = result.isPost ? 'posts' : result.isTopic ? 'topics' : '';
    ^^^
7/5 16:29 [6695] - error: SyntaxError: Unexpected strict mode reserved word
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/home/centos/nodebb_installation/DEVpath/node_modules/nodebb-plugin-smoothshorts/lib/sockets.js:7:15)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
7/5 16:29 [6695] - warn: [plugins] Unable to parse library for: nodebb-plugin-smoothshorts
rbeer commented 8 years ago

Oh, sorry. I should update the README. :smile:

I started using ES6, which comes with very good improvements to functionality and syntax, but isn't understood by older versions of NodeJS (don't get me started on browsers :unamused: ). Anyway; looks like you have one of those older NodeJS versions running, so you need to transpile (ES6 back to ES5) the scripts, first:

I recommend creating a separate directory outside NodeBB for this. Using your path from the log, my setup looks like:

/home/centos/nodebb_installation/DEVpath  <- NodeBB itself
/home/centos/nodebb_installation/plugins/    <- clone plugin in here

Install grunt-cli

~  npm -g install grunt-cli

Clone the plugin. Or just pull the latest commit; I had to fix Gruntfile.js. Used ES6 in there, too. Which was an obviously bad idea, since it's the one script transpiling all others. :smile:

git clone https://github.com/rbeer/nodebb-plugin-smoothshorts/
Cloning into 'nodebb-plugin-smoothshorts'...
remote: Counting objects: 989, done.
...
Resolving deltas: 100% (529/529), done.
Checking connectivity... done.

Install dependencies. It's important that this also installs the "devDependencies", like 'babel-preset-es2015', 'grunt', 'grunt-babel', etc.

nodebb-plugin-smoothshorts   master  npm install
npm WARN prefer global coffee-script@1.10.0 should be installed with -g

> xxhash@0.2.3 install /var/wwn/NodeBB/plugins/nodebb-plugin-smoothshorts/node_modules/xxhash
> node-gyp rebuild
...
├─┬ babel-preset-es2015@6.6.0 
│ ├─┬ babel-plugin-check-es2015-constants@6.8.0 
│ │ └─┬ babel-runtime@6.6.1 
│ │   └── core-js@2.4.0

Optional Change the path to your NodeBB instance in Gruntfile.js (around line 15)

  grunt.initConfig({
    NodeBB: '../../dev/',  // This should be '../DEVpath/' for you
    pkg: grunt.file.readJSON('package.json'),
    buildPath: {
      _buildsBase: function(relative) {
...

Now you can use grunt and its different tasks (defined in Gruntfile.js), e.g.:

nodebb-plugin-smoothshorts   master  grunt publish

The publish task alone does the transpiling, some linting, moving files around and good stuff like that. When it finished without warnings/errors, you should have a new directory named builds/publish/, e.g. _/home/centos/nodebbinstallation/plugins/nodebb-plugin-smoothshorts/builds/publish/. This, finally, is what you would want to show to NodeBB as the plugin (i.e. copy or link to node_modules).

If you took the optional step (setting the path to your NodeBB) above, you can have grunt do the linking for you! Simply use the task publish:symlinks

nodebb-plugin-smoothshorts   master  grunt publish:symlinks

This task does exactly the same as publish alone, but adds a symlink builds/current which points to builds/publish (because there are other tasks like dev and npm that would also create folders in builds/; current basically just points to the build directory of the last completed grunt task). This builds/current link itself then is linked to NodeBB, e.g. _/home/centos/nodebb_installation/DEVpath/nodemodules/nodebb-plugin-smoothshorts.

P.S. When you let grunt do the linking, it can happen that it aborts with:

Running "symlink:NodeBB" (symlink) task
Checking target...OK
Removing link...Link is a directory!
>> Error: EISDIR: illegal operation on a directory, unlink '../../dev/node_modules/nodebb-plugin-smoothshorts'

That's to be expected when there is a folder with the plugin's name in _nodemodules, meaning that you installed the plugin from another source than those grunt tasks (e.g. npm). Just a failsafe to not accidentially overwrite things. You'd have to manually delete that folder, before running the :symlink task.

GitPuffy commented 8 years ago

Well, I didn't understand all of that but I did my best to try it out.

/home/centos/nodebb_installation/plugins/nodebb-plugin-smoothshorts/Gruntfile.js:144
            grunt.log.verbose.error(`Can\'t access '${sym.target}' !`);
                                    ^
Loading "Gruntfile.js" tasks...ERROR
>> SyntaxError: Unexpected token ILLEGAL
Warning: Task "publish" not found. Use --force to continue.

Aborted due to warnings.

I feel so dense that I cannot figure out what is missing from my environment to get this to "publish."

rbeer commented 8 years ago
`Can\'t access '${sym.target}' !`

Those are string templates. One of these very nice improvements in ES6. I forgot to replace them. :)

GitPuffy commented 8 years ago

Ok, I now have your current master deployed into my DEV. I have made no other changes to DEV from PRD with the exception of changing the site name, page name and disabling notifications.

Please now take a look at when you click from the home route to a category. The page never fully loads without a refresh.

Thank you.

rbeer commented 8 years ago

Good morning! :smiley: Good news: I can reproduce the problem now. It happens when a sub-category in clicked category has no posts. I will fix it after work; already know how to, just gotta do it. :+1: