9 Replies Latest reply on Jun 22, 2011 1:55 AM by areohbee

    configurations file


      Hi, I would like to design an evironment where two plugins can use or share the same configurations file. One possible solution is to make a copy of the configuration file and put it into the two plugins folder, then just make a require 'config' line for both plugins and it should work. But this way it's a little bit hard to maintain because I'll always keep an eyes of those copy. It's there a smart way to make it easier?






        • 1. Re: configurations file
          areohbee Level 6

          I assume this will be a static config file, right? i.e. not changed by any plugins, nor different from plugin to plugin - also true?


          If that's so, it can really be handled the same as any other common/shared code, which I now handle by having a release procedure that automatically copies the common code into plugin specific directories for the released form of the plugin.


          summary: during development, plugins have lrdevplugin extension and share common code from a common directory.

          following release, plugins have lrplugin extension and common code has been copied to lrplugin subdirectory.

          • 2. Re: configurations file
            fovitan Level 1

            Yes, that's it true. The file is static, so it should not be changed by any other plugins. Automatic copy is a good solution, but I'm looking for the other way of solutions,  like when you create a line require 'config' and it should find automatic the config file for you. Maybe we should set path on OS environment or something like that?


            However, I find a temporarily solutions that need not to make any other copy of the original. It's to use symlink,, a way to make a reference to the original file without any copy. 


            Anyway thanks for advice.





            • 3. Re: configurations file
              areohbee Level 6

              Well, you can write your own loader to load files from wherever you want to, but then you need to make sure the file is in at least one of the place your going to look for it, which means you need to either write an installer, or trust your user to do the right thing.


              John Ellis wrote such a require function that he has been generous enough to share with the community if you want to have a look.



              • 4. Re: configurations file
                fovitan Level 1

                Hi Rob, your solutions seem to be better, so I've change to what you has recommended, also make an automatic copy. Thanks again.




                • 5. Re: configurations file
                  areohbee Level 6

                  Hi Fovitan,


                  One thing I've learned: Its not good to have any critical files outside the lrplugin folder upon delivery.


                  Reason: Users sometimes assume there isn't, and may move it around without asking, or even delete other files that came with it.


                  I mean, if the plugin is using some form of link/reference to some files, then it may still find them, I've just never invented a way to handle this, but maybe you could, or make a feature request if you'd need Lr/SDK support for it to work well...


                  Case Study:



                  I used to have plugin dev folders and files:


                  - Common (lua modules)

                  - Plugin X.lrplugin

                  - Plugin Y.lrplugin

                  Doc X.txt

                  Doc Y.txt


                  So when it was time to release, I just zipped up the doc, plugin, and common folder and that was all. Very convenient for me, but users kept misplacing the common folder, and then the plugin would not work, sometimes they even let me know there was a problem ;-}


                  Now, I have a plugin that releases other plugins and copies "Common modules" into 'lrplugin' subfolder.


                  So, its entirely possible you could invent a scheme that uses pseudo environment variables or a common subdirectory outside lrplugin or something, but I'm having a hard time imagining that being foolproof without an installer.


                  PS - I actually have a standard subdirectory under lrplugin named 'Preferences' just for config files.


                  Typical released plugin nowadays:

                  - Plugin X.lrplugin

                    - App (optional sidekick app)

                    - Framework (common lua modules)

                    - Preferences (config support files)

                    - Export Presets (if export plugin with built-in presets)




                  (No installer)




                  If you use common/shared/config modules, only way I know is to have a release procedure to copy stuff to lrplugin folder, or an installer to make sure files will be found outside lrplugin folder - but maybe I've missed some brilliant idea you are about to come up with :-)


                  Sorry, if I'm explaining too much about something you already understood - I'd be crucified for it on the tougher forums ;-}



                  • 6. Re: configurations file
                    fovitan Level 1

                    Hello Rob. I've was busy for last moment so answer you a little bit late. Hope you don't mind.   I've have now read your post. Yes, your theory seem to be correct, because the only way to do is to put your config file on plugins folder. So i got help to do an installer to make it work. I hope that in version sdk 4 it should be easier to make reference to path in require statement so we could refer in any folder we liket to. I've hope you have had a good weekend, and enjoy fun for the rest.





                    • 7. Re: configurations file
                      areohbee Level 6

                      I'd love to hear about that installer, if you wouldn't mind sharing...

                      • 8. Re: configurations file
                        fovitan Level 1

                        Hello again. The installer is not done by my self so I'm not wise as I should be. But  basically what i know is that you are using Maven to do the installer. Here in maven you have to configure the xlm like the path to lightroom plugins. In the maven it auto zip your lightroom files then in the end it produce the .exe files if you are using windows. You can read more about maven,, how to do and some examples here  at http://maven.apache.org/ and http://maven.apache.org/plugins/maven-install-plugin/.




                        • 9. Re: configurations file
                          areohbee Level 6

                          Thanks Tan.