mirror of https://github.com/Calamitous/iris.git
Compare commits
8 Commits
b13ac5fd03
...
08694c1403
Author | SHA1 | Date |
---|---|---|
Eric B. Budd | 08694c1403 | |
Eric B. Budd | 0462ada0a0 | |
Eric B. Budd | 28db4d3e20 | |
Eric B. Budd | 9fd530c41c | |
Eric B. Budd | b3d3640f97 | |
Eric B. Budd | 7c3fad429e | |
Amarpreet Minhas | 95e77eb1b1 | |
Eric B. Budd | ce84f6ed10 |
61
README.md
61
README.md
|
@ -36,11 +36,11 @@ Iris has a readline interface that can be used to navigate the message corpus.
|
|||
|
||||
```bash
|
||||
%> iris
|
||||
Welcome to Iris v. 1.0.11. Type "help" for a list of commands.; Ctrl-D or 'quit' to leave.
|
||||
Welcome to Iris v. 1.0.12. Type "help" for a list of commands.; Ctrl-D or 'quit' to leave.
|
||||
|
||||
| ID | U | TIMESTAMP | AUTHOR | TITLE
|
||||
| 1 | | 2018-01-24T05:49:53Z | jimmy_foo@ctrl-c.club | Welcome!
|
||||
| 2 | 1 | 2018-01-24T16:13:05Z | jerry_berry@ctrl-c.club | Suggestions for imp...
|
||||
| 2 | 1 | 2018-01-24T16:13:05Z | jerry_berry@ctrl-c.club | Suggestions for a...
|
||||
|
||||
jimmy_foo@ctrl-c.club>
|
||||
```
|
||||
|
@ -50,11 +50,13 @@ jimmy_foo@ctrl-c.club>
|
|||
* [[t]opics](#topics)
|
||||
* [[u]nread](#unread)
|
||||
* [Display topic](#display-topic)
|
||||
* [[n]ext](#next)
|
||||
* [[c]ompose](#compose)
|
||||
* [[r]eply](#reply)
|
||||
* [[e]dit](#edit)
|
||||
* [[d]elete and un[d]elete](#delete)
|
||||
* [[m]ark_read](#mark_read)
|
||||
* [mark_all_read](#mark_all_read)
|
||||
* [[f]reshen](#freshen)
|
||||
* [reset OR clear](#reset-or-clear)
|
||||
* [[i]nfo](#info)
|
||||
|
@ -72,7 +74,7 @@ jimmy_foo@ctrl-c.club> topics
|
|||
|
||||
| ID | U | TIMESTAMP | AUTHOR | TITLE
|
||||
| 1 | | 2018-01-24T05:49:53Z | jimmy_foo@ctrl-c.club | Welcome!
|
||||
| 2 | 1 | 2018-01-24T16:13:05Z | jerry_berry@ctrl-c.club | Suggestions for i...
|
||||
| 2 | 1 | 2018-01-24T16:13:05Z | jerry_berry@ctrl-c.club | Suggestions for a...
|
||||
|
||||
```
|
||||
|
||||
|
@ -93,7 +95,7 @@ This outputs a list of top-level topics that have not been read, or have unread
|
|||
jimmy_foo@ctrl-c.club> unread
|
||||
|
||||
| ID | U | TIMESTAMP | AUTHOR | TITLE
|
||||
| 2 | 1 | 2018-01-24T16:13:05Z | jerry_berry@ctrl-c.club | Suggestions for i...
|
||||
| 2 | 1 | 2018-01-24T16:13:05Z | jerry_berry@ctrl-c.club | Suggestions for a...
|
||||
|
||||
```
|
||||
|
||||
|
@ -110,7 +112,7 @@ jimmy_foo@ctrl-c.club> topics
|
|||
|
||||
| ID | U | TIMESTAMP | AUTHOR | TITLE
|
||||
| 1 | | 2018-01-24T05:49:53Z | jimmy_foo@ctrl-c.club | Welcome!
|
||||
| 2 | 1 | 2018-01-24T16:13:05Z | jerry_berry@ctrl-c.club | Suggestions for i...
|
||||
| 2 | 1 | 2018-01-24T16:13:05Z | jerry_berry@ctrl-c.club | Suggestions for a...
|
||||
|
||||
jimmy_foo@ctrl-c.club> 1
|
||||
*** [1] On 2018-01-24T05:49:53Z, jimmy_foo@ctrl-c.club posted...-----------------
|
||||
|
@ -126,6 +128,32 @@ It's good to see everyone here!
|
|||
|
||||
---
|
||||
|
||||
### [n]ext
|
||||
`next, n - Read the next unread topic`
|
||||
|
||||
This command displays the first topic which is unread or has unread replies.
|
||||
```
|
||||
jimmy_foo@ctrl-c.club> topics
|
||||
|
||||
| ID | U | TIMESTAMP | AUTHOR | TITLE
|
||||
| 1 | | 2018-01-24T05:49:53Z | jimmy_foo@ctrl-c.club | Welcome!
|
||||
| 2 | 1 | 2018-01-24T16:13:05Z | jerry_berry@ctrl-c.club | Suggestions for a...
|
||||
|
||||
jimmy_foo@ctrl-c.club> next
|
||||
*** [2] On 2018-01-24T16:13:05Z, jerry_berry@ctrl-c.club posted...---------------
|
||||
Suggestions for a tilde home?
|
||||
|
||||
I'm trying to decide on a new place in the tildeverse to call home. Any ideas?
|
||||
---------------------------------------------------------------------------------
|
||||
|
||||
| === [M4] On 2018-01-30T22:50:38Z, jimmy_foo@ctrl-c.club replied...-----------
|
||||
| Have you considered https://ctrl-c.club?
|
||||
| -----------------------------------------------------------------------------
|
||||
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### [c]ompose
|
||||
`compose, c - Add a new topic`
|
||||
|
||||
|
@ -149,7 +177,7 @@ jimmy_foo@ctrl-c.club~> topics
|
|||
|
||||
| ID | U | TIMESTAMP | AUTHOR | TITLE
|
||||
| 1 | | 2018-01-24T05:49:53Z | jimmy_foo@ctrl-c.club | Welcome!
|
||||
| 2 | | 2018-01-24T16:13:05Z | jerry_berry@ctrl-c.club | Suggestions for i...
|
||||
| 2 | | 2018-01-24T16:13:05Z | jerry_berry@ctrl-c.club | Suggestions for a...
|
||||
| 3 | 1 | 2018-01-23T00:13:44Z | jimmy_foo@ctrl-c.club | How do I spoo the...
|
||||
```
|
||||
|
||||
|
@ -313,6 +341,13 @@ Mark a topic and all its replies as read without displaying them.
|
|||
|
||||
---
|
||||
|
||||
### [m]ark_all_read
|
||||
`mark_all_read - Mark all messages as read`
|
||||
|
||||
Marks all topics and their replies as read without displaying them.
|
||||
|
||||
---
|
||||
|
||||
### [f]reshen
|
||||
`freshen, f - Reload to get any new messages`
|
||||
|
||||
|
@ -335,7 +370,7 @@ This outputs the current version of Iris, along with messsage, topic, and author
|
|||
```bash
|
||||
jennie_minnie@ctrl-c.club~> info
|
||||
|
||||
Iris 1.0.11
|
||||
Iris 1.0.12
|
||||
13 topics, 0 unread.
|
||||
50 messages, 0 unread.
|
||||
10 authors.
|
||||
|
@ -355,6 +390,7 @@ There are a few options you can pass in from the command-line:
|
|||
* [--version, -v](#--version-v)
|
||||
* [--stats, -s](#--stats-s)
|
||||
* [--interactive, -i](#--interactive-i)
|
||||
* [--mark-all-read](#--mark-all-read)
|
||||
* [--dump, -d](#--dump-d)
|
||||
* [--help, -h](#--help-h)
|
||||
* [--debug](#--debug)
|
||||
|
@ -368,7 +404,7 @@ iris --version
|
|||
```
|
||||
|
||||
```bash
|
||||
Iris 1.0.11
|
||||
Iris 1.0.12
|
||||
```
|
||||
|
||||
---
|
||||
|
@ -384,7 +420,7 @@ iris --stats
|
|||
```
|
||||
|
||||
```bash
|
||||
Iris 1.0.11
|
||||
Iris 1.0.12
|
||||
13 topics, 0 unread.
|
||||
50 messages, 0 unread.
|
||||
10 authors.
|
||||
|
@ -400,6 +436,13 @@ This is the mode that Iris enters if no options are passed on the command-line.
|
|||
|
||||
---
|
||||
|
||||
|
||||
### --mark-all-read
|
||||
|
||||
This command simply marks every message as read in Iris. It's a quick way to get to "Irisbox Zero".
|
||||
|
||||
---
|
||||
|
||||
### --dump/-d
|
||||
|
||||
This reads the entire message corpus and outputs it as a stream of JSON data, suitable for piping into a backup file, `jq` parser, or similar.
|
||||
|
|
17
TODO.md
17
TODO.md
|
@ -10,22 +10,21 @@
|
|||
* Flesh out technical sections
|
||||
|
||||
### Bugs
|
||||
* Replying implicitly to 24 replied to 6 instead-- remove implicit reply?
|
||||
* Is `Time.now.utc.iso8601` working as expected?
|
||||
* Fix bug when people are posting from different time zones
|
||||
* Fix message ordering when editing/deleting multiple messages
|
||||
* Exclude user''s own messages from "unread" count
|
||||
* Replying implicitly to 24 replied to 6 instead
|
||||
* Gracefully handle attempt to "r 1 message"
|
||||
|
||||
### Features
|
||||
* Add pagination/less for long message lists
|
||||
* https://github.com/Calamitous/iris/issues/1
|
||||
* Add "unread" marker to topic replies
|
||||
* Allow shelling out to editor for message editing
|
||||
* https://github.com/Calamitous/iris/issues/2
|
||||
* Add pagination/less for long message lists
|
||||
* https://github.com/Calamitous/iris/issues/1
|
||||
* Add local timezone rendering
|
||||
* Add "Mark all read" option
|
||||
* Add option to mark all messages in a thread as read
|
||||
* CLI option to show response count to threads the user authored
|
||||
* Search/regex function to find all messages
|
||||
|
||||
### Tech debt
|
||||
* Flesh out tests
|
||||
|
@ -69,6 +68,12 @@
|
|||
|
||||
# Changelog
|
||||
|
||||
## 1.0.12
|
||||
* Add Asara's "mark all read" functionality
|
||||
* Fix(?) bug with handling broken UTF-8 characters
|
||||
* Add feature to read the next unread topic ("next")
|
||||
* Exclude user''s own messages from "unread" count
|
||||
|
||||
## 1.0.11
|
||||
* Speed up the topic listing significantly
|
||||
* Add 'unread' (short form 'u') to only list topics with unread messages
|
||||
|
|
117
iris.rb
117
iris.rb
|
@ -8,7 +8,7 @@ require 'time'
|
|||
# require 'pry' # Only needed for debugging
|
||||
|
||||
class Config
|
||||
VERSION = '1.0.11'
|
||||
VERSION = '1.0.12'
|
||||
MESSAGE_FILE = "#{ENV['HOME']}/.iris.messages"
|
||||
HISTORY_FILE = "#{ENV['HOME']}/.iris.history"
|
||||
IRIS_SCRIPT = __FILE__
|
||||
|
@ -17,10 +17,11 @@ class Config
|
|||
HOSTNAME = `hostname -d`.chomp
|
||||
AUTHOR = "#{USER}@#{HOSTNAME}"
|
||||
OPTIONS = %w[
|
||||
--dump
|
||||
--debug
|
||||
--dump
|
||||
--help
|
||||
--interactive
|
||||
--mark-all-read
|
||||
--stats
|
||||
--test-file
|
||||
--version
|
||||
|
@ -28,11 +29,12 @@ class Config
|
|||
-f
|
||||
-h
|
||||
-i
|
||||
-p
|
||||
-s
|
||||
-v
|
||||
]
|
||||
INTERACTIVE_OPTIONS = %w[-i --interactive]
|
||||
NONINTERACTIVE_OPTIONS = %w[-d --dump -h --help -v --version -s --stats]
|
||||
NONINTERACTIVE_OPTIONS = %w[-d --dump -h --help -v --version -s --stats --mark-all-read]
|
||||
NONFILE_OPTIONS = %w[-h --help -v --version]
|
||||
|
||||
@@debug_mode = false
|
||||
|
@ -230,6 +232,7 @@ class Corpus
|
|||
@@unread_messages ||= @@corpus
|
||||
.select { |message| message.show_me? }
|
||||
.reject{ |m| @@my_reads.include? m.hash }
|
||||
.reject{ |m| @@my_corpus.map(&:hash).include? m.hash }
|
||||
end
|
||||
|
||||
def self.unread_message_hashes
|
||||
|
@ -247,6 +250,12 @@ class Corpus
|
|||
def self.size
|
||||
@@corpus.size
|
||||
end
|
||||
|
||||
def self.mark_as_read(hashes)
|
||||
new_reads = (Corpus.read_hashes + hashes).uniq.sort
|
||||
IrisFile.write_read_file(new_reads.to_json)
|
||||
Corpus.load
|
||||
end
|
||||
end
|
||||
|
||||
class IrisFile
|
||||
|
@ -643,34 +652,37 @@ class Display
|
|||
end
|
||||
|
||||
class Interface
|
||||
ONE_SHOTS = %w{help topics unread compose quit freshen reset_display reply edit delete mark_read info}
|
||||
ONE_SHOTS = %w{ compose delete edit freshen help info mark_all_read mark_read next quit reply reset_display topics unread }
|
||||
CMD_MAP = {
|
||||
't' => 'topics',
|
||||
'topics' => 'topics',
|
||||
'u' => 'unread',
|
||||
'unread' => 'unread',
|
||||
'm' => 'mark_read',
|
||||
'mark' => 'mark_read',
|
||||
'c' => 'compose',
|
||||
'compose' => 'compose',
|
||||
'h' => 'help',
|
||||
'?' => 'help',
|
||||
'help' => 'help',
|
||||
'r' => 'reply',
|
||||
'reply' => 'reply',
|
||||
'e' => 'edit',
|
||||
'edit' => 'edit',
|
||||
'd' => 'delete',
|
||||
'delete' => 'delete',
|
||||
'undelete' => 'delete',
|
||||
'q' => 'quit',
|
||||
'quit' => 'quit',
|
||||
'freshen' => 'freshen',
|
||||
'f' => 'freshen',
|
||||
'reset' => 'reset_display',
|
||||
'clear' => 'reset_display',
|
||||
'i' => 'info',
|
||||
'info ' => 'info',
|
||||
'?' => 'help',
|
||||
'c' => 'compose',
|
||||
'clear' => 'reset_display',
|
||||
'compose' => 'compose',
|
||||
'd' => 'delete',
|
||||
'delete' => 'delete',
|
||||
'e' => 'edit',
|
||||
'edit' => 'edit',
|
||||
'f' => 'freshen',
|
||||
'freshen' => 'freshen',
|
||||
'h' => 'help',
|
||||
'help' => 'help',
|
||||
'i' => 'info',
|
||||
'info ' => 'info',
|
||||
'm' => 'mark_read',
|
||||
'mark' => 'mark_read',
|
||||
'mark_all_read' => 'mark_all_read',
|
||||
'n' => 'next',
|
||||
'next' => 'next',
|
||||
'q' => 'quit',
|
||||
'quit' => 'quit',
|
||||
'r' => 'reply',
|
||||
'reply' => 'reply',
|
||||
'reset' => 'reset_display',
|
||||
't' => 'topics',
|
||||
'topics' => 'topics',
|
||||
'u' => 'unread',
|
||||
'undelete' => 'delete',
|
||||
'unread' => 'unread',
|
||||
}
|
||||
|
||||
def browsing_handler(line)
|
||||
|
@ -713,12 +725,39 @@ class Interface
|
|||
Display.say
|
||||
end
|
||||
|
||||
def self.mark_all_read
|
||||
Corpus.mark_as_read(Corpus.unread_messages.map(&:hash))
|
||||
end
|
||||
|
||||
def mark_all_read
|
||||
Display.say "Marking all messages as read..."
|
||||
Interface.mark_all_read
|
||||
Display.say "Done!"
|
||||
end
|
||||
|
||||
def compose
|
||||
@mode = :composing
|
||||
@text_buffer = ''
|
||||
Display.say 'Writing a new topic. Type a period on a line by itself to end message.'
|
||||
end
|
||||
|
||||
def next
|
||||
Display.say
|
||||
|
||||
if Corpus.unread_topics.size == 0
|
||||
Display.say "{gvi You're all caught up! No new topics to read.}"
|
||||
return
|
||||
end
|
||||
|
||||
message = Corpus.unread_topics.first
|
||||
@reply_topic = message.hash
|
||||
|
||||
Display.say message.to_topic_display
|
||||
Display.say
|
||||
|
||||
Corpus.mark_as_read([message.hash] + message.replies.map(&:hash))
|
||||
end
|
||||
|
||||
def reply(topic_id = @reply_topic)
|
||||
unless topic_id
|
||||
Display.say "I can't reply to nothing! Include a topic ID or view a topic to reply to."
|
||||
|
@ -787,9 +826,7 @@ class Interface
|
|||
return
|
||||
end
|
||||
|
||||
new_reads = (Corpus.read_hashes + [message.hash] + message.replies.map(&:hash)).uniq.sort
|
||||
IrisFile.write_read_file(new_reads.to_json)
|
||||
Corpus.load
|
||||
Corpus.mark_as_read([message.hash] + message.replies.map(&:hash))
|
||||
end
|
||||
|
||||
def delete(message_id = nil)
|
||||
|
@ -826,6 +863,7 @@ class Interface
|
|||
end
|
||||
|
||||
def replying_handler(line)
|
||||
line.encode!('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')
|
||||
if line !~ /^\.$/
|
||||
if @text_buffer.empty?
|
||||
@text_buffer = line
|
||||
|
@ -901,9 +939,7 @@ class Interface
|
|||
Display.say msg.to_topic_display
|
||||
Display.say
|
||||
|
||||
new_reads = (Corpus.read_hashes + [msg.hash] + msg.replies.map(&:hash)).uniq.sort
|
||||
IrisFile.write_read_file(new_reads.to_json)
|
||||
Corpus.load
|
||||
Corpus.mark_as_read([msg.hash] + msg.replies.map(&:hash))
|
||||
else
|
||||
Display.say 'Could not find a topic with that ID'
|
||||
end
|
||||
|
@ -974,7 +1010,9 @@ class Interface
|
|||
'topics, t - List all topics',
|
||||
'unread, u - List all topics with unread messages',
|
||||
'# (topic id) - Read specified topic',
|
||||
'next, n - Read the next unread topic',
|
||||
'mark_read #, m # - Mark the associated topic as read',
|
||||
'mark_all_read - Mark all messages as read',
|
||||
'help, h, ? - Display this text',
|
||||
'',
|
||||
'WRITING',
|
||||
|
@ -1034,6 +1072,7 @@ class CLI
|
|||
'--version, -v - Display the current version of Iris.',
|
||||
'--stats, -s - Display Iris version and message stats.',
|
||||
'--interactive, -i - Enter interactive mode (default)',
|
||||
'--mark-all-read - Mark all messages as read.',
|
||||
'--dump, -d - Dump entire message corpus out.',
|
||||
'--test-file <filename>, -f <filename> - Use the specified test file for messages.',
|
||||
'--debug - Print warnings and debug informtation during use.',
|
||||
|
@ -1063,8 +1102,14 @@ class CLI
|
|||
exit(0)
|
||||
end
|
||||
|
||||
if (args & %w{--mark-all-read}).any?
|
||||
Interface.mark_all_read
|
||||
exit(0)
|
||||
end
|
||||
|
||||
Display.say "Unrecognized option(s) #{args.join(', ')}"
|
||||
Display.say "Try -h for help"
|
||||
exit(1)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue