Skip to content

Commit

Permalink
Fix admin styles for comment suggestions.
Browse files Browse the repository at this point in the history
  • Loading branch information
knadh committed Jun 19, 2022
1 parent b5a48c5 commit 21318f7
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion admin/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</div>
<nav class="eight columns nav">
<a href="" @click.prevent="onNewEntry">Add new</a>
<a href="pending">Pending</a>
<a href="/admin/pending">Pending</a>
</nav>
</div>
</header>
Expand Down
2 changes: 1 addition & 1 deletion admin/pending.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ <h3>
</p>
<template x-if="`${e.id}-${r.id}` in comments" x-data="{ c: comments[`${e.id}-${r.id}`]}">
<div class="comments">
<div x-text="c.comments"></div>
<pre x-text="c.comments"></pre>
<button class="button-outline button-small" @click.prevent="onClearComments(c.id)">Clear</button>
</div>
</template>
Expand Down
3 changes: 3 additions & 0 deletions admin/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,12 @@ function searchResultsComponent(typ) {
this.api('entries.search', '/entries/comments').then((data) => {
let out = {};

const r = new RegExp("\n+", "gm");

// Create a from_id-to_id lookup map that can be used in
// the UI to show comments.
data.forEach((d) => {
d.comments = d.comments.replace(r, "\n");
if (d.to_id) {
out[`${d.from_id}-${d.to_id}`] = d;
} else {
Expand Down
3 changes: 3 additions & 0 deletions admin/static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ form .help {
padding: 15px;
margin: 10px 0 10px 30px;
}
.entries .comments pre {
margin: 0 0 15px 0;
}
.entries .meta {
font-weight: normal;
color: var(--light);
Expand Down
4 changes: 4 additions & 0 deletions cmd/dictpress/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ func handleNewComments(c echo.Context) error {
return echo.NewHTTPError(http.StatusBadRequest, "Invalid `from_guid`.")
}

if len(s.Comments) > 1000 {
return echo.NewHTTPError(http.StatusBadRequest, "Comments are too big.")
}

if err := app.data.InsertComments(s.FromGUID, s.ToGUID, s.Comments); err != nil {
app.logger.Printf("error inserting change submission: %v", err)
return echo.NewHTTPError(http.StatusInternalServerError,
Expand Down
1 change: 0 additions & 1 deletion site/static/logo.svg

This file was deleted.

0 comments on commit 21318f7

Please sign in to comment.