Skip to content

Commit

Permalink
Fix zim builder for new schema
Browse files Browse the repository at this point in the history
  • Loading branch information
mdp committed Jun 15, 2023
1 parent 36ba74e commit 5185e42
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions openzim/fcctozim/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,21 @@

def build_curriculum_redirects(clientdir, language):
fcc_lang = FCC_LANG_MAP[language]
index_json_path = pathlib.Path(clientdir, "fcc/index.json")
index_json_path = pathlib.Path(clientdir, "fcc", "curriculum", fcc_lang, "index.json")
with open(index_json_path) as course_index_str:
course_list = json.load(course_index_str)[fcc_lang]
superblock_dict = json.load(course_index_str)[fcc_lang]

redirects = []
for course in course_list:
meta_json_path = pathlib.Path(
clientdir, "fcc/curriculum/", fcc_lang, course, "_meta.json"
)
challenges = json.loads(meta_json_path.read_text())["challenges"]
for challenge in challenges:
title = challenge["title"]
redirects.append((f'{fcc_lang}/{course}/{challenge["slug"]}', title))
for superblock in superblock_dict:
course_list = superblock_dict[superblock]
for course in course_list:
meta_json_path = pathlib.Path(
clientdir, "fcc/curriculum/", fcc_lang, superblock, course, "_meta.json"
)
challenges = json.loads(meta_json_path.read_text())["challenges"]
for challenge in challenges:
title = challenge["title"]
redirects.append((f'{fcc_lang}/{superblock}/{course}/{challenge["slug"]}', title))

return OrderedDict(redirects).items()

Expand Down

0 comments on commit 5185e42

Please sign in to comment.