Compare commits
3 commits
e0107a3d81
...
5397833935
Author | SHA1 | Date | |
---|---|---|---|
5397833935 | |||
71fb71ddb9 | |||
a19c4f6a36 |
8 changed files with 43 additions and 14 deletions
18
flake.lock
18
flake.lock
|
@ -21,11 +21,11 @@
|
||||||
"nixpkgs-lib": "nixpkgs-lib"
|
"nixpkgs-lib": "nixpkgs-lib"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1693611461,
|
"lastModified": 1696343447,
|
||||||
"narHash": "sha256-aPODl8vAgGQ0ZYFIRisxYG5MOGSkIczvu2Cd8Gb9+1Y=",
|
"narHash": "sha256-B2xAZKLkkeRFG5XcHHSXXcP7To9Xzr59KXeZiRf4vdQ=",
|
||||||
"owner": "hercules-ci",
|
"owner": "hercules-ci",
|
||||||
"repo": "flake-parts",
|
"repo": "flake-parts",
|
||||||
"rev": "7f53fdb7bdc5bb237da7fefef12d099e4fd611ca",
|
"rev": "c9afaba3dfa4085dbd2ccb38dfade5141e33d9d4",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -89,11 +89,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1696009558,
|
"lastModified": 1696419054,
|
||||||
"narHash": "sha256-/1nNL8lCF0gn38XaFyu2ufpWcBFwCDZyYUxdZkM6GxU=",
|
"narHash": "sha256-EdR+dIKCfqL3voZUDYwcvgRDOektQB9KbhBVcE0/3Mo=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "c182df2e68bd97deb32c7e4765adfbbbcaf75b60",
|
"rev": "7131f3c223a2d799568e4b278380cd9dac2b8579",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -106,11 +106,11 @@
|
||||||
"nixpkgs-lib": {
|
"nixpkgs-lib": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"dir": "lib",
|
"dir": "lib",
|
||||||
"lastModified": 1693471703,
|
"lastModified": 1696019113,
|
||||||
"narHash": "sha256-0l03ZBL8P1P6z8MaSDS/MvuU8E75rVxe5eE1N6gxeTo=",
|
"narHash": "sha256-X3+DKYWJm93DRSdC5M6K5hLqzSya9BjibtBsuARoPco=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "3e52e76b70d5508f3cec70b882a29199f4d1ee85",
|
"rev": "f5892ddac112a1e9b3612c39af1b72987ee5783a",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
@ -28,6 +28,7 @@ defmodule BdfrBrowser.Comment do
|
||||||
join: p in assoc(c, :post),
|
join: p in assoc(c, :post),
|
||||||
join: s in assoc(p, :subreddit),
|
join: s in assoc(p, :subreddit),
|
||||||
select: %{
|
select: %{
|
||||||
|
id: c.id,
|
||||||
body: c.body,
|
body: c.body,
|
||||||
children: [],
|
children: [],
|
||||||
posted_at: c.posted_at,
|
posted_at: c.posted_at,
|
||||||
|
@ -51,6 +52,7 @@ defmodule BdfrBrowser.Comment do
|
||||||
join: p in assoc(c, :post),
|
join: p in assoc(c, :post),
|
||||||
join: s in assoc(p, :subreddit),
|
join: s in assoc(p, :subreddit),
|
||||||
select: %{
|
select: %{
|
||||||
|
id: c.id,
|
||||||
author: c.author,
|
author: c.author,
|
||||||
body: c.body,
|
body: c.body,
|
||||||
children: [],
|
children: [],
|
||||||
|
@ -73,6 +75,7 @@ defmodule BdfrBrowser.Comment do
|
||||||
join: p in assoc(c, :post),
|
join: p in assoc(c, :post),
|
||||||
join: s in assoc(p, :subreddit),
|
join: s in assoc(p, :subreddit),
|
||||||
select: %{
|
select: %{
|
||||||
|
id: c.id,
|
||||||
author: c.author,
|
author: c.author,
|
||||||
body: c.body,
|
body: c.body,
|
||||||
children: [],
|
children: [],
|
||||||
|
|
|
@ -44,7 +44,8 @@ defmodule BdfrBrowser.HTTP.Plug do
|
||||||
|
|
||||||
tpl_args = [
|
tpl_args = [
|
||||||
subreddit: subreddit,
|
subreddit: subreddit,
|
||||||
dates: subreddit_record |> Post.date_listing() |> Repo.all()
|
dates: subreddit_record |> Post.date_listing() |> Repo.all(),
|
||||||
|
statistics: subreddit |> Subreddit.statistics() |> Repo.all()
|
||||||
]
|
]
|
||||||
|
|
||||||
content = render_template("subreddit", tpl_args)
|
content = render_template("subreddit", tpl_args)
|
||||||
|
@ -94,7 +95,8 @@ defmodule BdfrBrowser.HTTP.Plug do
|
||||||
|
|
||||||
tpl_args = [
|
tpl_args = [
|
||||||
subreddit: subreddit_names,
|
subreddit: subreddit_names,
|
||||||
dates: subreddit_records |> Post.date_listing() |> Repo.all()
|
dates: subreddit_records |> Post.date_listing() |> Repo.all(),
|
||||||
|
statistics: subreddit_names |> Subreddit.statistics() |> Repo.all()
|
||||||
]
|
]
|
||||||
|
|
||||||
content = render_template("subreddit", tpl_args)
|
content = render_template("subreddit", tpl_args)
|
||||||
|
|
|
@ -22,4 +22,16 @@ defmodule BdfrBrowser.Subreddit do
|
||||||
def names_without(hidden) do
|
def names_without(hidden) do
|
||||||
from(s in __MODULE__, select: s.name, where: s.name not in ^hidden, order_by: [asc: fragment("lower(?)", s.name)])
|
from(s in __MODULE__, select: s.name, where: s.name not in ^hidden, order_by: [asc: fragment("lower(?)", s.name)])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def statistics(subreddit) when is_binary(subreddit), do: statistics([subreddit])
|
||||||
|
|
||||||
|
def statistics(subreddits) when is_list(subreddits) do
|
||||||
|
from(s in __MODULE__,
|
||||||
|
join: p in assoc(s, :posts),
|
||||||
|
left_join: c in assoc(p, :comments),
|
||||||
|
select: {s.name, count(p.id), count(c.id)},
|
||||||
|
where: s.name in ^subreddits,
|
||||||
|
group_by: [s.name]
|
||||||
|
)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<div style="padding-left: <%= level * 5 %>px; margin-bottom: 2px;">
|
<div style="padding-left: <%= level * 5 %>px; margin-bottom: 2px;" id="cmt-<%= comment.id %>">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body" style="padding: 8px;">
|
<div class="card-body" style="padding: 8px;">
|
||||||
<blockquote class="blockquote mb-0" style="font-size: 1rem;">
|
<blockquote class="blockquote mb-0" style="font-size: 1rem;">
|
||||||
|
|
|
@ -54,7 +54,9 @@
|
||||||
|
|
||||||
<footer class="blockquote-footer">
|
<footer class="blockquote-footer">
|
||||||
<%= BdfrBrowser.RenderUtils.link_to_user(comment.author) %>,
|
<%= BdfrBrowser.RenderUtils.link_to_user(comment.author) %>,
|
||||||
<a href="/r/<%= comment.subreddit %>/<%= comment.post_date %>/<%= comment.post_id %>"><%= comment.post_title %></a>,
|
<a href="/r/<%= comment.subreddit %>/<%= comment.post_date %>/<%= comment.post_id %>#cmt-<%= comment.id %>">
|
||||||
|
<%= comment.post_title %>
|
||||||
|
</a>,
|
||||||
<a href="/r/<%= comment.subreddit %>/<%= comment.post_date %>/"><%= comment.subreddit %></a>,
|
<a href="/r/<%= comment.subreddit %>/<%= comment.post_date %>/"><%= comment.subreddit %></a>,
|
||||||
<small><%= DateTime.to_iso8601(comment.posted_at) %></small>
|
<small><%= DateTime.to_iso8601(comment.posted_at) %></small>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
|
@ -49,4 +49,12 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="d-grid gap-2 col-12 mx-auto">
|
||||||
|
<p class="text-secondary">
|
||||||
|
<%= for {name, post_count, comment_count} <- statistics do %>
|
||||||
|
<%= name %>: <%= post_count %> Posts; <%= comment_count %> Comments<br />
|
||||||
|
<% end %>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -59,7 +59,9 @@
|
||||||
<%= BdfrBrowser.RenderUtils.comment(comment.body) %>
|
<%= BdfrBrowser.RenderUtils.comment(comment.body) %>
|
||||||
|
|
||||||
<footer class="blockquote-footer">
|
<footer class="blockquote-footer">
|
||||||
<a href="/r/<%= comment.subreddit %>/<%= comment.post_date %>/<%= comment.post_id %>"><%= comment.post_title %></a>,
|
<a href="/r/<%= comment.subreddit %>/<%= comment.post_date %>/<%= comment.post_id %>#cmt-<%= comment.id %>">
|
||||||
|
<%= comment.post_title %>
|
||||||
|
</a>,
|
||||||
<a href="/r/<%= comment.subreddit %>/<%= comment.post_date %>/"><%= comment.subreddit %></a>,
|
<a href="/r/<%= comment.subreddit %>/<%= comment.post_date %>/"><%= comment.subreddit %></a>,
|
||||||
<small><%= DateTime.to_iso8601(comment.posted_at) %></small>
|
<small><%= DateTime.to_iso8601(comment.posted_at) %></small>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
Reference in a new issue