code.pablomurad.com

patchwork

Publishes the revisions of your pages as a feed, with notes and readable diffs, written in Go

schema/v1/defs.json raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://git.pablomurad.com/pablo/patchwork/raw/branch/main/schema/v1/defs.json",
  "title": "Patchwork API v1: shared definitions",
  "$defs": {
    "time": {
      "type": "string",
      "format": "date-time",
      "description": "RFC 3339, UTC."
    },
    "date": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
      "description": "Calendar date in the site's time zone."
    },
    "url": {
      "type": "string",
      "description": "Absolute when site.base_url is set, otherwise a path."
    },
    "kind": {
      "enum": ["correction", "expansion", "position", "reorganization"]
    },
    "maturity": {
      "enum": ["seed", "sprout", "bloom"]
    },
    "pageRef": {
      "type": "object",
      "additionalProperties": false,
      "required": ["uid", "slug", "title", "url"],
      "properties": {
        "uid": { "type": "string" },
        "slug": { "type": "string" },
        "title": { "type": "string" },
        "url": { "$ref": "#/$defs/url" }
      }
    },
    "pageSummary": {
      "$ref": "#/$defs/pageSummaryFields",
      "unevaluatedProperties": false
    },
    "pageSummaryFields": {
      "description": "pageSummary without the closing rule, so page.json can extend it.",
      "type": "object",
      "required": ["uid", "slug", "path", "title", "url", "history_url", "original_date", "first_seen_at", "revision_count", "latest_number"],
      "properties": {
        "uid": { "type": "string" },
        "slug": { "type": "string" },
        "path": { "type": "string" },
        "title": { "type": "string" },
        "url": { "$ref": "#/$defs/url" },
        "history_url": { "$ref": "#/$defs/url" },
        "maturity": { "$ref": "#/$defs/maturity" },
        "original_date": { "$ref": "#/$defs/date" },
        "first_seen_at": { "$ref": "#/$defs/time" },
        "last_revised_at": { "$ref": "#/$defs/time", "description": "Absent until the first published revision." },
        "revision_count": { "type": "integer", "minimum": 0, "description": "Published revisions, not counting the first version." },
        "latest_number": { "type": "integer", "minimum": 1 }
      }
    },
    "versionSummary": {
      "type": "object",
      "additionalProperties": false,
      "required": ["number", "published_at", "updated_at", "url", "words_added", "words_removed"],
      "properties": {
        "number": { "type": "integer", "minimum": 1 },
        "baseline": { "const": true, "description": "Present only on the first version." },
        "published_at": { "$ref": "#/$defs/time" },
        "updated_at": { "$ref": "#/$defs/time" },
        "note": { "type": "string" },
        "kind": { "$ref": "#/$defs/kind" },
        "maturity": { "$ref": "#/$defs/maturity" },
        "url": { "$ref": "#/$defs/url" },
        "words_added": { "type": "integer", "minimum": 0 },
        "words_removed": { "type": "integer", "minimum": 0 }
      }
    },
    "segment": {
      "type": "object",
      "additionalProperties": false,
      "required": ["t", "s"],
      "properties": {
        "t": { "enum": ["eq", "del", "ins"] },
        "s": { "type": "string" }
      }
    },
    "op": {
      "type": "object",
      "additionalProperties": false,
      "required": ["op"],
      "description": "One block of a diff. eq/insert/delete/move carry text; modify carries segments; gap carries count.",
      "properties": {
        "op": { "enum": ["eq", "insert", "delete", "modify", "move", "gap"] },
        "kind": { "enum": ["paragraph", "heading", "code", "list_item", "quote", "html", "table", "break"] },
        "text": { "type": "string" },
        "segments": { "type": "array", "items": { "$ref": "#/$defs/segment" } },
        "replaced": { "const": true, "description": "The block was rewritten: segments are the whole old text, then the whole new text." },
        "from": { "type": "integer", "minimum": 0 },
        "to": { "type": "integer", "minimum": 0 },
        "count": { "type": "integer", "minimum": 1 },
        "removed": { "const": true, "description": "On a gap: the omitted blocks were deleted, not unchanged. Excerpts show the first two blocks of a long deletion and sum up the rest this way." }
      }
    },
    "stats": {
      "type": "object",
      "additionalProperties": false,
      "required": ["words_added", "words_removed", "blocks_changed"],
      "properties": {
        "words_added": { "type": "integer", "minimum": 0 },
        "words_removed": { "type": "integer", "minimum": 0 },
        "blocks_changed": { "type": "integer", "minimum": 0 }
      }
    },
    "metaChange": {
      "type": "object",
      "additionalProperties": false,
      "required": ["key", "old", "new"],
      "properties": {
        "key": { "type": "string" },
        "old": {},
        "new": {}
      }
    },
    "diff": {
      "type": "object",
      "additionalProperties": false,
      "required": ["ops", "stats"],
      "properties": {
        "ops": { "type": "array", "items": { "$ref": "#/$defs/op" } },
        "stats": { "$ref": "#/$defs/stats" },
        "meta_changes": { "type": "array", "items": { "$ref": "#/$defs/metaChange" } }
      }
    },
    "revision": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "number", "base_number", "page", "note", "published_at", "updated_at", "original_date", "version_url", "history_url", "stats", "meta_changes", "excerpt"],
      "properties": {
        "id": { "type": "string", "description": "Permanent; the same id as the feed entry." },
        "number": { "type": "integer", "minimum": 2 },
        "base_number": { "type": "integer", "minimum": 1 },
        "page": { "$ref": "#/$defs/pageRef" },
        "kind": { "$ref": "#/$defs/kind" },
        "maturity": { "$ref": "#/$defs/maturity" },
        "note": { "type": "string" },
        "published_at": { "$ref": "#/$defs/time" },
        "updated_at": { "$ref": "#/$defs/time" },
        "original_date": { "$ref": "#/$defs/date" },
        "version_url": { "$ref": "#/$defs/url" },
        "history_url": { "$ref": "#/$defs/url" },
        "stats": { "$ref": "#/$defs/stats" },
        "meta_changes": { "type": "array", "items": { "$ref": "#/$defs/metaChange" } },
        "excerpt": {
          "type": "object",
          "additionalProperties": false,
          "required": ["truncated", "blocks"],
          "properties": {
            "truncated": { "type": "boolean" },
            "blocks": { "type": "array", "items": { "$ref": "#/$defs/op" } }
          }
        }
      }
    }
  }
}