Posts Tagged lineBreaks
v0.9 Release - Fix for the Line Break bug
Posted by Sid in DPS911, Mercurial Project, Open Source on April 11th, 2009
In my previous blog post I explained the line break bug and how I would go about fixing it. I’ve managed to get the functionality up and running now. Lets have a look at the code:
// ellipsis for multi-line desc messages $('.desc').each(function (i) { if($(this).html().indexOf("\n") != -1) { $(this).html($(this).html().replace(/\n/g, " ")); $(this).html(createEllipsis($(this).html(), ($(this).attr("class")).match(/id\d+/) + i)); $('.hide').hide(); } }); $('.ellipsisexpand').click(function () { var pushid = $(this).attr("class"); pushid = 'span.' + pushid.match(/id\d+/); $(pushid).toggle(); return false; });
function createEllipsis(html, pushid) { return html.substring(0, html.indexOf("")) + "<a class="\"ellipsisexpand" href="\">[...]</a><span class="\"hide">" + html.substring(html.indexOf(""), html.length) + "</span>"; }
The map file:
<strong class="desc id#id#">#author|person# — #desc|strip|escape|buglink#</strong>
When using jquery you want to keep all your functionality within the $(document).ready function, which is what I have done. So, in the map file I gave the strong tag that contains the commit message a new class, called desc (see above). Then, I loop through each tag containing a class called desc with the code on line 36. Within the loop I replace all occurances of ‘\n’ with ‘<br/>’. Next I call createEllipsis() (line 39). This function rewrites the html within the strong tag to include an ellipsis link and puts all the lines that will get expanded/collapsed in a different span tag. Lastly, line 40 hides everything that should be hidden.
Next I have a click handler that expands/collapses any span tag with the class name ‘hide’. Within this function, I also uniquely identify which span tag to toggle. This is needed because there are can be more than one span tag with the class name, ‘hide’ on any given page. I set the pushid as one of the class names to uniquely identify each span tag. Thus, each span tag that should be hidden will have two class names, hide and the pushid. See the results below:
Collapsed Example

Expanded Example

v0.9 Release - Contemplating the Implementation for the Line Break bug
Posted by Sid in DPS911, Mercurial Project, Open Source on April 10th, 2009
As one of my goals for this release I wanted to take on a new bug. Now, the problem is that if there are line breaks in the commit message the pushlog will just turn them into spaces. Thus the message will become one big clump of text, which doesn’t look good.
The goal is to only show the very first line of the commit message if it has any line breaks in it. Then have an ellipsis link at the end that the user can click to expand/collapse the rest of the message. Also, when the message is expanded the line breaks should be displayed properly. For example:
Current Implementation
I am trying to fix a new bug 1) I will use jquery 2) I will finish it soon 3) 2 + 2 is 4
New Implementation while collapsed
I am trying to fix a new bug [...]
New Implementation while expanded
I am trying to fix a new bug [...]
1) I will use jquery
2) I will finish it soon
3) 2 + 2 is 4 or is it 22?
I will probably keep all the new code on the client side, implemented using jquery. Right now the line breaks are turned into spaces because they use the ‘\n’ character instead of using ‘<br/>’. I want to change all the line breaks to ‘<br />’ and then add an ellipsis link to all the commit messages that need it.
I’ve added expand/collapse functionality to the pushlog before so this shouldn’t be very hard to do. Look out for my next blog post explaining my implementation.
v0.9 Release Goals
Posted by Sid in DPS911, Mercurial Project, Open Source on April 8th, 2009
The end of the semester is approaching rapidly (only 2 weeks left) and so is my time here at Seneca. I can’t believe 4 years have gone by so fast. No time to think about my time after graduation though. I’m in engulfed in work right now, a typical situation this late in the semester. Anyway, it’s time for yet another release.
This time I’m not going to touch my major bug. Instead, I’ll be making changes to three other bugs this time around. I’ll be revisting one of the bugs that I fixed last semester (files touched). It had been approved for a long time now but the patch never got applied to the repo and it seems to have bitrotted now. The next bug I will be tackling is the changesetUI one for which I need to make some changes. Last but not the least, I’ll will take on a new bug regarding line breaks for long messages. The following are the goals for this release:
- Files touched - Update the patch to make it work with the new code in hgpoller and hg_templates. Also move the all the css to a stylesheet.
- Changeset UI - ted reviewed the patch that I submitted for this bug and he doesn’t want me to set the value when the drop down changes. This would mean that whatever the user has already entered would be overwritten. I guess it makes sense, since you want to avoid that from a usability standpoint. Also I will look to re-write the code to take advantage of jquery which has been added to the repo now. Furthermore, there is another query for the pushlog that takes in two pushids. I will be adding that to the drop down list as well.
- Line breaks turned into spaces - When a long message is displayed in the pushlog the linebreaks are not registered. My goal is to only show the first line and then show an ellipsis link that the user can click to show/hide the rest of the message that has the line breaks.
Fun stuff! Time to get to work!