Discourse Docs è il motivo principale per cui ho scelto di usare Discourse rispetto ad altri software per forum. Tuttavia, ha una grave pecca per me: per impostazione predefinita, ordina per attività. Vorrei rimuovere del tutto la possibilità di ordinare per attività, ma non riesco a capire come fare.
Ho trovato questa sezione di codice e ho rimosso l’istruzione elsif per l’ordinamento per attività, ma non ha aiutato.
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
Ho fatto lo stesso anche in questo file e ha comunque fornito le stesse capacità di ordinamento.
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
Ho apportato le modifiche sia direttamente nel file sul server, sia in un fork di Discourse Docs che ho poi installato.
Qualcuno ha qualche suggerimento? Pensavo davvero che sarebbe stato un lavoro di 3 minuti, ma ci ho passato molte ore…
Grazie!