Skip to content

Commit

Permalink
Grades configuration (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
demostanis committed Oct 13, 2020
1 parent b3cd0dc commit f4aea29
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func index(c echo.Context) error {
"Blacklist": blacklist,
},
"GradeComment": grade.Comment(randInstance.Html.Grade),
"Grades": grade.Grades(),
})
} else {
return c.Render(http.StatusTooEarly, "index.html", map[string]bool{
Expand Down
9 changes: 9 additions & 0 deletions pkg/grade/grade.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
package grade

func Grades() []map[string]interface{} {
return []map[string]interface{}{
{ "Symbol": "V", "Id": "grade-v", },
{ "Symbol": "C", "Id": "grade-c", },
{ "Symbol": "Cjs", "Id": "grade-cjs", },
{ "Symbol": "E", "Id": "grade-e", },
}
}

func Comment(grade string) string {
switch grade {
case "V":
Expand Down
11 changes: 7 additions & 4 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,14 @@ <h3>Configuration panel</h3>

<label for="blacklist">Blacklist <small>(separated by semicolons)</small></label><br />
<textarea name="blacklist">{{range .OptionsSelected.Blacklist}}
{{.}} ;
{{else}}
{{.}} ;{{else}}
https://unwanted.instance.com/ ;
*://another.unwanted.instance.cn/
{{end}}</textarea><br />
*://another.unwanted.instance.cn/{{end}}</textarea><br /><br />

<label for="grades">Grades: </label>
{{range .Grades}}
<input type="checkbox" name="{{.Id}}">{{.Symbol}}
{{end}}

<input type="submit" value="Save">
</form>
Expand Down

0 comments on commit f4aea29

Please sign in to comment.