Tweak topic listing

- Display topic timestamp OR latest reply timestamp
- Remove leading space
- Clean up 'T' and 'Z' in timestamp for readability
- Fix topic list left alignment bug
This commit is contained in:
Eric Budd 2018-03-31 20:38:58 -04:00
parent eee023dab3
commit efd496cecc
3 changed files with 10 additions and 6 deletions

View File

@ -65,7 +65,7 @@ jimmy_foo@ctrl-c.club> topics
```
1. The first column is the topic index. This is the reference number to use when displaying or replying to a topic.
1. The second column is the timestamp. This is the server-local time when the topic was composed.
1. The second column is the timestamp. This is the server-local time when the topic was composed or last replied to.
1. The third column is the author. This is the user who composed the topic.
1. The fourth column is the title. This is the truncated first line of the topic.

View File

@ -18,7 +18,6 @@
* Split helptext into separate file?
# Features:
* Change listing to show last updated timestamp, instead of thread creation timestamp
* Message deletion
* Message editing
* Gracefully handle bad message files
@ -54,3 +53,4 @@
* Add color
* Add full message corpus dump for backup/debugging
* Add startup enviro health check
* Change listing to show last updated timestamp, instead of thread creation timestamp

12
iris.rb
View File

@ -299,11 +299,15 @@ class Message
stub.slice(0, length - 6) + '...'
end
def latest_topic_timestamp
(replies.map(&:timestamp).max || timestamp).gsub(/T/, ' ').gsub(/Z/, '')
end
def to_topic_line(index)
error_marker = valid? ? ' ' : 'X'
head = [error_marker, Display.print_index(index), timestamp, Display.print_author(author)].join(' | ')
message_stub = truncated_message(Display::WIDTH - head.length)
[head, message_stub].join(' | ')
error_marker = valid? ? '|' : 'X'
head = [Display.print_index(index), latest_topic_timestamp, Display.print_author(author)].join(' | ')
message_stub = truncated_message(Display::WIDTH - head.decolorize.length - 1)
error_marker + ' ' + [head, message_stub].join(' | ')
end
def to_display