Bug 1029285

Summary: RFE: Add the ability to upload local revision history changes
Product: [Community] PressGang CCMS Reporter: Lee Newson <lnewson>
Component: CSProcessorAssignee: Lee Newson <lnewson>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 1.2CC: mcaspers, ykatabam
Target Milestone: ---   
Target Release: 1.4   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-02-23 23:43:51 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Lee Newson 2013-11-12 04:49:17 UTC
From an email conversion with Yuko, it would be extremely handy for translators (maybe even writers) if you could make changes locally and then upload them to the server for additional Revision History entries (this can't be done via WebDAV at the moment either). This would be helpful to the translators as it is closer to their current workflow and would mean that they wouldn't have to use the PressGang UI to make changes to the additional revision history elements.

To go with that it may also be handy to be able to delete a revision by just specifying the revision number.

Comment 1 Lee Newson 2014-01-28 00:11:18 UTC
Added in 1.4-SNAPSHOT build 201401280947

We've added a new "edit" command to the csprocessor which will allow users to edit normal (untranslated) topics and content specs, as well as translated revision histories using their favourite editor (assuming the editor can be started from the command line with a file argument).

To edit a content spec/topic you will need the following configured in csprocessor.ini (the setup command has also been updated to set this up):

[editor]
command=nano
requiresTerminal=true

The "command" setting is the command name to be used (you may need to use the full path in some instances, ie /usr/bin/nano). The "requiresTerminal" setting should be "true" for command line editors and "false" for graphical editors.

To edit a content specification the format is:

    csprocessor edit --content-spec <ID>

To edit a topic the format is (topic is the default, so "--topic" can be left out):

    csprocessor edit --topic <ID>

To edit a translated revision history the format is:

    csprocessor edit --rev-history <ID> --lang <ZANATA LANG>

Technical Details:

The command works by using an observer to check for modifications to a specific file. When a modification (ie a save in the editor) is detected the file content will be uploaded back to the server. The file it checks is a temporary file created with the contents of the downloaded topic/content spec.

The command will remain active as long as the editor is active. Once it is closed it will wait a short while to make sure the file observer picks up any changes. After that it will then make sure the content has finished saving and then exit.

For terminal based apps, because the Java Process implementation doesn't direct to tty devices (or the equivalent for non linux OSes) we were required to start another terminal to run the editor. To do this I had to implement some OS specific code. At this stage we've added support for Windows, Linux and OSX distros (although the later is untested since I don't have access to a Mac). See http://stackoverflow.com/questions/9690702/how-can-i-launch-vi-from-within-java-under-commons-exec or http://stackoverflow.com/questions/11559265/open-vim-with-java-application

Comment 2 Lee Newson 2014-01-28 00:28:03 UTC
Made a mistake in the above sorry, the revision-history command should be:

csprocessor edit --rev-history <CSID> --lang <ZANATA LANG>

where CSID is the content specifications ID.

Comment 5 Lee Newson 2014-02-12 02:07:38 UTC
Fixed in 1.4-SNAPSHOT build 201402121201

The UI editors were failing due to a bug in the run command method that was removing the last option if it was wrapped in quotes (something I had added later to deal with the possibility of file names with spaces).

The NPE was caused by the getLinuxTerminalCommand() method not handling finding no running processes and also a typo in the KDE session process name.

Comment 7 Matthew Casperson 2014-02-12 02:21:02 UTC
Editing with a desktop text editor works ok now.

When editing with a terminal editor, csprocessor will open the editor and then exit, meaning the editor sees nothing.

We should also take this opportunity to add a step before the topic is uploaded to define a log message. This will overcome one of the big limitations with WebDAV.

Comment 8 Lee Newson 2014-02-12 02:34:26 UTC
I'll have to install KDE to test that, as it doesn't occur with GNOME.

As for the log message, I'd prefer to make that a separate RFE and handle it at a later stage as there are a lot of potential issues with that. Some of which include:

- What to do when saves are really close together. ie should we queue them and do one at a time, but then how do you know what save to associate a message with.
- What to do when waiting for a log message (see above).
- The usability issue of having to switch between tabs/terminals for every save to add a log message.

One thing we could do is add the --message option which would allow users to define a message that would be added for all saves. In my opinion this option is probably a good compromise.

Comment 9 Lee Newson 2014-02-12 06:37:48 UTC
Okay found out why this wasn't working under KDE. It was because konsole was forking the process so the parent process was ending and so was csprocessor. Adding the "--nofork" option when starting konsole fixes the issue.

As an additional note I found an issue with gnome-terminal under Fedora 20, as such I've removed the check that gnome is running so it will always use xterm instead (the --disable-factory option no longer works under F20).

Comment 11 Matthew Casperson 2014-02-12 07:00:12 UTC
Is it better to only save the changes once the editor has quit? That way you'd be prompted for one save message in the terminal that run csprocessor.

I tired to edit a file in vim, and this time csprocessor did not exit until vim was closed, but vim still didn't show the file. It's like vim was started without having a filename passed to it.

Comment 12 Lee Newson 2014-02-12 22:42:18 UTC
We could do it that way, however what if you are doing a large amount of editing and doing regular saves, then you close the editor and csprocessor has crashed? You'd lose all your work, which is why it saves whenever a file has changed.

There is also the use case of say I'm using a GUI text editor and open other files in the window. You might not close it after finishing editing the file, so therefore you'd have to close all other open tabs as well just to save the file. So in my opinion saving when changes are detected is the better option (plus it follows the way WebDAV works as well).

Comment 13 Lee Newson 2014-02-13 01:48:56 UTC
Fixed in 1.4-SNAPSHOT build 201402131141

The problem was that some programs started under konsole won't work if you enclose the command in quotes. As such I've updated the getLinuxTerminalCommand() method to remove the quotes for konsole and leave it for the other terminal emulators (since gnome-terminal and mate require it).

I've also re-enabled gnome-terminal and to counteract the process forking added in a check so that if the program exits within 1 second of starting, then the csprocessor will get the user to type "exit" when they are finished editing to close down the listener.

Comment 15 Matthew Casperson 2014-02-13 03:20:33 UTC
Tried a number of terminal and desktop based editors and they worked ok.