How to synchronize Publishing Configuration automatically

I see the option for automatically synchronizing when a new local file is saved, but what about the reverse? I am editing the source files on the server and want to synch the latest to local frequently, e.g. when I close Komodo. Is there any way to do this?

This wouldn’t be possible to do automatically, not easily any way. The way it’s implemented, to “pull” things down you have to have the sync dialog open. I’d have to dig in there a little more to see if you can just force a sync to pull things down.

That sounds risky and totally backwards to me though. What is your use case? Why are you modifying remotely and pulling things down locally?

  • Carey

I’m modifying remotely because the server environment is somewhat complex and I don’t want to try to build it on a local machine; it’s easier to set up a dev server.
I want to pull local because I have Source Tree monitoring the local directory for changes, allowing me to check them in (or reject them and have Komodo replicate the change back to the server).
I’d be happy to learn there’s an easier way, however!

For now, though, it looks like I’ll just need to remember to re-synch at the end of each session. Not a huge deal, but wondered if it could be more automated somehow.

I’ve written a macro that you can use to run when Komodo shuts down. Just in case you’re new to Komodo (or someone that finds this is):

  • Open your toolbox; View > Tabs & Sidebars > Toolbox
  • Click gear icon and select New Macro
  • Paste code below into code area
  • Name it…
  • Click Triggers
  • Select Macro should trigger…*
  • Select On shutdown…

You can return to this screen by right clicking the marco in the toolbox and selecting Properties.


//Cycle through the current views and check for a publishingStatus
var views = ko.views.manager.getAllViews();
var ids = [];

for (var i in views) {
    var view = views[i];
    var file = (view && view.koDoc && view.koDoc.file) || null;
    // Check if the file is under Publishing control, eg != 0
    if (file.publishingStatus) {
        var fileURIDir = ko.uriparse.pathToURI(file.dirName);
        var settings = ko.publishing.getSettingsForUri(fileURIDir);
        // Only open the sync dialog if it's not been opened yet
        // Don't need to run sync twice
        if (ids.indexOf(settings.id) == -1 ) {
            ids.push(settings.id);
            displaySync(settings.id);
        }
    }
}

// Open the dialog if it hasn't been opened yet
function displaySync(id) {
    ko.publishing.synchronize(id);
}

That should help a bit at least. I don’t think we would ever implement a blind sync to the remote server on shutdown, that’s definitely macro territory. Hopefully this is what you wanted.

  • Carey
1 Like

Hi Carey,

That’s fantastic, I was wondering about a macro. It’s my dev environment on the server. If it was production, a blind synch wouldn’t be such a good idea :slight_smile:

Appreciate the help,

Richard

Hey Carey, I sure you should add the macro to the Resources :wink:

I considered it @Defman but it’s such a narrow use case I decided not to. It would be better to add it as an option in Publishing :wink: Gotta move on to other stuff though.

  • Carey