Discourse Docs ist der Hauptgrund, warum ich mich für Discourse und nicht für andere Forensoftware entschieden habe. Es hat jedoch einen großen Nachteil für mich – standardmäßig wird nach Aktivität sortiert. Ich möchte die Möglichkeit, nach Aktivität zu sortieren, komplett entfernen, kann aber nicht herausfinden, wie das geht.
Ich habe diesen Codeabschnitt gefunden und die elsif-Anweisung für die Aktivitätssortierung entfernt, aber das hat nicht geholfen.
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
Ich habe das Gleiche auch in dieser Datei gemacht, und es bietet immer noch die gleichen Sortierungsmöglichkeiten.
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
Ich habe die Änderungen sowohl direkt in der Datei auf dem Server als auch in einer Fork von Discourse Docs vorgenommen, die ich dann installiert habe.
Hat jemand Tipps? Ich dachte wirklich, es wäre eine 3-Minuten-Aufgabe, aber ich habe jetzt viele Stunden damit verbracht…
Danke!