Skip to contentSkip to conversation

pkg-stats: allow to sort by column

RFC PATCH Superseded Ricardo Martincoski 3 participants 6 messages Jun 30, 2017 – Jul 6, 2017

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 pkg-stats: allow to sort by column

With 2000+ packages it's not trivial to identify i.e.:
- all packages that don't have a hash file;
- all packages that have patches;
- all packages that have code style warnings;

User experience can be improved by dynamically sorting the result.

There is an open-source solution that does that in the client-side [1] and requires minimal changes to our script.
The script is MIT licensed as stated in its website.

Include the third-party script and adapt our script accordingly.

Usage (static table):
./support/scripts/pkg-stats > /tmp/pkg.html

Usage (sortable table):
./support/scripts/pkg-stats > /tmp/pkg.html
cp ./support/scripts/sorttable.js /tmp/
Open it on a JavaScript-enabled web browser and click on the headers of the table to sort it.

[1] https://www.kryogenix.org/code/browser/sorttable/sorttable.js

---
Lots of doubts:

USEFULNESS
Do anyone else think this is useful? If not, please feel free to mark it as Rejected.

LICENSE
I trusted both the header that uses the alternate name X11 for the MIT license (the source file is 10 years old) and links to the website, and the website that says MIT.
I don't know the author.
I didn't contact the author directly. Should I?

The license text seems equivalent to me:
https://kryogenix.org/code/browser/licence.html
https://spdx.org/licenses/MIT.html
but it does not include this sentence:
"The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software."

HOW TO HOST IT
Also I am not sure if the JavaScript file should be placed in this directory or not. It just needs to be present in the same directory as the *output* of the script in order to turn the table sortable.

I added the script as-is (md5=3809d26cbae145842e56f374192e56d9). Do I need to add my SoB saying [downloaded from ...]?

Or should we not host the file in the git tree and just add instructions to wget it and add a copy to the server [2]?
[2] http://autobuild.buildroot.net/stats/

TESTS
I tested the output html with and without the .js file with:
Mozilla Firefox 54.0
Chromium 58.0.3029.110
Microsoft Edge 25.10586.672.0

WARNING
The JavaScript file has some special characters in line 172. I am not sure how patchwork will handle them. Let's find out...

---
 support/scripts/pkg-stats    |   6 +-
 support/scripts/sorttable.js | 495 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 500 insertions(+), 1 deletion(-)
 create mode 100644 support/scripts/sorttable.js
support/scripts/pkg-stats +5 -1
index 4cf1f82518..346691a0a5 100755
@@ -24,8 +24,12 @@
 #
 #  ./support/scripts/pkg-stats > /tmp/pkg.html
 #
+# If you want the table to be sortable also copy the 3rd-party JavaScript
+#
+#  cp ./support/scripts/sorttable.js /tmp/
 
 echo "<head>
