oficina / mapa Public

Clone
git clone https://amadan.net/oficina/mapa

Plain git — no account needed to clone.

Download

Download this file

1package main
2
3// The columns and icons spec's mutations for a page's look (§9): the
4// attach rule's record clause, the look's own image check, and the
5// small-image cache's place after the read rule.
6
7const (
8 looks = "internal/mapa/looks.go"
9 looksImages = "internal/mapa/looks_images.go"
10 imagesHTTP = "internal/mapa/handlers_images.go"
11)
12
13var lookMutations = []mutation{
14 {gate: "LOOK5",
15 test: "TestLookImagesAreKeptAndStampedAsBodyImagesAre",
16 pkg: inside,
17 name: "the record's icon is not a reference",
18 edits: []edit{{file: looks,
19 from: "\tif record.Icon != nil && record.Icon.Image != \"\" {",
20 to: "\tif record.Icon != nil && false {"}}},
21 {gate: "LOOK4",
22 test: "TestALookNamesOnlyTheSettersOwnOrThisPagesImages",
23 pkg: inside,
24 name: "a look names any image",
25 edits: []edit{{file: looksImages,
26 from: "\tif row.ID == 0 {\n\t\treturn ErrNotFound\n\t}",
27 to: "\tif row.ID < 0 {\n\t\treturn ErrNotFound\n\t}"}, {
28 file: looksImages,
29 from: "\t\t\"owner_id = ?) OR page_id = ?)\", " +
30 "public, actor, page.ID).",
31 to: "\t\t\"owner_id != ?) OR page_id != ?)\", " +
32 "public, actor, page.ID)."}}},
33 {gate: "LOOK12",
34 test: "TestLook12ACachedPictureStillAnswersToTheReadRule",
35 name: "a cached picture skips the read rule",
36 edits: []edit{{file: imagesHTTP,
37 from: "\trow, err := app.store.ReadableImage(" +
38 "request.Context(), viewer, id)",
39 to: "\tif data, kind, ok := app.store.small.get(id); ok {\n" +
40 "\t\twriter.Header().Set(\"Content-Type\", kind)\n" +
41 "\t\t_, _ = writer.Write(data)\n\t\treturn\n\t}\n" +
42 "\trow, err := app.store.ReadableImage(" +
43 "request.Context(), viewer, id)"}}},
44}
45