Skip to content

Commit 7a44cc9

Browse files
authored
Merge pull request #1020 from openzim/devdocs
Add Devdocs offliner, category and warehouse path
2 parents 72481c2 + 4547867 commit 7a44cc9

File tree

11 files changed

+172
-6
lines changed

11 files changed

+172
-6
lines changed

dev/receiver/create-warehouse-paths.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ mkdir -p \
66
/jail/zim/freecodecamp \
77
/jail/zim/gutenberg \
88
/jail/zim/ifixit \
9+
/jail/zim/devdocs \
910
/jail/zim/mooc \
1011
/jail/zim/other \
1112
/jail/zim/phet \
@@ -28,6 +29,7 @@ chmod 777 \
2829
/jail/zim/freecodecamp \
2930
/jail/zim/gutenberg \
3031
/jail/zim/ifixit \
32+
/jail/zim/devdocs \
3133
/jail/zim/mooc \
3234
/jail/zim/other \
3335
/jail/zim/phet \

dispatcher/backend/docs/openapi_v1.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1915,6 +1915,7 @@ components:
19151915
- wikihow
19161916
- zimit
19171917
- ifixit
1918+
- devdocs
19181919
example:
19191920
- mwoffliner
19201921
- sotoki

dispatcher/backend/src/common/enum.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ class ScheduleCategory:
113113
wiktionary = "wiktionary"
114114
ifixit = "ifixit"
115115
freecodecamp = "freecodecamp"
116+
devdocs = "devdocs"
116117

117118
@classmethod
118119
def all(cls):
@@ -137,6 +138,7 @@ def all(cls):
137138
cls.wiktionary,
138139
cls.ifixit,
139140
cls.freecodecamp,
141+
cls.devdocs,
140142
]
141143

142144
@classmethod
@@ -168,6 +170,7 @@ class DockerImageName:
168170
wikihow = "openzim/wikihow"
169171
ifixit = "openzim/ifixit"
170172
freecodecamp = "openzim/freecodecamp"
173+
devdocs = "openzim/devdocs"
171174

172175
@classmethod
173176
def all(cls) -> set:
@@ -185,6 +188,7 @@ def all(cls) -> set:
185188
cls.wikihow,
186189
cls.ifixit,
187190
cls.freecodecamp,
191+
cls.devdocs,
188192
}
189193

190194

@@ -202,6 +206,7 @@ class Offliner:
202206
wikihow = "wikihow"
203207
ifixit = "ifixit"
204208
freecodecamp = "freecodecamp"
209+
devdocs = "devdocs"
205210

206211
@classmethod
207212
def all(cls):
@@ -219,6 +224,7 @@ def all(cls):
219224
cls.wikihow,
220225
cls.ifixit,
221226
cls.freecodecamp,
227+
cls.devdocs,
222228
]
223229

224230
@classmethod
@@ -243,6 +249,7 @@ def get_image_name(cls, offliner):
243249
cls.wikihow: DockerImageName.wikihow,
244250
cls.ifixit: DockerImageName.ifixit,
245251
cls.freecodecamp: DockerImageName.freecodecamp,
252+
cls.devdocs: DockerImageName.devdocs,
246253
}.get(offliner, "-")
247254

248255

@@ -264,10 +271,18 @@ class Platform:
264271
wikihow = "wikihow"
265272
ifixit = "ifixit"
266273
ted = "ted"
274+
devdocs = "devdocs"
267275

268276
@classmethod
269277
def all(cls) -> str:
270-
return [cls.wikimedia, cls.youtube, cls.wikihow, cls.ifixit, cls.ted]
278+
return [
279+
cls.wikimedia,
280+
cls.youtube,
281+
cls.wikihow,
282+
cls.ifixit,
283+
cls.ted,
284+
cls.devdocs,
285+
]
271286

272287
@classmethod
273288
def get_max_per_worker_tasks_for(cls, platform) -> int:

