1 |
bea4923f
|
Wojtek Kosior
|
// SPDX-License-Identifier: CC0-1.0
|
2 |
|
|
|
3 |
|
|
// Copyright (C) 2021, 2022 Wojtek Kosior <koszko@koszko.org>
|
4 |
|
|
// Available under the terms of Creative Commons Zero v1.0 Universal.
|
5 |
|
|
|
6 |
|
|
// This is an example index.json file describing Hydrilla site content. As you
|
7 |
|
|
// can see, for storing site content information Hydrilla utilizes JSON with an
|
8 |
|
|
// additional extension in the form of '//' comments support.
|
9 |
|
|
|
10 |
|
|
// An index.json file conveys definitions of site resources and pattern->payload
|
11 |
|
|
// mappings. The definitions may reference files under index.json's containing
|
12 |
|
|
// directory, using relative paths. This is how scripts, license texts, etc. are
|
13 |
|
|
// included.
|
14 |
|
|
// File reference always takes the form of an object with "file" property
|
15 |
|
|
// specifying path to the file. In certain contexts additional properties may be
|
16 |
|
|
// allowed or required. Unix paths (using '/' as separator) are assumed. It is
|
17 |
|
|
// not allowed for an index.json file to reference files outside its directory.
|
18 |
|
|
|
19 |
|
|
// Certain objects are allowed to contain a "comment" field. Although '//'
|
20 |
|
|
// comments can be used in index.json files, they will not be included in
|
21 |
|
|
// generated JSON definitions. If a comment should be included in the
|
22 |
|
|
// definitions served by Hydrilla API, it should be put in a "comment" field of
|
23 |
|
|
// the proper object.
|
24 |
|
|
|
25 |
|
|
// Unknown object properties will be ignored. This is for compatibility with
|
26 |
|
|
// possible future revisions of the format.
|
27 |
|
|
{
|
28 |
|
|
// Once our index.json schema changes, this field's value will change. Our
|
29 |
|
|
// software will be able to handle both current and older formats thanks to
|
30 |
|
|
// this information present in every index.json file. Schemas that differ by
|
31 |
|
|
// the first (major) number are always incompatible (e.g. a Hydrilla builder
|
32 |
|
|
// instance released at the time of 1.2 being the most recent schema version
|
33 |
48606f28
|
Wojtek Kosior
|
// will not understand version 2.1).
|
34 |
bea4923f
|
Wojtek Kosior
|
// Schemas that are backwards-compatible will have the same major number
|
35 |
|
|
// and might differ by the second (minor) version number. The third (patch)
|
36 |
|
|
// and subsequent numbers are being ignored right now.
|
37 |
48606f28
|
Wojtek Kosior
|
"$schema": "https://hydrilla.koszko.org/schemas/package_source-1.schema.json",
|
38 |
bea4923f
|
Wojtek Kosior
|
|
39 |
|
|
// Used when referring to this source package. Should be consize, unique
|
40 |
|
|
// (among other source package names) and can only use a restricted set of
|
41 |
|
|
// characters. It has to match: [-0-9a-z.]+
|
42 |
|
|
"source_name": "hello",
|
43 |
|
|
|
44 |
e571b391
|
Wojtek Kosior
|
// This property lists files that contain copyright information regarding
|
45 |
|
|
// this source package as well as texts of licenses used. Although no
|
46 |
|
|
// specific format of these files is mandated, it is recommended to make
|
47 |
|
|
// each source package REUSE-compliant, generate an spdx report for it as
|
48 |
|
|
// `report.spdx` and list this report together with all license files here.
|
49 |
bea4923f
|
Wojtek Kosior
|
"copyright": [
|
50 |
|
|
{"file": "report.spdx"},
|
51 |
|
|
{"file": "LICENSES/CC0-1.0.txt"}
|
52 |
|
|
],
|
53 |
|
|
|
54 |
|
|
// Where this software/work initially comes from.
|
55 |
e571b391
|
Wojtek Kosior
|
"upstream_url": "https://git.koszko.org/hydrilla-source-package-example",
|
56 |
bea4923f
|
Wojtek Kosior
|
|
57 |
|
|
// Additional "comment" field can be used if needed.
|
58 |
|
|
// "comment": ""
|
59 |
|
|
|
60 |
|
|
// List of actual site resources and pattern->payload mappings. Each of them
|
61 |
|
|
// is represented by an object. Meta-sites and replacement site interfaces
|
62 |
|
|
// will also belong here once they get implemented.
|
63 |
|
|
"definitions": [
|
64 |
|
|
{
|
65 |
|
|
// Value of "type" can currently be one of: "resource" and
|
66 |
|
|
// "mapping". The one we have here, "resource", defines a list
|
67 |
|
|
// of injectable scripts that can be used as a payload or as a
|
68 |
|
|
// dependency of another "resource". In the future CSS style sheets
|
69 |
|
|
// and WASM modules will also be composite parts of a "resource" as
|
70 |
|
|
// scripts are now.
|
71 |
|
|
"type": "resource",
|
72 |
|
|
|
73 |
|
|
// Used when referring to this resource in "dependencies" list of
|
74 |
|
|
// another resource or in "payload" field of a mapping. Should
|
75 |
|
|
// be consize and can only use a restricted set of characters. It
|
76 |
|
|
// has to match: [-0-9a-z]+
|
77 |
|
|
"identifier": "helloapple",
|
78 |
|
|
|
79 |
|
|
// "long_name" should be used to specify a user-friendly alternative
|
80 |
|
|
// to an identifier. It should generally not collide with a long
|
81 |
92a4d31c
|
Wojtek Kosior
|
// name of some resource with a different UUID and also shouldn't
|
82 |
bea4923f
|
Wojtek Kosior
|
// change in-between versions of the same resource, although
|
83 |
|
|
// exceptions to both rules might be considered. Long name is
|
84 |
|
|
// allowed to contain arbitrary unicode characters (within reason!).
|
85 |
|
|
"long_name": "Hello Apple",
|
86 |
|
|
|
87 |
48606f28
|
Wojtek Kosior
|
// Item definitions contain version information. Version is
|
88 |
|
|
// represented as an array of integers, with major version number
|
89 |
|
|
// being the first array item. In case of resources, version is
|
90 |
|
|
// accompanied by a revision field which contains a positive
|
91 |
|
|
// integer. If versions specified by arrays of different length need
|
92 |
|
|
// to be compared, the shorter array gets padded with zeroes on the
|
93 |
|
|
// right. This means that for example version 1.3 could be given as
|
94 |
|
|
// both [1, 3] and [1, 3, 0, 0] (aka 1.3.0.0) and either would mean
|
95 |
|
|
// the same.
|
96 |
bea4923f
|
Wojtek Kosior
|
// Different versions (e.g. 1.0 and 1.3) of the same resource can be
|
97 |
|
|
// defined in separate index.json files. This makes it easy to
|
98 |
92a4d31c
|
Wojtek Kosior
|
// accidently cause an identifier clash. To help detect it, we allow
|
99 |
|
|
// each resource to have a UUID associated with it. Attempt to
|
100 |
|
|
// define multiple resources with the same identifier and different
|
101 |
|
|
// UUIDs will result in an error being reported. Defining multiple
|
102 |
|
|
// resources with different identifiers and the same UUID is
|
103 |
|
|
// disallowed for now (it may be later permitted if we consider it
|
104 |
|
|
// good for some use-case).
|
105 |
|
|
// As of package source schema version 1.0, UUIDs are optional and
|
106 |
|
|
// can be omitted.
|
107 |
bea4923f
|
Wojtek Kosior
|
"uuid": "a6754dcb-58d8-4b7a-a245-24fd7ad4cd68",
|
108 |
|
|
|
109 |
|
|
// Version should match the upstream version of the resource (e.g. a
|
110 |
d30ce38c
|
Wojtek Kosior
|
// version of JavaScript library). Revision number starts as 1 for
|
111 |
bea4923f
|
Wojtek Kosior
|
// each new resource version and gets incremented by 1 each time a
|
112 |
|
|
// modification to the packaging of this version is done. Hydrilla
|
113 |
|
|
// will allow multiple definitions of the same resource to load, as
|
114 |
|
|
// long as their versions differ. Thanks to the "version" and
|
115 |
|
|
// "revision" fields, clients will know they have to update certain
|
116 |
|
|
// resource after it has been updated. If multiple definitions of
|
117 |
|
|
// the same version of given resource are provided, an error is
|
118 |
|
|
// generated (even if those definitions differ by revision number).
|
119 |
|
|
"version": [2021, 11, 10],
|
120 |
|
|
"revision": 1,
|
121 |
|
|
|
122 |
|
|
// A short, meaningful description of what the resource is and/or
|
123 |
|
|
// what it does.
|
124 |
|
|
"description": "greets an apple",
|
125 |
|
|
|
126 |
|
|
// If needed, a "comment" field can be added to provide some
|
127 |
|
|
// additional information.
|
128 |
|
|
// "comment": "this resource something something",
|
129 |
|
|
|
130 |
|
|
// Resource's "dependencies" array shall contain names of other
|
131 |
|
|
// resources that (in case of scripts at least) should get evaluated
|
132 |
|
|
// on a page before this resource's own scripts.
|
133 |
26c46224
|
Wojtek Kosior
|
"dependencies": [{"identifier": "hello-message"}],
|
134 |
bea4923f
|
Wojtek Kosior
|
|
135 |
d30ce38c
|
Wojtek Kosior
|
// Array of JavaScript files that belong to this resource.
|
136 |
bea4923f
|
Wojtek Kosior
|
"scripts": [
|
137 |
|
|
{"file": "hello.js"},
|
138 |
|
|
{"file": "bye.js"}
|
139 |
|
|
]
|
140 |
|
|
}, {
|
141 |
|
|
"type": "resource",
|
142 |
|
|
"identifier": "hello-message",
|
143 |
|
|
"long_name": "Hello Message",
|
144 |
|
|
"uuid": "1ec36229-298c-4b35-8105-c4f2e1b9811e",
|
145 |
|
|
"version": [2021, 11, 10],
|
146 |
|
|
"revision": 2,
|
147 |
|
|
"description": "define messages for saying hello and bye",
|
148 |
|
|
// If "dependencies" is empty, it can also be omitted.
|
149 |
|
|
// "dependencies": [],
|
150 |
|
|
"scripts": [{"file": "message.js"}]
|
151 |
|
|
}, {
|
152 |
|
|
"type": "mapping",
|
153 |
|
|
|
154 |
|
|
// Has similar function to resource's identifier. Should be consize
|
155 |
|
|
// and can only use a restricted set of characters. It has to match:
|
156 |
|
|
// [-0-9a-z]+
|
157 |
|
|
// It can be the same as some resource identifier (those are
|
158 |
|
|
// different entities and are treated separately).
|
159 |
|
|
"identifier": "helloapple",
|
160 |
|
|
|
161 |
|
|
// "long name" and "uuid" have the same meaning as in the case of
|
162 |
92a4d31c
|
Wojtek Kosior
|
// resources and "uuid" is also optional. UUIDs of a resource and a
|
163 |
|
|
// mapping can technically be the same but it is recommended to
|
164 |
|
|
// avoid even this kind of repetition.
|
165 |
bea4923f
|
Wojtek Kosior
|
"long_name": "Hello Apple",
|
166 |
|
|
"uuid": "54d23bba-472e-42f5-9194-eaa24c0e3ee7",
|
167 |
|
|
|
168 |
|
|
// "version" differs from its counterpart in resource in that it has
|
169 |
|
|
// no accompanying revision number.
|
170 |
|
|
"version": [2021, 11, 10],
|
171 |
|
|
|
172 |
|
|
// A short, meaningful description of what the mapping does.
|
173 |
|
|
"description": "causes apple to get greeted on Hydrillabugs issue tracker",
|
174 |
|
|
|
175 |
|
|
// A comment, if necessary.
|
176 |
|
|
// "comment": "blah blah because bleh"
|
177 |
|
|
|
178 |
|
|
// The "payloads" object specifies which payloads are to be applied
|
179 |
|
|
// to which URLs.
|
180 |
|
|
"payloads": {
|
181 |
|
|
// Each key should be a valid Haketilo URL pattern.
|
182 |
|
|
"https://hydrillabugs.koszko.org/***": {
|
183 |
|
|
// Should be the name of an existing resource. The resource
|
184 |
|
|
// may, but doesn't have to, be defined in the same
|
185 |
|
|
// index.json file.
|
186 |
|
|
"identifier": "helloapple"
|
187 |
|
|
},
|
188 |
|
|
// More associations may follow.
|
189 |
|
|
"https://hachettebugs.koszko.org/***": {
|
190 |
|
|
"identifier": "helloapple"
|
191 |
|
|
}
|
192 |
|
|
}
|
193 |
|
|
}
|
194 |
|
|
],
|
195 |
|
|
// We can also list additional files to include in the produced source
|
196 |
|
|
// archive. Hydrilla builder will then include those together with all
|
197 |
|
|
// script and copyright files used.
|
198 |
|
|
"additional_files": [
|
199 |
e571b391
|
Wojtek Kosior
|
{"file": "README.txt"},
|
200 |
|
|
{"file": "README.txt.license"},
|
201 |
|
|
{"file": ".reuse/dep5"}
|
202 |
bea4923f
|
Wojtek Kosior
|
],
|
203 |
|
|
// We can optionally tell Hydrilla builder to run the REUSE tool to generate
|
204 |
|
|
// report.spdx file. Using this option requires REUSE to be installed and
|
205 |
|
|
// and importable in the Python virtualenv used by Hydrilla builder.
|
206 |
|
|
"reuse_generate_spdx_report": true
|
207 |
|
|
}
|