This is *not* really necessary right now because of the limited
character set we allow for add-on names (currently [A-Za-z0-9_-]), but
it doesn't hurt to future-proof this since odds that someone will change
the limitations in the C++ code at some point without remembering to
update this script are staggeringly high these days.
[ci skip]
This is primarily a code clean-up and there are no known behavior
changes. Some of the code changes follow:
* The add-on type labels and explanations are now part of a dictionary
rather than embedded in the program logic so it's easier to change
them in the future if more add-on types get added.
* The full URL to each add-on tarball is HTML-escaped, instead of just
the add-on id.
* The list of HTML/CSS resources that need to be copied into the output
dir is somewhere more visible.
* Some indentation issues have been fixed.
* html.escape is used instead of cgi.escaped
[ci skip]
Using the original paths given in WML as alt-text does not serve any
purpose other than breaking the layout when the page hasn't finished
loading and half the icons are overlong text. If anyone really needs
those they should use a data attribute instead. The alt attribute is for
accessibility, not for making programmers happy with themselves.
* Relabeled the "Notes" column to "Translations" since that's what it
really is.
* Replaced the Download label with an icon and moved it to the add-on
names column.
* Restyled add-on version/author a bit.
* Add-on type is now more or less aligned to the middle of the icon
(regardless of what the cell height actually is -- there can be extra
empty space below the type line if the add-on title is too long, for
instance).
This also adds SVG icons to be used in table headers instead of GIF
images for browsers that support SVG in background-image. It makes
things scale better for high DPI screens.
This escapes all strings provided by add-ons server data to guarantee
they can't be used to get extraneous and potentially harmful HTML into
the generated web index.
However, and because I don't have time to look into the dense regex
contained in the relevant code right now, it also removes the hidden
feature of linkifying any URLs found in add-on descriptions. It's a
small price to pay for our safety, really.
This includes campaignserver_client.py which is also used by wescamp.py
- however wescamp.py is still Python 2 at this point and will need to be
upgraded at a later point in time.
First, a couple of extraneous quotes were left in the second regex around
"</a>".
Second, it is possible that a period or question mark could be used to end
a sentence, rather than be part of the URL. So check that these characters
are followed by an alphanumeric character to make them part of the URL.
After my last change dealing with this issue, I noticed that descriptions
with <pre> had an extra blank line at the top. Adding top-margin to the
CSS file made this go away, but it also made the <br/> superfluous. Thus,
it is simpler just to have every description use <pre> instead of <br/>.
This should finally resolve everything having to do with the add-on
descriptions.
If I'd noticed that the re module hadn't been imported, I probably wouldn't
have considered URL linking to be important enough to do so. Since I've
already written the code, however, I'll keep it.
This is one source of missing-image results.
There remain other reasons for missing icons. The script doesn't find images
in add-ons. And when resources are moved or renamed, they are no longer found
by the script, even if they had been found before.
Also, capitalize a sentence.
After looking into it some more, I think I've figured out how to handle <pre>
in the CSS. So, use that, when description has more than one line.
Also, go to re.sub for turning URLs into links. The version of Python I was
testing my code on wasn't properly handling backreferences in the replacement
string when in the form "\#", causing me to use finditer instead of sub. But
I've discovered that it does handle backreferences in the form "\g<#>". So
switch to much simpler re.sub code.
The description text does not get rendered very well on a webpage. One
solution might be to use pre-wrap/word-wrap in the CSS, but due to
differences between browsers, that's a can of worms (at least for me, I'm
not a web pro).
So, the not-so-elegant solution is to add <br/> to every line.
URLs are also not linked in the plain text. Although in modern browsers
you can select the text and right-click, it's still convenient to turn
them into actual links.