diff options
author | href <href@random.sh> | 2020-07-07 21:39:10 +0200 |
---|---|---|
committer | href <href@random.sh> | 2020-07-07 21:39:51 +0200 |
commit | d6ee134a5957e299c3ad59011df320b3c41e6e61 (patch) | |
tree | 29567e6635466f8a3415a935b3cc8a777019f5bc /lib/lsg_web/templates | |
parent | bleh (diff) |
pouet
Diffstat (limited to 'lib/lsg_web/templates')
-rw-r--r-- | lib/lsg_web/templates/alcoolog/auth.html.eex | 39 | ||||
-rw-r--r-- | lib/lsg_web/templates/alcoolog/index.html.eex | 61 | ||||
-rw-r--r-- | lib/lsg_web/templates/irc/index.html.eex | 30 | ||||
-rw-r--r-- | lib/lsg_web/templates/irc/txt.html.eex | 7 | ||||
-rw-r--r-- | lib/lsg_web/templates/irc/txts.html.eex | 14 | ||||
-rw-r--r-- | lib/lsg_web/templates/layout/app.html.eex | 16 | ||||
-rw-r--r-- | lib/lsg_web/templates/network/index.html.eex | 1 | ||||
-rw-r--r-- | lib/lsg_web/templates/page/user.html.eex | 38 |
8 files changed, 141 insertions, 65 deletions
diff --git a/lib/lsg_web/templates/alcoolog/auth.html.eex b/lib/lsg_web/templates/alcoolog/auth.html.eex new file mode 100644 index 0000000..af6db53 --- /dev/null +++ b/lib/lsg_web/templates/alcoolog/auth.html.eex @@ -0,0 +1,39 @@ +<h1>authentication</h1> + +<div id="authenticator"> + <p> + <%= if @bot, do: "Send this to #{@bot} on #{@network}:", else: "Find your bot nickname and send:" %><br /><br /> + <strong>/msg <%= @bot || "the-bot-nickname" %> web</strong> + <br /><br /> + ... then come back to this address. + </p> +</div> + +<script type="text/javascript"> + var authSse = new EventSource("/api/irc-auth.sse?redirect_to=" + window.location.pathname); + authSse.addEventListener("token", function(event) { + html = "<%= if @bot, do: "Send this to #{@bot} on #{@network}:", else: "Find your bot nickname and send:" %><br /><br /><strong>/msg <%= @bot || "the-bot-nickname" %> "+event.data+"</strong>"; + elem = document.getElementById("authenticator"); + elem.innerHTML = html; + }); + authSse.addEventListener("authenticated", function(event) { + elem = document.getElementById("authenticator"); + elem.innerHTML = "<strong>success, redirecting...</strong>"; + window.keepInner = true; + window.location.pathname = event.data; + }); + authSse.addEventListener("expire", function(event) { + elem = document.getElementById("authenticator"); + elem.innerHTML = "<strong>authentication expired</strong>"; + window.keepInner = true; + }); + authSse.onerror = function() { + authSse.close(); + if (!window.keepInner) { + elem = document.getElementById("authenticator"); + elem.innerHTML = "<strong>server closed connection :(</strong>"; + } + }; + +</script> + diff --git a/lib/lsg_web/templates/alcoolog/index.html.eex b/lib/lsg_web/templates/alcoolog/index.html.eex index 507be71..e656e64 100644 --- a/lib/lsg_web/templates/alcoolog/index.html.eex +++ b/lib/lsg_web/templates/alcoolog/index.html.eex @@ -1,16 +1,12 @@ <style type="text/css"> -h1 small { - font-size: 14px; -} ol li { margin-bottom: 5px } </style> -<h1> - <small><a href="/irc"><%= Keyword.get(Application.get_env(:lsg, :irc), :name, "ircbot") %></a> › </small><br/> - alcoolog <%= @channel %> -</h1> +<%= if @stats == [] do %> + </strong><i>:o personne ne boit</i></strong> +<% end %> <ul> <%= for {nick, status} <- @stats do %> @@ -28,28 +24,35 @@ ol li { <% end %> </ul> -<p> - top consommateur par volume, les 7 derniers jours: <%= Enum.intersperse(for({nick, count} <- @top, do: "#{nick}: #{Float.round(count,4)}"), ", ") %> -</p> +<%= if @stats == %{} do %> + <strong><i>... et personne n'a bu :o :o :o</i></strong> +<% else %> + <p> + top consommateur par volume, les 7 derniers jours: <%= Enum.intersperse(for({nick, count} <- @top, do: "#{nick}: #{Float.round(count,4)}"), ", ") %> + </p> -<table class="table"> - <thead> - <tr> - <th scope="col">date</th> - <th scope="col">nick</th> - <th scope="col">points</th> - <th scope="col">nom</th> - </tr> - </thead> - <tbody> - <%= for {{nick, date}, points, _, nom, comment} <- @drinks do %> - <% date = DateTime.from_unix!(date, :millisecond) %> - <th scope="row"><%= LSGWeb.LayoutView.format_time(date, false) %></th> - <td><%= nick %></td> - <td><%= Float.round(points+0.0, 5) %></td> - <td><%= nom||"" %> <%= comment||"" %></td> + <table class="table"> + <thead> + <tr> + <th scope="col">date</th> + <th scope="col">nick</th> + <th scope="col">points</th> + <th scope="col">nom</th> </tr> - <% end %> - </tbody> -</table> + </thead> + <tbody> + <%= for {{{account, date}, points, _, nom, comment}, nick} <- @drinks do %> + <% date = DateTime.from_unix!(date, :millisecond) %> + <th scope="row"><%= LSGWeb.LayoutView.format_time(date, false) %></th> + <td><%= nick %></td> + <td><%= Float.round(points+0.0, 5) %></td> + <td><%= nom||"" %> <%= comment||"" %></td> + </tr> + <% end %> + </tbody> + </table> +<% end %> +<%= if @conn.assigns.account && (@network || @channel) do %> + <%= link("alcoolog global", to: alcoolog_path(@conn, :index)) %> +<% end %> diff --git a/lib/lsg_web/templates/irc/index.html.eex b/lib/lsg_web/templates/irc/index.html.eex index f127101..9e4f724 100644 --- a/lib/lsg_web/templates/irc/index.html.eex +++ b/lib/lsg_web/templates/irc/index.html.eex @@ -1,23 +1,4 @@ <style type="text/css"> -h1 small { - font-size: 14px; -} -</style> - -<h1><%= Keyword.get(Application.get_env(:lsg, :irc), :name, "ircbot") %></h1> - -<!--<p> -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>. -</del> -</p>--> - - -<style type="text/css"> .help-entry h1 { font-size: 18px; } @@ -29,15 +10,22 @@ Serveur IRC: <a href="irc://irc.quakenet.org/lsg">irc.quakenet.org #lsg</a>. <p> <% list = for {identifier, _} <- @commands do %> <% name = String.replace(identifier, "_", " ") %> - <%= link(name, to: "##{identifier}") #raw("<a href='##{identifier}'>#{name}</a>") %> + <%= link(name, to: "##{identifier}") %> <% end %> <small><%= Enum.intersperse(list, " - ") %></small> </p> +<%= if @members != [] do %> +<% users = for {_acc, user, nick} <- @members, do: if(user, do: nick, else: content_tag(:i, nick)) %> +<%= for u <- Enum.intersperse(users, ", ") do %> + <%= u %> +<% end %> +<% end %> + <div class="irchelps"> <%= for {identifier, help} <- @commands do %> <%= if help do %> - <div class="help-entry" id="<%= identifier %>"><%= help |> Earmark.as_html! |> raw() %></div> + <div class="help-entry" id="<%= identifier %>"><%= LSGWeb.LayoutView.liquid_markdown(@conn, help) %></div> <% end %> <% end %> </div> diff --git a/lib/lsg_web/templates/irc/txt.html.eex b/lib/lsg_web/templates/irc/txt.html.eex index 5b31320..e9df681 100644 --- a/lib/lsg_web/templates/irc/txt.html.eex +++ b/lib/lsg_web/templates/irc/txt.html.eex @@ -1,16 +1,9 @@ <style type="text/css"> -h1 small { - font-size: 14px; -} ol li { margin-bottom: 5px } </style> -<h1> - <small><a href="/irc"><%= Keyword.get(Application.get_env(:lsg, :irc), :name, "ircbot") %></a> › <a href="/irc/txt">txt</a> ›</small><br/> - <%= @name %>.txt</h1> - <ol> <%= for {txt, id} <- Enum.with_index(@data) do %> <li id="<%= @name %>-<%= id %>"><%= txt %></li> diff --git a/lib/lsg_web/templates/irc/txts.html.eex b/lib/lsg_web/templates/irc/txts.html.eex index 28d0220..5971ffa 100644 --- a/lib/lsg_web/templates/irc/txts.html.eex +++ b/lib/lsg_web/templates/irc/txts.html.eex @@ -5,13 +5,7 @@ .help-entry h2 { font-size: 16px; } -h1 small { - font-size: 14px; -} </style> -<h1> - <small><a href="/irc"><%= Keyword.get(Application.get_env(:lsg, :irc), :name, "ircbot") %></a> › </small><br/> - txt</h1> <p><strong><%= @lines %></strong> lignes dans <strong><%= @files %></strong> fichiers. <a href="#help">Aide</a>. @@ -19,9 +13,13 @@ h1 small { <ul> <%= for {txt, data} <- @data do %> - <li><a href="/irc/txt/<%= txt %>"><%= txt %></a> <i>(<%= Enum.count(data) %>)</i></li> + <% base_url = cond do + @conn.assigns[:chan] -> "/#{@conn.assigns.network}/#{LSGWeb.format_chan(@conn.assigns.chan)}" + true -> "/-" + end %> + <li><a href="<%= base_url %>/txt/<%= txt %>"><%= txt %></a> <i>(<%= Enum.count(data) %>)</i></li> <% end %> </ul> -<div class="help-entry" id="help"><%= @doc |> Earmark.as_html! |> raw() %></div> +<div class="help-entry" id="help"><%= LSGWeb.LayoutView.liquid_markdown(@conn, @doc) %></div> diff --git a/lib/lsg_web/templates/layout/app.html.eex b/lib/lsg_web/templates/layout/app.html.eex index 4c2ad44..1871e8b 100644 --- a/lib/lsg_web/templates/layout/app.html.eex +++ b/lib/lsg_web/templates/layout/app.html.eex @@ -1,16 +1,32 @@ <!DOCTYPE html> <html lang="en"> <head> + <%= page_title(@conn) %> <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"> + <meta name="robots" content="noindex, noarchive, nofollow, nosnippet" /> + <title><%= Map.get(assigns, :title, "") %></title> <link rel="stylesheet" href="<%= static_path(@conn, "/assets/css/app.css") %>"> </head> <body> <div class="container"> <main role="main"> + <%= if !@conn.assigns[:no_header] do %> + <h1> + <small style="font-size: 14px;"> + <a href="/"><%= Keyword.get(Application.get_env(:lsg, :irc), :name, "ircbot") %></a> + <%= if @conn.assigns[:account], do: @conn.assigns.account.name %> + › + <%= if n = @conn.assigns[:network] do %><a href="/<%= n %>"><%= n %></a> › <% end %> + <%= if c = @conn.assigns[:chan] do %><a href="/<%= @conn.assigns.network %>/<%= LSGWeb.format_chan(c) %>"><%= c %></a> › <% end %> + <%= for({name, href} <- @conn.assigns[:breadcrumbs]||[], do: [link(name, to: href), raw(" › ")]) %> + </small><br /> + <%= @conn.assigns[:title] || @conn.assigns[:chan] || @conn.assigns[:network] %> + </h1> + <% end %> <%= render @view_module, @view_template, assigns %> </main> </div> diff --git a/lib/lsg_web/templates/network/index.html.eex b/lib/lsg_web/templates/network/index.html.eex new file mode 100644 index 0000000..fc024dd --- /dev/null +++ b/lib/lsg_web/templates/network/index.html.eex @@ -0,0 +1 @@ +pouet diff --git a/lib/lsg_web/templates/page/user.html.eex b/lib/lsg_web/templates/page/user.html.eex new file mode 100644 index 0000000..8a043a0 --- /dev/null +++ b/lib/lsg_web/templates/page/user.html.eex @@ -0,0 +1,38 @@ +<ul> + <li><%= link("Help", to: "/-") %></li> +</ul> + +<h2>channels</h2> +<ul> + <%= for {net, channel} <- @memberships do %> + <li> + <% url = LSGWeb.Router.Helpers.irc_path(LSGWeb.Endpoint, :index, net, LSGWeb.format_chan(channel)) %> + <%= link([net, ": ", content_tag(:strong, channel)], to: url) %> + </li> + <% end %> +</ul> + +<h2>connections</h2> +<ul> + <%= for user <- @users do %> + <li> + <strong><%= user.network %></strong>: <strong><%= user.nick %></strong>!<%= user.username %>@<%= user.host %> <i><%= user.realname %></i><br /> + <%= Enum.join(Enum.intersperse(Enum.map(user.privileges, fn({c, _}) -> c end), ", ")) %> + </li> + <% end %> +</ul> + +<h2>account</h2> +<ul> + <li>account-id: <%= @conn.assigns.account.id %></li> + <%= for {k, v} <- @metas do %> + <li><%= k %>: <%= to_string(v) %></li> + <% end %> +</ul> + +<strong>irc auths:</strong> +<ul> + <%= for {net, {predicate, v}} <- @predicates do %> + <li><%= net %>: <%= to_string(predicate) %>, <%= v %></li> + <% end %> +</ul> |