From 72f33de711b24ceb922ed641df1599dbdc147e6b Mon Sep 17 00:00:00 2001 From: 3eef8a28f26fb2bcc514e6f1938929a1f931762 <116031952+3eef8a28f26fb2bcc514e6f1938929a1f931762@users.noreply.github.com> Date: Fri, 10 Feb 2023 17:06:30 -0500 Subject: [PATCH] Re-fix STSS+STSH=STSO handling --- src/GenerateHtml.cpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/GenerateHtml.cpp b/src/GenerateHtml.cpp index 1e07758..47f6171 100644 --- a/src/GenerateHtml.cpp +++ b/src/GenerateHtml.cpp @@ -12,6 +12,7 @@ struct quatalog_data_t { Json::Value prerequisites; Json::Value list_of_terms; Json::Value catalog; + Json::Value searchable_catalog; }; enum struct TAG { BEGIN, END, INLINE, COMPLEX_BEGIN }; enum struct TERM { SPRING, SUMMER, SUMMER2, SUMMER3, FALL, WINTER }; @@ -140,20 +141,31 @@ bool create_dir_if_not_exist(const fs::path& path) { return fs::create_directory(path); } -const Json::Value& get_data(const Json::Value& data, - std::string course_id) { +Json::Value get_data(const Json::Value& data, + std::string course_id) { course_id[4] = '-'; if(course_id.substr(0,3) != "STS") { return data[course_id]; } const auto& stso = data[course_id]; - if(stso) return stso; course_id[3] = 'S'; const auto& stss = data[course_id]; - if(stss) return stss; course_id[3] = 'H'; const auto& stsh = data[course_id]; - return stsh; + + Json::Value out; + + for(const auto& key : stso.getMemberNames()) { + out[key] = stso[key]; + } + for(const auto& key : stss.getMemberNames()) { + out[key] = stss[key]; + } + for(const auto& key : stsh.getMemberNames()) { + out[key] = stsh[key]; + } + + return out; } void generate_course_page(const std::string& course_id, @@ -184,6 +196,8 @@ void generate_course_page(const std::string& course_id, "They are often recycled and used for new/experimental courses."; } + quatalog_data.searchable_catalog[] + const std::regex escape_string(R"(")"); const std::string& description_meta = std::regex_replace(description,escape_string,"""); @@ -197,6 +211,8 @@ void generate_course_page(const std::string& course_id, tag(os,TAG::INLINE) << R"()" << '\n'; tag(os,TAG::INLINE) << R"()" << '\n'; tag(os,TAG::INLINE) << R"()" << '\n'; + tag(os,TAG::INLINE) << R"(