Skip to content

Commit

Permalink
Merge pull request #280 from a0eoc/fixes1110
Browse files Browse the repository at this point in the history
Some updates and fixes
  • Loading branch information
vednoc authored May 2, 2024
2 parents 6011def + 3ea3097 commit 2399807
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 13 deletions.
5 changes: 4 additions & 1 deletion handlers/style/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ func CreatePost(c *fiber.Ctx) error {
}
c.Locals("Style", s)

// Get previewURL
preview := c.FormValue("previewURL")
c.Locals("PreviewURL", preview)

m, err := s.Validate(validator.V, true)
if err != nil {
c.Locals("err", m)
Expand Down Expand Up @@ -82,7 +86,6 @@ func CreatePost(c *fiber.Ctx) error {

// Check preview image.
file, _ := c.FormFile("preview")
preview := c.FormValue("previewURL")
styleID := strconv.FormatUint(uint64(s.ID), 10)
if file != nil || preview != "" {
if err = images.Generate(file, styleID, "0", "", preview); err != nil {
Expand Down
15 changes: 9 additions & 6 deletions handlers/style/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,18 @@ func ImportPost(c *fiber.Ctx) error {
s.MirrorCode = c.FormValue("mirrorCode") == "on"
s.MirrorMeta = c.FormValue("mirrorMeta") == "on"

// Get previewURL
preview := c.FormValue("previewURL", s.Preview)

m, err := s.Validate(validator.V, true)
if err != nil {
return c.Render("style/import", fiber.Map{
"Title": "Import userstyle",
"User": u,
"Style": s,
"err": m,
"Error": "Incorrect userstyle data was entered. Please review the fields bellow.",
"Title": "Import userstyle",
"User": u,
"Style": s,
"PreviewURL": preview,
"err": m,
"Error": "Incorrect userstyle data was entered. Please review the fields bellow.",
})
}

Expand Down Expand Up @@ -140,7 +144,6 @@ func ImportPost(c *fiber.Ctx) error {

// Check preview image.
file, _ := c.FormFile("preview")
preview := c.FormValue("previewURL", s.Preview)
styleID := strconv.FormatUint(uint64(s.ID), 10)
if file != nil || preview != "" {
if err := images.Generate(file, styleID, "0", "", preview); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion web/views/core/dashboard.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
{{ if or .DailyHistory .TotalHiistory .UserHistory .StyleHistory }}
<section class="history">
<h2 class="td:d">History</h2>
<p>Learn more about style statistics <a href="/docs/faq#how-do-view-install-update-statistics-work">in the FAQ</a>.</p>
<p>Learn more about style statistics <a href="/docs/faq#how-do-viewinstallupdate-statistics-work">in the FAQ</a>.</p>
{{ if not (or .DailyHistory .TotalHistory) }}
<i>No style history. Come back in a couple of days.</i>
{{ end }}
Expand Down
2 changes: 1 addition & 1 deletion web/views/core/search.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
</ul>
<ul class="List-unstyled">
<li><a href="/search?q=ChatGPT">ChatGPT</a></li>
<li><a href="/search?category=Gmail">Gmail</a></li>
<li><a href="/search?q=Gmail">Gmail</a></li>
<li><a href="/search?q=Google+Docs">Google Docs</a></li>
<li><a href="/search?category=Roblox">Roblox</a></li>
<li><a href="/search?q=Lichess">Lichess</a></li>
Expand Down
2 changes: 1 addition & 1 deletion web/views/style/add.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<input
type="url" name="previewURL" id="previewURL"
aria-describedby="previewURL-hint"
value="{{ .Style.Preview }}"
value="{{ .PreviewURL }}"
placeholder="Link to userstyle's preview image (jpg, jpeg, png, avif, and webp formats only)">

<label for="preview">Upload preview image</label>
Expand Down
2 changes: 1 addition & 1 deletion web/views/style/import.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<input
type="url" name="previewURL" id="previewURL"
aria-describedby="previewURL-hint"
value="{{ .Style.Preview }}"
value="{{ .PreviewURL }}"
placeholder="Link to userstyle's preview image (jpg, jpeg, png, avif, and webp formats only)">

<label for="preview">Upload preview image</label>
Expand Down
4 changes: 2 additions & 2 deletions web/views/style/view.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@

<section id="stats">
<h2 class="td:d">Statistics</h2>
<p class="mb:s">Learn how we calculate statistics <a href="/docs/faq#how-do-view-install-update-statistics-work">in the FAQ</a>.</p>
<p class="mb:s">Learn how we calculate statistics <a href="/docs/faq#how-do-viewinstallupdate-statistics-work">in the FAQ</a>.</p>
{{ with .Stats }}
<p class="total-views"><span class="minw">Total views</span>{{ .TotalViews }}</p>
<p class="total-installs"><span class="minw">Total installs</span>{{ .TotalInstalls }}</p>
Expand Down Expand Up @@ -194,7 +194,7 @@
{{/*
<section class="history">
<h2 class="td:d">History</h2>
<p>Daily snapshots of <a href="/docs/faq#how-do-view-install-update-statistics-work">style statistics</a>.</p>
<p>Daily snapshots of <a href="/docs/faq#how-do-viewinstallupdate-statistics-work">style statistics</a>.</p>
{{ if not (or .DailyHistory .TotalHistory) }}
<i>No style history. Come back in a couple of days.</i>
{{ end }}
Expand Down

0 comments on commit 2399807

Please sign in to comment.