bengillies.net

a blog by Ben Gillies

PublishCommand

config.commands.saveTiddler.old_handler = config.commands.saveTiddler.handler;
config.commands.saveTiddler.handler = function (event, src, title) { 
        var stored_tiddler = store.getTiddler(title);

    if(stored_tiddler&&stored_tiddler.fields && stored_tiddler.fields['sourceworkspace']){
        delete stored_tiddler.fields['sourceworkspace'];
    }

    config.commands.saveTiddler.old_handler(event,src,title);
};

config.commands.publishtiddler = {
    text: "publish",
    tooltip: "publish this so everyone can see it",
    confirmMsg: "Are you sure you want to publish this? If so, it will become visible to everybody and you will no longer be able to edit it",
    saveFirstMsg: "Please save this first!",
    handler: function(event,src,title){
        var t = store.getTiddler(title);
        if(!t){
            alert(this.saveFirstMsg);
        }
        if (!confirm(this.confirmMsg)) {
            return false;
        }
        var fields = store.getTiddler(title).fields;
//********************CHANGE THIS BIT TO YOUR PREFERRED BAG***************
        fields['publishtobag'] = "blog";
        fields['publishlevel'] = "copy";
//********************************************************************************************

        var publishToBag = fields.publishtobag;
        var newWorkspace = "bags/"+publishToBag;
        var publishLevel = fields.publishlevel;

        if(publishLevel) {
            fields['sourceworkspace'] = fields['server.workspace'];
            fields['revisionsidinsource'] = fields['server.page.revision'];
            fields['server.workspace'] = newWorkspace;
        
                store.saveTiddler(title);
        autoSaveChanges();
        } else {
            alert("no publish level set!");
        }
}
};

Comments

name:
comment: