~mlb/linkhut

6872e1ad6d80ad8d4b4081864d7d72707e580c12 — Matías Larre Borges 15 days ago 90bace5
Fix formatting and refactor a couple of minor things
M lib/linkhut/application.ex => lib/linkhut/application.ex +1 -1
@@ 19,7 19,7 @@ defmodule Linkhut.Application do
      # Start genserver to store transient metrics
      {LinkhutWeb.MetricsStorage, LinkhutWeb.Telemetry.metrics()},
      # Start the endpoint when the application starts
      LinkhutWeb.Endpoint,
      LinkhutWeb.Endpoint
      # Starts a worker by calling: Linkhut.Worker.start_link(arg)
      # {Linkhut.Worker, arg},
    ]

M lib/linkhut/pagination.ex => lib/linkhut/pagination.ex +1 -1
@@ 26,7 26,7 @@ defmodule Linkhut.Pagination do
      Repo.one(from t in (query |> exclude(:preload) |> subquery()), select: count("*"))

    num_pages = ceil(total_count / per_page)
    has_next = (num_pages - 1) > page
    has_next = num_pages - 1 > page
    has_prev = page > 0

    %Page{

M lib/linkhut/prom_ex.ex => lib/linkhut/prom_ex.ex +1 -1
@@ 63,7 63,7 @@ defmodule Linkhut.PromEx do
      Plugins.Application,
      Plugins.Beam,
      {Plugins.Phoenix, router: LinkhutWeb.Router, endpoint: LinkhutWeb.Endpoint},
      {Plugins.Ecto, otp_app: :linkhut, repos: [Linkhut.Repo]},
      {Plugins.Ecto, otp_app: :linkhut, repos: [Linkhut.Repo]}

      # Add your own PromEx metrics plugins
      # Linkhut.Users.PromExPlugin

M lib/linkhut_web/controllers/api/ifttt/errors.ex => lib/linkhut_web/controllers/api/ifttt/errors.ex +1 -2
@@ 13,14 13,13 @@ defmodule LinkhutWeb.Api.IFTTT.Errors do

    defp error_message(errors) do
      errors
      |> Enum.map(fn
      |> Enum.map_join(". ", fn
        {field, errors} ->
          "#{Phoenix.Naming.humanize(field)}: #{Enum.join(errors, ", ")}"

        error ->
          error
      end)
      |> Enum.join(". ")
    end
  end
end

M lib/linkhut_web/controllers/link_controller.ex => lib/linkhut_web/controllers/link_controller.ex +3 -1
@@ 272,7 272,9 @@ defmodule LinkhutWeb.LinkController do
  end

  defp context(%{"tags" => tags}),
    do: %Context{tagged_with: Enum.uniq_by(tags, &String.downcase/1) |> Enum.map(&URI.decode_www_form/1)}
    do: %Context{
      tagged_with: Enum.uniq_by(tags, &String.downcase/1) |> Enum.map(&URI.decode_www_form/1)
    }

  defp context(%{"username" => username}), do: %Context{from: Accounts.get_user!(username)}
  defp context(%{"url" => url}), do: %Context{url: URI.decode(url)}

M lib/linkhut_web/controllers/settings/oauth_controller.ex => lib/linkhut_web/controllers/settings/oauth_controller.ex +7 -2
@@ 67,7 67,9 @@ defmodule LinkhutWeb.Settings.OauthController do
  end

  def new_application(conn, _) do
    render(conn, "oauth/application/new.html", changeset: Oauth.change_application(%Application{}))
    render(conn, "oauth/application/new.html",
      changeset: Oauth.change_application(%Application{})
    )
  end

  def create_application(conn, %{"application" => application_params}) do


@@ 114,7 116,10 @@ defmodule LinkhutWeb.Settings.OauthController do
        |> redirect(to: Routes.oauth_path(conn, :show))

      {:error, %Ecto.Changeset{} = changeset} ->
        render(conn, "oauth/application/edit.html", changeset: changeset, application: application)
        render(conn, "oauth/application/edit.html",
          changeset: changeset,
          application: application
        )
    end
  end


M lib/linkhut_web/templates/link/_bookmark.html.heex => lib/linkhut_web/templates/link/_bookmark.html.heex +2 -2
@@ 6,7 6,7 @@
        <span class="no-css-label"><%= gettext("Private") %></span>
      <% end %>
      <%= if @context.url == nil and not (@link.is_private or @link.is_unread) and @link.saves > 1 do %>
        <a class="savers" data-count={@link.saves} data-label={gettext("people")} href={Routes.bookmark_path(@conn, :show, @link.url)}></a>
        <a class="savers" data-count={@link.saves} data-label={gettext("people")} href={html_path(@scope, url: @link.url)}></a>
      <% end %>
    </div>
    <div class="full-url">


@@ 26,7 26,7 @@
      </span>
      <%= if @context.url == nil and not (@link.is_private) and @link.saves > 1 do %>
        <span class="savers">
          <%= gettext("saved") %> <a href={Routes.bookmark_path(@conn, :show, @link.url)}><%= @link.saves %></a> <%= ngettext("time", "times", @link.saves) %>
          <%= gettext("saved") %> <a href={html_path(@scope, url: @link.url)}><%= @link.saves %></a> <%= ngettext("time", "times", @link.saves) %>
        </span>
      <% end %>
    </div>