From 0f8ec1de53b54ef596ad4dabb703a658c88d34b6 Mon Sep 17 00:00:00 2001 From: Donovan Daniels Date: Thu, 18 Apr 2024 05:31:25 -0500 Subject: [PATCH] [Notes] Remove note previews, replace with dtext previews --- app/controllers/note_previews_controller.rb | 14 -------------- app/javascript/src/javascripts/notes.js | 10 ++++++---- config/routes.rb | 1 - test/functional/note_previews_controller_test.rb | 14 -------------- 4 files changed, 6 insertions(+), 33 deletions(-) delete mode 100644 app/controllers/note_previews_controller.rb delete mode 100644 test/functional/note_previews_controller_test.rb diff --git a/app/controllers/note_previews_controller.rb b/app/controllers/note_previews_controller.rb deleted file mode 100644 index ac9dd113f..000000000 --- a/app/controllers/note_previews_controller.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -class NotePreviewsController < ApplicationController - respond_to :json - - def show - @body = helpers.format_text(params[:body].to_s) - respond_with(@body) do |format| - format.json do - render :json => {:body => @body}.to_json - end - end - end -end diff --git a/app/javascript/src/javascripts/notes.js b/app/javascript/src/javascripts/notes.js index 779441843..3f915877a 100644 --- a/app/javascript/src/javascripts/notes.js +++ b/app/javascript/src/javascripts/notes.js @@ -434,10 +434,11 @@ let Note = { var text = $textarea.val(); $note_body.data("original-body", text); Note.Body.set_text($note_body, $note_box, "Loading..."); - $.get("/note_previews.json", {body: text}).then(function(data) { - Note.Body.set_text($note_body, $note_box, data.body); + $.post("/dtext_preview.json", {body: text}).then(function(data) { + Note.Body.set_text($note_body, $note_box, data.html); Note.Box.resize_inner_border($note_box); $note_body.show(); + $(window).trigger("e621:add_deferred_posts", data.posts); }); $this.dialog("close"); @@ -467,9 +468,10 @@ let Note = { var $note_box = Note.Box.find(id); $note_box.find(".note-box-inner-border").addClass("unsaved"); Note.Body.set_text($note_body, $note_box, "Loading..."); - $.get("/note_previews.json", {body: text}).then(function(data) { - Note.Body.set_text($note_body, $note_box, data.body); + $.post("/dtext_preview.json", {body: text}).then(function(data) { + Note.Body.set_text($note_body, $note_box, data.html); $note_body.show(); + $(window).trigger("e621:add_deferred_posts", data.posts); }); }, diff --git a/config/routes.rb b/config/routes.rb index 2da5b48a0..6a631b9b3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -189,7 +189,6 @@ Rails.application.routes.draw do end end resources :note_versions, :only => [:index] - resource :note_previews, :only => [:show] resources :pools do member do put :revert diff --git a/test/functional/note_previews_controller_test.rb b/test/functional/note_previews_controller_test.rb deleted file mode 100644 index 5fbd38e77..000000000 --- a/test/functional/note_previews_controller_test.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -require "test_helper" - -class NotePreviewsControllerTest < ActionDispatch::IntegrationTest - context "The note previews controller" do - context "show action" do - should "work" do - get note_previews_path, params: { body: "test", format: "json" } - assert_response :success - end - end - end -end