• HOME
    • PRODUCT
    • PRICING
    • ABOUT
    • COMMUNITY
    Menu
    • HOME
    • PRODUCT
    • PRICING
    • ABOUT
    • COMMUNITY
    Get in touch
    Get in touch
    Menu
    • HOME
    • PRODUCT
    • PRICING
    • ABOUT
    • COMMUNITY
    • Sign in
    • Start free trial
    • Get in touch
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Tags
    • Users
    • Groups
    • Documentation
      • Home
      • Read API
      • Write API
      • Plugin Development
    1. Home
    2. magnusvhendin
    • Profile
    • Following 0
    • Followers 3
    • Topics 25
    • Posts 70
    • Best 13
    • Controversial 0
    • Groups 2

    magnusvhendin

    @magnusvhendin

    Swedes

    18
    Reputation
    70
    Profile views
    70
    Posts
    3
    Followers
    0
    Following
    Joined Last Online
    Location Stockholm, Sweden

    magnusvhendin Unfollow Follow
    Users with 50 posts Swedes

    Best posts made by magnusvhendin

    • Why isn't email required anymore?

      Or to be more precise, why was this moved to the interstitials step in the registration?

      I'm referring to this commit.

      I don't really see why this was needed. If the forum requires a valid email address, why not just show that at registration, and not as an after thought? Even if you tick "Require new users to specify an email address" at /admin/settings/user#user-registration, you only get prompted in the optional email input during the interstitials.

      posted in NodeBB Development
      magnusvhendin
      magnusvhendin
    • RE: Why isn't email required anymore?

      @crazycells That's exactly what I mean. The way it was implemented now is very confusing. I get the need to remove email as a factor (GDPR etc), but I don't understand the way it was implemented. And for some forums emails could be crucial, so why put it after registration? I know it's not technically after registration but, still not where expected.

      No where else have I encountered a registration where you don't input your information all at once. I even feel that the TOS could be a checkbox with a link to the information.

      But in the end it's the decision of the NodeBB team and I don't want to nag about it. I'm just interested in the reasoning.

      posted in NodeBB Development
      magnusvhendin
      magnusvhendin
    • RE: Unable to override scripts

      @julian This worked great. I did this in my main client file (like persona.js).

      require(['hooks'], (hooks) => {
      	hooks.on('filter:script.load', (data) => {
      		const replaceMap = {
      			register: {
      				target: 'forum/register',
      				with: 'replacement/register',
      			},
      		};
      
      		const replace = replaceMap[data.tpl_url];
      
      		if (replace) {
      			const index = data.scripts.indexOf(replace.target);
      			if (index > -1) data.scripts[index] = replace.with;
      			else data.scripts.push(replace.with);
      		}
      
      		return data;
      	});
      });
      

      Then I can just add my scripts that I want to replace to the replaceMap object.

      posted in Plugin Development
      magnusvhendin
      magnusvhendin
    • RE: Fetching post data with formatting

      Turned out I was fetching the post data wrong. I was using getPostData when i should've been using getPostsByPids.

      posted in NodeBB Plugins
      magnusvhendin
      magnusvhendin
    • Getting all recent topics in all available categories

      I'm getting all available categories for a user with categories.getCategoriesByPrivilege. Then I append to it with
      categories.getRecentTopicReplies. I'm not getting what I want, only the top post (reply).

      What I want is the following; a list of all topics with recent posts (preferably with a max limit in time range), within my available categories. What the client I'm working for want is a feed type thing with all recent activity displayed in one single flow. Then I will also drill down into specific categories but I think I've got that covered.

      This is where I'm at so far:

      Controllers.renderFeedPage = function (req, res) {
      	if (!req.uid) {
      		res.render('feed', {});
      	}
      	let categoriesData;
      	let tree;
      
      	async.waterfall([
      		(next) => {
      			categories.getCategoriesByPrivilege('categories:cid', req.uid, 'find', next);
      		},
      		(_categoriesData, next) => {
      			categoriesData = _categoriesData;
      
      			tree = categories.getTree(categoriesData, 0);
      			categories.getRecentTopicReplies(categoriesData, req.uid, next);
      		},
      		() => {
      			const data = {
      				title: meta.config.homePageTitle || '[[pages:home]]',
      				categories: tree,
      			};
      			res.render('feed', data);
      		},
      	]);
      };
      

      I haven't found a good example from the forum and I'm reading source code at this point.

      If anyone has done something similar I would really appreciate the input and a nudge in the right direction.

      Thanks!

      posted in NodeBB Development
      magnusvhendin
      magnusvhendin
    • Append templateData to sidebar

      So I've been working with NodeBB for a while now and am familiar with several concepts, but one thing I'm not sure about.

      If I want to add data to the "global scope" before render. How would I do that?

      I know how to get data to the page templates, but that doesn't carry over into the global templates, like the sidebar menu.

      How can I, for instance, fetch my categories and place them in the sidebar?

      posted in Plugin Development
      magnusvhendin
      magnusvhendin
    • RE: Test fail for missing translation key

      @julian Okay, I'll do that. Thanks!

      posted in NodeBB Development
      magnusvhendin
      magnusvhendin
    • RE: Append templateData to sidebar

      @baris Just what I needed. Thanks a lot!!

      posted in Plugin Development
      magnusvhendin
      magnusvhendin
    • Cached scripts

      Hi all!
      I've run into an issue that when I deploy a new version of my theme/plugin, most users don't get any changes done until they do a hard refresh. This only seems to affect the client side Javascript, so everything looks updated, but in reality functionality gets lost.

      Has anyone stumbled upon something similar? Is there a better way to release code?

      The background in this is that I have forked Persona and built upon it, so all changes to the platform is basically in the theme. Is there a way to make sure all clients receive all updates?

      Thanks!

      posted in Plugin Development
      magnusvhendin
      magnusvhendin
    • RE: Client script cannot be available in both main and admin?

      Thanks for the clarification @PitaJ! I did a lot of experimenting but I guess I didn't get the right combination. I think I never tried naming the module with its extension. That might have been it. For anyone who might be interested in the actual solution, here it is:

      In file-explorer.js:

      define('azure/file-explorer', ['components'], function (components) {
      	const FileExplorer = {};
      
      	FileExplorer.init = function () {
      		// Init stuff here	
      	});
      
      	return FileExplorer;
      });
      

      In plugin.json:

      "modules": {
      	"azure/file-explorer.js": "static/lib/file-explorer.js"
      },
      

      In admin.js:

      define('admin/plugins/azure', ['settings', 'azure/file-explorer'], function (settings, fileExplorer) {
      	fileExplorer.init();
      });
      

      In main.js:

      $(document).ready(function () {
      	require(['azure/file-explorer'], (fileExplorer) => {
      		fileExplorer.init();
      	});
      });
      
      posted in Plugin Development
      magnusvhendin
      magnusvhendin

    Latest posts made by magnusvhendin

    • RE: Template helpers not working in in NodeBB v2

      @baris This worked like a charm. Thank you!

      posted in Plugin Development
      magnusvhendin
      magnusvhendin
    • RE: Unable to override scripts

      @julian This worked great. I did this in my main client file (like persona.js).

      require(['hooks'], (hooks) => {
      	hooks.on('filter:script.load', (data) => {
      		const replaceMap = {
      			register: {
      				target: 'forum/register',
      				with: 'replacement/register',
      			},
      		};
      
      		const replace = replaceMap[data.tpl_url];
      
      		if (replace) {
      			const index = data.scripts.indexOf(replace.target);
      			if (index > -1) data.scripts[index] = replace.with;
      			else data.scripts.push(replace.with);
      		}
      
      		return data;
      	});
      });
      

      Then I can just add my scripts that I want to replace to the replaceMap object.

      posted in Plugin Development
      magnusvhendin
      magnusvhendin
    • Unable to override scripts

      Migrating to NodeBB v2 I came across an issue that I cannot resolve. In my theme/plugin I override two scripts because I want to write my own logic for two pages:

      • register
      • email

      I get this error:

      uncaughtException: EEXIST: file already exists, symlink '../../../../node_modules/[PLUGIN/THEME NAME]/lib/client/register.js'

      Any ideas on how to get around this?

      posted in Plugin Development
      magnusvhendin
      magnusvhendin
    • RE: Template helpers not working in in NodeBB v2

      I get the following error client side:

      Uncaught TypeError: can't access property "registerHelper", Benchpress is undefined

      posted in Plugin Development
      magnusvhendin
      magnusvhendin
    • Template helpers not working in in NodeBB v2

      I'm at the moment adapting my plugins for v2 and ran into an issue with template helper functions. I've until now included them as below, so they work both when rendered on the server and the client.

      'use strict';
      
      /* globals */
      
      (function (factory) {
      	if (typeof module === 'object' && module.exports) {
      		factory(require.main.require('benchpressjs'));
      	} else {
      		require(['benchpress'], factory);
      	}
      }((Benchpress) => {
      	const number_of_answers = (data) => {
      		const replies = data.postcount - 1;
      
      		switch (replies) {
      			case 0:
      				return 'No comments';
      			case 1:
      				return '1 comment';
      			default:
      				return `${replies} comments`;
      		}
      	};
      
      	const customHelpers = {
      		number_of_answers,
      	};
      
      	function register() {
      		Object.keys(customHelpers).forEach((helperName) => {
      			Benchpress.registerHelper(helperName, customHelpers[helperName]);
      		});
      	}
      
      	register();
      
      	if (typeof module === 'object' && module.exports) {
      		module.exports = customHelpers;
      	}
      }));
      
      

      This has worked great but now that I'm running v2 (2.0.0) it only works server side. I'm including the file in plugin.json under scripts, "lib/helpers.js".

      One guess is that I should move it to modules as other client scripts, but I'm not sure how I should do that with template helpers.

      Appreciate all help.

      posted in Plugin Development
      magnusvhendin
      magnusvhendin
    • RE: Why isn't email required anymore?

      @julian I agree with you on the extra steps (TOS etc), but just not on the email bit.

      For me these are the logical paths:

      Do not require email

      1. Input username and password.
      2. Click register
      3. Fill in optional information

      Require email

      1. Input username, email and password
      2. Click register
      3. Fill in optional information

      This makes it very obvious what is and what isn't optional.

      That said. It's obviously up to you but I don't think it would be a huge amount of work to do this. Is it something that you would approve as a PR or do you want to keep it as is?

      posted in NodeBB Development
      magnusvhendin
      magnusvhendin
    • RE: Why isn't email required anymore?

      @crazycells That's exactly what I mean. The way it was implemented now is very confusing. I get the need to remove email as a factor (GDPR etc), but I don't understand the way it was implemented. And for some forums emails could be crucial, so why put it after registration? I know it's not technically after registration but, still not where expected.

      No where else have I encountered a registration where you don't input your information all at once. I even feel that the TOS could be a checkbox with a link to the information.

      But in the end it's the decision of the NodeBB team and I don't want to nag about it. I'm just interested in the reasoning.

      posted in NodeBB Development
      magnusvhendin
      magnusvhendin
    • Why isn't email required anymore?

      Or to be more precise, why was this moved to the interstitials step in the registration?

      I'm referring to this commit.

      I don't really see why this was needed. If the forum requires a valid email address, why not just show that at registration, and not as an after thought? Even if you tick "Require new users to specify an email address" at /admin/settings/user#user-registration, you only get prompted in the optional email input during the interstitials.

      posted in NodeBB Development
      magnusvhendin
      magnusvhendin
    • RE: Test fail for missing translation key

      @julian Okay, I'll do that. Thanks!

      posted in NodeBB Development
      magnusvhendin
      magnusvhendin
    • RE: Test fail for missing translation key

      Okay I now found this.

      So does that mean that I should suggest this key be added and wait with my request or that I should push it with language in template and update at a later point?

      posted in NodeBB Development
      magnusvhendin
      magnusvhendin

    Get Started

    • Product
    • Pricing

    Resources

    • Demo Site
    • Answers
    • Docs
    • Bug Bounty

    Company

    • About
    • Blog
    • Contact
    Start Free Trial
    Github Facebook Instagram Twitter
    © 2014 – 2022 NodeBB, Inc. — Made in Canada.
    • Terms
    • Privacy
    • GDPR
    • DMCA
    • Contact
    Menu
    • Terms
    • Privacy
    • GDPR
    • DMCA
    • Contact