mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-30 14:57:59 +01:00
don't recode tag slugs, fixes #18
This commit is contained in:
parent
912e64559b
commit
ecfe60bcaa
7 changed files with 1 additions and 25 deletions
|
@ -5,8 +5,6 @@ defmodule PhilomenaWeb.Api.Json.TagController do
|
||||||
alias Philomena.Repo
|
alias Philomena.Repo
|
||||||
import Ecto.Query
|
import Ecto.Query
|
||||||
|
|
||||||
plug PhilomenaWeb.RecodeParameterPlug, [name: "id"] when action in [:show]
|
|
||||||
|
|
||||||
def show(conn, %{"id" => slug}) do
|
def show(conn, %{"id" => slug}) do
|
||||||
tag =
|
tag =
|
||||||
Tag
|
Tag
|
||||||
|
|
|
@ -7,7 +7,6 @@ defmodule PhilomenaWeb.Filter.HideController do
|
||||||
plug PhilomenaWeb.FilterBannedUsersPlug
|
plug PhilomenaWeb.FilterBannedUsersPlug
|
||||||
plug :authorize_filter
|
plug :authorize_filter
|
||||||
|
|
||||||
plug PhilomenaWeb.RecodeParameterPlug, name: "tag"
|
|
||||||
plug :load_resource, model: Tag, id_field: "slug", id_name: "tag", persisted: true
|
plug :load_resource, model: Tag, id_field: "slug", id_name: "tag", persisted: true
|
||||||
|
|
||||||
def create(conn, _params) do
|
def create(conn, _params) do
|
||||||
|
|
|
@ -7,7 +7,6 @@ defmodule PhilomenaWeb.Filter.SpoilerController do
|
||||||
plug PhilomenaWeb.FilterBannedUsersPlug
|
plug PhilomenaWeb.FilterBannedUsersPlug
|
||||||
plug :authorize_filter
|
plug :authorize_filter
|
||||||
|
|
||||||
plug PhilomenaWeb.RecodeParameterPlug, name: "tag"
|
|
||||||
plug :load_resource, model: Tag, id_field: "slug", id_name: "tag", persisted: true
|
plug :load_resource, model: Tag, id_field: "slug", id_name: "tag", persisted: true
|
||||||
|
|
||||||
def create(conn, _params) do
|
def create(conn, _params) do
|
||||||
|
|
|
@ -4,7 +4,6 @@ defmodule PhilomenaWeb.Tag.WatchController do
|
||||||
alias Philomena.Tags.Tag
|
alias Philomena.Tags.Tag
|
||||||
alias Philomena.Users
|
alias Philomena.Users
|
||||||
|
|
||||||
plug PhilomenaWeb.RecodeParameterPlug, name: "tag_id"
|
|
||||||
plug :load_resource, model: Tag, id_field: "slug", id_name: "tag_id", persisted: true
|
plug :load_resource, model: Tag, id_field: "slug", id_name: "tag_id", persisted: true
|
||||||
|
|
||||||
def create(conn, _params) do
|
def create(conn, _params) do
|
||||||
|
|
|
@ -9,7 +9,6 @@ defmodule PhilomenaWeb.TagController do
|
||||||
alias Philomena.Interactions
|
alias Philomena.Interactions
|
||||||
import Ecto.Query
|
import Ecto.Query
|
||||||
|
|
||||||
plug PhilomenaWeb.RecodeParameterPlug, [name: "id"] when action in [:show]
|
|
||||||
plug PhilomenaWeb.CanaryMapPlug, update: :edit
|
plug PhilomenaWeb.CanaryMapPlug, update: :edit
|
||||||
|
|
||||||
plug :load_and_authorize_resource,
|
plug :load_and_authorize_resource,
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
defmodule PhilomenaWeb.RecodeParameterPlug do
|
|
||||||
def init(opts), do: opts
|
|
||||||
|
|
||||||
def call(conn, name: name) do
|
|
||||||
fixed_value =
|
|
||||||
conn
|
|
||||||
|> Map.get(:params)
|
|
||||||
|> Map.get(name)
|
|
||||||
|> to_string()
|
|
||||||
|> URI.encode_www_form()
|
|
||||||
|> String.replace("%2B", "+")
|
|
||||||
|> String.replace("%25", "%")
|
|
||||||
|
|
||||||
params = Map.put(conn.params, name, fixed_value)
|
|
||||||
|
|
||||||
%{conn | params: params}
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -10,7 +10,7 @@ span.tag.dropdown data-tag-category="#{@tag.category}" data-tag-id="#{@tag.id}"
|
||||||
span.tag__state.hidden title="Hidden"
|
span.tag__state.hidden title="Hidden"
|
||||||
| H
|
| H
|
||||||
|
|
||||||
a.tag__name< href="/tags/#{@tag.slug}" title="#{@tag.short_description}" = @tag.name
|
a.tag__name< href=Routes.tag_path(@conn, :show, @tag) title="#{@tag.short_description}" = @tag.name
|
||||||
|
|
||||||
div.dropdown__content
|
div.dropdown__content
|
||||||
a.tag__dropdown__link.hidden data-method="delete" data-remote="true" data-tag-action="unwatch" href=Routes.tag_watch_path(@conn, :delete, @tag) Unwatch
|
a.tag__dropdown__link.hidden data-method="delete" data-remote="true" data-tag-action="unwatch" href=Routes.tag_watch_path(@conn, :delete, @tag) Unwatch
|
||||||
|
|
Loading…
Reference in a new issue