Bug 796009

Summary: RFE: Improve client to accommodate User Workflow
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.xCC: jwulf
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 0.22.0 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-05-01 08:07:02 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 788014, 795216    
Bug Blocks: 799821    

Description Lee Newson 2012-02-22 02:43:41 UTC
At the moment the client does accommodate workflow very well and as such Josh has created the scripts in: https://bugzilla.redhat.com/show_bug.cgi?id=766408, https://bugzilla.redhat.com/show_bug.cgi?id=766413, https://bugzilla.redhat.com/show_bug.cgi?id=766406.

To fix this the client should be reworked to work in the same manner as these scripts.

There are multiple components to do this, they are as follows:

- Add the ability to read and create the a csprocessor.cfg file. The file should be stored in a sub directory.

- Add a root directory to the .ini file that will specify where content specs will be stored. If this attribute is empty then use the current working directory.

- Change the push command into two separate commands. 
    - The push command should update an existing content spec designated by the csprocessor.cfg in the current working directory or by a file in the same manner as the current "push -ce <FILE>" command.
    - The "push -cn <FILE>" command should be moved to a "create <FILE>" command. Upon completion of this command, a csprocessor.cfg file and sub-directory should be created. A post content specification should also be saved into the sub directory.

- Change the pull command so that if no arguments are given it will get the ID from the csprocessor.cfg file

- Change the build command so that if a csprocessor.cfg file is present then the ZIP archive will be stored in $SUB_DIRECTORY/assembly/publican/

- Add a assemble command that will build a content spec, store the ZIP archive in $SUB_DIRECTORY/assembly/publican/ and then unzip the file in the same directory

- Add a preview command that will do the same as the assemble command, build the book using publican and then open the index.html file.

An example output, where /home/jwulf/scratch/ is the root directory, as described by jwulf is shown below:

<jwulf> /home/jwulf/scratch/Content_Spec_Processor/
<jwulf> /home/jwulf/scratch/Content_Spec_Processor/csprocessor.cfg
<jwulf> /home/jwulf/scratch/Content_Spec_Processor/post-Content_Spec_Processor.spec
<jwulf> /home/jwulf/scratch/Content_Spec_Processor/assembly/publican/Content_Spec_Processor.zip
<jwulf> /home/jwulf/scratch/Content_Spec_Processor/assembly/publican/Content_Spec_Processor/publican.cfg

Comment 1 Joshua Wulf 2012-02-23 14:46:35 UTC
*** Bug 795216 has been marked as a duplicate of this bug. ***

Comment 2 Lee Newson 2012-03-05 07:10:54 UTC
Done in 0.22.0.

A few changes from the above details:

The output structure is now:

/home/jwulf/scratch/Content_Spec_Processor/
/home/jwulf/scratch/Content_Spec_Processor/csprocessor.cfg
/home/jwulf/scratch/Content_Spec_Processor/post-Content_Spec_Processor.spec
/home/jwulf/scratch/Content_Spec_Processor/assembly/Content_Spec_Processor-publican.zip
/home/jwulf/scratch/Content_Spec_Processor/assembly/publican/publican.cfg

This was done since it is redundant to have the $TITLE twice in the same directory structure. It also makes it easier to navigate as by going directly to the publican folder you can run publican commands straight away. It also creates a more meaningful zip archive as the ZIP now contains the program that it was built for in its file name.

More comments about the new client and configuration files to come.

Comment 3 Lee Newson 2012-03-05 10:59:18 UTC
New configuration file:

-----------------------------------------------
[directory]
# Main directory to store content specifications
root = 

[publican]
build.parameters = --langs=en-US --format=html-single,html
preview.format = html-single

[servers]
default.url = http://localhost:8080/TopicIndex/
default.username = 

production.url = http://skynet.cloud.lab.bne.redhat.com:8080/TopicIndex/
production.username = 

test.url = http://skynet.usersys.redhat.com:8080/TopicIndex/
test.username = 
-----------------------------------------------

The default.url must exist. The username parameter isn't required and will default back to the default.username if no username is set in the other server parameters.

The root parameter in directory is the root directory to store all the content specifications. If it it null then the current working directory will be used.

The publican configuration files define which commands publican should use to build the specs and to preview them.

