1. 25 1月, 2010 1 次提交
    • J
      gitweb.js: Workaround for IE8 bug · b2c2e4c2
      Jakub Narebski 提交于
      In Internet Explorer 8 (IE8) the 'blame_incremental' view, which uses
      JavaScript to generate blame info using AJAX, sometimes hang at the
      beginning (at 0%) of blaming, e.g. for larger files with long history
      like git's own gitweb/gitweb.perl.
      
      The error shown by JavaScript console is "Unspecified error" at char:2
      of the following line in gitweb/gitweb.js:
      
        if (xhr.readyState === 3 && xhr.status !== 200) {
      
      Debugging it using IE8 JScript debuger shown that the error occurs
      when trying to access xhr.status (xhr is XMLHttpRequest object).
      Watch for xhr object shows 'Unspecified error.' as "value" of
      xhr.status, and trying to access xhr.status from console throws error.
      
      This bug is some intermittent bug, depending on XMLHttpRequest timing,
      as it doesn't occur in all cases.  It is probably caused by the fact
      that handleResponse is called from timer (pollTimer), to work around
      the fact that some browsers call onreadystatechange handler only once
      for each state change, and not like required for 'blame_incremental'
      as soon as new data is available from server.  It looks like xhr
      object is not properly initialized; still it is a bug to throw an
      error when accessing xhr.status (and not use 'null' or 'undefined' as
      value).
      
      Work around this bug in IE8 by using try-catch block when accessing
      xhr.status.
      Signed-off-by: NJakub Narebski <jnareb@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b2c2e4c2
  2. 25 11月, 2009 2 次提交
  3. 20 11月, 2009 1 次提交
  4. 01 9月, 2009 3 次提交
    • J
      gitweb: Create links leading to 'blame_incremental' using JavaScript · c4ccf61f
      Jakub Narebski 提交于
      The new 'blame_incremental' view requires JavaScript to run.  Not all
      web browsers implement JavaScript (e.g. text browsers such as Lynx),
      and not all users have JavaScript enabled.  Therefore instead of
      unconditionally linking to 'blame_incremental' view, we use JavaScript
      to convert those links to lead to view utilizing JavaScript, by adding
      'js=1' to link.
      
      Currently the only action that takes 'js=1' into account is 'blame',
      which then acts as if it was called as 'blame_incremental' action.
      Possible enhancement would be to do JavaScript redirect by setting
      window.location instead of modifying $format and $action in
      git_blame_common() subroutine.
      
      The only JavaScript-aware/using view is currently 'blame_incremental'.
      While at it move reading JavaScript to git_footer_html() subroutine.
      Note that in this view we do not add 'js=1' currently (even though
      perhaps we should; note that for consistency we should also add 'js=1'
      in links added by JavaScript part of 'blame_incremental').
      
      This idea was originally implemented by Petr Baudis in
        http://article.gmane.org/gmane.comp.version-control.git/47614
      but it added <script> element with fixBlameLinks() function in page
      header, to be added as onload event using 'onload' attribute of HTML
      'body' element: <body onload="fixBlameLinks();">.  This version adds
      script at then end of page (in the page footer), and uses JavaScript
      'window.onload=fixLinks();'.  Also in Petr version only links marked
      with 'blamelink' class were modified, and they were modified by
      replacing "a=blame" by "a=blame_incremental"... which doesn't work for
      path_info links, and might replace wrong part if there is "a=blame" in
      project name, ref name or file name.
      
      Slightly different solution was implemented by Martin Koegler in
        http://thread.gmane.org/gmane.comp.version-control.git/47902/focus=47905
      Here GitAddLinks() function was in gitweb.js file, not as contents of
      <script> element.  It was also included in page header (in <head>
      element) though, which means waiting for a script to load (and run).
      It was smarter in that to "fix" (modify) link, it split URL, modified
      value of 'a' parameter, and then recreated modified link.  It avoids
      trouble with "a=blame" as substring in project name or file name, but
      it doesn't work with path_info URL/link in the way it was written.
      Signed-off-by: NJakub Narebski <jnareb@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c4ccf61f
    • J
      gitweb: Colorize 'blame_incremental' view during processing · e206d62a
      Jakub Narebski 提交于
      This requires using 3 colors, not only two, to choose a color that is
      different from colors of up to 2 neighbors.
      
      gitweb.js selects the least used color, if more than one color is
      possible.
      Signed-off-by: NJakub Narebski <jnareb@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e206d62a
    • J
      gitweb: Incremental blame (using JavaScript) · 4af819d4
      Jakub Narebski 提交于
      Add 'blame_incremental' view, which uses "git blame --incremental"
      and JavaScript (Ajax), where 'blame' use "git blame --porcelain".
      
       * gitweb generates initial info by putting file contents (from
         "git cat-file") together with line numbers in blame table
       * then gitweb makes web browser JavaScript engine call startBlame()
         function from gitweb.js
       * startBlame() opens XMLHttpRequest connection to 'blame_data' view,
         which in turn calls "git blame --incremental" for a file, and
         streams output of git-blame to JavaScript (gitweb.js)
       * XMLHttpRequest event handler updates line info in blame view as soon
         as it gets data from 'blame_data' (from server), and it also updates
         progress info
       * when 'blame_data' ends, and gitweb.js finishes updating line info,
         it fixes colors to match (as far as possible) ordinary 'blame' view,
         and updates information about how long it took to generate page.
      
      Gitweb deals with streamed 'blame_data' server errors by displaying
      them in the progress info area (just in case).
      
      The 'blame_incremental' view tries to be equivalent to 'blame' action;
      there are however a few differences in output between 'blame' and
      'blame_incremental' view:
      
       * 'blame_incremental' always used query form for this part of link(s)
         which is generated by JavaScript code.  The difference is visible
         if we use path_info link (pass some or all arguments in path_info).
         Changing this would require implementing something akin to href()
         subroutine from gitweb.perl in JavaScript (in gitweb.js).
       * 'blame_incremental' always uses "rowspan" attribute, even if
         rowspan="1".  This simplifies code, and is not visible to user.
       * The progress bar and progress info are still there even after
         JavaScript part of 'blame_incremental' finishes work.
      
      Note that currently no link generated by gitweb leads to this new view.
      
      This code is based on patch by Petr Baudis <pasky@suse.cz> patch, which
      in turn was tweaked up version of Fredrik Kuivinen <frekui@gmail.com>'s
      proof of concept patch.
      
      This patch adds GITWEB_JS compile configuration option, and modifies
      git-instaweb.sh to take gitweb.js into account.  The code for
      git-instaweb.sh was taken from Pasky's patch.
      Signed-off-by: NFredrik Kuivinen <frekui@gmail.com>
      Signed-off-by: NPetr Baudis <pasky@suse.cz>
      Signed-off-by: NJakub Narebski <jnareb@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4af819d4