Reporting back. Using existing libraries, this is much simpler than I was making it. Here's some sample Python code which posts "Hello, World!" to topic ID 2. Thanks, @julian, for telling me about socket.io.
from socketIO_client import SocketIO, LoggingNamespace import requests import json session = requests.Session() csrf_token = json.loads(session.get('http://yourdomain:port/api/config').text)['csrf_token'] headers = { 'x-csrf-token': csrf_token } data = { "username": "yourUsername", "password": "yourPassword" } response = session.post("http://yourdomain:port/login", headers=headers, data=data) def on_response(*args): print('on_response', json.dumps(args)) with SocketIO('yourdomain', port, LoggingNamespace, cookies=session.cookies.get_dict()) as s: s.emit('posts.reply', {'tid': 2, 'content': "Hello, World!"}, on_response) s.wait_for_callbacks(seconds=1)Override template from plugin
-
Hello !
Is it possible to override a template file provided by a plugin ? It's not the first time I try it without success...
For example, I need to replace composer.tpl from nodebb-plugin-composer-default to change
<div class="hidden-sm hidden-xs preview-container">
into
<div class="hidden-xs preview-container">
I tried to put my composer.tpl version into my own theme templates directory but... no success.
Any help ? Must I really fork the plugin to change a so small thing ?
Thanks in advance !
(Add-on : on small screens, it would be great to be able to replace the write-container with the preview-container on clicking "show preview" and revert to write-container on clicking "show editor").
-
You need to arrange the plugin priority in the ACP so that your theme overrides the rest.
-
My theme is already loaded after the plugin (I tried before and after ; no change)... It's strange.
More infos :
My theme is loaded at last (in /admin/extend/plugins when sorting plugins).
I rebuild nodebb.
My composer.tpl is in /node_modules/nodebb-theme-oxide-YA/templates/modules and it doesn't override composer.tpl in /node_modules/nodebb-plugin-composer-default/static/templates/?
-
If there composer one is just in
templates/
then the one in your theme should be intemplates/
, not a subdirectory of it. -
@PitaJ Thanks ! Success !!!
composer.tpl needed to be in /node_modules/nodebb-theme-oxide-YA/templates/ and not in /node_modules/nodebb-theme-oxide-YA/templates/modules...
Sorry
Must I write a request for nodebb-plugin-composer-default for this :
On small screens, it would be great to be able to replace the write-container with the preview-container on clicking "show preview" and revert to write-container on clicking "show editor" ? -
@alfazaz would you mind opening an issue on the composer GitHub page requesting as much? Thanks
-
@PitaJ Ok ! I do it now.