Skip to content

Commit

Permalink
Enforce that ZIM title must not be longer than 30 chars on our ZIMs
Browse files Browse the repository at this point in the history
  • Loading branch information
benoit74 committed Oct 8, 2024
1 parent 7a44cc9 commit 6e8ab19
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 7 deletions.
1 change: 1 addition & 0 deletions dispatcher/backend/src/common/schemas/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def validate_schedule_name(value) -> bool:
regex=r"^(.+?_)([a-z\-]{2,3}?_)(.+_|)([\d]{4}-[\d]{2}|{period}).zim$",
error="ZIM filename format is incorrect",
)
validate_zim_title = validate.Length(max=30)
validate_zim_description = validate.Length(max=80)
validate_zim_longdescription = validate.Length(max=4000)

Expand Down
2 changes: 2 additions & 0 deletions dispatcher/backend/src/common/schemas/offliners/devdocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
validate_output,
validate_zim_description,
validate_zim_longdescription,
validate_zim_title,
)


Expand Down Expand Up @@ -73,6 +74,7 @@ class Meta:
"to `{full_name} Docs`",
},
data_key="title-format",
validate=validate_zim_title,
)

description_format = String(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
validate_zim_description,
validate_zim_filename,
validate_zim_longdescription,
validate_zim_title,
)

FCC_LANG_MAP = {
Expand Down Expand Up @@ -59,6 +60,7 @@ class Meta:
"description": "ZIM title",
},
required=True,
validate=validate_zim_title,
)

description = String(
Expand Down
3 changes: 2 additions & 1 deletion dispatcher/backend/src/common/schemas/offliners/gutenberg.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from marshmallow import fields

from common.schemas import SerializableSchema, String
from common.schemas.fields import validate_zim_description
from common.schemas.fields import validate_zim_description, validate_zim_title


class GutenbergFlagsSchema(SerializableSchema):
Expand Down Expand Up @@ -34,6 +34,7 @@ class Meta:
"description": "Custom title for your project and ZIM.",
},
data_key="zim-title",
validate=validate_zim_title,
)

zim_desc = String(
Expand Down
2 changes: 2 additions & 0 deletions dispatcher/backend/src/common/schemas/offliners/ifixit.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
validate_output,
validate_zim_description,
validate_zim_filename,
validate_zim_title,
)


Expand Down Expand Up @@ -38,6 +39,7 @@ class Meta:
"description": "Custom title for your ZIM. "
"iFixIt homepage title otherwise",
},
validate=validate_zim_title,
)

description = String(
Expand Down
4 changes: 3 additions & 1 deletion dispatcher/backend/src/common/schemas/offliners/kolibri.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
validate_zim_description,
validate_zim_filename,
validate_zim_longdescription,
validate_zim_title,
)


Expand Down Expand Up @@ -52,7 +53,8 @@ class Meta:
metadata={
"label": "Title",
"description": "Custom title for your ZIM. Kolibri channel name otherwise",
}
},
validate=validate_zim_title,
)

description = String(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
validate_output,
validate_zim_description,
validate_zim_longdescription,
validate_zim_title,
)


Expand Down Expand Up @@ -59,7 +60,8 @@ class Meta:
metadata={
"label": "ZIM Title",
"description": "Custom ZIM title. Wiki name otherwise.",
}
},
validate=validate_zim_title,
)
customZimDescription = String(
metadata={"label": "ZIM Description", "description": "Max length is 80 chars"},
Expand Down
4 changes: 3 additions & 1 deletion dispatcher/backend/src/common/schemas/offliners/nautilus.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
validate_output,
validate_zim_description,
validate_zim_filename,
validate_zim_title,
)


Expand Down Expand Up @@ -98,7 +99,8 @@ class Meta:
metadata={
"label": "Title",
"description": "Title for your project and ZIM. Otherwise --name.",
}
},
validate=validate_zim_title,
)
description = String(
metadata={
Expand Down
2 changes: 2 additions & 0 deletions dispatcher/backend/src/common/schemas/offliners/openedx.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
validate_output,
validate_zim_description,
validate_zim_filename,
validate_zim_title,
)


Expand Down Expand Up @@ -174,6 +175,7 @@ class Meta:
"description": "Custom title for your ZIM. Based on MOOC otherwise",
},
data_key="title",
validate=validate_zim_title,
)

description = String(
Expand Down
2 changes: 2 additions & 0 deletions dispatcher/backend/src/common/schemas/offliners/sotoki.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
validate_output,
validate_zim_description,
validate_zim_filename,
validate_zim_title,
)


Expand Down Expand Up @@ -33,6 +34,7 @@ class Meta:
"label": "Title",
"description": "Custom title for your ZIM. Site name otherwise",
},
validate=validate_zim_title,
)

description = String(
Expand Down
4 changes: 3 additions & 1 deletion dispatcher/backend/src/common/schemas/offliners/ted.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
validate_zim_description,
validate_zim_filename,
validate_zim_longdescription,
validate_zim_title,
)


Expand Down Expand Up @@ -111,7 +112,8 @@ class Meta:
metadata={
"label": "Title",
"description": "Custom title for your ZIM. Based on selection otherwise",
}
},
validate=validate_zim_title,
)

description = String(
Expand Down
2 changes: 2 additions & 0 deletions dispatcher/backend/src/common/schemas/offliners/wikihow.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
validate_output,
validate_zim_description,
validate_zim_filename,
validate_zim_title,
)


Expand Down Expand Up @@ -34,6 +35,7 @@ class Meta:
"description": "Custom title for your ZIM. "
"Wikihow homepage title otherwise",
},
validate=validate_zim_title,
)

description = String(
Expand Down
4 changes: 3 additions & 1 deletion dispatcher/backend/src/common/schemas/offliners/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
validate_zim_description,
validate_zim_filename,
validate_zim_longdescription,
validate_zim_title,
)


Expand Down Expand Up @@ -85,7 +86,8 @@ class Meta:
"label": "ZIM Title",
"description": "Custom title for your ZIM. "
"Default to Channel name (of first video if playlists)",
}
},
validate=validate_zim_title,
)

description = String(
Expand Down
4 changes: 3 additions & 1 deletion dispatcher/backend/src/common/schemas/offliners/zimit.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
validate_output,
validate_zim_description,
validate_zim_filename,
validate_zim_title,
)

# https://github.com/puppeteer/puppeteer/blob/main/src/common/DeviceDescriptors.ts
Expand Down Expand Up @@ -175,7 +176,8 @@ class Meta:
metadata={
"label": "Title",
"description": "Custom title for ZIM. Defaults to title of main page",
}
},
validate=validate_zim_title,
)

description = String(
Expand Down

0 comments on commit 6e8ab19

Please sign in to comment.