fmtClozeQ = _read_template(template_dir, "abhiyan_cloze_front.html", "", "") fmtClozeA = _read_template(template_dir, "abhiyan_cloze_back.html", "", "") fmtQ = _read_template(template_dir, "abhiyan_basic_front.html", "", "") fmtA = _read_template(template_dir, "abhiyan_basic_back.html", "", "") fmtInputQ = _read_template(template_dir, "abhiyan_input_front.html", "", "") fmtInputA =_read_template(template_dir, "abhiyan_basic_back.html", "", "") # Note: reusing the basic back, essentially the same. # else notionstyle for deck in data: cards = deck.get("cards", []) notes = [] for card in cards: fields = [card["name"], card["back"], ",".join(card["media"])] model = basic_model(basic_model_id, basic_model_name, CSS, fmtQ, fmtA) if card.get('cloze', False) and "{{c" in card["name"] : model = cloze_model(cloze_model_id, cloze_model_name, CLOZE_STYLE + "\n" + CSS, fmtClozeQ, fmtClozeA) elif card.get('enableInput', False) and card.get('answer', False): model = input_model(input_model_id, input_model_name, CSS, fmtInputQ, fmtInputA) fields = [ card["name"].replace("{{type:Input}}", ""), card["back"], card["answer"], ",".join(card["media"]), ] my_note = Note(model, fields=fields, sort_field=card["number"], tags=card['tags']) notes.append(my_note) media_files = media_files + card["media"] deck_desc = "<p>This deck is brought to you by some amazing <a class='patreon-cta' href='https://www.patreon.com/alemayhu'>patrons</a> 🤩</p>" if deck.get('emptyDescription', False): deck_desc = '' else:
INPUT_BACK = fmtInputA INPUT_STYLE = CSS if n2aInput: INPUT_STYLE = n2aInput["styling"] INPUT_FRONT = n2aInput["front"] INPUT_BACK = n2aInput["back"] for deck in data: cards = deck.get("cards", []) notes = [] for card in cards: fields = [card["name"], card["back"], ",".join(card["media"])] model = basic_model(basic_model_id, basic_model_name, BASIC_STYLE, BASIC_FRONT, BASIC_BACK) if card.get('cloze', False) and "{{c" in card["name"]: model = cloze_model(cloze_model_id, cloze_model_name, CLOZE_STYLE, CLOZE_FRONT, CLOZE_BACK) elif card.get('enableInput', False) and card.get( 'answer', False): model = input_model(input_model_id, input_model_name, INPUT_STYLE, INPUT_FRONT, INPUT_BACK) fields = [ card["name"].replace("{{type:Input}}", ""), card["back"], card["answer"], ",".join(card["media"]), ] # Cards marked with -1 number means they are breaking compatability, treat them differently by using their respective Notion Id if card["number"] == -1: card["number"] = card["notionId"] if mt.get("useNotionId"):
cloze_model_id = mt.get('cloze_model_id', 998877661) basic_model_id = mt.get('basic_model_id', 2020) template = mt.get('template', 'specialstyle') if template == 'specialstyle': CSS += _read_template(template_dir, "custom.css", "", "") elif template == 'nostyle': CSS = "" # else notionstyle for deck in data: cards = deck.get("cards", []) notes = [] for card in cards: fields = [card["name"], card["back"], ",".join(card["media"])] model = cloze_model(cloze_model_id, cloze_model_name, CLOZE_STYLE + "\n" + CSS) # TODO: sanity check the card fields if not "{{c" in card["name"] and not "{{type" in card["name"]: model = basic_model(basic_model_id, basic_model_name, CSS) elif card["enable-input"] and 'answer' in card: model = input_model(input_model_id, input_model_name, CSS) fields = [ card["name"].replace("{{type:Input}}", ""), card["back"], card["answer"], ",".join(card["media"]), ] my_note = Note(model, fields=fields, sort_field=card["number"],