dispatcher/backend/src/common/schemas/models.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
validate_warehouse_path,
2222
)
2323
from common.schemas.offliners import (
24+
DevDocsFlagsSchema,
2425
FreeCodeCampFlagsSchema,
2526
GutenbergFlagsSchema,
2627
IFixitFlagsSchema,
@@ -101,6 +102,7 @@ def get_offliner_schema(offliner):
101102
Offliner.wikihow: WikihowFlagsSchema,
102103
Offliner.ifixit: IFixitFlagsSchema,
103104
Offliner.freecodecamp: FreeCodeCampFlagsSchema,
105+
Offliner.devdocs: DevDocsFlagsSchema,
104106
}.get(offliner, Schema)
105107

106108
@validates_schema

dispatcher/backend/src/common/schemas/offliners/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from common.schemas import SerializableSchema
2+
from common.schemas.offliners.devdocs import DevDocsFlagsSchema
23
from common.schemas.offliners.freecodecamp import FreeCodeCampFlagsSchema
34
from common.schemas.offliners.gutenberg import GutenbergFlagsSchema
45
from common.schemas.offliners.ifixit import IFixitFlagsSchema
@@ -16,6 +17,7 @@
1617
from common.schemas.offliners.zimit import ZimitFlagsSchema, ZimitFlagsSchemaRelaxed
1718

1819
__all__ = (
20+
"DevDocsFlagsSchema",
1921
"FreeCodeCampFlagsSchema",
2022
"GutenbergFlagsSchema",
2123
"IFixitFlagsSchema",
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
from marshmallow import fields
2+
3+
from common.schemas import SerializableSchema, String
4+
from common.schemas.fields import (
5+
validate_output,
6+
validate_zim_description,
7+
validate_zim_longdescription,
8+
)
9+
10+
11+
class DevDocsFlagsSchema(SerializableSchema):
12+
class Meta:
13+
ordered = True
14+
15+
slug = String(
16+
metadata={
17+
"label": "Slug",
18+
"description": "Fetch the provided Devdocs resource. "
19+
"Slugs are the first path entry in the Devdocs URL. "
20+
"For example, the slug for: `https://devdocs.io/gcc~12/` is `gcc~12`. "
21+
"Mutually exclusive with `All` setting, set only one option. Either this"
22+
"setting or `All` must be configured.",
23+
},
24+
)
25+
26+
all_flag = fields.Boolean(
27+
truthy=[True],
28+
falsy=[False],
29+
metadata={
30+
"label": "All",
31+
"description": "Fetch all Devdocs resources, and produce one ZIM "
32+
"per resource. Mutually exclusive with `Slug` setting, set only "
33+
"one option. Either this setting or `Slug` must be configured.",
34+
},
35+
data_key="all",
36+
)
37+
38+
skip_slug_regex = String(
39+
metadata={
40+
"label": "Skip slugs regex",
41+
"description": "Skips slugs matching the given regular expression."
42+
"Do not set to fetch all slugs. Only useful when `All` is set.",
43+
},
44+
data_key="skip-slug-regex",
45+
)
46+
47+
file_name_format = String(
48+
metadata={
49+
"label": "ZIM filename",
50+
"description": "ZIM filename. Do not input trailing `.zim`, it "
51+
"will be automatically added. You can use placeholders, see "
52+
"https://github.com/openzim/devdocs/blob/main/README.md. Defaults "
53+
"to devdocs.io_en_{clean_slug}_{period}",
54+
},
55+
data_key="file-name-format",
56+
)
57+
58+
name_format = String(
59+
metadata={
60+
"label": "ZIM name",
61+
"description": "ZIM name. You can use placeholders, see "
62+
"https://github.com/openzim/devdocs/blob/main/README.md. Defaults "
63+
"to devdocs.io_en_{clean_slug}",
64+
},
65+
data_key="name-format",
66+
)
67+
68+
title_format = String(
69+
metadata={
70+
"label": "ZIM title",
71+
"description": "ZIM title. You can use placeholders, see "
72+
"https://github.com/openzim/devdocs/blob/main/README.md. Defaults "
73+
"to `{full_name} Docs`",
74+
},
75+
data_key="title-format",
76+
)
77+
78+
description_format = String(
79+
metadata={
80+
"label": "ZIM description",
81+
"description": "ZIM description. You can use placeholders, see "
82+
"https://github.com/openzim/devdocs/blob/main/README.md. Defaults "
83+
"to `{full_name} docs by DevDocs`",
84+
},
85+
data_key="description-format",
86+
validate=validate_zim_description,
87+
)
88+
89+
long_description_format = String(
90+
metadata={
91+
"label": "ZIM long description",
92+
"description": "ZIM long description. You can use placeholders, see "
93+
"https://github.com/openzim/devdocs/blob/main/README.md. Defaults to no "
94+
"long description",
95+
},
96+
data_key="long-description-format",
97+
validate=validate_zim_longdescription,
98+
)
99+
100+
tags = String(
101+
metadata={
102+
"label": "ZIM Tags",
103+
"description": "List of semi-colon-separated Tags for the ZIM file. "
104+
" You can use placeholders, see "
105+
"https://github.com/openzim/devdocs/blob/main/README.md. Defaults to"
106+
"`devdocs;{slug_without_version}`",
107+
}
108+
)
109+
110+
creator = String(
111+
metadata={
112+
"label": "Creator",
113+
"description": "Name of content creator. “DevDocs” otherwise",
114+
},
115+
)
116+
117+
publisher = String(
118+
metadata={
119+
"label": "Publisher",
120+
"description": "Custom publisher name (ZIM metadata). “openZIM” otherwise",
121+
},
122+
)
123+
124+
output = String(
125+
metadata={
126+
"label": "Output folder",
127+
"placeholder": "/output",
128+
"description": "Output folder for ZIM file(s). Leave it as `/output`",
129+
},
130+
load_default="/output",
131+
dump_default="/output",
132+
validate=validate_output,
133+
)
134+
135+
debug = fields.Boolean(
136+
truthy=[True],
137+
falsy=[False],
138+
metadata={"label": "Debug", "description": "Enable verbose output"},
139+
)

dispatcher/backend/src/utils/offliners.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
Offliner.nautilus: od("nautiluszim", True, False),
2626
Offliner.zimit: od("zimit", True, "statsFilename"),
2727
Offliner.kolibri: od("kolibri2zim", True, False),
28+
Offliner.devdocs: od("devdocs2zim", True, False),
2829
}
2930

