whatwg/wattsi

Allowing new images to be added

domenic opened this issue · 2 comments

See whatwg/html#132 (comment)

Code is at

wattsi/src/wattsi.pas

Lines 60 to 61 in fc38b65

kOldImgPrefix = 'images/';
kNewImgPrefix = 'https://images.whatwg.org/';
and

wattsi/src/wattsi.pas

Lines 757 to 782 in fc38b65

if (Element.IsIdentity(nsHTML, eImg)) then
begin
if (Element.HasAttribute('src')) then
begin
ExtractedData := Element.GetAttribute('src');
ImageSrc := Default(Rope);
ImageSrc.AppendDestructively(ExtractedData);
Index := 1;
Enumerator := ImageSrc.GetEnumerator();
Matching := True;
while (Matching and Enumerator.MoveNext() and (Index <= Length(kOldImgPrefix))) do
begin
Matching := Enumerator.Current = Ord(kOldImgPrefix[Index]);
Inc(Index);
end;
if (Matching and (Index > Length(kOldImgPrefix))) then
begin
ExtractedData := ImageSrc.ExtractToEnd(Enumerator.GetPointer());
Scratch := Default(Rope);
Scratch.Append(@kNewImgPrefix[1], Length(kNewImgPrefix));
Scratch.AppendDestructively(ExtractedData);
Element.SetAttributeDestructively('src', Scratch);
end;
Enumerator.Free();
end;
end

Solutions:

  1. Leave as-is and get credentials for images.whatwg.org and change the deploy script. Pros: helps spread the load out to multiple servers. So, possibly best for readers. Cons: more complicated and less transparent deploy script, and more servers to administer.
  2. Change source references to /images/ instead and remove rewriting code. Pros: no rewriting needed anymore. No longer need to host images in both singlepage and multipage, and can 301 the multipage copies. Cons: absolute URLs involve making assumptions; the spec works pretty well otherwise when mounted in a subdirectory.
  3. Remove rewriting code and leave source as-is. Pros: probably most seamless for spec authors and script maintainers. Cons: we continue duplicating the images in singlepage and multipage.
  4. Change rewriting code to rewrite multipage to ../images. Pros: no double image hosting; pretty easy to maintain. Cons: requires lots of Wattsi knowledge.

Leaning toward (3) but they all are pretty good.

I prefer (3) as well, for the reason that as noted it’s the most seamless for spec authors and less costly and potentially error-prone than touching the Wattsi code

We have already done 2 for 404.html.