-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7791743
commit 3d0a4b2
Showing
54 changed files
with
332 additions
and
364 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
package scraper | ||
package main | ||
|
||
import ( | ||
"context" | ||
|
||
scraper "github.com/salt-today/salttoday2/pkg/scraper/internal" | ||
"github.com/salt-today/salttoday2/internal/scraper" | ||
) | ||
|
||
func Main() { | ||
func main() { | ||
scraper.ScrapeAndStoreArticles(context.Background()) | ||
|
||
scraper.ScrapeAndStoreComments(context.Background()) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
pkg/server/internal/handlers/handler.go → internal/server/handlers/handler.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package components | ||
|
||
import "fmt" | ||
import "github.com/salt-today/salttoday2/internal/store" | ||
|
||
func getGradient(comment *store.Comment) string { | ||
if comment.Likes+comment.Dislikes == 0 { | ||
return "bg-gray-500" | ||
} | ||
if comment.Likes == 0 { | ||
return "bg-red-600" | ||
} | ||
if comment.Dislikes == 0 { | ||
return "bg-blue-600" | ||
} | ||
return fmt.Sprintf("bg-gradient-to-br from-blue-600 to-red-600 from-%d%% to-%d%%", | ||
max(0, | ||
int((float64(comment.Likes)/float64(comment.Likes+comment.Dislikes))*100)/5*5), | ||
min(100, | ||
int((float64(comment.Likes)/float64(comment.Likes+comment.Dislikes))*100-5)/5*5), | ||
) | ||
|
||
} | ||
|
||
func max(x, y int) int { | ||
if x > y { | ||
return x | ||
} | ||
return y | ||
} | ||
|
||
func min(x, y int) int { | ||
if x > y { | ||
return y | ||
} | ||
return x | ||
} | ||
|
||
templ CommentComponent(comment *store.Comment) { | ||
<div class=""> | ||
<div> | ||
<a href={ templ.URL(comment.Article.Url) }>{ comment.Article.Title }</a> | ||
</div> | ||
<div class={ fmt.Sprintf(`flex flex-col p-2 rounded %s`, getGradient(comment)) }> | ||
<div class=" flex flex-col p-3 bg-gray-200 text-black rounded"> | ||
<span>{ comment.Text }</span> | ||
<span>👍 { fmt.Sprintf("%d", comment.Likes) } 👎 { fmt.Sprintf("%d", comment.Dislikes) }</span> | ||
</div> | ||
</div> | ||
<div class="w-half flex flex-row max-width"> | ||
<div><a href={ templ.URL(fmt.Sprintf(" /user/%d", comment.User.ID)) }>- { comment.User.UserName }</a></div> | ||
if comment.Deleted { | ||
<div class="px-3 text-right font-bold text-red-600">DELETED</div> | ||
} | ||
</div> | ||
</div> | ||
} |
2 changes: 1 addition & 1 deletion
2
...nternal/ui/components/comments_form.templ → .../server/ui/components/comments_form.templ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 24 additions & 24 deletions
48
...rnal/ui/components/comments_form_templ.go → ...rver/ui/components/comments_form_templ.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...nternal/ui/components/comments_list.templ → .../server/ui/components/comments_list.templ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.