A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

Jump to

Quick reference

Showing posts with label confluence. Show all posts
Showing posts with label confluence. Show all posts

Stop Confluence making CamelCase links

You can include the following code in the page, or make a macro out of it.
Note: You need to attach JQuery to one of your wiki pages, and edit the URL in the code.
{html}
<script type="text/javascript" src="/download/attachments/59835554/jquery-1.2.6.js"></script>
<script type="text/javascript"> 
//The $ notation is used by DWR. So we rely on jQuery namespace only
jQuery.noConflict();          
jQuery(document).ready(function() {
   //The camel case links have class createlink. So fetch all such links and remove the html part and retain the text part
   jQuery("a.createlink").each(function(index){
    var text = jQuery(this).text();
    if(isValidCamelCase(text)){//Only filter where we have a camelcase text and not valid yet to be created link
       jQuery(this).after(text).remove();
    }
    return true;
   });
});

function isValidCamelCase(s){
 if(s == null || s.length == 1){
  return false;
 }
 
 if(s.indexOf(' ') != -1){
  return false;
 }

 //Check for case where valid link is being created like [Test123]
 var indexOfNonUpperCaseChar = -1;
 for(var i = 0; i < s.length; i++){
  var c = s.charAt(i);
  if(!isUpperCase(c)){
   indexOfNonUpperCaseChar = i;
   break;
  }
 }
 
 if(indexOfNonUpperCaseChar == -1){
    return false;
 }
 
 var lowerCase = s.toLowerCase().substring(indexOfNonUpperCaseChar);
    var originalCase = s.substring(indexOfNonUpperCaseChar);
    if(originalCase == lowerCase){
     return false;
    }
 return true;
}

function isUpperCase(char){
 return char >= 'A' && char <= 'Z'
}
</script>
{html}

Thanks

Allow PRE text to wrap on Confluence wiki


Add this to the wiki code:


{html}
<style type="text/css">
/* Allow PRE elements to wrap --- better than manually adding ad-hoc
 * linebreaks because
 * (a) It's automatic
 * (b) It adapts to the window width
 * (c) People can still copy-and-paste from the browser window and get the
 * original long lines
 */
pre {
 white-space: pre-wrap; /* css-3 */
 white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
 white-space: -pre-wrap; /* Opera 4-6 */
 white-space: -o-pre-wrap; /* Opera 7 */
 word-wrap: break-word; /* Internet Explorer 5.5+ */
}
</style>
{html}

Thanks duckbill


Confluence calendar


{calendar:id=nameOfCalendar|title=Title of Calendar|defaultView=month}

It publishes in iCal.