What's new

[Dev] Q&A for Merlin Addons API

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

The limit i was referring to was the way FreshJR implemented custom rules - they're currently saved to an unused nvram variable, which have set limits. I of course don't expect you to add an unlimited number of mount points!

My bad, I must have read it too quickly, I thought you were referring to the current limit of 10 custom pages.
 
I like this idea. I'm thrashing out some code to see if I can use your framework with spdmerlin as we speak!
@dave14305 I think I've got the backend sorted for update checks and unattended updates on spdmerlin develop branch. I think it is in a similar vein to your approach. Just need to sort out the WebUI side of it now....I will of course credit you for the idea once I get a stable release (I'm supposed to adding an option to use 24h time on daily charts :p)
 
For custom events generated by a user ASP page, is there any benefit to using service-event versus service-event-end? The former is blocking while the latter is not, so I just wonder if there's a good reason to choose one over the other.

I assume if you want to intercept a restart of a service you intend to modify, then service-event is better, but if you are just looking for an after-the-fact trigger, I think service-event-end might be just as good and potentially less impactful.
 
For custom events generated by a user ASP page, is there any benefit to using service-event versus service-event-end? The former is blocking while the latter is not, so I just wonder if there's a good reason to choose one over the other.

I assume if you want to intercept a restart of a service you intend to modify, then service-event is better, but if you are just looking for an after-the-fact trigger, I think service-event-end might be just as good and potentially less impactful.
No preference. I use service-event because I hooked into that for custom actions before service-event-end even existed ;-)
 
No preference. I use service-event because I hooked into that for custom actions before service-event-end even existed ;-)
Using ntpMerlin as an example, if you didn't fork your script into the background with &, every service event would wait for your script to generate stats. So it could have unintended impacts if not done properly, as you did. :)
 
Using ntpMerlin as an example, if you didn't fork your script into the background with &, every service event would wait for your script to generate stats. So it could have unintended impacts if not done properly, as you did. :)
Indeed. As I say, the "end" script didn't exist when I hooked into using services to trigger stat updates etc. from the WebUI. Innovating has its pain points :p
 
Hey all.
I occasionally see double or triple entries of same variable names in custom_settings.txt
Unfortunately, the duplicates have an empty value string which usually renders that variable as empty or not set, depending how am_settings_get reads the file.
I only use am_settings_set and am_settings_get throughout so I'm a little confused as to what I do wrong.
I DO use sed to remove (no longer needed) variables as there is no unset command provided to remove variables in custom_settings.txt.
Do any of you have a better /usr/sbin/helper.sh that may fix this?

Also, the Merlin /usr/sbin/helper.sh does not support variable values with spaces, as opposed to the wiki saying it can be done.
@john9527 's helper.sh does support values with spaces AFAIK, maybe his file is better used instead?
 
I occasionally see double or triple entries of same variable names in custom_settings.txt
Unfortunately, the duplicates have an empty value string which usually renders that variable as empty or not set, depending how am_settings_get reads the file.
I only use am_settings_set and am_settings_get throughout so I'm a little confused as to what I do wrong.
There's not really any validation going on with settings, maybe you're writing a setting with a multi-line value somewhere?

I DO use sed to remove (no longer needed) variables as there is no unset command provided to remove variables in custom_settings.txt.
Do any of you have a better /usr/sbin/helper.sh that may fix this?
The easiest way I see of doing this is treating empty and unset settings the same, and deleting them internally. For example
Code:
[ -n "$2" ] && echo "$@" >> $_am_settings_path
in helper.sh and similarly in data_arrays.c

Also, the Merlin /usr/sbin/helper.sh does not support variable values with spaces, as opposed to the wiki saying it can be done.
@john9527 's helper.sh does support values with spaces AFAIK, maybe his file is better used instead?
They source looks the same (release/src/router/others/helper.sh and release/src/router/httpd/data_arrays.c). Seems fine on the shell side, not sure why it's limited in ej_get_custom_settings, I think it's the "[ \n]" doing it.
 
There's not really any validation going on with settings, maybe you're writing a setting with a multi-line value somewhere?
I'll double check my code. As with everything Diversion, the WebUI code is far bigger and more complex than any other code I've seen from other developers.
This is not bragging, just expressing that Diversion and it's upcoming next WebUI release is as inclusive as you would expect from its developer.
I might push the addons API to the limit here.
They source looks the same (release/src/router/others/helper.sh and release/src/router/httpd/data_arrays.c). Seems fine on the shell side, not sure why it's limited in ej_get_custom_settings, I think it's the "[ \n]" doing it.
Yeah, I can set a spaced value in shell with am_settings_set [variable name] "this value and more" in Johns and retrieve and re-set it through the WebUI, but not in Merlins.
 
I'll double check my code. As with everything Diversion, the WebUI code is far bigger and more complex than any other code I've seen from other developers.
This is not bragging, just expressing that Diversion and it's upcoming next WebUI release is as inclusive as you would expect from its developer.
I might push the addons API to the limit here.
Did you solve the annoying page refresh to change between your tabs yet?

EDIT: IMHO bigger and more complex doesn't necessarily mean better ;)
 
Did you solve the annoying page refresh to change tabs yet?
No, why would I as it's the only way to do it with the limited possibilities.
It's not that one changes pages every second or so. Also that is an action that requires server code running and the browser updating the page.
Just like any other action like checking for an update or saving the page or a new parameter as some of you have built in.
 
No, why would I as it's the only way to do it with the limited possibilities.
It's not that one changes pages every second or so. Also that is an action that requires server code running and the browser updating the page.
Just like any other action like checking for an update or saving the page or a new parameter as some of you have built in.
I await the final release with anticipation.
 
EDIT: IMHO bigger and more complex doesn't necessarily mean better
Remember, I always have the users in mind, that includes the interaction with my scripts.
 
I’m looking at using table.js to enable in-cell editing of rules for my FreshJR fork (like the Port Trigger table in the base firmware). But I need to clone the firmware versions because I need to adjust the built-in validation functions to account for slightly different input allowed in FreshJR rules.

Anyone tried any of this yet? Or should I take good notes? ;)
 
Did you solve the annoying page refresh to change between your tabs yet?

EDIT: IMHO bigger and more complex doesn't necessarily mean better ;)
I could mount two tabs, but that would be excessive, a waste of tab space and the available limit of 10 user pages.
 
Anyone have an idea why this JavaScript / jquery code does not work on John's fork but happily in Merlin's?
Code:
if (custom_settings.Div_p_page !== undefined) {
   if (custom_settings.Div_p_page == "index") {
       $('#thisContent').load('/user/diversion/div-index.html');
   } else {
       $('#thisContent').load('/user/diversion/div-lists.html');
   }
}
The console error is for the first $('#thisContent').load('/user/diversion/div-index.html');
TypeError: $(...) is null


id #thisContent is set in <td bgcolor="#4D595D" colspan="3" valign="top" id="thisContent"></td>

I'm loading these js files, jquery is from Merlins, but even with johns built in it does not work:
Code:
/user/diversion/div-jquery.js
/state.js
/general.js
/popup.js
/help.js
/detect.js
/base64.js
 

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top