Comment 4 Lee Newson 2012-03-05 11:49:38 UTC
To go with the last comment servers in the csprocessor.cfg will will never match to a default server. This is because the default URL is designed for commands that don't use the csprocessor.cfg. It must be defined elsewhere i.e:

csprocessor.cfg:
----------------------------------------------------------
SPEC_ID = 6192
SERVER_URL = http://localhost:8080/TopicIndex/
----------------------------------------------------------

csprocessor.ini
----------------------------------------------------------
[servers]
default.url = http://localhost:8080/TopicIndex/
default.username = lnewson

local.url = http://localhost:8080/TopicIndex/

....
----------------------------------------------------------

Comment 5 Lee Newson 2012-03-05 11:52:35 UTC
The client was completely rewritten to go with the removal of the server. The client now uses a modified version of JCommander (http://www.jcommander.org/) to parse the arguments. The new list of commands can be seen below:

Usage: csprocessor [options] [command] [command options]
  Options:
   --config <FILE>            
   --help                     
   --host, -H <URL>           
   --username, -u <USERNAME>  
  Commands:
    assemble      Builds and Assembles a Content Specification so that it is ready to be built
    build      Build a Content Specification from the server
    checkout      Checkout an existing Content Specification from the server
    create      Create a new Content Specification on the server
    checksum      Get the checksum value for a Content Specification
    list      List the Content Specifications on the server
    preview      Build, Assemble and then open the preview of the Content Specification
    pull      Pull a Content Specification from the server
    push      Push an updated Content Specification to the server
    revisions      Get a list of revisions for a specified ID
    search      Search for a Content Specification
    validate      Validate a Content Specification

The pull command will create a backup file when it pulls a content specification. This is done to protect overwriting the changes of local files.

Comment 6 Lee Newson 2012-03-05 12:05:04 UTC
Another difference from the original guidelines is the assemble command will also build the book using publican since this is actually part of assembling a book.

So the Assemble command will build the book, unzip it to the publican directory and then build using publican. You can stop the book from being rebuilt by the processor by using the "--no-build" option.

The preview command will build the book, unzip it to the publican directory, build it using publican and then open the file specified by the "preview.format" config parameter. You can stop the building or assembling by using the "--no-build" or "--no-assemble" commands.

If no "build.parameters" is set it will default to "--langs=en-US --format=html-single".

If no "preview.format" is set then it will default to "html-single".

Comment 7 Lee Newson 2012-03-05 12:17:03 UTC
Known issues:

- If you try and use the preview command with Google Chrome as the default web browser and no open instance, Chrome fails to start properly. This appears to be an issue with the Java Runtime library.

Comment 8 Lee Newson 2012-03-06 01:45:53 UTC
More Information:

The Preview and Assemble commands also have the ability to be used with an ID. When this is done the build will behave in the same manner it did in the old version, where a <TITLE>.zip is created in the current working directory (cwd). 

From there the assemble will extract the zip into cwd/<TITLE>/ and then run publican from that directory in the same manner as assembling using a csprocessor.cfg. The preview is also no different except it opens it from the cwd/<TITLE>/tmp/en-US/ directory.

Comment 9 Lee Newson 2012-03-06 01:47:49 UTC
Additional feature to be implemented:

A new status command should be added so that a user can check if their current post processed spec is the same version that exists on the server. This makes it easier to use when multiple people are working on the same Content Spec.

Comment 10 Lee Newson 2012-03-07 07:20:57 UTC
Added the status command.

It will print a message or error stating that the content specification is up to date or if it is out of date a message is display stating to get the latest download it using the pull command.

Also one component that I added is that when using the assemble command it will delete everything in the assembly/publican/ folder. This is done to ensure that the publican build has only the files from the latest build. While having old files shouldn't cause an issue for publican it could confuse the user if they see those old files in there.

Comment 11 Joshua Wulf 2012-03-23 08:31:11 UTC
*** Bug 766408 has been marked as a duplicate of this bug. ***

Comment 12 Joshua Wulf 2012-03-23 08:31:32 UTC
*** Bug 766413 has been marked as a duplicate of this bug. ***

Comment 13 Joshua Wulf 2012-03-23 08:31:43 UTC
*** Bug 766406 has been marked as a duplicate of this bug. ***

Comment 14 Joshua Wulf 2012-05-01 08:07:02 UTC
Verified in cspclient-0.23.2-1.