Bug 766406 - 3. Client Workflow automation - building a spec
Summary: 3. Client Workflow automation - building a spec
Keywords:
Status: CLOSED DUPLICATE of bug 796009
Alias: None
Product: PressGang CCMS
Classification: Community
Component: CSProcessor
Version: 1.x
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: ---
Assignee: Joshua Wulf
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks: 766408 766412 766413
TreeView+ depends on / blocked
 
Reported: 2011-12-12 00:59 UTC by Joshua Wulf
Modified: 2014-10-19 22:59 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-03-23 08:31:43 UTC
Embargoed:


Attachments (Terms of Use)

Description Joshua Wulf 2011-12-12 00:59:04 UTC
Here is a script that automates downloading and building the latest version of a Content Spec:
--------------------------------------------------------------
#!/bin/bash

SPECID=14
SPECNAME=Writing_with_Topics
DIR=`pwd`

rm -rf $SPECNAME
rm $SPECNAME.zip
java -jar ~/Skynet/skynet.jar build $SPECID
unzip $SPECNAME.zip
cd $SPECNAME
publican build --formats=html-single --langs=en-US

#google-chrome file://$DIR/$SPECNAME/tmp/en-US/html-single/index.html

#Use the locally configured default web browser
xdg-open file://$DIR/$SPECNAME/tmp/en-US/html-single/index.html
----------------------------------------------

This could be improved by making a csprocessor.cfg file that contains the SPECID and SPECNAME attributes. Then the buildit script could be an aliased command, and it could be run wherever a csprocessor.cfg file is located. It reads the SPECID and SPECNAME from the config file.

Comment 1 Joshua Wulf 2011-12-12 01:11:40 UTC
OK, here it is:
----------------------------------------------------------------------
#!/bin/bash

SKYNETCLIENTCMD="java -jar /home/jwulf/Skynet/skynet.jar"
DIR=`pwd`
CONFFILE=csprocessor.cfg

  if [ ! -f $CONFFILE ]
  then
    echo "Cannot find $CONFFILE. Exiting."
    exit 2
  else
    source $CONFFILE
  fi

  if [ -z "$SPECID" ]
  then 
     echo "Please set a value for SPECID in $CONFFILE"
     exit 3
  fi
  
  if [ -z "$SPECNAME" ]
  then 
     echo "Please set a value for SPECNAME in $CONFFILE"
     exit 3
  fi
  
rm -rf $SPECNAME
rm $SPECNAME.zip
$SKYNETCLIENTCMD build $SPECID
unzip $SPECNAME.zip
cd $SPECNAME
publican build --formats=html-single --langs=en-US
#google-chrome file://$DIR/$SPECNAME/tmp/en-US/html-single/index.html
xdg-open file://$DIR/$SPECNAME/tmp/en-US/html-single/index.html
----------------------------------------------------------

Here's how to set it up:

Copy the script above and put it into a file like ~/skynet/buildit.sh. 

Modify the value of SKYNETCLIENTCMD  in the script to point to your local installation of the skynet client.

Make it executable with "chmod 755 buildit.sh".

Edit ~/.bashrc and add a line to point to the buildit.sh script:

alias buildit='~/skynet/buildit.sh'

Reload your environment with "source ~/.bashrc"

Now create a csprocessor.cfg with the following syntax:
-----------------------------------
SPECID=14
SPECNAME=Writing_with_Topics
-----------------------------------

Then just run "buildit" in the same directory as the csprocessor.cfg file. The script will delete the previously downloaded zip and the extracted files, contact the webservice to get the latest build as a zip, extract it, build it with publican, and then open it for preview in your browser. 

Enjoy!

Comment 2 Joshua Wulf 2011-12-13 01:06:26 UTC
This version will copy in a custom entities file. Just put the entities file next to the csprocessor.cfg file. Whenever you build, the custom entities file will be copied into the correct location.


-------------------------------------------------------------------
#!/bin/bash

