Author Topic: File Mapping Team Directories to URLs  (Read 1779 times)

scm6079

  • Community Member
  • Posts: 13
  • Hero Points: 2
File Mapping Team Directories to URLs
« on: April 06, 2012, 02:54:28 am »
One of the many things we use SlickEdit for is website development.  Our developers are setup with an individual company run alpha web server for each of the many projects they work on.  We rely on the Local->Url mapping SlickEdit provides to allow for PHP debugging and "Execute" feature to view file output - which mostly works great.

HOWEVER - in order to do this we need to manually edit the XML project files because of an overly aggressive file check in the PHP Options menu.  Because we are putting EVERY team members' directory in the project as a mapping (/home/foo to http://foo.example.com, /home/bar to http://bar.example.com, etc) there will ALWAYS be all but one directory mapping that doesn't work on the current computer.

Trying to use the graphical menu we get this:


If I manually edit the .vpj XML project files like:
Code: [Select]
         ...
         <List Name="Map">
            <Item
               Name="RemoteUrl"
               Value="http://example.jwatson.cyberitas.com"/>
            <Item
               Name="LocalRoot"
               Value="/Users/jwatson/mnt/alpha/hosting4.alpha/home/jwatson/Source/ExampleSite/htdocs/"/>
         </List>
         <List Name="Map">
            <Item
               Name="RemoteUrl"
               Value="http://example.dporchia.cyberitas.com"/>
            <Item
               Name="LocalRoot"
               Value="/Volumes/alpha/hosting4.alpha/home/dporchia/Source/ExampleSite/htdocs/"/>
         </List>
         ...

I get the behavior I'm looking for.

Is there either:
   A) a way to get slickedit to ignore invalid directories (e.g. modify the code to give an IGNORE button to that dialog)
   B) specify a 'variable' in those paths that my team could configure locally
   C) another way of handling this.

It's important for us to have our wildcard projects in source control - so having users define a local/per developer project is not a viable option for us. 

Any help would be appreciated!

Thanks,
  Scott

« Last Edit: April 06, 2012, 02:57:22 am by scm6079 »

Graeme

  • Senior Community Member
  • Posts: 2093
  • Hero Points: 252
Re: File Mapping Team Directories to URLs
« Reply #1 on: April 06, 2012, 06:05:56 am »
I don't do php projects so I don't know what those mappings are all about but in the slickedit installation macros folder, in phpopts.e you'll see the following code which is what generates your error message.  You might be able to see how to modify it to get what you want.  If you decide to change the code, copy the phpopts.e file to some other folder and edit and load it from there.  To load it, use "load module" on the macro menu.

If this doesn't help, someone else will probably have an idea.  I don't understand how manual editing of the project file solves the problem  - so you could try explaining that further if no-one else can help.

Code: [Select]
         // Both local-to-url and remote-to-local mappings pivot on the local-directory.
         // It is never okay to have an invalid local-directory.
         _str localRoot = php_opts.urlMap[i].localRoot;
         if( localRoot == "" || !isdirectory(localRoot) ) {
            // Park the user on the problem
            _str msg = "";
            if( localRoot == "" ) {
               msg = nls("Missing local directory.");
            } else {
               msg = nls("Invalid local directory '%s'.",localRoot);
            }
            _message_box(msg,"",MB_OK|MB_ICONEXCLAMATION);
            activateOptionsTab("Run");
            p_window_id = ctl_mappings;
            _set_focus();
            selectMapping(i+1);
            return false;
         }
« Last Edit: April 06, 2012, 06:09:33 am by Graeme »

scm6079

  • Community Member
  • Posts: 13
  • Hero Points: 2
Re: File Mapping Team Directories to URLs
« Reply #2 on: April 06, 2012, 07:01:10 am »
Thanks for helping.  The reason that manually editing the XML helps is that SlickEdit properly handles multiple directory to URL mappings if you can get them into the project file. 

For example, if you are editing the file /home/scott/myproject/myfile.php it will know to go to the URL http://myproject.scott.mycompany.com/myfile.php -- and if you are editing the file /home/jason/myproject/myfile.php it will know to go to the URL http://myproject.jason.mycompany.com/myfile.php. 

This setup lets the team leader setup the project file with the first team member's paths/servers pre-configured -- and when the developers check out the project from source control they can start using it.  When a new team member comes onboard they can just hit the how-to wiki and add themselves. Right now this means editing the raw XML file - which I'd prefer to keep some of the more designer/HTML oriented guys from having to do.  The C++/hardcore PHP guys are great with editing the XML - but in all cases it's often slower and cumbersome for them -- and downright scary/impossible for some of the mostly photoshop designers entering into the HTML world.

SlickEdit functions if the configuration entries are there - so it's just an issue of getting them in there. 

I took your advice and found the phpopts.e file and took a look.  It appears very straightforward, so I took a crack at modifying it.  The key modification was to edit the error dialog as follows:

msg = nls("Invalid local directory '%s'.  Do you wish to continue anyways?",localRoot);
continueResult = _message_box(msg,"",MB_YESNO|MB_ICONQUESTION);



This seems to fix it nicely. :)


