7dd2adc13a694996b1db0b1011bb29acbd3549c3 — HokieGeek a month ago a8de10b v1.6.0
Added colors to the Rating column in the HTML page as a finishing touch
2 files changed, 33 insertions(+), 2 deletions(-)

M scraper.go
M serve.go
M scraper.go => scraper.go +1 -1
@@ 106,7 106,7 @@ Rating:      Rating(rating),
  					GradeLevels: strings.Split(strings.Replace(gradeLevels, " ", "", -1), ","),
  					Subjects:    strings.Split(strings.Replace(subjects, " ", "", -1), ","),
- 					Description: desc,
+ 					Description: strings.Replace(desc, " |", "", -1),
  					URL:         link,
  				}
  				mu.Lock()

M serve.go => serve.go +32 -1
@@ 20,6 20,22 @@ tr:nth-child(even) {
  			background-color: #c0c0c0;
  		}
+ 
+ 		.ratingNotSecular {
+ 			background-color: #f54646;
+ 		}
+ 		.ratingNeutral {
+ 			background-color: #f9ac63;
+ 		}
+ 		.ratingMostlySecular {
+ 			background-color: #ecec58;
+ 		}
+ 		.ratingSecular {
+ 			background-color: #d0f172;
+ 		}
+ 		.ratingSuperSecular {
+ 			background-color: #60bd60;
+ 		}
  		</style>
  	</head>
  	<body>


@@ 43,7 59,7 @@ {{else}}
  					<td>{{.Name}}</td>
  					{{end}}
- 					<td>{{.Rating}}</td>
+ 					<td class="{{.Rating | ratingClass}}">{{.Rating}}</td>
  					<td>{{join .GradeLevels}}</td>
  					<td>{{joinbr .Subjects}}</td>
  					<td>{{.Description}}</td>


@@ 64,6 80,21 @@ "joinbr": func(v []string) template.HTML {
  				return template.HTML(strings.Join(v, "<br />"))
  			},
+ 			"ratingClass": func(v Rating) string {
+ 				switch v {
+ 				case RatingNotSecular:
+ 					return "ratingNotSecular"
+ 				case RatingNeutral:
+ 					return "ratingNeutral"
+ 				case RatingMostlySecular:
+ 					return "ratingMostlySecular"
+ 				case RatingSecular:
+ 					return "ratingSecular"
+ 				case RatingSuperSecular:
+ 					return "ratingSuperSecular"
+ 				}
+ 				return ""
+ 			},
  		}).Parse(pageTmpl))
  	if err := t.Execute(w, db); err != nil {
  		return fmt.Errorf("could not generate page: %v", err)