diff options
Diffstat (limited to 'lib/lsg_web/views')
-rw-r--r-- | lib/lsg_web/views/alcoolog_view.ex | 6 | ||||
-rw-r--r-- | lib/lsg_web/views/error_helpers.ex | 40 | ||||
-rw-r--r-- | lib/lsg_web/views/error_view.ex | 17 | ||||
-rw-r--r-- | lib/lsg_web/views/irc_view.ex | 3 | ||||
-rw-r--r-- | lib/lsg_web/views/layout_view.ex | 81 | ||||
-rw-r--r-- | lib/lsg_web/views/network_view.ex | 4 | ||||
-rw-r--r-- | lib/lsg_web/views/open_id_view.ex | 4 | ||||
-rw-r--r-- | lib/lsg_web/views/page_view.ex | 3 |
8 files changed, 0 insertions, 158 deletions
diff --git a/lib/lsg_web/views/alcoolog_view.ex b/lib/lsg_web/views/alcoolog_view.ex deleted file mode 100644 index ad52472..0000000 --- a/lib/lsg_web/views/alcoolog_view.ex +++ /dev/null @@ -1,6 +0,0 @@ -defmodule NolaWeb.AlcoologView do - use NolaWeb, :view - require Integer - -end - diff --git a/lib/lsg_web/views/error_helpers.ex b/lib/lsg_web/views/error_helpers.ex deleted file mode 100644 index 25214bd..0000000 --- a/lib/lsg_web/views/error_helpers.ex +++ /dev/null @@ -1,40 +0,0 @@ -defmodule NolaWeb.ErrorHelpers do - @moduledoc """ - Conveniences for translating and building error messages. - """ - - use Phoenix.HTML - - @doc """ - Generates tag for inlined form input errors. - """ - def error_tag(form, field) do - Enum.map(Keyword.get_values(form.errors, field), fn (error) -> - content_tag :span, translate_error(error), class: "help-block" - end) - end - - @doc """ - Translates an error message using gettext. - """ - def translate_error({msg, opts}) do - # Because error messages were defined within Ecto, we must - # call the Gettext module passing our Gettext backend. We - # also use the "errors" domain as translations are placed - # in the errors.po file. - # Ecto will pass the :count keyword if the error message is - # meant to be pluralized. - # On your own code and templates, depending on whether you - # need the message to be pluralized or not, this could be - # written simply as: - # - # dngettext "errors", "1 file", "%{count} files", count - # dgettext "errors", "is invalid" - # - if count = opts[:count] do - Gettext.dngettext(NolaWeb.Gettext, "errors", msg, msg, count, opts) - else - Gettext.dgettext(NolaWeb.Gettext, "errors", msg, opts) - end - end -end diff --git a/lib/lsg_web/views/error_view.ex b/lib/lsg_web/views/error_view.ex deleted file mode 100644 index 5cad939..0000000 --- a/lib/lsg_web/views/error_view.ex +++ /dev/null @@ -1,17 +0,0 @@ -defmodule NolaWeb.ErrorView do - use NolaWeb, :view - - def render("404.html", _assigns) do - "Page not found" - end - - def render("500.html", _assigns) do - "Internal server error" - end - - # In case no render clause matches or no - # template is found, let's render it as 500 - def template_not_found(_template, assigns) do - render "500.html", assigns - end -end diff --git a/lib/lsg_web/views/irc_view.ex b/lib/lsg_web/views/irc_view.ex deleted file mode 100644 index 331d91f..0000000 --- a/lib/lsg_web/views/irc_view.ex +++ /dev/null @@ -1,3 +0,0 @@ -defmodule NolaWeb.IrcView do - use NolaWeb, :view -end diff --git a/lib/lsg_web/views/layout_view.ex b/lib/lsg_web/views/layout_view.ex deleted file mode 100644 index 2bffc6f..0000000 --- a/lib/lsg_web/views/layout_view.ex +++ /dev/null @@ -1,81 +0,0 @@ -defmodule NolaWeb.LayoutView do - use NolaWeb, :view - - def liquid_markdown(conn, text) do - context_path = cond do - conn.assigns[:chan] -> "/#{conn.assigns[:network]}/#{NolaWeb.format_chan(conn.assigns[:chan])}" - conn.assigns[:network] -> "/#{conn.assigns[:network]}/-" - true -> "/-" - end - - {:ok, ast} = Liquex.parse(text) - context = Liquex.Context.new(%{ - "context_path" => context_path - }) - {content, _} = Liquex.render(ast, context) - content - |> to_string() - |> Earmark.as_html!() - |> raw() - end - - def page_title(conn) do - target = cond do - conn.assigns[:chan] -> - "#{conn.assigns.chan} @ #{conn.assigns.network}" - conn.assigns[:network] -> conn.assigns.network - true -> Keyword.get(Nola.name()) - end - - breadcrumb_title = Enum.map(Map.get(conn.assigns, :breadcrumbs)||[], fn({title, _href}) -> title end) - - title = [conn.assigns[:title], breadcrumb_title, target] - |> List.flatten() - |> Enum.uniq() - |> Enum.filter(fn(x) -> x end) - |> Enum.intersperse(" / ") - |> Enum.join() - - content_tag(:title, title) - end - - def format_time(date, with_relative \\ true) do - alias Timex.Format.DateTime.Formatters - alias Timex.Timezone - date = if is_integer(date) do - date - |> DateTime.from_unix!(:millisecond) - |> DateTime.shift_zone!("Europe/Paris", Tzdata.TimeZoneDatabase) - else - date - |> DateTime.shift_zone!("Europe/Paris", Tzdata.TimeZoneDatabase) - end - - now = DateTime.now!("Europe/Paris", Tzdata.TimeZoneDatabase) - - now_week = Timex.iso_week(now) - date_week = Timex.iso_week(date) - - {y, w} = now_week - now_last_week = {y, w-1} - now_last_roll = 7-Timex.days_to_beginning_of_week(now) - - date_date = DateTime.to_date(date) - now_date = DateTime.to_date(date) - - format = cond do - date.year != now.year -> "{D}/{M}/{YYYY} {h24}:{m}" - date_date == now_date -> "{h24}:{m}" - (now_week == date_week) || (date_week == now_last_week && (Date.day_of_week(date) >= now_last_roll)) -> "{WDfull} {h24}:{m}" - (now.year == date.year && now.month == date.month) -> "{WDfull} {D} {h24}:{m}" - true -> "{WDfull} {D} {M} {h24}:{m}" - end - - {:ok, relative} = Formatters.Relative.relative_to(date, Timex.now("Europe/Paris"), "{relative}", "fr") - {:ok, full} = Formatters.Default.lformat(date, "{WDfull} {D} {YYYY} {h24}:{m}", "fr") #"{h24}:{m} {WDfull} {D}", "fr") - {:ok, detail} = Formatters.Default.lformat(date, format, "fr") #"{h24}:{m} {WDfull} {D}", "fr") - - content_tag(:time, if(with_relative, do: relative, else: detail), [title: full]) - end - -end diff --git a/lib/lsg_web/views/network_view.ex b/lib/lsg_web/views/network_view.ex deleted file mode 100644 index 7a24db1..0000000 --- a/lib/lsg_web/views/network_view.ex +++ /dev/null @@ -1,4 +0,0 @@ -defmodule NolaWeb.NetworkView do - use NolaWeb, :view - -end diff --git a/lib/lsg_web/views/open_id_view.ex b/lib/lsg_web/views/open_id_view.ex deleted file mode 100644 index bd8089b..0000000 --- a/lib/lsg_web/views/open_id_view.ex +++ /dev/null @@ -1,4 +0,0 @@ -defmodule NolaWeb.OpenIdView do - use NolaWeb, :view - -end diff --git a/lib/lsg_web/views/page_view.ex b/lib/lsg_web/views/page_view.ex deleted file mode 100644 index 1bfaadd..0000000 --- a/lib/lsg_web/views/page_view.ex +++ /dev/null @@ -1,3 +0,0 @@ -defmodule NolaWeb.PageView do - use NolaWeb, :view -end |