diff --git a/Makefile b/Makefile index f4fe988..ffe7e04 100644 --- a/Makefile +++ b/Makefile @@ -21,8 +21,8 @@ clean: install: $(MAKE) clean; $(MAKE); - rm -rf ${SRV_ROOT}build/; - cp -rT ./build ${SRV_ROOT}build/; + rm -rf /srv/http/build/; + cp -rT ./build /srv/http/build/; cp -rT ./build/scripts/ ${SRV_ROOT}scripts/; cp -rT ./build/styles/ ${SRV_ROOT}styles/; - cp search.ini ${SRV_ROOT}build/; + cp search.ini /srv/http/build/; diff --git a/src/goasearch.py b/src/goasearch.py index b661f87..a0852fc 100755 --- a/src/goasearch.py +++ b/src/goasearch.py @@ -1,7 +1,8 @@ #! /usr/bin/python2 from search import indexListing from textbookExceptions import UnIndexable -from mcmaster.classes import allCourses, classToJSON, indexListing +from mcmaster.classes import allCourses +from search import indexListing, createIndex from itertools import imap try: @@ -11,7 +12,7 @@ except Exception as e: print e print "Downloading course info" -for c in imap(classToJSON, allCourses()): +for c in allCourses(): try: print indexListing(c) except UnIndexable as e: diff --git a/src/mcmaster/classes.py b/src/mcmaster/classes.py index 2103c30..d6d2ca6 100755 --- a/src/mcmaster/classes.py +++ b/src/mcmaster/classes.py @@ -118,10 +118,19 @@ class Section(dict): self.time = time.encode("UTF-8") self.loc = loc.encode("UTF-8") self.prof = prof.encode("UTF-8") - self.sem = sem.encode("UTF-8") + self._sem = sem.encode("UTF-8") self._date = False self._day = False + @property + def sem(self): + if self._sem == fall: + return "Fall" + elif self._sem == winter: + return "Winter" + else: + return "Spring/Summer" + @property def date(self): if self.time != "TBA": @@ -341,7 +350,7 @@ def getCourses(semester, threadcount=10): def allCourses(): return chain.from_iterable( - (getCourses(sem, threadcount=10) + (getCourses(sem, threadcount=25) for sem in (fall, winter, spring_summer))) if __name__ == "__main__": diff --git a/src/scripts/book.tag b/src/scripts/book.tag index 5a987c4..8565193 100644 --- a/src/scripts/book.tag +++ b/src/scripts/book.tag @@ -23,7 +23,7 @@

-

+

Couldn't find anything, sorry :(

diff --git a/src/scripts/class.tag b/src/scripts/class.tag index cf4e64c..f428c4d 100644 --- a/src/scripts/class.tag +++ b/src/scripts/class.tag @@ -21,8 +21,8 @@
-

No books at this time

-

Check back later, or verify the course has books

+

No books at this time

+

Check back later, or verify the course has books

