Commit f2ec598d authored by Zac Wood's avatar Zac Wood

mini redesign

parent fbb5d5b8
Pipeline #4148 failed with stage
in 2 minutes and 41 seconds
......@@ -20,6 +20,11 @@ body {
background-color: #E4E4E4;
}
#page {
padding-top: 16px;
padding-bottom: 16px;
}
.card {
margin-bottom: 12px;
......@@ -90,3 +95,30 @@ body {
.quick-add-header {
margin-top: 32px;
}
%flex-display {
display: inline-flex;
}
.star-rating {
@extend %flex-display;
align-items: center;
font-size: 1em;
justify-content: flex-start;
}
.back-stars {
@extend %flex-display;
position: relative;
text-shadow: 4px 4px 10px #843a3a;
}
.front-stars {
@extend %flex-display;
color: #FFBC0B;
overflow: hidden;
position: absolute;
text-shadow: 2px 2px 5px #d29b09;
top: 0;
}
// .jumbotron {
// color: #FFFFFF
// }
# Configures the application.
class ApplicationController < ActionController::Base
protect_from_forgery with: :null_session
include BySemester
# On each request, set the semester and cart.
before_action :set_semester, :set_cart
# Every page needs to know what semester it should load data from.
# set_semester checks both the semester_id query parameter and the user's cookies
# to look for a semester id and loads whatever it finds into @semester.
#
# By default, load the most recent semester.
def set_semester
if params.key?(:semester_id)
@semester = Semester.find_by_id params[:semester_id]
cookies[:semester_id] = @semester.id
elsif cookies[:semester_id].nil?
@semester = Semester.first
cookies[:semester_id] = @semester.id
else
@semester = Semester.find_by_id cookies[:semester_id]
end
end
before_action :set_cart
# The user's cart is stored as a JSON-encoded list of CRNs.
# set_cart sets the @cart variable, which is a list of the sections represented by the CRNs.
......
class SearchController < ApplicationController
include BySemester
def index
redirect_to(home_url) unless params[:query].length > 1
......@@ -10,5 +12,11 @@ class SearchController < ApplicationController
results = SearchHelper::GenericItem.fetchall(String.new(params[:query]), semester: @semester).group_by(&:type)
@instructors = results[:instructor]&.map(&:data)
@courses = results[:course]&.map(&:data)
if @courses&.count == 1
redirect_to course_url(@courses.first)
elsif @instructors&.count == 1
redirect_to instructor_url(@instructors.first)
end
end
end
......@@ -38,13 +38,13 @@ class Cart {
for (const courseId in this._courses) {
if (this._courses[courseId].length === 0) delete this._courses[courseId];
}
document.getElementById('course-counter').innerText = Object.keys(this._courses).length;
document.getElementById('cart-counter').innerText = Object.keys(this._courses).length;
}
async toggleSection(section) {
const resp = await fetch(`/sessions/cart?&crn=${section.crn}`, {
cache: 'no-store',
credentials: 'same-origin'
credentials: 'same-origin',
});
const json = await resp.json();
this.courses = json;
......@@ -65,4 +65,3 @@ const cart = new Cart();
document.addEventListener('DOMContentLoaded', () => cart._parseData());
export default cart;
......@@ -33,8 +33,8 @@
<%= sections.count %> sections
</div>
</div>
<p class="description"><%= course.description %></p>
<p class="description"><%= course.description %></p>
<% unless course.prereqs.nil? || course.prereqs.empty? %>
<% first, rest = course.prereqs.split(':') %>
<% prereqs, note = rest.split('.') %>
......@@ -53,6 +53,8 @@
</div>
<% end %>
<!-- List of Course Sections -->
......
<div id="navbar" class="container-fluid">
<div class="row align-left align-sm-center align-md-right" id="navbar">
<div class="col align-center">
<div class="center-vert">
<a href="/" id="logo">
<i class="fas fa-calendar-alt"></i>
Schedules
</a>
<select id="semester-select" class="custom-select">
<% Semester.all.each do |semester| %>
<option
value="<%= semester.id %>"
<% if @semester == semester %> selected <% end %>
>
<%= "#{semester.season} #{semester.year}" %>
</option>
<% end %>
</select>
</div>
</div>
<!-- <div id="navbar" class="container-fluid">
<div class="row align-left align-sm-center align-md-right" id="navbar">
<div class="col align-center">
<div class="center-vert">
<a href="/" id="logo">
<i class="fas fa-calendar-alt"></i>
Schedules
</a>
<div class="col-sm align-center order-0 order-sm-1">
<a id="cart-button" href="<%= schedule_path %>">
<h1>
<span class="fa-layers fa-fw" id="schedule-icon">
<i class="fas fa-shopping-cart"></i>
<span class="fa-layers fa-fw">
<i class="fas fa-circle" data-fa-transform="shrink-3 up-12 right-12" style="color:gray"></i>
<span id="course-counter" class="fa-layers-text fa-inverse" data-fa-transform="shrink-10 up-12 right-12" style="font-weight:600">
<%= @cart.length %>
</span>
</span>
</span>
</h1>
</a>
</div>
</div>
</div>
<div class="col-sm align-center order-0 order-sm-1">
<a id="cart-button" href="<%= schedule_path %>">
<h1>
<span class="fa-layers fa-fw" id="schedule-icon">
<i class="fas fa-shopping-cart"></i>
<span class="fa-layers fa-fw">
<i class="fas fa-circle" data-fa-transform="shrink-3 up-12 right-12" style="color:gray"></i>
<span id="course-counter" class="fa-layers-text fa-inverse" data-fa-transform="shrink-10 up-12 right-12" style="font-weight:600">
<%= @cart.length %>
</span>
</span>
</span>
</h1>
</a>
</div>
<div class="col order-1 order-sm-0">
<form action="/search" class="form">
<div class="input-group" style="width:100%;">
<input
id="searchbar"
value="<%= params[:query] %>"
name="query"
type="text"
class="form-control"
placeholder="Search course or professor..."
aria-describedby="basic-addon2"
autocomplete="off"
>
<div class="input-group-append">
<button type="submit" class="btn btn-secondary" type="button">
<i class="fas fa-search"></i>
</button>
</div>
</div>
</form>
</div>
</div>
</div> -->
<nav class="navbar navbar-expand-lg navbar-dark" style="background-color: #006633">
<div class="container">
<a class="navbar-brand mb-0 h1" href="/">
<i class="fas fa-calendar-alt"></i>
Schedules
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo02" aria-controls="navbarTogglerDemo02" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="col order-1 order-sm-0">
<form action="/search" class="form">
<div class="input-group" style="width:100%;">
<input
id="searchbar"
<div class="collapse navbar-collapse" id="navbarTogglerDemo02">
<ul class="navbar-nav mr-auto mt-2 mt-lg-0">
<li class="nav-item">
<a href="/schedule" class="nav-link">Your Schedule (<span id="cart-counter"><%= @cart.length %></span>)</a>
</li>
</ul>
<form action="/search" class="form-inline">
<input
id="searchbar"
value="<%= params[:query] %>"
name="query"
type="text"
......@@ -47,14 +78,10 @@
placeholder="Search course or professor..."
aria-describedby="basic-addon2"
autocomplete="off"
>
<div class="input-group-append">
<button type="submit" class="btn btn-secondary" type="button">
<i class="fas fa-search"></i>
</button>
</div>
</div>
>
<button class="btn btn-secondary my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</div>
</div>
</nav>
<div class="container-fluid">
<div class="container">
<!-- The main screen consists of a row with two columns: the search results, and the cart -->
<div class="row">
<div id="page" class="row">
<!-- Search result, List of Courses -->
<div class="col-lg-8 col-12 col-sm-10 mx-auto order-2 order-lg-0" id="search-list">
<div class="col-lg-12 col-12 col-sm-12 mx-auto order-2 order-lg-0" id="search-list">
<%= yield %>
</div>
<!-- List of sections in the cart -->
</div>
<footer class="footer">
Schedules was built by <a href="https://srct.gmu.edu">Mason SRCT</a> and is completely open source.<br/>
Want to contribute? View the code on the <a href="https://git.gmu.edu/srct/schedules">SRCT GitLab</a>.
</footer>
</div>
<template id="cart-data" data-cart="<%= @cart.to_json %>"></template>
......@@ -24,6 +24,25 @@
TBA
<% else %>
<%= link_to section.instructor.name, section.instructor %>
<% unless section.instructor.rating.nil? %>
<div class="star-rating">
<div class="back-stars">
<i class="far fa-star" aria-hidden="true"></i>
<i class="far fa-star" aria-hidden="true"></i>
<i class="far fa-star" aria-hidden="true"></i>
<i class="far fa-star" aria-hidden="true"></i>
<i class="far fa-star" aria-hidden="true"></i>
<div class="front-stars" style="width: <%= (section.instructor.rating[0] / 5 * 100).to_i %>%">
<i class="fa fa-star" aria-hidden="true"></i>
<i class="fa fa-star" aria-hidden="true"></i>
<i class="fa fa-star" aria-hidden="true"></i>
<i class="fa fa-star" aria-hidden="true"></i>
<i class="fa fa-star" aria-hidden="true"></i>
</div>
</div>
</div>
<% end %>
<% end %>
<br/>
......
require 'json'
[['f18', 'Fall', '2018'], ['sp18', 'Spring', '2018'],
['f17', 'Fall', '2017'], ['sp17', 'Spring', '2017']].each do |arr|
puts arr
[['sp18', 'Spring', '2018'], ['sm18', 'Summer', '2018'], ['f18', 'Fall', '2018'],
['sp17', 'Spring', '2017'], ['sm17', 'Summer', '2017'], ['f17', 'Fall', '2017'],
['sp16', 'Spring', '2016'], ['sm16', 'Summer', '2016'], ['f16', 'Fall', '2016']].each do |arr|
ratings = JSON.parse(File.read("db/data/#{arr[0]}.json"))
semester = Semester.find_by!(season: arr[1], year: arr[2])
semester = Semester.find_by(season: arr[1], year: arr[2])
next if semester.nil?
puts "#{ratings[1]} #{ratings[2]}"
ratings.each do |section, qs|
section = section.split(',').first
subj = section.match(/[A-Z]+/)[0]
......
......@@ -118,7 +118,7 @@ def main
[parser.parse_semesters.first]
else
# expand to include however many semesters you want
parser.parse_semesters[0..7]
parser.parse_semesters[1..7]
end
puts "\tParsing subjects..."
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment