diff options
author | href <href@random.sh> | 2018-02-17 21:21:42 +0100 |
---|---|---|
committer | href <href@random.sh> | 2018-02-17 21:21:42 +0100 |
commit | 50c6a09ff64cb081b27a0c30790b86873449d172 (patch) | |
tree | ba1bebfc7e367f169276692e0ac02709d62d6516 /lib/lsg_web | |
parent | txt: fix against malicious filenames (aka 'fuck you shiv') (diff) |
:)
Diffstat (limited to 'lib/lsg_web')
-rw-r--r-- | lib/lsg_web/controllers/irc_controller.ex | 11 | ||||
-rw-r--r-- | lib/lsg_web/templates/irc/index.html.eex | 15 | ||||
-rw-r--r-- | lib/lsg_web/templates/irc/txt.html.eex | 2 | ||||
-rw-r--r-- | lib/lsg_web/templates/irc/txts.html.eex | 18 | ||||
-rw-r--r-- | lib/lsg_web/templates/layout/app.html.eex | 1 |
5 files changed, 40 insertions, 7 deletions
diff --git a/lib/lsg_web/controllers/irc_controller.ex b/lib/lsg_web/controllers/irc_controller.ex index a5a68f7..bff5476 100644 --- a/lib/lsg_web/controllers/irc_controller.ex +++ b/lib/lsg_web/controllers/irc_controller.ex @@ -2,9 +2,11 @@ defmodule LSGWeb.IrcController do use LSGWeb, :controller def index(conn, _) do + doc = LSG.IRC.TxtHandler.irc_doc() commands = for mod <- Application.get_env(:lsg, :irc)[:handlers] do mod.irc_doc() end + |> Enum.reject(fn(i) -> i == nil end) render conn, "index.html", commands: commands end @@ -12,13 +14,16 @@ defmodule LSGWeb.IrcController do def txt(conn, _), do: do_txt(conn, nil) defp do_txt(conn, nil) do - render conn, "txts.html", data: data() + doc = LSG.IRC.TxtHandler.irc_doc() + data = data() + lines = Enum.reduce(data, 0, fn({_, lines}, acc) -> acc + Enum.count(lines) end) + render conn, "txts.html", data: data, doc: doc, files: Enum.count(data), lines: lines end defp do_txt(conn, txt) do data = data() if Map.has_key?(data, txt) do - render(conn, "txt.html", name: txt, data: data[txt]) + render(conn, "txt.html", name: txt, data: data[txt], doc: nil) else conn |> put_status(404) @@ -26,7 +31,7 @@ defmodule LSGWeb.IrcController do end defp data() do - dir = Application.get_env(:lsg, LSG.IRC.TxtHandler)[:directory] + dir = Application.get_env(:lsg, :data_path) <> "/irc.txt/" Path.wildcard(dir <> "/*.txt") |> Enum.reduce(%{}, fn(path, m) -> path = String.split(path, "/") diff --git a/lib/lsg_web/templates/irc/index.html.eex b/lib/lsg_web/templates/irc/index.html.eex index 91873e6..c42d71f 100644 --- a/lib/lsg_web/templates/irc/index.html.eex +++ b/lib/lsg_web/templates/irc/index.html.eex @@ -1,7 +1,18 @@ -<h1>bot `115ans</h1> +<style type="text/css"> +h1 small { + font-size: 14px; +} +</style> + +<h1> + <small><a href="https://115ans.net">115ans.net</a> › </small><br/> +irc 115ans</h1> <p> -Si vous cherchez l'IRC c'est <a href="https://115ans.net/irc/">par là</a>. +Serveur IRC: <a href="irc://irc.quakenet.org/lsg">irc.quakenet.org #lsg</a>. + Matrix: <a href="https://matrix.random.sh/riot/#rooms/#lsg:random.sh">#lsg:random.sh</a>. +<br /> +<a href="https://115ans.net/irc/">Webchat</a>. <br /> <a href="/irc/stats/">Statistiques</a>. </p> diff --git a/lib/lsg_web/templates/irc/txt.html.eex b/lib/lsg_web/templates/irc/txt.html.eex index 4ffde50..e060e5f 100644 --- a/lib/lsg_web/templates/irc/txt.html.eex +++ b/lib/lsg_web/templates/irc/txt.html.eex @@ -8,7 +8,7 @@ ol li { </style> <h1> - <small><a href="/irc/txt">irc.txt</a>:</small><br/> + <small><a href="https://115ans.net">115ans.net</a> › <a href="/irc">irc</a> › <a href="/irc/txt">txt</a> ›</small><br/> <%= @name %>.txt</h1> <ol> diff --git a/lib/lsg_web/templates/irc/txts.html.eex b/lib/lsg_web/templates/irc/txts.html.eex index 7c96ed9..5039c29 100644 --- a/lib/lsg_web/templates/irc/txts.html.eex +++ b/lib/lsg_web/templates/irc/txts.html.eex @@ -1,4 +1,18 @@ -<h1>irc.txt</h1> +<style type="text/css"> +.help-entry h1 { + font-size: 18px; +} +.help-entry h2 { + font-size: 16px; +} +h1 small { + font-size: 14px; +} +</style> +<h1><small><a href="https://115ans.net">115ans.net</a> › <a href="/irc">irc</a> ›</small><br/> + txt</h1> + +<p><strong><%= @lines %></strong> lignes dans <strong><%= @files %></strong> fichiers.</p> <ul> <%= for {txt, data} <- @data do %> @@ -6,3 +20,5 @@ <% end %> </ul> +<div class="help-entry"><%= @doc |> Earmark.as_html! |> raw() %></div> + diff --git a/lib/lsg_web/templates/layout/app.html.eex b/lib/lsg_web/templates/layout/app.html.eex index 1c8f900..4c2ad44 100644 --- a/lib/lsg_web/templates/layout/app.html.eex +++ b/lib/lsg_web/templates/layout/app.html.eex @@ -2,6 +2,7 @@ <html lang="en"> <head> <meta charset="utf-8"> + <meta name="robots" content="noindex, nofollow, nosnippet"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="<%= static_path(@conn, "/assets/css/app.css") %>"> |