Discourse Docs は、他のフォーラムソフトウェアではなく Discourse を使用することにした主な理由です。しかし、私にとっては 1 つの大きな欠点があります。デフォルトでは、アクティビティで並べ替えられます。アクティビティでの並べ替え機能を完全に削除したいのですが、方法がわかりません。
このコードセクションを見つけ、アクティビティ並べ替えの elsif ステートメントを削除しましたが、効果はありませんでした。
if @filters[:order] == "title"
if @filters[:ascending].present?
results = results.reorder('topics.title')
else
results = results.reorder('topics.title DESC')
end
elsif @filters[:order] == "activity"
if @filters[:ascending].present?
results = results.reorder('topics.last_posted_at')
else
results = results.reorder('topics.last_posted_at DESC')
end
end
このファイルでも同様のことを行いましたが、それでも同じ並べ替え機能が提供されます。
context 'when ordering results' do
context 'by title' do
it 'should return the list ordered descending' do
get "/docs.json?order=title"
expect(response.status).to eq(200)
json = response.parsed_body
topics = json['topics']['topic_list']['topics']
expect(topics[0]['id']).to eq(topic2.id)
expect(topics[1]['id']).to eq(topic.id)
end
it 'should return the list ordered ascending with an additional parameter' do
get "/docs.json?order=title&ascending=true"
expect(response.status).to eq(200)
json = response.parsed_body
topics = json['topics']['topic_list']['topics']
expect(topics[0]['id']).to eq(topic.id)
expect(topics[1]['id']).to eq(topic2.id)
end
end
context 'by date' do
before do
topic2.update(last_posted_at: Time.zone.now + 100)
end
it 'should return the list ordered descending' do
get "/docs.json?order=activity"
expect(response.status).to eq(200)
json = response.parsed_body
topics = json['topics']['topic_list']['topics']
expect(topics[0]['id']).to eq(topic.id)
expect(topics[1]['id']).to eq(topic2.id)
end
it 'should return the list ordered ascending with an additional parameter' do
get "/docs.json?order=activity&ascending=true"
expect(response.status).to eq(200)
json = response.parsed_body
topics = json['topics']['topic_list']['topics']
expect(topics[0]['id']).to eq(topic2.id)
expect(topics[1]['id']).to eq(topic.id)
end
end
end
サーバー上のファイルに直接編集しただけでなく、Discourse Docs のフォークをインストールして編集しました。
何かヒントはありますか?本当に 3 分で終わる作業だと思っていましたが、何時間も費やしてしまいました…
ありがとうございます!