3031

dispatcher/frontend-ui/src/constants.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,17 +336,17 @@ export default {
336336
cancelable_statuses: cancelable_statuses,
337337
running_statuses: running_statuses,
338338
contact_email: "contact@kiwix.org",
339-
categories: ["freecodecamp", "gutenberg", "ifixit", "other", "phet", "psiram", "stack_exchange",
339+
categories: ["devdocs", "freecodecamp", "gutenberg", "ifixit", "other", "phet", "psiram", "stack_exchange",
340340
"ted", "openedx", "vikidia", "wikibooks", "wikihow", "wikinews",
341341
"wikipedia", "wikiquote", "wikisource", "wikispecies", "wikiversity",
342342
"wikivoyage", "wiktionary"], // list of categories for fileering
343-
warehouse_paths: ["/freecodecamp", "/gutenberg", "/ifixit", "/other", "/phet", "/psiram", "/stack_exchange",
343+
warehouse_paths: ["/devdocs", "/freecodecamp", "/gutenberg", "/ifixit", "/other", "/phet", "/psiram", "/stack_exchange",
344344
"/ted", "/mooc", "/videos", "/vikidia", "/wikibooks", "/wikihow",
345345
"/wikinews", "/wikipedia", "/wikiquote", "/wikisource",
346346
"/wikiversity", "/wikivoyage", "/wiktionary", "/zimit",
347347
"/.hidden/dev", "/.hidden/private", "/.hidden/endless",
348348
"/.hidden/bard", "/.hidden/bsf", "/.hidden/custom_apps"],
349-
offliners: ["mwoffliner", "youtube", "phet", "gutenberg", "sotoki", "nautilus", "ted", "openedx", "zimit", "kolibri", "wikihow", "ifixit", "freecodecamp"],
349+
offliners: ["mwoffliner", "youtube", "phet", "gutenberg", "sotoki", "nautilus", "ted", "openedx", "zimit", "kolibri", "wikihow", "ifixit", "freecodecamp", "devdocs"],
350350
periodicities: ["manually", "monthly", "quarterly", "biannualy", "annually"],
351351
memory_values: [536870912, // 512MiB
352352
1073741824, // 1GiB

workers/app/common/constants.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
OFFLINER_WIKIHOW = "wikihow"
123123
OFFLINER_IFIXIT = "ifixit"
124124
OFFLINER_FREECODECAMP = "freecodecamp"
125+
OFFLINER_DEVDOCS = "devdocs"
125126

126127
ALL_OFFLINERS = [
127128
OFFLINER_MWOFFLINER,
@@ -137,6 +138,7 @@
137138
OFFLINER_WIKIHOW,
138139
OFFLINER_IFIXIT,
139140
OFFLINER_FREECODECAMP,
141+
OFFLINER_DEVDOCS,
140142
]
141143
SUPPORTED_OFFLINERS = [
142144
offliner
@@ -152,7 +154,7 @@
152154
OFFLINER_YOUTUBE,
153155
]
154156

155-
ALL_PLATFORMS = ["wikimedia", "youtube", "wikihow", "ifixit", "ted"]
157+
ALL_PLATFORMS = ["wikimedia", "youtube", "wikihow", "ifixit", "ted", "devdocs"]
156158
PLATFORMS_TASKS = {}
157159
for platform in ALL_PLATFORMS:
158160
name = f"PLATFORM_{platform}_MAX_TASKS"

workers/contrib/zimfarm.config.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ ZIMFARM_CPU="3"
4747
# Comma-separated list of offliners to run or `""` for all of them. If
4848
# you want to run `youtube` tasks, you need to be whitelisted, contact
4949
# us.
50-
ZIMFARM_OFFLINERS="mwoffliner,sotoki,gutenberg,phet,nautilus,ted,openedx,zimit,kolibri,wikihow,ifixit,freecodecamp"
50+
ZIMFARM_OFFLINERS="mwoffliner,sotoki,gutenberg,phet,nautilus,ted,openedx,zimit,kolibri,wikihow,ifixit,freecodecamp,devdocs"
5151

5252
# Set to `"y"` to only run task specifically assigned to this worker
5353
# (`""` otherwise)
@@ -66,4 +66,5 @@ DISABLE_IPV6=""
6666
# PLATFORM_youtube_MAX_TASKS=2
6767
# PLATFORM_wikihow_MAX_TASKS=2
6868
# PLATFORM_ifixit_MAX_TASKS=2
69+
# PLATFORM_devdocs_MAX_TASKS=2
6970
# PLATFORM_ted_MAX_TASKS=2

workers/contrib/zimfarm.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ function restart() {
197197
--env PLATFORM_youtube_MAX_TASKS=$PLATFORM_youtube_MAX_TASKS \
198198
--env PLATFORM_wikihow_MAX_TASKS=$PLATFORM_wikihow_MAX_TASKS \
199199
--env PLATFORM_ifixit_MAX_TASKS=$PLATFORM_ifixit_MAX_TASKS \
200+
--env PLATFORM_devdocs_MAX_TASKS=$PLATFORM_devdocs_MAX_TASKS \
200201
--env PLATFORM_ted_MAX_TASKS=$PLATFORM_ted_MAX_TASKS \
201202
--env POLL_INTERVAL=$POLL_INTERVAL \
202203
--env DNSCACHE_IMAGE=$DNSCACHE_IMAGE \

0 commit comments

Comments
 (0)