diff --git a/src/scripts/results.tag b/src/scripts/results.tag index fc51318..5f1d0d6 100644 --- a/src/scripts/results.tag +++ b/src/scripts/results.tag @@ -1,13 +1,22 @@ -
+
this.rows = []; var self = this; + +results_passer.on("loading", + function() { + self.notLoading = false; + self.update(); + }); + results_passer.on("new_results", function(data) { console.log("new search results detected"); + console.log(data); self.rows = data; + self.notLoading = true; self.update(); }); diff --git a/src/scripts/search.js b/src/scripts/search.js index 8fe25b4..77c4bfa 100644 --- a/src/scripts/search.js +++ b/src/scripts/search.js @@ -8,11 +8,9 @@ function makeResourceGetter(self) { "author" : this.bookauthor }; var url = "/search/resources"; - console.log(params); $.getJSON(url, { data : JSON.stringify(params) }).done(function(results) { - if (results.iarchive) { self.iarchive = results.iarchive[0]; } @@ -50,8 +48,11 @@ function ResultsPasser() { var results_passer = new ResultsPasser(); -riot.mount("search"); -riot.mount("results"); +riot.mount("search", { + showHelp : false, + booksLoading : false + }); +riot.mount("results", {notLoading : true}); function autocomplete(element, endpoint) { // The element should be an input class @@ -65,7 +66,24 @@ function autocomplete(element, endpoint) { }); } +function realBook(book) { + var noAdoption = book.booktitle.indexOf("No Adoption"); + var noBooks = book.booktitle.indexOf("No Textbooks"); + return ((noAdoption == -1) && + (noBooks == -1)); +} + function filterCourses(courses) { + var books; + + for (var i in courses) { + books = courses[i].books; + if ((books.length > 0) && + (!realBook(books[0]))) { + courses[i].books = ""; + } + } + return courses.filter( function (c) { return c.prof != "Staff"; diff --git a/src/scripts/search.tag b/src/scripts/search.tag index 5154ca8..fed9c83 100644 --- a/src/scripts/search.tag +++ b/src/scripts/search.tag @@ -1,30 +1,84 @@ -
+
-
- -
-
- +
+
+ -
-
- + + +
+
+ +
+
+
+ + Type keywords of your course's name or the course code (e.g. PSYCH 2B03) +
+
+
+this.showedHelp = false; +this.waiting = false; + +function showHelp() { + if (!this.showedHelp) { + this.opts.showHelp = true; + this.update(); + if (!waiting) { + waiting = true; + window.setTimeout( + (function() { + this.waiting = false; + clearHelpTemp.bind(this)(); + }).bind(this), 10000); + } + } +} + +function clearHelp() { + this.showedHelp = true; + this.opts.showHelp = false; + this.update(); +} + +function clearHelpTemp() { + this.opts.showHelp = false; + this.update(); +} + function submit(ev) { + ev.preventDefault(); + this.showedHelp = true; + this.opts.showHelp = false; console.log("submitted"); + this.opts.booksLoading = true; + this.update(); + results_passer.trigger("loading"); var params = $(ev.currentTarget).serialize(); $.getJSON("/search/fc?"+params, - function(courses) { + (function(courses) { var fcourses = filterCourses(courses); var cgroups = groupsof(3, fcourses); results_passer.trigger("new_results", cgroups); - }); + this.opts.booksLoading = false; + this.update(); + }).bind(this)); } diff --git a/src/search.py b/src/search.py index 848b455..33aeb22 100755 --- a/src/search.py +++ b/src/search.py @@ -9,6 +9,7 @@ from json import dumps, loads from itertools import chain, imap from hashlib import sha1 +from syslog import syslog from textbookExceptions import UnIndexable @@ -106,11 +107,12 @@ def indexListing(course): } """ - courseID = hashsec(course) + json_course = classToJSON(course) + courseID = hashsec(json_course) print es.index(index="oersearch", doc_type="course", id=courseID, - body=course) + body=json_course) # For every course we index, we also create a resource for it # This should be an idempotent operation because we're putting it in couchdb @@ -169,6 +171,7 @@ def searchTerms(terms): """ Run a search for courses """ + syslog(repr(terms)) # A list of all the queries we want to run qs = [searchers[field](term) for diff --git a/src/styles/search.scss b/src/styles/search.scss index 1a7aa07..8df8cfc 100644 --- a/src/styles/search.scss +++ b/src/styles/search.scss @@ -6,6 +6,31 @@ header { white-space: pre-wrap !important; } +.search-load { + color: transparent !important; + min-height: 1.6rem; + pointer-events: none; + position: relative; +} + +.search-load::after { + -webkit-animation: loading 500ms infinite linear; + animation: loading 500ms infinite linear; + border: .2rem solid #5764c6; + border-radius: 2.9rem; + border-right-color: transparent; + border-top-color: transparent; + content: ""; + display: block; + height: 2.8rem; + left: 50%; + margin-left: -.8rem; + margin-top: -.8rem; + position: absolute; + top: 50%; + width: 3rem; +} + .body { color: #1c75bc; } @@ -18,9 +43,18 @@ a { background-color: #1c75bc !important; } -.courses { +@media (min-width: 1335px) { + .courses { margin-top: 100px; max-width: 75%; + } +} + +@media (max-width: 1366px) { + .courses { + margin-top: 100px; + max-width: 85%; + } } .course { @@ -34,7 +68,7 @@ a { } .search-form { - margin-top: 9%; + margin-top: 6%; -webkit-appearance: none !important; } @@ -43,8 +77,9 @@ a { } .form-item { - padding-left: 15px; - padding-right: 15px; + padding-left: 5px; + padding-right: 5px; + margin-right: -15px; } #title { @@ -95,22 +130,28 @@ a { background-image: none; } -.logo-div { - height:67px; - width:150px; - margin-right:1%; - margin-bottom: 0%; - margin-top:1%; - margin-left:2%; - background-size: 100%; - background-size: cover; - -webkit-background-size: cover; - -o-background-size: cover; - background-size: cover; - background-position: center center; - /*background-image: url('https://mgoal.ca/goal_transp.png');*/ -} - -.title-div { - font-size: 25px; +@media (min-width: 480px) { + .logo { + margin-top: 20px; + margin-left: -175px; + } +} + +@media (min-width: 480px) { + .title { + margin-left: 80px; + } +} + +.page-top { + font-size: 15px; + width: 50% !important; +} + +.help-toast { + background-color: rgba(28,117,188, 0.7) !important; + font-size: 0.8em; + max-width: 55%; + margin-top: -10px; + border: none; } diff --git a/src/templates/search.html b/src/templates/search.html index 90c984e..9e8f654 100644 --- a/src/templates/search.html +++ b/src/templates/search.html @@ -3,16 +3,26 @@ {{super()}} {% endblock %} +
+ +
{% block content %}