Home of the Squeezebox™ & Transporter® network music players.
Page 1 of 3 123 LastLast
Results 1 to 10 of 29
  1. #1
    Senior Member
    Join Date
    May 2005
    Location
    UK
    Posts
    712

    Migrating plugin preferences

    Hi,

    The first thing I want to do to my plugin, is improve the preferences mechanism so that instead of a semi-colon separated list of library view names as a single string, I want an array of strings for the library view names.

    What I want to know is whether I can migrate a string preference called 'libraries' to an array of strings with the same name? Or should I rename the preference in the migration process and delete the old version.

    Any pointers as to how to do this would be appreciated. I've found the 'migrate' method and think I know what needs to be done, just want to know which approach I should take.

    Thanks

    Andy

  2. #2
    Senior Member
    Join Date
    May 2005
    Location
    UK
    Posts
    712
    Ok, I think I've answered my own question. It appears I can replace a string pref with an array one of the same name.

    Now working on altering the configuration page to use the new scheme.

    Thanks for reading

    Andy

  3. #3
    Senior Member
    Join Date
    May 2005
    Location
    UK
    Posts
    712
    Ok, trying to modify the configuration page for the plugin to display each library name in a separate field. I'm basing this on the repo list from the plugins page.

    The change is here:

    https://github.com/adhawkins/SimpleL...ngs/basic.html

    Any suggestion as to what I've done wrong? The bit where the list of library view names should appear is just empty.

    Thanks

    Andy

  4. #4
    Senior Member
    Join Date
    May 2005
    Location
    UK
    Posts
    712
    I'm not sure if Michael's comments on GitHub were related to the problem displaying the preferences on the web page. I should clarify that the migration appears to be working correctly. If I look at the preferences file I see the items listed as what I assume is an array:

    Old style preferences:

    Code:
    ---
    _ts_libraries: 1463688231
    _version: 0
    libraries: AudioBooks; Catrin
    New style:

    Code:
    ---
    _ts_libraries: 1465678494
    _version: 1
    libraries:
    - AudioBooks
    - Catrin
    When the plugin loads, the debug suggests it's loading the list of libraries correctly from the new array storage method.

    However, the issue I'm now having is that the web page doesn't seem to be displaying the list of libraries correctly.

    I'm sure it's something obvious I've done wrong...

    I think I've asked before, but is there any documentation for writing plugins? Specifically in this instance the storing / modification of preferences, and the writing of the web page to configure a plugin.

    Thanks

    Andy
    Last edited by adhawkins; 2016-06-11 at 14:19. Reason: minor clarification

  5. #5
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    20,352

    Migrating plugin preferences

    > Ok, trying to modify the configuration page for the plugin to display
    > each library name in a separate field. I'm basing this on the repo list
    > from the plugins page.


    Check out the formatting.html and
    Slim/Web/Settings/Server/TextFormatting.pm instead. In your template you
    are iterating over your list ref. But as it's empty there's no input
    field. To work around this you either have to add an empty field in the
    template, or make sure you add an empty entry to the list ref.

    --

    Michael

  6. #6
    Senior Member
    Join Date
    May 2005
    Location
    UK
    Posts
    712
    I'll check them out, but the list should have something in it at the moment, as the first thing I did was ensure the migration code worked. As a result, there should be some items in the list (as per the config file I posted a couple of messages ago).

    Andy

  7. #7
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    20,352

    Migrating plugin preferences

    > I'll check them out, but the list should have something in it at the
    > moment, as the first thing I did was ensure the migration code worked.
    > As a result, there should be some items in the list (as per the config
    > file I posted a couple of messages ago).


    I'm sorry, I've been away for the weekend (and more :-)). I didn't fully
    check out your code. But there might be a problem with the variable
    name. If I remember correctly you'll have to prefix it with "pref_" when
    accessing it from the template. Maybe I'll find a few minutes later
    today to look into this more closely.

    BTW: the templates are built using the Template Toolkit
    (http://template-toolkit.org). You'll find a lot of information there.

    --

    Michael

  8. #8
    Senior Member
    Join Date
    May 2005
    Location
    UK
    Posts
    712
    Quote Originally Posted by mherger View Post
    I'm sorry, I've been away for the weekend (and more :-)).
    That's allowed

    Quote Originally Posted by mherger View Post
    I didn't fully check out your code. But there might be a problem with the variable
    name. If I remember correctly you'll have to prefix it with "pref_" when
    accessing it from the template. Maybe I'll find a few minutes later
    today to look into this more closely.
    Ah, you might have hit the nail on the head there. I'll try that later.

    Still a little unsure about the empty box for adding new entries. I'll get it working as is first, and then try to work that bit out.

    Quote Originally Posted by mherger View Post
    BTW: the templates are built using the Template Toolkit
    (http://template-toolkit.org). You'll find a lot of information there.
    Ah excellent, I'll take look.

    Thanks as ever.

    Andy

  9. #9
    Senior Member
    Join Date
    May 2005
    Location
    UK
    Posts
    712
    Ok, I've made some changes that are at least showing the currently configured library views.

    I've been basing the code on the plugin downloader page, and that doesn't seem to have anywhere that explicitly adds in an empty field, or creates an empty item in the list of repositories shown at the bottom. I've checked out TextFormatting.pm and its associated web page too, and they don't seem to have anything obvious.

    I'll go off and read the web page you pointed me too now, see if that helps at all.

    Andy

  10. #10
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    20,352

    Migrating plugin preferences

    > I've been basing the code on the plugin downloader page, and that
    > doesn't seem to have anywhere that explicitly adds in an empty field, or
    > creates an empty item in the list of repositories shown at the bottom.


    https://github.com/Logitech/slimserv...ttings.pm#L286
    - the code is adding an empty entry ('') to the end of the list.

    > I've checked out TextFormatting.pm and its associated web page too, and
    > they don't seem to have anything obvious.


    https://github.com/Logitech/slimserv...matting.pm#L52
    - dito

    --

    Michael

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •