autocomplete: render html server-side.

Render the HTML for autocomplete results server-side instead of in
Javascript. This is cleaner than building HTML in Javascript, but it may
hurt caching because the HTTP responses are larger.

Fixes #4698: user autocomplete contains links to /posts

Also fixes a bug where tag counts in the autocomplete menu were different
from tag counts displayed elsewhere because of differences in rounding.
This commit is contained in:
evazion
2022-08-29 20:50:19 -05:00
parent 55266be2ef
commit cf13ab1540
7 changed files with 84 additions and 58 deletions

View File

@@ -1,7 +1,7 @@
# frozen_string_literal: true
class AutocompleteController < ApplicationController
respond_to :xml, :json
respond_to :html, :xml, :json
def index
@query = params.dig(:search, :query)
@@ -14,6 +14,6 @@ class AutocompleteController < ApplicationController
@public = @autocomplete.cache_publicly?
expires_in @expires_in, public: @public unless response.cache_control.present?
respond_with(@results)
respond_with(@results, layout: false)
end
end