From f6c8d57bdfb4657342d5ce4a00896134d33201e2 Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Tue, 9 Feb 2021 17:37:54 -0500 Subject: [PATCH] fix autocomplete and fetch controller paths --- assets/js/booru.js | 2 +- .../tag_controller.ex} | 2 +- .../{tag/fetch_controller.ex => fetch/tag_controller.ex} | 2 +- lib/philomena_web/router.ex | 8 +++++--- .../templates/profile/artist_link/_form.html.slime | 2 +- lib/philomena_web/templates/tag/_tag_editor.html.slime | 2 +- 6 files changed, 10 insertions(+), 8 deletions(-) rename lib/philomena_web/controllers/{tag/autocomplete_controller.ex => autocomplete/tag_controller.ex} (95%) rename lib/philomena_web/controllers/{tag/fetch_controller.ex => fetch/tag_controller.ex} (94%) diff --git a/assets/js/booru.js b/assets/js/booru.js index e6884dd0..6d9f4942 100644 --- a/assets/js/booru.js +++ b/assets/js/booru.js @@ -44,7 +44,7 @@ function fetchAndPersistTags(tagIds) { const ids = tagIds.slice(0, 40); const remaining = tagIds.slice(41); - fetch(`/tags/fetch?ids[]=${ids.join('&ids[]=')}`) + fetch(`/fetch/tags?ids[]=${ids.join('&ids[]=')}`) .then(response => response.json()) .then(data => data.tags.forEach(tag => persistTag(tag))) .then(() => fetchAndPersistTags(remaining)); diff --git a/lib/philomena_web/controllers/tag/autocomplete_controller.ex b/lib/philomena_web/controllers/autocomplete/tag_controller.ex similarity index 95% rename from lib/philomena_web/controllers/tag/autocomplete_controller.ex rename to lib/philomena_web/controllers/autocomplete/tag_controller.ex index be0ce1ac..5cffa509 100644 --- a/lib/philomena_web/controllers/tag/autocomplete_controller.ex +++ b/lib/philomena_web/controllers/autocomplete/tag_controller.ex @@ -1,4 +1,4 @@ -defmodule PhilomenaWeb.Tag.AutocompleteController do +defmodule PhilomenaWeb.Autocomplete.TagController do use PhilomenaWeb, :controller alias Philomena.Elasticsearch diff --git a/lib/philomena_web/controllers/tag/fetch_controller.ex b/lib/philomena_web/controllers/fetch/tag_controller.ex similarity index 94% rename from lib/philomena_web/controllers/tag/fetch_controller.ex rename to lib/philomena_web/controllers/fetch/tag_controller.ex index 725d0ed5..e9df5024 100644 --- a/lib/philomena_web/controllers/tag/fetch_controller.ex +++ b/lib/philomena_web/controllers/fetch/tag_controller.ex @@ -1,4 +1,4 @@ -defmodule PhilomenaWeb.Tag.FetchController do +defmodule PhilomenaWeb.Fetch.TagController do use PhilomenaWeb, :controller alias Philomena.Tags.Tag diff --git a/lib/philomena_web/router.ex b/lib/philomena_web/router.ex index d9c4b5fb..76002a99 100644 --- a/lib/philomena_web/router.ex +++ b/lib/philomena_web/router.ex @@ -446,9 +446,11 @@ defmodule PhilomenaWeb.Router do resources "/favorites", Image.FavoriteController, only: [:index] end - scope "/tags", Tag, as: :tag do - resources "/autocomplete", AutocompleteController, only: [:show], singleton: true - resources "/fetch", FetchController, only: [:index] + scope "/autocomplete", Autocomplete, as: :autocomplete do + resources "/tags", TagController, only: [:show], singleton: true + end + scope "/fetch", Fetch, as: :fetch do + resources "/tags", TagController, only: [:index] end resources "/tags", TagController, only: [:index, :show] do diff --git a/lib/philomena_web/templates/profile/artist_link/_form.html.slime b/lib/philomena_web/templates/profile/artist_link/_form.html.slime index dcfb0292..cfe75981 100644 --- a/lib/philomena_web/templates/profile/artist_link/_form.html.slime +++ b/lib/philomena_web/templates/profile/artist_link/_form.html.slime @@ -10,7 +10,7 @@ ' Artist Link validation is intended for artists. Validating your link will give you control over your content on the site, allowing you to create a a> href="/commissions" commissions ' listing and request takedowns or DNPs. Do not request a link if the source contains no artwork which you have created. - = text_input f, :tag_name, value: assigns[:tag_name], class: "input", autocomplete: "off", placeholder: "artist:your-name", data: [ac: "true", ac_min_length: "3", ac_source: "/tags/autocomplete?term="] + = text_input f, :tag_name, value: assigns[:tag_name], class: "input", autocomplete: "off", placeholder: "artist:your-name", data: [ac: "true", ac_min_length: "3", ac_source: "/autocomplete/tags?term="] = error_tag f, :tag .field diff --git a/lib/philomena_web/templates/tag/_tag_editor.html.slime b/lib/philomena_web/templates/tag/_tag_editor.html.slime index 2a6a1b4c..3f4d43db 100644 --- a/lib/philomena_web/templates/tag/_tag_editor.html.slime +++ b/lib/philomena_web/templates/tag/_tag_editor.html.slime @@ -9,7 +9,7 @@ elixir: .js-tag-block class="fancy-tag-#{@type}" = textarea @f, @name, html_options .js-taginput.input.input--wide.tagsinput.hidden class="js-taginput-fancy" data-click-focus=".js-taginput-input.js-taginput-#{@name}" - input.input class="js-taginput-input js-taginput-#{@name}" id="taginput-fancy-#{@name}" type="text" placeholder="add a tag" autocomplete="off" autocapitalize="none" data-ac="true" data-ac-min-length="3" data-ac-source="/tags/autocomplete?term=" + input.input class="js-taginput-input js-taginput-#{@name}" id="taginput-fancy-#{@name}" type="text" placeholder="add a tag" autocomplete="off" autocapitalize="none" data-ac="true" data-ac-min-length="3" data-ac-source="/autocomplete/tags?term=" button.button.button--state-primary.button--bold class="js-taginput-show" data-click-show=".js-taginput-fancy,.js-taginput-hide" data-click-hide=".js-taginput-plain,.js-taginput-show" data-click-focus=".js-taginput-input.js-taginput-#{@name}" = hidden_input :fuck_ie, :fuck_ie, value: "fuck_ie" ' Fancy Editor