This is a Greasemonkey script for PAUSE.
Problem
File lists displayed in "Show my files" and "Delete files" are err… too spartan.
If you have a dozen of distributions and few releases (let me say, 3) for every distribution, your
file list will include more than hundred files. The list is badly aligned (if you have file names
longer than ~50 characters). It would be nice to group files by releases and distributions, use
color highlighting for denoting trial releases and files scheduled for deletion. But spartan list
markup does not allow applying user style sheet because entire list is just a single PRE
element
without a structure.
The list on "Delete files" page has 3-color highlighting, but it does not help because coloring is
not semantic: first line highlighted with red, the second with green, the third with blue
regardless of files shown in these lines. Usually release consist of 3 files (.meta, .readme and
.tar.gz), so at the top of the list .meta files are red, .readme are green, and tarballs are blue,
but trial releases (which includes only tarball with no .meta and no .readme) and special file
CHECKSUMS
break the system.
Deleting a release is not trivial because you have to mark 3 files to delete. Color highlighting
dazzles and it is so easy to mark a file from adjacent release. (Thanks they are not deleted
immediatelly.)
Solution
This script parses original file list and re-creates it with semantic markup. Every file has name,
size and date. Files are grouped into releases, releases are grouped into distributions.
Semantic markup allows using user style sheet to highlight files, releases, or distributions, group
releases and/or distributions visually, add headings, etc.
Also, the script makes two changes in list behavior:
The script adds two buttons: "Show tarballs only" and "Show all files". Pressing the first
button hides non-tarball files making the list 3 times shorter. Pressing the second button shows
hidden files back. The buttons are added to both "Show my files" and "Delete files" pages.
The script automates selecting releases to delete. When you change state of tarball file
checkbox, the change is automatically propagated to all files of the release containing this
tarball. So, the most frequent operation (selecting a release to delete) now requires just one
click instead of 3 clicks. It also eliminates risk to mistakenly select 2 files from one release
and a file from adjacent release. (Selecting individual files is still possible, though.)
Both behavioral changes work together nicely: You can hide non-tarball files to have more
compact list of tarballs, select a tarball from the list — accompanying (and currently
invisible) meta and readme files will be selected automatically.
Note: The script does not provide any style sheet. I made it intentionally because my color
preferences may not be suitable for everybody. You may try my style
sheet.
Details
<pre id="fileList" class="fileList">
<span id="Foo" class="distribution">
<span id="Foo-v0.1.2" class="release">
<span id="Foo.meta" class="file meta">
<!-- checkbox in case of "Delete files" page -->
<span class="name">Foo.meta</span>
<span class="namePad"> </span>
<span class="sizePad"> </span>
<span class="size">2 300</span>
<span class="date">2016-11-11T12:00:05Z</span>
<span class="eof"><!-- newline character --></span>
</span>
<!-- More files of this release -->
</span>
<!-- More releases of this distribution -->
</span>
<!-- More distributions -->
<span id="special" class="special">
<span id="CHECKSUMS" class="file">
<span class="name">CHECKSUMS</span>
<span class="namePad"> </span>
<span class="sizePad"></span>
<span class="size">34 895</span>
<span class="date">2016-11-11T12:00:15Z</span>
<span class="eof"><!-- newline character --></span>
</span>
</span>
</pre>
The sample is splitted into multiple lines and indented for the sake of readability, actual PRE
element has only SPAN
s children. Text nodes appears only in the bottom level SPAN
s (name, size,
date, etc).
The list generated for "Delete files" page also has INPUT
elements (checkboxes) taken from the
original list.
Trial releases have additional class trial
. Files sheduled for deletion — class delete
,
files with ".tar.gz" suffix — tarball
, files with ".readme" suffix — readme
, files with
".meta" suffix — meta
(shown in example above).
Dates are converted to ISO fomat (with dropped second fraction part). Digits in file sizes are
groped by inserting blanks.
It is assumed the element is displayed using monospaced font.
History Log
v0.1.0 — Initial release, "Show my files" and "Delete files" are processed.
v0.1.1 — Page detection implemented to avoid unintentional processing other pages. "Force
reindexing" page is processed too.
v0.1.2 — Buttons functionality does not require external style sheet, buttons work out-of-the-box
now.