Patchwork [3,of,4,V2] hgweb: add selector argument to process_dates

login
register
mail settings
Submitter Alexander Plavin
Date Aug. 17, 2013, 10:35 p.m.
Message ID <988392ad5f1e39a099a1.1376778919@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/2223/
State Deferred
Headers show

Comments

Alexander Plavin - Aug. 17, 2013, 10:35 p.m.
# HG changeset patch
# User Alexander Plavin <alexander@plav.in>
# Date 1374681754 -14400
#      Wed Jul 24 20:02:34 2013 +0400
# Node ID 988392ad5f1e39a099a1b00c4595628420d19991
# Parent  122061a7a549d6e3faa84a0657699b5ed705f413
hgweb: add selector argument to process_dates

Allow specifying elements to process with selector, useful for incremental page
updates.
Martin Geisler - Aug. 19, 2013, 7:37 a.m.
Alexander Plavin <alexander@plav.in> writes:

> # HG changeset patch
> # User Alexander Plavin <alexander@plav.in>
> # Date 1374681754 -14400
> #      Wed Jul 24 20:02:34 2013 +0400
> # Node ID 988392ad5f1e39a099a1b00c4595628420d19991
> # Parent  122061a7a549d6e3faa84a0657699b5ed705f413
> hgweb: add selector argument to process_dates
>
> Allow specifying elements to process with selector, useful for
> incremental page updates.
>
> diff -r 122061a7a549 -r 988392ad5f1e mercurial/templates/static/mercurial.js
> --- a/mercurial/templates/static/mercurial.js	Wed Jul 24 20:13:52 2013 +0400
> +++ b/mercurial/templates/static/mercurial.js	Wed Jul 24 20:02:34 2013 +0400
> @@ -168,7 +168,7 @@
>  }
>  
>  
> -function process_dates(){
> +function process_dates(selector){
>  
>  	// derived from code from mercurial/templatefilter.py
>  
> @@ -245,7 +245,11 @@
>  		}
>  	}
>  
> -    var nodes = document.querySelectorAll('.age');
> +    if (typeof selector === 'undefined') {
> +        selector = '';
> +    }
> +
> +    var nodes = document.querySelectorAll(selector + ' .age');

I think parentSelector would be a better name. At first I expected that
selector would be a general selector one could use instead of '.age'.
But then I saw that it is combined like above, meaning that selector is
specifically a parent element seletor for the '.age' elements.

Patch looks good otherwise!

>      var dateclass = new RegExp('\\bdate\\b');
>      for (var i=0; i<nodes.length; ++i){
>          var node = nodes[i];
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Laurens Holst - Aug. 20, 2013, 9:59 a.m.
Op 18-08-13 00:35, Alexander Plavin schreef:
> # HG changeset patch
> # User Alexander Plavin <alexander@plav.in>
> # Date 1374681754 -14400
> #      Wed Jul 24 20:02:34 2013 +0400
> # Node ID 988392ad5f1e39a099a1b00c4595628420d19991
> # Parent  122061a7a549d6e3faa84a0657699b5ed705f413
> hgweb: add selector argument to process_dates
>
> Allow specifying elements to process with selector, useful for incremental page
> updates.
>
> diff -r 122061a7a549 -r 988392ad5f1e mercurial/templates/static/mercurial.js
> --- a/mercurial/templates/static/mercurial.js	Wed Jul 24 20:13:52 2013 +0400
> +++ b/mercurial/templates/static/mercurial.js	Wed Jul 24 20:02:34 2013 +0400
> @@ -168,7 +168,7 @@
>   }
>   
>   
> -function process_dates(){
> +function process_dates(selector){
>   
>   	// derived from code from mercurial/templatefilter.py
>   
> @@ -245,7 +245,11 @@
>   		}
>   	}
>   
> -    var nodes = document.querySelectorAll('.age');
> +    if (typeof selector === 'undefined') {
> +        selector = '';
> +    }
> +
> +    var nodes = document.querySelectorAll(selector + ' .age');

Nit: I would simply do (selector || '').

~Laurens
Alexander Plavin - Aug. 20, 2013, 11:24 a.m.
20.08.2013, 13:59, "Laurens Holst" <laurens.nospam@grauw.nl>:
> Op 18-08-13 00:35, Alexander Plavin schreef:
>
>>  # HG changeset patch
>>  # User Alexander Plavin <alexander@plav.in>
>>  # Date 1374681754 -14400
>>  #      Wed Jul 24 20:02:34 2013 +0400
>>  # Node ID 988392ad5f1e39a099a1b00c4595628420d19991
>>  # Parent  122061a7a549d6e3faa84a0657699b5ed705f413
>>  hgweb: add selector argument to process_dates
>>
>>  Allow specifying elements to process with selector, useful for incremental page
>>  updates.
>>
>>  diff -r 122061a7a549 -r 988392ad5f1e mercurial/templates/static/mercurial.js
>>  --- a/mercurial/templates/static/mercurial.js Wed Jul 24 20:13:52 2013 +0400
>>  +++ b/mercurial/templates/static/mercurial.js Wed Jul 24 20:02:34 2013 +0400
>>  @@ -168,7 +168,7 @@
>>    }
>>
>>  -function process_dates(){
>>  +function process_dates(selector){
>>
>>            // derived from code from mercurial/templatefilter.py
>>
>>  @@ -245,7 +245,11 @@
>>                    }
>>            }
>>
>>  -    var nodes = document.querySelectorAll('.age');
>>  +    if (typeof selector === 'undefined') {
>>  +        selector = '';
>>  +    }
>>  +
>>  +    var nodes = document.querySelectorAll(selector + ' .age');
>
> Nit: I would simply do (selector || '').

Sure, will change :) At first there was slightly different code where this wouldn't suit, and after a change I didn't notice it can be rewritten better.

>
> ~Laurens

Patch

diff -r 122061a7a549 -r 988392ad5f1e mercurial/templates/static/mercurial.js
--- a/mercurial/templates/static/mercurial.js	Wed Jul 24 20:13:52 2013 +0400
+++ b/mercurial/templates/static/mercurial.js	Wed Jul 24 20:02:34 2013 +0400
@@ -168,7 +168,7 @@ 
 }
 
 
-function process_dates(){
+function process_dates(selector){
 
 	// derived from code from mercurial/templatefilter.py
 
@@ -245,7 +245,11 @@ 
 		}
 	}
 
-    var nodes = document.querySelectorAll('.age');
+    if (typeof selector === 'undefined') {
+        selector = '';
+    }
+
+    var nodes = document.querySelectorAll(selector + ' .age');
     var dateclass = new RegExp('\\bdate\\b');
     for (var i=0; i<nodes.length; ++i){
         var node = nodes[i];