diff --git a/.data/subjects.json b/.data/subjects.json index 6ca2997..a1f3993 100644 --- a/.data/subjects.json +++ b/.data/subjects.json @@ -13,11 +13,11 @@ { "code": "BIOL", "description": "Biology" }, { "code": "BIOT", "description": "Biotechnology" }, { "code": "BUSN", "description": "Business Administration" }, - { "code": "EXSC", "description": "Cardiopulmonary & Exercise Sci" }, + { "code": "EXSC", "description": "Cardiopulmonary & Exercise Sci" }, { "code": "CHME", "description": "Chemical Engineering" }, - { "code": "CHEM", "description": "Chemistry & Chemical Biology" }, + { "code": "CHEM", "description": "Chemistry & Chemical Biology" }, { "code": "CHNS", "description": "Chinese" }, - { "code": "CIVE", "description": "Civil & Environmental Engineer" }, + { "code": "CIVE", "description": "Civil & Environmental Engineer" }, { "code": "COMM", "description": "Communication Studies" }, { "code": "CS", "description": "Computer Science" }, { "code": "EEAM", "description": "Coop/Exper Ed - Arts/Med/Dsgn" }, @@ -27,9 +27,10 @@ { "code": "INNO", "description": "Corporate Innovation" }, { "code": "CAEP", "description": "Counseling and Applied Ed Psyc" }, { "code": "CRIM", "description": "Criminal Justice" }, + { "code": "CLTR", "description": "Culture" }, { "code": "CY", "description": "Cybersecurity" }, { "code": "DS", "description": "Data Science" }, - { "code": "ENVR", "description": "Earth & Environmental Sciences" }, + { "code": "ENVR", "description": "Earth & Environmental Sciences" }, { "code": "ECON", "description": "Economics" }, { "code": "EECE", "description": "Electrical and Comp Engineerng" }, { "code": "ENSY", "description": "Energy Systems" }, @@ -38,8 +39,8 @@ { "code": "EMGT", "description": "Engineering Management" }, { "code": "ENGL", "description": "English" }, { "code": "ENGW", "description": "English Writing" }, - { "code": "ENTR", "description": "Entrepreneurship & Innovation" }, - { "code": "FINA", "description": "Finance & Insurance" }, + { "code": "ENTR", "description": "Entrepreneurship & Innovation" }, + { "code": "FINA", "description": "Finance & Insurance" }, { "code": "GE", "description": "General Engineering" }, { "code": "HINF", "description": "Health Informatics" }, { "code": "HLTH", "description": "Health Sci - Interdisciplinary" }, @@ -58,7 +59,7 @@ { "code": "MGSC", "description": "Management Science" }, { "code": "MKTG", "description": "Marketing" }, { "code": "MATH", "description": "Mathematics" }, - { "code": "MEIE", "description": "Mech & Industrial Engineering" }, + { "code": "MEIE", "description": "Mech & Industrial Engineering" }, { "code": "ME", "description": "Mechanical Engineering" }, { "code": "MSCR", "description": "Media and Screen Studies" }, { "code": "MUSC", "description": "Music" }, @@ -76,14 +77,15 @@ { "code": "PPUA", "description": "Pub Policy and Urban Affairs" }, { "code": "PHTH", "description": "Public Health" }, { "code": "SOCL", "description": "Sociology" }, - { "code": "SLPA", "description": "Speech-Lang Path & Audiology" }, + { "code": "SLPA", "description": "Speech-Lang Path & Audiology" }, { "code": "STRT", "description": "Strategy" }, { "code": "SCHM", "description": "Supply Chain Management" }, { "code": "THTR", "description": "Theatre" }, { "code": "AMSL", "description": "American Sign Language" }, { "code": "ARTS", "description": "Art - Studio" }, - { "code": "AACE", "description": "Arts Admin & Cultural Entrep" }, - { "code": "EEMB", "description": "Ecology, Evolutn & Marine Biol" }, + { "code": "AACE", "description": "Arts Admin & Cultural Entrep" }, + { "code": "DAMG", "description": "Data Architecture Management" }, + { "code": "EEMB", "description": "Ecology, Evolutn & Marine Biol" }, { "code": "ENLR", "description": "Engineering Leadership" }, { "code": "TECE", "description": "Entrepreneurship Technological" }, { "code": "FRNH", "description": "French" }, @@ -91,6 +93,7 @@ { "code": "GRMN", "description": "German" }, { "code": "HSCI", "description": "Health Science" }, { "code": "HRMG", "description": "Human Resources Management" }, + { "code": "INFO", "description": "Information Systems Program" }, { "code": "INTB", "description": "International Business" }, { "code": "JPNS", "description": "Japanese" }, { "code": "JWSS", "description": "Jewish Studies" }, @@ -100,8 +103,9 @@ { "code": "SPNS", "description": "Spanish" }, { "code": "ABRU", "description": "Study USA" }, { "code": "SUEN", "description": "Sustainable Urban Environments" }, - { "code": "WMNS", "description": "Women's/Gender/Sexualty Stdies" }, + { "code": "WMNS", "description": "Women's/Gender/Sexualty Stdies" }, { "code": "CMMN", "description": "Communicatn Studies - CPS Spec" }, + { "code": "CSYE", "description": "Computer Systems Engineering" }, { "code": "DA", "description": "Data Analytics" }, { "code": "ESLG", "description": "English as Scnd Lng - CPS Spec" }, { "code": "NETS", "description": "Network Science" }, @@ -118,9 +122,6 @@ { "code": "ASNS", "description": "Asian Studies" }, { "code": "BNSC", "description": "Behavioral Neuroscience" }, { "code": "BIOC", "description": "Biochemistry" }, - { "code": "CSYE", "description": "Computer Systems Engineering" }, - { "code": "CLTR", "description": "Culture" }, - { "code": "DAMG", "description": "Data Architecture Management" }, { "code": "DEAF", "description": "Deaf Studies" }, { "code": "ECNM", "description": "Economics - CPS Spec" }, { "code": "EDUC", "description": "Education" }, @@ -131,13 +132,12 @@ { "code": "GBST", "description": "Global Studies - CPS Spec" }, { "code": "HBRW", "description": "Hebrew" }, { "code": "IS", "description": "Information Science" }, - { "code": "INFO", "description": "Information Systems Program" }, { "code": "INAM", "description": "Interdisc Studies - Arts/Media" }, { "code": "INSC", "description": "Interdisc Studies - Science" }, { "code": "INTP", "description": "Interpreting" }, { "code": "ITLN", "description": "Italian" }, { "code": "LARC", "description": "Landscape Architecture" }, - { "code": "LACS", "description": "Latin Am & Carib Studies" }, + { "code": "LACS", "description": "Latin Am & Carib Studies" }, { "code": "LAW", "description": "Law" }, { "code": "LW", "description": "Law (for Non-Law School Stu)" }, { "code": "MATL", "description": "Materials Engineering" }, diff --git a/banner/subject.ts b/banner/subject.ts index c29f33c..4eb11bd 100644 --- a/banner/subject.ts +++ b/banner/subject.ts @@ -1,5 +1,6 @@ import { Subject, Term } from "@/types.ts"; import { dedup } from "@/util/dedup.ts"; +import { decodeHTML } from "../util/decode-html.ts"; // Requires terms to be passed in export const getAllSubjects = async (terms: Term[]): Promise => { @@ -8,7 +9,7 @@ export const getAllSubjects = async (terms: Term[]): Promise => { const subjectsToAdd = await getSubjects(term.code); subjectsToAdd.forEach((subject) => { if (!subjects.some((s) => s.code === subject.code)) { - subjects.push(subject); + subjects.push({ ...subject, description: decodeHTML(subject.description) }); } }); } @@ -21,7 +22,7 @@ export const getAllSubjects = async (terms: Term[]): Promise => { export const getSubjects = async (term: string): Promise => { // TODO: use URLSearchParams const response = await fetch( - `https://nubanner.neu.edu/StudentRegistrationSsb/ssb/classSearch/get_subject?searchTerm=&term=${term}&offset=1&max=400`, // 400 to get all + `https://nubanner.neu.edu/StudentRegistrationSsb/ssb/classSearch/get_subject?searchTerm=&term=${term}&offset=1&max=400` // 400 to get all ); const terms = await response.json(); return terms; diff --git a/util/decode-html.ts b/util/decode-html.ts index 4861919..05f63c9 100644 --- a/util/decode-html.ts +++ b/util/decode-html.ts @@ -1,12 +1,9 @@ import { DOMParser } from "https://deno.land/x/deno_dom@v0.1.33-alpha/deno-dom-wasm.ts"; export const decodeHTML = (string: string): string => { - const document = new DOMParser().parseFromString( - ``, - "text/html", - ); + const document = new DOMParser().parseFromString(``, "text/html"); const textarea = document?.getElementsByTagName("textarea")[0]; textarea!.innerHTML = string; const decoded = textarea?.innerText; - return decoded!.replaceAll("’", "'").replaceAll("#8217;", "'"); + return decoded!.replaceAll("’", "'").replaceAll("#8217;", "'").replaceAll("&", "&"); };