Posts Tagged HTML

v0.7 Release - The Scroll Bar Problem

As a part of one of my goals for this release I want to find a solution to the pesky scroll bar problem. Let me explain:

The Problem

Basically, by default the pushlog only loads 10 entries, which doesn’t fill out the entire page and thus the scroll bar does not show up. Now, this means that when the user tries to scroll down (to load more entries) nothing happens as the scroll bar event doesn’t fire. You might be wondering why not just load more entries by default? Well, first of all that isn’t an elegant solution, it’s a cop out and second, different users have varying screen sizes and thus this solution is not feasible.

A dynamic solution is needed where, according to the users screen size, a varying amount of entries are loaded automatically to fill out the page so that the scroll bar appears.

Possible Solutions

This problem is quite frustrating, to be honest. I’ve tried various methods to solve this issue but none have worked ideally. So far, I’ve tried to approach this problem from one angle, using the onload attribute of the body tag through which you can pass in a function that is executed when the page loads. In this function, I call my OnScroll function that loads more entries according to the screen size. So basically a loop is required but this reveals a very frustrating issue. Any kind of loop in this function causes the browser to throw an unresponsive script error. Since, I absolutely have to have a loop to implement the desired functionality, this solution is useless.

Next, I tried to get rid of the unresponsive script error by using setTimeout() which delays the execution of a function by x milliseconds. This gets rid of the script error that the browser was throwing but the browser Gods were still unhappy, as Firefox decided to freeze on me for 10-15secs. Once these seconds passed by the browser unfroze but my solution still didn’t work (no entries were loaded). Basically, nothing happened!

So all in all my attempts to come up with an efficient solution have all been futile, so far.

New Idea

I had a talk with Dave Humphrey this week about this scroll bar problem. He came up with an interesting idea. He approached the problem from a different angle. What if you could get the browser to tell you whether the scroll bar is available or not. So all you would do is keep on adding new entries until the scroll bar appeared and then stop.

I hadn’t thought about the problem in the manner that Dave highlighted. I think he might be onto something here. I’ll have to look into how I can do this in JavaScript. I am certain that there is a way to know whether the scroll bar is present or not. This new lead sounds very promising!

Stay tuned! I’ll be blogging about my findings very soon!

, , ,

No Comments

v0.5 Release - Examining How Other Templates Implement Hg Annotate

In order to complete the goals for my v0.5 release I examined how other templates implement hg annotate. I wanted to find out whether these other implementations had the ability to load 10,000 line cpp files quickly or not.

Default Template

Hgweb comes with a default template, which is quite ugly if you ask me but maybe it is efficient. I put together my local hgweb environment to use the default template and I was able to get a time of ~12secs. However, there was a major problem with this template. I noticed that after about 2000 lines the rest of the lines stopped showing up. The page kept loading new content but as I scrolled down the rest of the page was completely blank. None of the other 8000 or so lines of code were visible. This problem means that this template is of no use to me.

Coal Template

The next step was to try the coal template, which strangely doesn’t look very different from the default template. I configured my local hgweb environment to use the coal template and I got a time of ~14secs. This is not a significant improvement over Mozilla’s template which was clocking in at ~20secs but it is definitely better. Any reduction in loading time is a good thing. The problem is that gitweb_mozilla (the template that Mozilla uses) and the Coal template both use the same type of implementation. They both use one HUGE table to display the file, which obviously is not the correct method to employ (see below).

gitweb_mozilla

<div class="page_body">
  <table border="0">
    #annotate%annotateline#</table>
</div>

coal

<div class="overflow">
  <table class="bigtable" border="0">
    <tr>
      <th class="annotate">rev</th>
      <th class="lineno">line</th>
      <th class="line">source</th>
    </tr>
    {annotate%annotateline}
  </table>
</div>

Neither of these templates have been able to help me to solve my problem. Next I’ll be having a look at some of the patches that people put up on the bug page. Lets see if they improve annotate’s loading time or not.

, , ,

No Comments

v0.2 Release - Show Files Touched by a Changeset in the Pushlog

As part of my v0.2 release I wanted to fix bug 448707. It is aparently a very desired feature by the community. Adding this featue definitely makes it easier to immediately find out which files were touched while right now one has to click the changset link to do that.

Initial Thoughts

I talked to ted and jorendorff about how they thought I should go about implementing this feature. ted recommended using the http://hg.mozilla.org/mozilla-central/pushlog feed which returns the files touched. I thought I could use an XMLHttpRequest to get the data to the front-end and then format it. But after looking at the code I decided that that wasn’t the way to go. I decided to format the data on the back-end and then just print it through the map file exactly how everything else in the pushlog is rendered

Implementation

So, as I mentioned before I had to make some back-end changes (changelist function in pushlog-feed.py and map). The following is the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
    def changelist(limit=0, **map):
        #pdb.set_trace()
        allentries = []
        lastid = None
        ch = None
        l = []
        mergehidden = ""
        p = 0
        currentpush = None
        for id, user, date, node in entries:
            filesTouched = ''
            ctx = web.repo.changectx(node)
            n = ctx.node()
            if len(ctx.files()) > 1:
              for f in ctx.files():
                filesTouched += f + '<br/>'
            else:
              for f in ctx.files():
                filesTouched += f
            entry = {"author": ctx.user(),
                     "desc": ctx.description(),
                     "files": web.listfilediffs(tmpl, ctx.files(), n),
                     "rev": ctx.rev(),
                     "node": hex(n),
                     "tags": nodetagsdict(web.repo, n),
                     "branches": nodebranchdict(web.repo, ctx),
                     "inbranch": nodeinbranch(web.repo, ctx),
                     "hidden": "",
                     "push": [],
                     "mergerollup": [],
                     "dateId": localdate(date),
                     "filesTouched": filesTouched
                     }

So basically, there is a function that gives me all the files touched by a changeset, ctx.files(). I just call the function append each file touched by a changeset into a string (filesTouched, in this case). Once I add it to the entry array I can then perform the following in the map file:

1
pushlogentry = '<tr id="date#dateId#" class="parity#parity# #hidden# #dateId#"><td>#push%pushinfo#</td><td class="age"><a href="{url}rev/#node|short#{sessionvars%urlparameter}">#node|short#</a></td><td id="#dateId#"><strong>#author|person# &mdash; #desc|strip|escape|buglink#</strong> <span class="logtags">{inbranch%inbranchtag}{branches%branchtag}{tags%tagtag}</span>#mergerollup%mergehidden#<br/><span style="font-size: x-small; color: #FF902B; font-weight: bold">#filesTouched#</span></td></tr>\n'

I added:

1
<br/><span style="font-size: x-small; color: #FF902B; font-weight: bold">#filesTouched#</span>

The above line of code gets the filesTouched variable from the back-end and formats it using CSS styles to display within on the page.

The following is the result of the obove code: http://sidkalra.com/files/mercurial/filesTouched1.png

This way it is easy to tell which files a changeset touched. A users knows it right away, no need to click on any other links to find out. Only thing I am unsure about is the text color of the files touched. At first I had gone with red but that was a bit too bold, so I decided to go with orange but I don’t know if it fits the theme well. As far as I can tell it seems like an OK choice but I might (or might not) change it in the future.

EDIT: I’ve changed the color of the text to a dark brown so that it is easier to read. I felt that the previous orange color was a bit too harsh on the eyes. Have a look: http://sidkalra.com/files/mercurial/filesTouched2.png

, , , , ,

No Comments