divider

How To

This page will show you how to perform some common tasks using Revolver.


Replace spaces in item names with dashes

To perform this task we'll use the find command to locate items with spaces, then we'll use sa to set the new name while manipulating the previous name using the replace command.

Start by finding the items we're looking for. Use cd to navigate to the root of the item where we'll be working. Now formulate the find command using an attribute filter. If you want to operate recursively don't forget to use the -r parameter.

find -a name \s pwd

Now let's work out the replace command. We want to pass it the current name, search for spaces and replace them with dashes.

replace < (ga -a name) \s -

Now, we combine these commands. We aren't using the sa command yet, so no updates will be made. We'll instead see the effect of the replacements in a simulated run.

find -a name \s (replace < (ga -a name) \s -)

If all is looking good we can go ahead and put the sa command in to make the updates.

find -a name \s (sa name < (replace < (ga -a name) \s -))

Manipulate locks

Revolver allows 2 methods for manipulating the locks of items. The first is to use the ci and co commands which check in or check out the item in question. The other method is to manipulate the lock data directly using sf. ci and co only manipulate locks the current users owns. So if I wanted to check in every item I had checked out in the content tree I could ise:

find -r ci

But sometimes we don't want to just check in our own items. Many times we want to remove the locks altogether. For example, just before creating a release. We don't want to hand off a packgae where half the items are locked by a developer. To remove the locks:

sf __lock (<r />)

We can also lock content using the co command. Why would we want to lock the content? If we need to freeze any chances to the content tree immediatley. This will only work if you're an administrator and there are no other administrators who will change the locks. To lock all content in the content tree, use the following:

find -r co

Copy Presentation between items and devices

There are 2 ways in which to copy presentation between items using Revolver. Firstly, we could just copy the presentation field (__renderings) data from the source item to the target. To achieve this in Revolver, navigate to the target item and execute the following.

sf __renderings < (gf -f __renderings /path/to/source/item)

We could also use the cpp command. As with most Revolver commands which accept a path, be careful about your source and target and which parameter is which. Revolver has tried to keep the convention that if a command accepts a path then it is the last parameter.

cpp /path/to/target
cpp /path/to/target /path/to/source

Both examples above copy presentation. The first example uses the current context item as the source.

We can also specify the source and target device for the copy. Using this command we can copy between devices of the same item, or between devices on different items. The first example below copies the presentation from the default device to the firefox device on the current context item. The second exmaple copies the presentation of the default device on the source item to the firefox device on the target item.

cpp -sd default -td firefox
cpp -sd default -td firefox /path/to/target /path/to/source

Update all internal links

This is another locate, modify, store example. In this case we're looking for URLs in content fields that need to be updated to fit a new URL structure. In this example we'll be changing links of the structure /au/content.aspx to /au/en/content.aspx.

The first thing we need to do is work out how to locate the content we need to update. We'll use the trusty find command here to locate items which need to be updated. Start by navigating to the root of the content where we wish to start making updates. We'll assume the URLs are limited to the "text" field, so we'll use a field filter with the find command.

find -r -f text /au/ pwd

The above command will search all descendants for items with a text field that contain anything with a "/au/" in it. As usual we don't want to start modifying items until we're sure our RegExs are working, so we use pwd to list the matched items.

Next we need to work out how we want to modify the matched item. We can use the replace command combined with the gf command. To test this part of the command, navigate to one of the items matched in the previous command.

replace < (gf -f text) /au/ /au/en/

If we already had a "/au/en" link in the field we were testing against the effect of the above command would be to replace the "/au/" still and we'd end up with a duplicate "en" such as "/au/en/en". To prevent this we need to tweak our RegExs to exclude the match if it is followed by "en".

replace < (gf -f text) /au/\(?!en\) /au/en/

We can now put the replace command into the find command. This is our dry run. Executing this command will show the updates that will be made.

find -r -f text /au/\(?!en\) (replace < (gf -f text) /au/\(?!en\) /au/en/)

The only thing left to do is to alter the command to update the existin fields using the sf command.

find -r -f text /au/\(?!en\) (sf text < (replace < (gf -f text) /au/\(?!en\) /au/en/))

If you have multiple combinations of URLs that need updating (or need to execute again in the future), create a script to execute this for you. The path parts can be passed in as parameters.

find -r -f text /$1$/\(?!$2$\) (sf text < (replace < (gf -f text) /$1$/\(?!$2$\) /$1$/$2$))

So if we store the above in a script called "fixlinks", then execution would be as simple as:

fixlinks au en