Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Wiki Markup
{repository-plugin:key=com.javahollic.confluence.plugins.html-include-replace}

h3. Summary
{excerpt}Enables arbitrary HTML pages to be pulled into Confluence and automatically have relative and site-specific links rewritten so that images, scripts and style-sheets load etc.{excerpt}

(!) *The inclusion of content from other websites on Confluence pages is a security risk. Use if you trust all your users.*

h3. Drivers for development
The [Confluence HTML Macros] include \{html-include\} which is neat way of pulling arbitrary content into Confluence. For me I have a sister Twiki that cant be imported into Confluence due to its dynamic data. The Atlassian plugin doesn't take account of relative URL's,

|| Example || Renders in Confluence as || Result ||
| href="someplace/somefile.gif| href="http://confluencePAGE_URL/someplace/somefile.gif" | (x) |
| location="../../someplace/somefile.gif | href="http://confluencePAGE_URL/../../someplace/somefile.gif | (x)|
| href="/someplace/somefile.gif| href="http://confluenceSERVER_URL/someplace/somefile.gif" | (x) |
| An ajaxy/GWT application | (x) |

{info:title=Attempting to get code adopted}This plugin was a response to [CONF-6567|http://jira.atlassian.com/browse/CONF-6567] and the low vote count it had, I;m currently attempting to get it adopted by Atlassian as it would be even better if this could take advantage of the 2.9.2+ site White-listing features in the Atlassian macro, which is currently not possible _probably_.
{info}

h3. Description
This plugin loads page content from a given URL and performs a regular expression search/replace for many common tag attributes that have URL parameters, one for relative URL's and one for absolute URL's. It conveniently enables No / DIV / IFRAME 'container' elements around content. In the case of IFrame, this plugin doesn't do much except render the IFrame tag with the related source, as 'it just works'.

h3. Installation
Grab the latest stable jar (snapshots are not stable), upload to Confluence manually through the admin Plugin Page.

h3. Usage(s)
{noformat}
{html-include-replace:url=http://someplace/possiblysomedir/somefile.html}
{noformat}
{noformat}
{html-include-replace:url=http://someplace/possiblysomedir/somefile.html|container=iframe|width=400|height=400}
{noformat}

||Options|| Example Value || Description||
| replace1 | replace1=badtag | eg'replace' with unique (replacement) number suffixes, (subject of future refactor I'm sure) causes the whole of the 'badtag' to be removed, including its closing badtag, necessary if a given tag causes jtidy parse problems|
| engine | jtidy | optional parameter, enables different cleanup engines to be selected, default is Atlassian Fast Page Parser, other options include: 'jtidy' and 'neko'|
| includeStyles | true | Styles (.css) referenced via href= attributes are dynamically loaded into page from the source server (!) *IS* a very real risk of *collisions* with Confluence CSS names, styling of Confluence may be adversely affectged. |
| includeScripts | true | Scripts (.js) referenced via href= attributes are dynamically loaded into page from the source server
(!) *IS* a very real risk of XSS attacks
(!) *IS* a very real risk of Javascript collisions, possibly causing Confluence to behave improperly (older version of common libraries being loaded for example|
| container | none\|div\|iframe | defines whether a container element should wrap included elements. In the case of IFrame, this totally separates content |
| width | 400|50% | sets the width of the IFrame if used |
| height | 500|50% | sets the height of the IFrame if used |
| style | 'scrolling: auto; align: right' | any CSS styles to be applied |

h3. Example
CNN in a box:
{noformat}
{html-include-replace:url=http://www.cnn.com|includeStyles=true}
{noformat}

h3. Gallery
{gallery:title=Some example websites|columns=3}

h3. Version History
|| ? | - hope to get Atlassian to merge this into their html-include plugin so this functionality gets the advantage of the target site whitelisting
- extend to allow users to specify additional tags/functions that need to get processed|
||0.5 | - Enables GWT applications to be embedded in confluence via Iframes |
||0.4| - Removals execute irrespective of engine selection
- Scripts and Styles referred to in the *head* section of the source URL page, can be dynamically loaded into the page to help fix layout/display problems (but introduces a whole *heap* of other possible problems |
||0.3 | - Uses regexp to replace most tags, added comprehensive unit testing for correct URL replacement |

h3. Known Issues
Legacy Issues
{noformat}
||Completed||Priority||Locked||CreatedDate||CompletedDate||Assignee||Name||
|F|M|F|1233054166753| |matus.ferko|Replacements not done with regex, only works for 'plain' tags, needs regexp'ing|
|F|M|F|1233078083387| |javahollic|Wonder about how to filter dynamically loaded content that may already have been loaded (eg confluence .js libraries), also figure out how to make CSS sheets loaded _not_ take precendence over Confluence loaded styles|
|F|M|F|1233156937148| |javahollic|It will not work with _every_ web page in the world, wellformed markup will help.|
|F|M|F|1233156953376| |javahollic|Inline scripts and styles are not yet supported|
{noformat}