1

I would like to embed a Google Doc into a FogBugz wiki page? Can I do it?

flag

1 Answer

2

FogBugz doesn't really support this out of the box (it will rewrite iFrames if you try to paste them in. However, you can use a simple BugMonkey script to replace google doc links with embedded doc links on view. I tried this out with google spreadsheets. Here's the finished result:

alt text

First, I went to http://support.google.com/docs/bin/answer.py?hl=en&answer=55244 to learn how to publish a spreadsheet to html. This is what my config looked like:

alt text

Next, I added inserted a link using that URL to where I want the spreadsheet to appear in the wiki page.

The final step is to add a BugMonkey script (My Settings > Customizations) to append an iFrame for the document after the link:

name:        Insert Google Doc into Wiki
description: Finds Google Doc links within a Wiki article and embeds the published Doc into the wiki
author:      Ben McCormack
version:     1.0.0.0
minApi:      1.0

js: 
$(document).ready(function(){
  //make sure we're on the view wiki page, not editing
  if ($('a#idViewArticle.selected').length === 0) {
    return;
  }

  var toMatch = /\bhttps:\/\/docs\.google\.com.*pub\?key=.*html\b/i;
  var matches = $('a[href*="https://docs.google.com/"]').filter(function(){
    return $(this).attr('href').match(toMatch);
  });

  $(matches).each(function() {
    var href = $(this).attr('href');
    var iframe = '<iframe src="' + href + '"width="800" height="600" frameborder="0"></iframe>';
    var replaceWith = $(this).clone().wrap('<p>').parent().html() + "<br/>" + iframe;
    $(this).after(iframe);
  });
});

css: 
/* body { background-color: red !important; } */

I haven't tested this on different types of documents, but the regex seemed to work for the spreadsheet I published.

link|flag

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.