+<script src=\"sorttable.js\"></script>
 <style type=\"text/css\">
 table {
   width: 100%;
@@ -59,7 +63,7 @@ td.lotsofpatches {
 
 <a href=\"#results\">Results</a><br/>
 
-<table>
+<table class=\"sortable\">
 <tr>
 <td>Id</td>
 <td>Package</td>
support/scripts/sorttable.js new file +495 -0

495 lines not on this page · raw message

Signature · 1 line
2.11.0
#1 lore raw

RFC PATCH v2 1/1 pkg-stats: allow to sort by column

With 2000+ packages it's not trivial to identify i.e.:
- all packages that don't have a hash file;
- all packages that have patches;
- all packages that have code style warnings;

User experience can be improved by dynamically sorting the resulting table.

There is an open-source solution that does that in the client-side and requires minimal changes to our script: sorttable.js.
The script is MIT licensed as stated in its website.

Include instructions to download the third-party script and adapt our script accordingly.

Usage (static table):
./support/scripts/pkg-stats > /tmp/pkg.html

Usage (sortable table):
./support/scripts/pkg-stats > /tmp/pkg.html
wget -O - https://www.kryogenix.org/code/browser/sorttable/sorttable.js\

Quoted 1 line

/tmp/sorttable.js

Open /tmp/pkg.html using a JavaScript-enabled web browser and click on the headers of the table to sort it.

---
Changes v1 -> v2:
- point to the file to download instead of adding it to the git tree;
- minor improvements to the commit message;

Lots of doubts:

USEFULNESS
Do anyone else think this is useful? If not, please feel free to mark it as Rejected.

LICENSE
I trusted both the header that uses the alternate name X11 for the MIT license (the source file is 10 years old) and links to the website, and the website that says MIT.
I don't know the author.
I didn't contact the author directly. Should I?

The license text seems equivalent to me:
https://kryogenix.org/code/browser/licence.html
https://spdx.org/licenses/MIT.html
but it does not include this sentence:
"The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software."

HOW TO HOST IT
Also I am not sure if the JavaScript file should be placed in the git tree or not. It just needs to be present in the same directory as the *output* of the script in order to turn the table sortable. We would need to host a copy in the same server as [1].
[1] http://autobuild.buildroot.net/stats/

TESTS
The downloaded .js file I tested has this md5:
3809d26cbae145842e56f374192e56d9
I tested the output html with and without the .js file using:
Mozilla Firefox 54.0
Chromium 58.0.3029.110
Microsoft Edge 25.10586.672.0

PATCH
The JavaScript file has some special characters in line 172. While using git-send-email 2.11.0 to send v1 I got this warning:

Quoted 3 lines

The following files are 8bit, but do not declare a Content-Transfer-Encoding.
outgoing/0001-pkg-stats-allow-to-sort-by-column.patch
Which 8bit encoding should I declare [UTF-8]?

and I accepted the default value. Patchwork seems to refuse the patch.

---
 support/scripts/pkg-stats | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
support/scripts/pkg-stats +6 -1
index 4cf1f82518..e2162d2381 100755
@@ -24,8 +24,13 @@
 #
 #  ./support/scripts/pkg-stats > /tmp/pkg.html
 #
+# If you want the table to be sortable also install this 3rd-party JavaScript:
+#
+#  wget -O - https://www.kryogenix.org/code/browser/sorttable/sorttable.js \
+#    > /tmp/sorttable.js
 
 echo "<head>
+<script src=\"sorttable.js\"></script>
 <style type=\"text/css\">
 table {
   width: 100%;
@@ -59,7 +64,7 @@ td.lotsofpatches {
 
 <a href=\"#results\">Results</a><br/>
 
-<table>
+<table class=\"sortable\">
 <tr>
 <td>Id</td>
 <td>Package</td>
Signature · 1 line
2.11.0
#2 lore raw

RFC PATCH v2 1/1 pkg-stats: allow to sort by column

Quoted 18 lines · Ricardo Martincoski

With 2000+ packages it's not trivial to identify i.e.:
- all packages that don't have a hash file;
- all packages that have patches;
- all packages that have code style warnings;

User experience can be improved by dynamically sorting the resulting table.

There is an open-source solution that does that in the client-side and requires minimal changes to our script: sorttable.js.
The script is MIT licensed as stated in its website.

Include instructions to download the third-party script and adapt our script accordingly.

Usage (static table):
./support/scripts/pkg-stats > /tmp/pkg.html

Quoted 6 lines

Usage (sortable table):
./support/scripts/pkg-stats > /tmp/pkg.html
wget -O - https://www.kryogenix.org/code/browser/sorttable/sorttable.js\

Quoted 1 line

/tmp/sorttable.js

Open /tmp/pkg.html using a JavaScript-enabled web browser and click on the headers of the table to sort it.

I think this is very useful!

However, I wonder: why not just use the upstream URL in the script tag? Or is
that too much of a security risk?

Regards,
Arnout

Quoted 27 lines

---
Changes v1 -> v2:
- point to the file to download instead of adding it to the git tree;
- minor improvements to the commit message;

Lots of doubts:

USEFULNESS
Do anyone else think this is useful? If not, please feel free to mark it as Rejected.

LICENSE
I trusted both the header that uses the alternate name X11 for the MIT license (the source file is 10 years old) and links to the website, and the website that says MIT.
I don't know the author.
I didn't contact the author directly. Should I?

The license text seems equivalent to me:
https://kryogenix.org/code/browser/licence.html
https://spdx.org/licenses/MIT.html
but it does not include this sentence:
"The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software."

Quoted 6 lines

HOW TO HOST IT
Also I am not sure if the JavaScript file should be placed in the git tree or not. It just needs to be present in the same directory as the *output* of the script in order to turn the table sortable. We would need to host a copy in the same server as [1].
[1] http://autobuild.buildroot.net/stats/

That's easy to do obviously.

Quoted 25 lines

TESTS
The downloaded .js file I tested has this md5:
3809d26cbae145842e56f374192e56d9
I tested the output html with and without the .js file using:
Mozilla Firefox 54.0
Chromium 58.0.3029.110
Microsoft Edge 25.10586.672.0

PATCH
The JavaScript file has some special characters in line 172. While using git-send-email 2.11.0 to send v1 I got this warning:

Quoted 3 lines

The following files are 8bit, but do not declare a Content-Transfer-Encoding.
outgoing/0001-pkg-stats-allow-to-sort-by-column.patch
Which 8bit encoding should I declare [UTF-8]?

and I accepted the default value. Patchwork seems to refuse the patch.

---
 support/scripts/pkg-stats | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
support/scripts/pkg-stats +0 -0
index 4cf1f82518..e2162d2381 100755

support/scripts/pkg-stats line 30

Quoted 7 lines
support/scripts/pkg-stats +4 -0
@@ -24,8 +24,13 @@
 #
 #  ./support/scripts/pkg-stats > /tmp/pkg.html
 #
+# If you want the table to be sortable also install this 3rd-party JavaScript:
+#
+#  wget -O - https://www.kryogenix.org/code/browser/sorttable/sorttable.js \
+#    > /tmp/sorttable.js

Small nit: -O specifies the output file, so the redirect bit silly.

wget https://www.kryogenix.org/code/browser/sorttable/sorttable.js \
-O /tmp/sorttable.js

support/scripts/pkg-stats td.lotsofpatches { · line 66

Quoted 10 lines
support/scripts/pkg-stats +1 -0
 echo "<head>
+<script src=\"sorttable.js\"></script>
 <style type=\"text/css\">
 table {
   width: 100%;
@@ -59,7 +64,7 @@ td.lotsofpatches {
 
 <a href=\"#results\">Results</a><br/>
 

It would be nice to add some text here to say that you can click on the title
to sort it, since it's not that obvious.

Regards,
Arnout

Quoted 6 lines
support/scripts/pkg-stats +1 -1
-<table>
+<table class=\"sortable\">
 <tr>
 <td>Id</td>
 <td>Package</td>
Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#3 lore raw

RFC PATCH v2 1/1 pkg-stats: allow to sort by column

Hello,

Quoted 2 lines · Arnout Vandecappelle

However, I wonder: why not just use the upstream URL in the script tag? Or is
that too much of a security risk?

I don't have much experience writing html/JavaScript code, so I just followed the instructions in the author's website.
https://www.kryogenix.org/code/browser/sorttable/
"
1. Download the Javascript library
2. Include the Javascript library, by putting a link to it in the HEAD of your page, like so:
<script src="sorttable.js"></script>
"
But I could contact the author if using the upstream URL is desirable.

Quoted 7 lines

support/scripts/pkg-stats line 30

Quoted 2 lines
support/scripts/pkg-stats +2 -0
+#  wget -O - https://www.kryogenix.org/code/browser/sorttable/sorttable.js \
+#    > /tmp/sorttable.js

Small nit: -O specifies the output file, so the redirect bit silly.

wget https://www.kryogenix.org/code/browser/sorttable/sorttable.js \
-O /tmp/sorttable.js

Thank you for catching this, I will fix it.

Quoted 5 lines
Quoted 2 lines

<a href=\"#results\">Results</a><br/>

It would be nice to add some text here to say that you can click on the title
to sort it, since it's not that obvious.

Good idea. I will do that.

Regards,
Ricardo

#4 lore raw

PATCH v3 1/1 pkg-stats: allow to sort by column

In reply to Ricardo Martincoski

With 2000+ packages it's not trivial to identify i.e.:
- all packages that don't have a hash file;
- all packages that have patches;
- all packages that have code style warnings;

User experience can be improved by dynamically sorting the resulting table.

There is an open-source solution that does that in the client-side and requires minimal changes to our script: sorttable.js.
The script is MIT licensed as stated in its website.

Include instructions to download the third-party script and adapt our script accordingly, following the example in the tool's website.

Also add a hint to the user that the table can be sorted. Display the hint when all these conditions are met:
- the browser has JavaScript support enabled;
- the sorttable.js script is loaded;
- the page is loaded.

Usage (static table):
./support/scripts/pkg-stats > /tmp/pkg.html

Usage (sortable table):
./support/scripts/pkg-stats > /tmp/pkg.html
wget https://www.kryogenix.org/code/browser/sorttable/sorttable.js \
-O /tmp/sorttable.js
Open /tmp/pkg.html using a JavaScript-enabled web browser and click on the headers of the table to sort it.

Cc Arnout Vandecappelle <[email protected]>

---
Changes v2 -> v3:
- use 'wget -O' instead of 'wget -O - >' (Arnout);
- add a hint to the user that the table can be sorted (Arnout);
- improve commit message (based on Arnout's question about sourcing

    from upstream URL);

Changes v1 -> v2:
- point to the file to download instead of adding it to the git tree;
- minor improvements to the commit message;

TESTS
The downloaded .js file I tested has this md5:
3809d26cbae145842e56f374192e56d9

I tested the output html with and without the .js file using:
Mozilla Firefox 54.0
Chromium 58.0.3029.110
Microsoft Edge 25.10586.672.0

I tested that the output html displays the hint above the table only when JavaScript is enabled using the QuickJava add-on for Firefox.

---
 support/scripts/pkg-stats | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
support/scripts/pkg-stats +16 -1
index 1956941f37..15b957c1ea 100755
@@ -24,8 +24,13 @@
 #
 #  ./support/scripts/pkg-stats > /tmp/pkg.html
 #
+# If you want the table to be sortable also install this 3rd-party JavaScript:
+#
+#  wget https://www.kryogenix.org/code/browser/sorttable/sorttable.js \
+#    -O /tmp/sorttable.js
 
 echo "<head>
+<script src=\"sorttable.js\"></script>
 <style type=\"text/css\">
 table {
   width: 100%;
@@ -59,7 +64,9 @@ td.lotsofpatches {
 
 <a href=\"#results\">Results</a><br/>
 
-<table>
+<p id=\"sortable_hint\"></p>
+
+<table class=\"sortable\">
 <tr>
 <td>Id</td>
 <td>Package</td>
@@ -428,4 +435,12 @@ echo "</table>"
 echo "<hr/>"
 echo "<i>Updated on $(LANG=C date), Git commit $(git log master -n 1 --pretty=format:%H)</i>"
 echo "</body>"
+
+echo "<script>
+if (typeof sorttable === \"object\") {
+  document.getElementById(\"sortable_hint\").innerHTML =
+  \"hint: the table can be sorted by clicking the column headers\"
+}
+</script>
+"
 echo "</html>"
Signature · 1 line
2.11.0
#5 lore raw

PATCH v3 1/1 pkg-stats: allow to sort by column

Hello,

Quoted 31 lines · Ricardo Martincoski

With 2000+ packages it's not trivial to identify i.e.:
- all packages that don't have a hash file;
- all packages that have patches;
- all packages that have code style warnings;

User experience can be improved by dynamically sorting the resulting table.

There is an open-source solution that does that in the client-side and requires minimal changes to our script: sorttable.js.
The script is MIT licensed as stated in its website.

Include instructions to download the third-party script and adapt our script accordingly, following the example in the tool's website.

Also add a hint to the user that the table can be sorted. Display the hint when all these conditions are met:
- the browser has JavaScript support enabled;
- the sorttable.js script is loaded;
- the page is loaded.

Usage (static table):
./support/scripts/pkg-stats > /tmp/pkg.html

Usage (sortable table):
./support/scripts/pkg-stats > /tmp/pkg.html
wget https://www.kryogenix.org/code/browser/sorttable/sorttable.js \
-O /tmp/sorttable.js
Open /tmp/pkg.html using a JavaScript-enabled web browser and click on the headers of the table to sort it.

Quoted 2 lines
Cc Arnout Vandecappelle <[email protected]>

I've changed your patch so that the generated HTML directly uses the online Javascript file, rather than having to download it separately. Applied with this change, and a few other additional changes to pkg-stats.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com