feat: Add a way to hide sureddits in the overview
This commit is contained in:
parent
e11e13f913
commit
478a328042
7 changed files with 54 additions and 24 deletions
|
@ -5,7 +5,8 @@ config :bdfr_browser,
|
||||||
chat_directory: System.get_env("BDFR_BROWSER_CHAT_DIRECTORY", "/nonexistant"),
|
chat_directory: System.get_env("BDFR_BROWSER_CHAT_DIRECTORY", "/nonexistant"),
|
||||||
watch_directories: System.get_env("BDFR_BROWSER_WATCH_DIRECTORIES", "true"),
|
watch_directories: System.get_env("BDFR_BROWSER_WATCH_DIRECTORIES", "true"),
|
||||||
http_ip: to_charlist(System.get_env("BDFR_BROWSER_HTTP_IP", "127.0.0.1")),
|
http_ip: to_charlist(System.get_env("BDFR_BROWSER_HTTP_IP", "127.0.0.1")),
|
||||||
http_port: String.to_integer(System.get_env("BDFR_BROWSER_HTTP_PORT", "4040"))
|
http_port: String.to_integer(System.get_env("BDFR_BROWSER_HTTP_PORT", "4040")),
|
||||||
|
config_file: YamlElixir.read_from_file!(System.fetch_env!("BDFR_BROWSER_CONFIG_FILE"))
|
||||||
|
|
||||||
config :bdfr_browser, BdfrBrowser.Repo,
|
config :bdfr_browser, BdfrBrowser.Repo,
|
||||||
database: System.get_env("BDFR_BROWSER_REPO_DATABASE", "postgres"),
|
database: System.get_env("BDFR_BROWSER_REPO_DATABASE", "postgres"),
|
||||||
|
|
|
@ -7,7 +7,10 @@ defmodule BdfrBrowser.HTTP.Plug do
|
||||||
plug :dispatch
|
plug :dispatch
|
||||||
|
|
||||||
get "/" do
|
get "/" do
|
||||||
tpl_args = [subreddits: Subreddit.names() |> Repo.all()]
|
config_file = Application.fetch_env!(:bdfr_browser, :config_file)
|
||||||
|
hidden_subreddits = config_file["hidden_subreddits"]
|
||||||
|
|
||||||
|
tpl_args = [subreddits: Subreddit.names_without(hidden_subreddits) |> Repo.all()]
|
||||||
content = render_template("index", tpl_args)
|
content = render_template("index", tpl_args)
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|
|
|
@ -14,4 +14,8 @@ defmodule BdfrBrowser.Subreddit do
|
||||||
def names do
|
def names do
|
||||||
from(s in __MODULE__, select: s.name, order_by: [asc: fragment("lower(?)", s.name)])
|
from(s in __MODULE__, select: s.name, order_by: [asc: fragment("lower(?)", s.name)])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
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)])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
1
mix.exs
1
mix.exs
|
@ -24,6 +24,7 @@ defmodule BdfrBrowser.MixProject do
|
||||||
{:ecto_sql, "~> 3.10"},
|
{:ecto_sql, "~> 3.10"},
|
||||||
{:postgrex, "~> 0.17"},
|
{:postgrex, "~> 0.17"},
|
||||||
{:jason, "~> 1.4"},
|
{:jason, "~> 1.4"},
|
||||||
|
{:yaml_elixir, "~> 2.9"},
|
||||||
{:earmark, "~> 1.4"},
|
{:earmark, "~> 1.4"},
|
||||||
{:file_system, "~> 0.2.10"},
|
{:file_system, "~> 0.2.10"},
|
||||||
{:typed_struct, "~> 0.3.0", runtime: false}
|
{:typed_struct, "~> 0.3.0", runtime: false}
|
||||||
|
|
2
mix.lock
2
mix.lock
|
@ -18,4 +18,6 @@
|
||||||
"ranch": {:hex, :ranch, "1.8.0", "8c7a100a139fd57f17327b6413e4167ac559fbc04ca7448e9be9057311597a1d", [:make, :rebar3], [], "hexpm", "49fbcfd3682fab1f5d109351b61257676da1a2fdbe295904176d5e521a2ddfe5"},
|
"ranch": {:hex, :ranch, "1.8.0", "8c7a100a139fd57f17327b6413e4167ac559fbc04ca7448e9be9057311597a1d", [:make, :rebar3], [], "hexpm", "49fbcfd3682fab1f5d109351b61257676da1a2fdbe295904176d5e521a2ddfe5"},
|
||||||
"telemetry": {:hex, :telemetry, "1.2.1", "68fdfe8d8f05a8428483a97d7aab2f268aaff24b49e0f599faa091f1d4e7f61c", [:rebar3], [], "hexpm", "dad9ce9d8effc621708f99eac538ef1cbe05d6a874dd741de2e689c47feafed5"},
|
"telemetry": {:hex, :telemetry, "1.2.1", "68fdfe8d8f05a8428483a97d7aab2f268aaff24b49e0f599faa091f1d4e7f61c", [:rebar3], [], "hexpm", "dad9ce9d8effc621708f99eac538ef1cbe05d6a874dd741de2e689c47feafed5"},
|
||||||
"typed_struct": {:hex, :typed_struct, "0.3.0", "939789e3c1dca39d7170c87f729127469d1315dcf99fee8e152bb774b17e7ff7", [:mix], [], "hexpm", "c50bd5c3a61fe4e198a8504f939be3d3c85903b382bde4865579bc23111d1b6d"},
|
"typed_struct": {:hex, :typed_struct, "0.3.0", "939789e3c1dca39d7170c87f729127469d1315dcf99fee8e152bb774b17e7ff7", [:mix], [], "hexpm", "c50bd5c3a61fe4e198a8504f939be3d3c85903b382bde4865579bc23111d1b6d"},
|
||||||
|
"yamerl": {:hex, :yamerl, "0.10.0", "4ff81fee2f1f6a46f1700c0d880b24d193ddb74bd14ef42cb0bcf46e81ef2f8e", [:rebar3], [], "hexpm", "346adb2963f1051dc837a2364e4acf6eb7d80097c0f53cbdc3046ec8ec4b4e6e"},
|
||||||
|
"yaml_elixir": {:hex, :yaml_elixir, "2.9.0", "9a256da867b37b8d2c1ffd5d9de373a4fda77a32a45b452f1708508ba7bbcb53", [:mix], [{:yamerl, "~> 0.10", [hex: :yamerl, repo: "hexpm", optional: false]}], "hexpm", "0cb0e7d4c56f5e99a6253ed1a670ed0e39c13fc45a6da054033928607ac08dfc"},
|
||||||
}
|
}
|
||||||
|
|
59
mix.nix
59
mix.nix
|
@ -1,13 +1,10 @@
|
||||||
{ pkgs, lib, beamPackages, overrides ? (x: y: { }) }:
|
{ lib, beamPackages, overrides ? (x: y: {}) }:
|
||||||
|
|
||||||
let
|
let
|
||||||
buildRebar3 = lib.makeOverridable beamPackages.buildRebar3;
|
buildRebar3 = lib.makeOverridable beamPackages.buildRebar3;
|
||||||
buildMix = lib.makeOverridable beamPackages.buildMix;
|
buildMix = lib.makeOverridable beamPackages.buildMix;
|
||||||
buildErlangMk = lib.makeOverridable beamPackages.buildErlangMk;
|
buildErlangMk = lib.makeOverridable beamPackages.buildErlangMk;
|
||||||
|
|
||||||
inherit (pkgs.stdenv) isDarwin;
|
|
||||||
inherit (pkgs.stdenv) isLinux;
|
|
||||||
|
|
||||||
self = packages // (overrides self packages);
|
self = packages // (overrides self packages);
|
||||||
|
|
||||||
packages = with beamPackages; with self; {
|
packages = with beamPackages; with self; {
|
||||||
|
@ -47,7 +44,7 @@ let
|
||||||
sha256 = "1c4dgi8canscyjgddp22mjc69znvwy44wk3r7jrl2wvs6vv76fqn";
|
sha256 = "1c4dgi8canscyjgddp22mjc69znvwy44wk3r7jrl2wvs6vv76fqn";
|
||||||
};
|
};
|
||||||
|
|
||||||
beamDeps = [ ];
|
beamDeps = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
db_connection = buildMix rec {
|
db_connection = buildMix rec {
|
||||||
|
@ -73,7 +70,7 @@ let
|
||||||
sha256 = "1k7z418b6cj977wswpxsk5844xrxc1smaiqsmrqpf3pdjzsfbksk";
|
sha256 = "1k7z418b6cj977wswpxsk5844xrxc1smaiqsmrqpf3pdjzsfbksk";
|
||||||
};
|
};
|
||||||
|
|
||||||
beamDeps = [ ];
|
beamDeps = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
earmark = buildMix rec {
|
earmark = buildMix rec {
|
||||||
|
@ -99,7 +96,7 @@ let
|
||||||
sha256 = "13qvlqnii8g6bcz6cl330vjwaan7jy30g1app3yvjncvf8rnhlid";
|
sha256 = "13qvlqnii8g6bcz6cl330vjwaan7jy30g1app3yvjncvf8rnhlid";
|
||||||
};
|
};
|
||||||
|
|
||||||
beamDeps = [ ];
|
beamDeps = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
ecto = buildMix rec {
|
ecto = buildMix rec {
|
||||||
|
@ -138,14 +135,7 @@ let
|
||||||
sha256 = "1p0myxmnjjds8bbg69dd6fvhk8q3n7lb78zd4qvmjajnzgdmw6a1";
|
sha256 = "1p0myxmnjjds8bbg69dd6fvhk8q3n7lb78zd4qvmjajnzgdmw6a1";
|
||||||
};
|
};
|
||||||
|
|
||||||
buildInputs = [ ] ++ lib.optionals isDarwin (with pkgs.darwin.apple_sdk.frameworks; [
|
beamDeps = [];
|
||||||
CoreFoundation
|
|
||||||
CoreServices
|
|
||||||
]) ++ lib.optionals isLinux (with pkgs; [
|
|
||||||
inotify-tools
|
|
||||||
]);
|
|
||||||
|
|
||||||
beamDeps = [ ];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
jason = buildMix rec {
|
jason = buildMix rec {
|
||||||
|
@ -171,7 +161,7 @@ let
|
||||||
sha256 = "0p50h0ki8ay5sraiqxiajgwy1829bvyagj65bj9wjny4cnin83fs";
|
sha256 = "0p50h0ki8ay5sraiqxiajgwy1829bvyagj65bj9wjny4cnin83fs";
|
||||||
};
|
};
|
||||||
|
|
||||||
beamDeps = [ ];
|
beamDeps = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
plug = buildMix rec {
|
plug = buildMix rec {
|
||||||
|
@ -210,7 +200,7 @@ let
|
||||||
sha256 = "0hnqgzc3zas7j7wycgnkkdhaji5farkqccy2n4p1gqj5ccfrlm16";
|
sha256 = "0hnqgzc3zas7j7wycgnkkdhaji5farkqccy2n4p1gqj5ccfrlm16";
|
||||||
};
|
};
|
||||||
|
|
||||||
beamDeps = [ ];
|
beamDeps = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
postgrex = buildMix rec {
|
postgrex = buildMix rec {
|
||||||
|
@ -236,7 +226,7 @@ let
|
||||||
sha256 = "1rfz5ld54pkd2w25jadyznia2vb7aw9bclck21fizargd39wzys9";
|
sha256 = "1rfz5ld54pkd2w25jadyznia2vb7aw9bclck21fizargd39wzys9";
|
||||||
};
|
};
|
||||||
|
|
||||||
beamDeps = [ ];
|
beamDeps = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
telemetry = buildRebar3 rec {
|
telemetry = buildRebar3 rec {
|
||||||
|
@ -249,7 +239,7 @@ let
|
||||||
sha256 = "1mgyx9zw92g6w8fp9pblm3b0bghwxwwcbslrixq23ipzisfwxnfs";
|
sha256 = "1mgyx9zw92g6w8fp9pblm3b0bghwxwwcbslrixq23ipzisfwxnfs";
|
||||||
};
|
};
|
||||||
|
|
||||||
beamDeps = [ ];
|
beamDeps = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
typed_struct = buildMix rec {
|
typed_struct = buildMix rec {
|
||||||
|
@ -262,9 +252,34 @@ let
|
||||||
sha256 = "0v8v3l8j7g3ran3f9gc2nc1mkj6kwfdr6kshm2cf3r0zlv1xa2y5";
|
sha256 = "0v8v3l8j7g3ran3f9gc2nc1mkj6kwfdr6kshm2cf3r0zlv1xa2y5";
|
||||||
};
|
};
|
||||||
|
|
||||||
beamDeps = [ ];
|
beamDeps = [];
|
||||||
|
};
|
||||||
|
|
||||||
|
yamerl = buildRebar3 rec {
|
||||||
|
name = "yamerl";
|
||||||
|
version = "0.10.0";
|
||||||
|
|
||||||
|
src = fetchHex {
|
||||||
|
pkg = "${name}";
|
||||||
|
version = "${version}";
|
||||||
|
sha256 = "0vjf9gnchvh4qfykrxf0jw0didvfrx54wdm26z41s1gicclxnsil";
|
||||||
|
};
|
||||||
|
|
||||||
|
beamDeps = [];
|
||||||
|
};
|
||||||
|
|
||||||
|
yaml_elixir = buildMix rec {
|
||||||
|
name = "yaml_elixir";
|
||||||
|
version = "2.9.0";
|
||||||
|
|
||||||
|
src = fetchHex {
|
||||||
|
pkg = "${name}";
|
||||||
|
version = "${version}";
|
||||||
|
sha256 = "1z4dq1x60a1r0daa0vasqhzw2f8fxmqadl9y4nk9jpkgqpafgc0c";
|
||||||
|
};
|
||||||
|
|
||||||
|
beamDeps = [ yamerl ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in
|
in self
|
||||||
self
|
|
||||||
|
|
||||||
|
|
4
priv/config.yml
Normal file
4
priv/config.yml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
hidden_subreddits:
|
||||||
|
- foo
|
||||||
|
- bar
|
Reference in a new issue