Line 1154: phpopts.e
Code: [Select]
static boolean validateFormOptions(PhpOptions& php_opts, XdebugOptions& xdebug_opts)
{
   getFormOptions(php_opts,xdebug_opts);

   // Note:
   // Standalone scripts do not use mappings. We will store them with the
   // project in case the user decides to change the apptype later.

   if( isAppTypeWeb(php_opts.appType) ) {

      int nLocalRoot = 0;
      int nRemoteRoot = 0;
      int nRemoteUrl = 0;

      // Used to flag duplicate local-to-url entries
      int local2url_dup_set:[] = null;
      // Used to flag duplicate remote-to-local entries
      int remote2local_dup_set:[] = null;

      // Note: php_opts and xdebug_opts are in-sync, so we can
      // get away with iterating over both with one index.
      int i, n=php_opts.urlMap._length();
      for( i=0; i < n; ++i ) {

         // Both local-to-url and remote-to-local mappings pivot on the local-directory.
         // It *is* okay to have an invalid local-directory if the user says so.
         _str localRoot = php_opts.urlMap[i].localRoot;
         if( localRoot == "" || !isdirectory(localRoot) ) {
            // Park the user on the problem
            _str msg = "";
            int continueResult = IDNO;
            if( localRoot == "" ) {
               msg = nls("Missing local directory.");
               _message_box(msg,"",MB_OK|MB_ICONEXCLAMATION);
               continueResult = IDNO;
            } else {
               msg = nls("Invalid local directory '%s'.  Do you wish to continue anyways?",localRoot);
               continueResult = _message_box(msg,"",MB_YESNO|MB_ICONQUESTION);
            }
            if( continueResult != IDYES ) {
               ctl_options_tab.sstActivateTabByCaption("Run");
               p_window_id = ctl_mappings;
               _set_focus();
               selectMapping(i+1);
               return false;
            }
         }

         // local-to-url mapping duplicate check
         _str remoteUrl = php_opts.urlMap[i].remoteUrl;
         if( remoteUrl != "" && local2url_dup_set._indexin(pathToHashKey(localRoot)) ) {
            // Park the user on the problem
            _str msg = nls("More than one entry for local-to-url mapping:\n\n%s",localRoot);
            _message_box(msg,"",MB_OK|MB_ICONEXCLAMATION);
            ctl_options_tab.sstActivateTabByCaption("Run");
            p_window_id = ctl_mappings;
            _set_focus();
            selectMapping(i+1);
            return false;
         }
         // New local-to-url mapping
         local2url_dup_set:[pathToHashKey(localRoot)] = 1;
         ++nLocalRoot;

         if( remoteUrl != "" ) {
            ++nRemoteUrl;
         }

         // remote-to-local duplicate check
         _str remoteRoot = xdebug_opts.remoteFileMap[i].remoteRoot;
         if( remoteRoot != "" ) {
            if( remote2local_dup_set._indexin(pathToHashKey(remoteRoot)) ) {
               // Park the user on the problem
               _str msg = nls("More than one entry for remote-to-local mapping:\n\n%s",remoteRoot);
               _message_box(msg,"",MB_OK|MB_ICONEXCLAMATION);
               ctl_options_tab.sstActivateTabByCaption("Run");
               p_window_id = ctl_mappings;
               _set_focus();
               selectMapping(i+1);
               return false;
            }
            // New remote-to-local mapping
            remote2local_dup_set:[pathToHashKey(remoteRoot)] = 1;
            ++nRemoteRoot;
         }
      }

      if( nLocalRoot == 0 ) {
         _str msg = "Please specify at least one mapping.";
         _message_box(msg,"",MB_OK|MB_ICONEXCLAMATION);
         ctl_options_tab.sstActivateTabByCaption("Run");
         p_window_id = ctl_mappings;
         _set_focus();
         return false;
      }
      if( nRemoteUrl == 0 ) {
         _str msg = "Please specify a URL.";
         _message_box(msg,"",MB_OK|MB_ICONEXCLAMATION);
         ctl_options_tab.sstActivateTabByCaption("Run");
         p_window_id = ctl_mappings;
         _set_focus();
         return false;
      }
      if( nRemoteRoot == 0 && isAppTypeRemote(php_opts.appType) ) {
         _str msg = "Please specify a remote directory.";
         _message_box(msg,"",MB_OK|MB_ICONEXCLAMATION);
         ctl_options_tab.sstActivateTabByCaption("Run");
         p_window_id = ctl_mappings;
         _set_focus();
         return false;
      }
   }

   if( xdebug_opts.serverHost == "" ) {
      _str msg = "Invalid/missing Xdebug host";
      _message_box(msg,"",MB_OK|MB_ICONEXCLAMATION);
      ctl_options_tab.sstActivateTabByCaption("Debug");
      p_window_id = ctl_server_host;
      _set_sel(1,length(p_text)+1);
      _set_focus();
      return false;
   }
   if( xdebug_opts.serverPort == "" || vssServiceNameToPort(xdebug_opts.serverPort) < 0 ) {
      _str msg = "Invalid/missing Xdebug port";
      _message_box(msg,"",MB_OK|MB_ICONEXCLAMATION);
      ctl_options_tab.sstActivateTabByCaption("Debug");
      p_window_id = ctl_server_port;
      _set_sel(1,length(p_text)+1);
      _set_focus();
      return false;
   }

   // All good
   return true;
}


:D Now I just need to get SlickEdit to include this in the next service release for v.16 and in v.17!!



Rodney

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 717
  • Hero Points: 46
Re: File Mapping Team Directories to URLs
« Reply #3 on: April 06, 2012, 05:55:02 pm »
I had not considered that use case. This will be addressed (similar to your patch) in v17. Thanks!

++rodney