SKYNETCLIENTCMD="java -jar /home/jwulf/Skynet/skynet.jar"
DIR=`pwd`
CONFFILE=csprocessor.cfg

  if [ ! -f $CONFFILE ]
  then
    echo "Cannot find $CONFFILE. Exiting."
    exit 2
  else
    source $CONFFILE
  fi

  if [ -z "$SPECID" ]
  then 
     echo "Please set a value for SPECID in $CONFFILE"
     exit 3
  fi
  
  if [ -z "$SPECNAME" ]
  then 
     echo "Please set a value for SPECNAME in $CONFFILE"
     exit 3
  fi
  
rm -rf $SPECNAME
rm $SPECNAME.zip
$SKYNETCLIENTCMD build $SPECID
unzip $SPECNAME.zip

# Copy a custom entities file, if one exists next to the csprocessor.cfg file
if [ -f $SPECNAME.ent ]
then
    cp $SPECNAME.ent $SPECNAME/en-US/$SPECNAME.ent
fi

cd $SPECNAME
cd $SPECNAME
publican build --formats=html-single --langs=en-US
#google-chrome file://$DIR/$SPECNAME/tmp/en-US/html-single/index.html
xdg-open file://$DIR/$SPECNAME/tmp/en-US/html-single/index.html

Comment 3 Joshua Wulf 2012-02-20 08:19:38 UTC
#!/bin/bash

SKYNETCLIENTCMD="csprocessor"
DIR=`pwd`
# Note that this script fails when the path of the current working directory contains spaces
# To fix this, a function should be added to escape characters in the xdg-open argument

CONFFILE=csprocessor.cfg

  if [ ! -f $CONFFILE ]
  then
    echo "Cannot find $CONFFILE. Exiting."
    exit 2
  else
    source $CONFFILE
  fi

  if [ -z "$SPECID" ]
  then 
     echo "Please set a value for SPECID in $CONFFILE"
     exit 3
  fi

  if [ -z "$SPECNAME" ]
  then 
     echo "Please set a value for SPECNAME in $CONFFILE"
     exit 3
  fi

  if [ -f $SPECNAME.zip ]
  then
     rm $SPECNAME.zip
  fi
  
rm -rf $SPECNAME
$SKYNETCLIENTCMD build $SPECID
unzip $SPECNAME.zip
rm $SPECNAME.zip
cd $SPECNAME
publican build --formats=html-single --langs=en-US

# The command below will fail if there are spaces in the path name
# WORKAROUND: Make sure no directories in the path have spaces in them. Use _ instead
xdg-open file://$DIR/$SPECNAME/tmp/en-US/html-single/index.html

Comment 4 Lee Newson 2012-02-21 00:04:21 UTC
Below is a fix to allow Working Directories to have spaces in them.

#!/bin/bash

SKYNETCLIENTCMD="csprocessor"
DIR=`pwd`

CONFFILE=csprocessor.cfg

  if [ ! -f $CONFFILE ]
  then
    echo "Cannot find $CONFFILE. Exiting."
    exit 2
  else
    source $CONFFILE
  fi

  if [ -z "$SPECID" ]
  then 
     echo "Please set a value for SPECID in $CONFFILE"
     exit 3
  fi

  if [ -z "$SPECNAME" ]
  then 
     echo "Please set a value for SPECNAME in $CONFFILE"
     exit 3
  fi

  if [ -f $SPECNAME.zip ]
  then
     rm $SPECNAME.zip
  fi

rm -rf $SPECNAME
$SKYNETCLIENTCMD build $SPECID
unzip $SPECNAME.zip
rm $SPECNAME.zip
cd $SPECNAME
publican build --formats=html-single --langs=en-US

# Open the index.html file
xdg-open "file://$DIR/$SPECNAME/tmp/en-US/html-single/index.html"

Comment 5 Joshua Wulf 2012-03-23 08:31:43 UTC
Functionality implemented by 796009

*** This bug has been marked as a duplicate of bug 796009 ***


Note You need to log in before you can comment on or make changes to this bug.