From 2b4ec13c46932ef3bcd5ad7dccc96b941cbfe3bc Mon Sep 17 00:00:00 2001
From: ThorGuy <32145412+ThorGuy@users.noreply.github.com>
Date: Mon, 24 Aug 2020 19:47:44 -0400
Subject: [PATCH 1/4] Fix Issue 14
Issue: https://github.com/srct/schedules/issues/14
Fixed issue by doing the following:
When processing a CRN, add a hash to the url so that when the course page is loaded, the section with the CRN will be jumped to. (app/controllers/search_controller.rb)
Additionally, with CSS, highlight the target course with a green color (#afa) to signify that it is the desired course. (app/assets/stylesheets/application.scss)
Turbolink messes with the behaviour of anchors, so when the page is loaded, a script makes sure that the hash is acted upon. (app/views/courses/show.html)
---
schedules/app/assets/stylesheets/application.scss | 4 ++++
schedules/app/controllers/search_controller.rb | 4 +++-
schedules/app/views/courses/show.html.erb | 10 ++++++++++
3 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/schedules/app/assets/stylesheets/application.scss b/schedules/app/assets/stylesheets/application.scss
index e76b631..d62549a 100644
--- a/schedules/app/assets/stylesheets/application.scss
+++ b/schedules/app/assets/stylesheets/application.scss
@@ -288,3 +288,7 @@ footer {
top: 3%;
}
}
+
+:target {
+ background-color:#afa;
+}
diff --git a/schedules/app/controllers/search_controller.rb b/schedules/app/controllers/search_controller.rb
index 786e320..3f0e683 100644
--- a/schedules/app/controllers/search_controller.rb
+++ b/schedules/app/controllers/search_controller.rb
@@ -32,7 +32,9 @@ def index
end
/[0-9]{5}/.match(params[:query]) do |m|
- redirect_to(course_url(CourseSection.latest_by_crn(m[0]).course))
+ course = CourseSection.latest_by_crn(m[0])
+ url = course_url(course.course) + "#section-" + course.id.to_s
+ redirect_to(url)
end
if @courses&.count == 1 && @instructors&.count&.zero?
diff --git a/schedules/app/views/courses/show.html.erb b/schedules/app/views/courses/show.html.erb
index d1e4254..31c4041 100644
--- a/schedules/app/views/courses/show.html.erb
+++ b/schedules/app/views/courses/show.html.erb
@@ -1,5 +1,15 @@
<%= render partial: 'shared/navbar' %>
+
+
<%= @course.full_name %>
From f6d6506ee95c5c4b597fb124b89f7faa2af7fffc Mon Sep 17 00:00:00 2001
From: ThorGuy <32145412+ThorGuy@users.noreply.github.com>
Date: Mon, 24 Aug 2020 21:31:35 -0400
Subject: [PATCH 2/4] Fixed master css
file got messed up during merge, just downloaded the original again and added my lines back
---
.../app/assets/stylesheets/application.scss | 111 ++++++++++++++++++
1 file changed, 111 insertions(+)
diff --git a/schedules/app/assets/stylesheets/application.scss b/schedules/app/assets/stylesheets/application.scss
index d62549a..0a27f8a 100644
--- a/schedules/app/assets/stylesheets/application.scss
+++ b/schedules/app/assets/stylesheets/application.scss
@@ -20,6 +20,11 @@ $gold: #febf10;
$green: #01693f;
$blue: #297dc5;
+$black: #212529;
+$white: #F5F5F5;
+$lightgreen: #3CD650;
+$lightgray: #b6b6b6;
+
* {
font-family: 'Roboto', sans-serif;
}
@@ -291,4 +296,110 @@ footer {
:target {
background-color:#afa;
+
+/* DARK MODE STYLING */
+@media (prefers-color-scheme: dark) {
+ * {
+ color: $white;
+ background-color: $black;
+ }
+
+ body {
+ background-color: $black;
+ }
+
+ form {
+ background-color: $white;
+ * {
+ color: #000000;
+ background-color: $white;
+ }
+ }
+
+ nav > span:first-child a {
+ color: $white;
+ }
+
+ a {
+ color: $lightgreen;
+
+ /* Could look somewhat better; feel free to change. */
+ &:hover {
+ color: $green;
+ }
+
+ /* I think it would look better somewhere between $green and $lightgreen,
+ but am going to leave it as is for simplity's sake. Feel free to change. */
+ &.cart {
+ background-color: $green;
+ & > i.fa-shopping-cart {
+ background-color: $green;
+ }
+ }
+ }
+
+ li.section-item {
+ background-color: $black;
+ border-color: $white;
+ }
+
+ section.instructor {
+ box-shadow: 0 3px 5px -2px $white;
+ }
+
+ section.course {
+ box-shadow: 0 3px 5px -2px $white;
+ h4 a {
+ color: $lightgreen;
+ }
+ h5 em {
+ color: $white;
+ }
+ span.description {
+ color: $lightgray;
+ }
+ a.see-more {
+ color: $lightgreen;
+ }
+ }
+
+ div.back-stars {
+ i {
+ color: $white;
+ }
+ div.front-stars i {
+ color: $gold;
+ }
+ }
+
+ div#exportModal {
+ background-color: rgba(0, 0, 0, 0);
+ div.modal-header {
+ border-bottom: 1px solid $gray;
+ }
+ hr {
+ background-color: $gray;
+ }
+ div.modal-footer {
+ border-top: 1px solid $gray;
+ }
+ }
+
+ /* This does nothing.
+ I can't seem to find a way to edit these given the current HTML structure.
+ If possible, I think that it would look more pleasing to make the background
+ of the pop-up $white and the text contained inside of it $black, as it currently
+ mixes in with the rest of the all-$black screen.
+ */
+ /*select.semester-select {
+ color: blue;
+ background-color: red;
+ & > select {
+ color: $green;
+ }
+ }*/
+
+ :target{
+ background-color: $lightgreen;
+ }
}
From 0817d0e8b00663f61b7113ffe1e1af3414bfdb8c Mon Sep 17 00:00:00 2001
From: ThorGuy <32145412+ThorGuy@users.noreply.github.com>
Date: Mon, 24 Aug 2020 21:32:30 -0400
Subject: [PATCH 3/4] Lines didn't get removed for some reason
---
schedules/app/assets/stylesheets/application.scss | 2 --
1 file changed, 2 deletions(-)
diff --git a/schedules/app/assets/stylesheets/application.scss b/schedules/app/assets/stylesheets/application.scss
index 0a27f8a..543ad22 100644
--- a/schedules/app/assets/stylesheets/application.scss
+++ b/schedules/app/assets/stylesheets/application.scss
@@ -294,8 +294,6 @@ footer {
}
}
-:target {
- background-color:#afa;
/* DARK MODE STYLING */
@media (prefers-color-scheme: dark) {
From 3e9f1cef863d88a109b76713d38f5016666c5c3b Mon Sep 17 00:00:00 2001
From: ThorGuy <32145412+ThorGuy@users.noreply.github.com>
Date: Mon, 24 Aug 2020 22:55:12 -0400
Subject: [PATCH 4/4] Fixed page constantly refreshing when not searching by
CRN
When not using the CRN to search for a course, window.location.hash is not set, causing the page to reload when updating window.location
---
schedules/app/views/courses/show.html.erb | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/schedules/app/views/courses/show.html.erb b/schedules/app/views/courses/show.html.erb
index 1c8c97d..745f532 100644
--- a/schedules/app/views/courses/show.html.erb
+++ b/schedules/app/views/courses/show.html.erb
@@ -6,7 +6,9 @@
//this prevented issue 14 from being resolved (https://github.com/srct/schedules/issues/14)
//the following script forces the page to update both the CSS and the window's location *after* turbolinks does its thing.
document.addEventListener("turbolinks:load", function(){
- window.location = window.location.hash;
+ if(window.location.hash){
+ window.location = window.location.hash;
+ }
});