At work, we use the most excellent Confluence wiki system by Atlassian for all of our shared documentation. We also use it for weekly status reports, which are based on a template that needs some minor changes each week before being created.
Creating these weekly pages for people to fill in used to be a manual process—copying the template to a new wiki document, then editing it to make some pre-defined changes (such as the date)—until I learned about a Ruby gem for the Confluence API. Now a small Ruby program run weekly does the work for me:
# Some variables specific for my Confluence setup
url = 'https://your.confluence.wiki.com/'
user = 'jamesbond'
password = '007'
wikispace = 'statusreports'
template = 'Status for week ending YYYY-MM-DD'
# Find the date of the next Friday
friday = Date.today
friday += 1 while friday.wday != 5
# Log in to Confluence and retrieve the template page
server = Confluence::Wiki.new(url)
page = server.getPage(space, template)
# Create a new page based on the template, changing the
# date placeholder with this Friday's date
newpage = Hash.new
newpage['space'] = space
newpage['title'] = template.gsub(/YYYY-MM-DD/, friday.to_s)
newpage['content'] = page['content'].gsub(/YYYY-MM-DD/, friday.to_s)
newpage['parentId'] = page['parentId']
# Save the new page
Leave a Reply