Topic Color
-
Published v0.0.2 :
- The topic title in the header bar updates without the color codes.
I've also added a dev branch on my git repo to work on the permission feature.
I have two issues and need some help :-
The
action:ajaxify.end
seems to not fire my method. So I'm usingaction:topic.edit
to run my tests -
My logic is the following :
-
Get topic ID (Topics)
-
Get Username from the topic data (uid is undefined for some reasons) (Users)
-
Test if username is in Group (Groups)
If I test only one group it works, I haven't managed to get the multiple groups working. It returns [false,false] but both are true.
https://github.com/esiao/nodebb-plugin-topic-color/blob/dev/library.js#L21-L23
I think it's because my arguments are false but I don't know why, this array seems totally nice to me.-
Is there a way to use my allowed variable after in my main script ? My idea is to do the colorify if it's true and if it's false only do the prettify one in order to have some permissions.
-
The final objective would be to have a Checkbox list with all groups in admin to allow a list of groups to colorify their titles and if some smart guys want to try out without being permitted just don't colorify the title but remove the code to keep it readable.
Thanks in advance for the future help.
-
Published v0.0.3DEV (only on github) :
- Some cleaning
- Group testing logic is working
- ACP integration
I need your help on several things :
-
Show existing groups in the plugin controls. I've tried to follow what's done for groups.tpl in the source but it's not working (and I'm not surprised about it).
https://github.com/esiao/nodebb-plugin-topic-color/blob/dev/public/templates/admin/plugins/topic-color.tpl#L14-L16
I think I could use theGroups.list
function but I haven't managed to require Groups in that file, so if there's a way out. -
Send my Data from ACP, I've not understood yet how the Settings and Meta are working but my JSON is ready to use.
-
Use the
testGroup
method anywhere I need to, but I've managed to only get thetid
withaction:topic.edit
-
Send my variable colorify to my main.js. I have tested the export and require thing (http://stackoverflow.com/questions/3922994/share-variables-between-files-in-node-js) but I don't get it to work.
I think it's an issue with my path but I don't see why I'm wrong.
https://github.com/esiao/nodebb-plugin-topic-color/blob/dev/public/js/main.js#L4
My final goal is to say if colorify is true do my colorifyTopics function. If not do a new one which will prettify the title for non permitted groups of users. Basically it would be https://github.com/esiao/nodebb-plugin-topic-color/blob/dev/public/js/main.js#L44-L50 for any item.
I really hope you can help me for this new version.
-
And so after a lot of time and tries I have finally done what I was expecting.
Upgrade to the latest version 1.0.1 (major update) which fixes some bugs and adds the groups permissions and settings from ACP.
I have updated the first post there's a lot of information and a fancy presentation check it outFor the tech part,
After trying every single hook and not retrieving the data I needed, I was going to abandon the plugin to the 0.0.2 version. But I've read somewhere on the forum (don't recall where) that there were actually an API for NodeBB by adding /api/ after the location origin. And I have to say amazing job on this guys it rocks. I was able to do what I had in mind after a lot of testing but this seems very promising for the future and I'm sure that I'll use it for my forum and maybe future plugins.
Anyway thanks a lot for the support and enjoy my plugin -
Well I have a problem. It seems that when a user without admin privileges is logged the plugin don't work as expected.
The reason is simple, I have to call/api/admin/plugins/topic-color
to retrieve the configuration which is stored here. I do it from front so if the user is not admin there's a 403 and only the admin users have their topics name correctly displayed.
So is there a way to counter this ? I have thought of doing this in the plugin back but I haven't managed to send the config variable to my main.js after. -
This is now fixed.
Please update to the 1.1.0 version :- Fixed non admin users not able to see colorified topics of non admin users.
- Notifications are cleaned from the ugly code
I've just added a new renderer on the front pointing to /api/plugins/topic-color.
Edit :
Version 1.1.1 is out:- Topics in user profile are now colorified.
Version 1.1.2 too :
- Topics in widget last topics are colorified.
-
@a_5mith Oh thanks didn't figured out it was /api/home. I was doing /api/ and getting a 404.
I will color the subject on home I'll edit this message if there's no reply when it's doneAnd now it's done :
Version 1.1.4 :- Preview on home are colored
-
I've a question. There seems to be a change to the hook
action:app.load
becomingstatic:app.load
. I've not updated the plugin tho because I have a bug when I change this inplugin.json
.
Whenever I try to acces a page on the forum I have a :
Cannot GET /[route]Going back to action app.load resolve this. Any clues of what is happening ? Or do I need to wait for next version to update my plugin ?
One more thing I've seen that I've forgotten the search results so there will be an update to expect and if I could include this aswell it could be nice. -
Hey,
static:app.load
has a fourth parameter (callback), ex:
https://github.com/psychobunny/nodebb-plugin-registration-question/blob/master/library.js#L6-L11 -
Version 1.2.0 is out.
- Bug fixes.
- Massive code revamp on main.js thanks to @Xevious. Would be easier to keep up-to-date. There's less request and a lot of improvement.
- Updated the ACP view.
- Compatible with next version of NodeBB, the topics will be colored on homepage for this version thanks to
https://github.com/NodeBB/NodeBB/commit/83de5ba5a43c15157ac2f879f44f857638325981
-
While the plugin is fully functional on 0.5.0...
Major issue DO NOT USE THIS PLUGIN WITH LATEST MASTER BUILD !
Your topics will return 404 pages. Deactivating the plugin give access back.On the code side and why there will likely be an update in not a long time but I need to be sure before.
NodeBB seems to have changed how the slugs are interpreted, so a topic calledI'm a test
is accessible via
domain/topic/1/i-m-a-test
If you write
%(violet)[I'm a test]
the address will become
domain/topic/1/violet-i-m-a-test
The thing is that having the color in the url was something I considered ugly and so I used a little regex to clean the address like to be again
domain/topic/1/i-m-a-test
But what worked before is no longer working it will return a 404 because NodeBB is looking for this address to display the topic information
domain/api/topic/1/i-m-a-test?_=1411760431011
Checking
domain/api/topic/1/
returnsdomain/topic/1/violet-i-m-a-test
so I guess it could just be a URL rewriting thing. I also don't know why the slugs would have change to be the exact same as the topic before doingdomain/topic/1/whatever
was displaying the topic.I did that rewriting for SEO issues and also to avoid things like
domain/topic/14/rgb-41-223-143-test
@baris, @julian, @psychobunny
What is the behaviour to keep, if the new one is the one to preserve I'll update the plugin in consequence, but I think rewriting urls should be something to consider. -
The wrong slugs are returning 404 now because of this issue.
Previously if you would include an image in your post with
![](test)
it would load the entire topic again because it would make a request todomain.com/topic/1/test
and since the slug didn't matter it would reload the entire topic.If we can figure out a better way to handle this instead of just sending 404 for wrong slugs then we can go back to ignoring slug.
-
@baris Isn't the problem to figure out why
![](test)
is callingdomain.com/topic/1/test
?
So if understand I'll have to wait and see if I remove this feature from the plugin or keep it.Maybe the solution is to be able to set custom slugs via plugin on action:topic.save
-
It's just the way it works, it treats it as a local image and tries to load from /topic/1/test which matches the topic route and loads the topic if we don't check the slug.
I haven't found another way to prevent it other than checking the slug and making sure its correct.