Skip to content

Commit

Permalink
date explanation, minor UI improvements and clean-ups
Browse files Browse the repository at this point in the history
- click on the date in a conversation browser to get an explanation of the timezone
- add missing oxford comma
- communicate special value #always for downloadRange
- rename DateAndTime>>talkPrettyPrintString
- rename String>>talkAsTextFromHtmlWithCRs
  • Loading branch information
LinqLover committed Jun 4, 2023
1 parent 28f1586 commit 9eac07e
Show file tree
Hide file tree
Showing 29 changed files with 115 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
*SqueakInboxTalk-UI-squeak protocol
talkPrintOn: aStream
talkPrettyPrintOn: aStream

self flag: #moveUpstream.

self offset = self class localOffset ifFalse: [^ self asLocal talkPrintOn: aStream].
self offset = self class localOffset ifFalse: [^ self asLocal talkPrettyPrintOn: aStream].

self printYMDOn: aStream.
aStream space.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*SqueakInboxTalk-UI-squeak protocol
talkPrettyPrintString

self flag: #moveUpstream.

^ String streamContents: [:stream | self talkPrettyPrintOn: stream]

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"class" : {
},
"instance" : {
"talkPrintOn:" : "ct 5/25/2021 17:02",
"talkPrintString" : "ct 5/20/2021 20:40" } }
"talkPrettyPrintOn:" : "ct 5/15/2023 19:37",
"talkPrettyPrintString" : "ct 5/15/2023 19:37" } }
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
*SqueakInboxTalk-UI-converting
talkAsTextFromHtml
talkAsTextFromHtmlWithCRs
"Answer a Text by interpreting the receiver as HTML. Don't ignore newlines."

self flag: #moveUpstream.
"maybe?"
^ (HtmlReadWriter on: self readStream)
breakLines: false;
nextText
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"levenshteinDistanceTo:" : "ct 6/11/2021 23:53",
"matches:ofNGrams:threshold:" : "ct 7/21/2021 22:43",
"matchesLevenshtein:maxDistance:" : "ct 6/17/2021 17:26",
"talkAsTextFromHtml" : "ct 7/7/2021 18:36",
"talkAsTextFromHtmlWithCRs" : "ct 6/3/2023 22:35",
"talkBeginsWith:caseSensitive:" : "ct 7/20/2021 18:54",
"talkWithoutLeading:caseSensitive:" : "ct 7/20/2021 18:54" } }
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ headerText
args := OrderedDictionary new
at: 'Subject' put: message subject;
at: 'From' put: message author;
at: 'Date'
put: (message date talkPrintString asText addAttribute: (TextInspectIt on: message date));
at: 'Date' put: (message date talkPrettyPrintString asText addAttribute:
(PluggableTextAttribute evalBlock: [message explainTimezone]));
yourself.

^ Text streamContents: [:stream |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"hasMessageSelectedWithRichText" : "ct 6/2/2023 19:40",
"headerHeight" : "ct 7/22/2021 18:42",
"headerSelection" : "ct 7/22/2021 23:06",
"headerText" : "ct 7/23/2021 15:49",
"headerText" : "ct 6/4/2023 00:47",
"inbox" : "ct 7/14/2021 18:34",
"initialize" : "ct 6/3/2023 22:51",
"labelForMessageFormat:" : "ct 5/16/2023 13:59",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
preferences
defaultMessageSignature

^ ('<font color="gray">---\\<i>Sent from {1}</i></font>' withCRs format: {
^ ('<font color="gray">---<br><i>Sent from {1}</i></font>' format: {
(self environment classNamed: #TalkInboxBrowser)
ifNil: ['Squeak Inbox Talk']
ifNotNil: ['<a href="{2}"><u><font color="gray">{1}</font></u></a>' format: {TalkInboxBrowser appName. TalkInboxBrowser repositoryUrl}]}) talkAsTextFromHtml
ifNotNil: ['<a href="{2}"><u><font color="gray">{1}</font></u></a>' format: {TalkInboxBrowser appName. TalkInboxBrowser repositoryUrl}]}) asTextFromHtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cleanUp:" : "ct 11/25/2022 20:55",
"clearAllCaches" : "ct 7/23/2021 21:21",
"decorateMessage:" : "ct 7/9/2021 19:49",
"defaultMessageSignature" : "ct 7/14/2021 17:17",
"defaultMessageSignature" : "ct 6/1/2023 19:12",
"editMessageSignature" : "ct 7/14/2021 15:55",
"messageSignature" : "ct 7/14/2021 17:30",
"messageSignature:" : "ct 7/9/2021 19:15",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ accessing - toolbuilder
conversationColumns

^ {
[:conversation | conversation latestDate talkPrintString].
[:conversation | conversation latestDate talkPrettyPrintString].
[:conversation | "contribution state icon"
''].
[:conversation | self subjectFor: conversation].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ emptyContents
addAttribute: TextEmphasis italic;
yourself]
ifFalse: [
'Displaying <b>{1} out of {2}</b> conversations matching your {3}.' withCRs talkAsTextFromHtml format: {
'Displaying <b>{1} out of {2}</b> conversations matching your {3}.' withCRs asTextFromHtml format: {
self conversations size.
self allConversations size.
(OrderedCollection streamContents: [:stream |
Expand All @@ -21,16 +21,16 @@ emptyContents
{2}
Press the {3} button to customize this tool, {4} or {5}.' talkAsTextFromHtml format: {
Press the {3} button to customize this tool, {4}, or {5}.' talkAsTextFromHtmlWithCRs format: {
'Welcome to {1}!' asText
addAttribute: (TextKern kern: 0.5);
format: {self appName}.
(self allConversations
ifEmpty: ['It looks empty here! You could start by pressing the <b>{6} button</b> to download the latest messages. You can also fetch older messages by setting the download range from the {7}.' asTextFromHtml]
ifNotEmpty: ['In the last {2}, the {1} community has produced <b>{3} messages</b> and <b>{4} contributions</b> that make up <b>{5} conversations</b> in total.
Press the <b>{6} button</b> to download the latest messages. You can also fetch older messages by setting the download range from the {7}.' talkAsTextFromHtml]) format: {
Press the <b>{6} button</b> to download the latest messages. You can also fetch older messages by setting the download range from the {7}.' talkAsTextFromHtmlWithCRs]) format: {
self inbox name.
'{1} days' format: {self inbox downloadRange days}.
'{1} days' format: {self inbox downloadRange ifNotNil: #days ifNil: ['infinite']}.
self inbox messages size.
self inbox contributions size.
self inbox conversations size.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing - toolbuilder
refreshMessagesHelp

^ 'Download and prepare the latest messages from the mail archive\<b>Last refreshed:</b> {1}' withCRs talkAsTextFromHtml format: {inbox lastRefreshed ifNil: ['never'] ifNotNil: #talkPrintString}
^ 'Download and prepare the latest messages from the mail archive<br><b>Last refreshed:</b> {1}' asTextFromHtml format: {inbox lastRefreshed ifNil: ['never'] ifNotNil: #talkPrettyPrintString}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ setDownloadRange
| answer range |
range := self inbox downloadRange.
answer := Project uiManager
request: 'Download messages as far back as how many days...?'
request: 'Download messages as far back as how many days...? (can also be #infinite)'
initialAnswer: (range ifNotNil: [range days asString] ifNil: [#infinite printString]).
answer isEmptyOrNil ifTrue: [^ false].

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"combineContributionConversations:" : "ct 7/2/2021 17:00",
"contents" : "ct 7/3/2021 02:00",
"contributeMenu:" : "ct 7/8/2021 13:32",
"conversationColumns" : "ct 7/15/2021 00:28",
"conversationColumns" : "ct 5/15/2023 19:37",
"conversationHelpAtRow:atColumn:" : "ct 7/20/2021 20:25",
"conversationHelpFor:atColumnNamed:" : "ct 7/20/2021 20:24",
"conversationIconAtRow:atColumn:" : "ct 7/20/2021 20:25",
Expand All @@ -95,7 +95,7 @@
"editMailMessage:decorate:" : "ct 7/24/2021 02:12",
"editMessageSignature" : "ct 7/14/2021 15:54",
"editUserInformation" : "ct 7/24/2021 02:09",
"emptyContents" : "ct 10/15/2022 22:05",
"emptyContents" : "ct 6/4/2023 23:18",
"filterLabel" : "ct 7/20/2021 23:59",
"filterMenu:" : "ct 7/2/2021 16:08",
"fullContents" : "ct 7/2/2021 16:49",
Expand Down Expand Up @@ -128,7 +128,7 @@
"openPreferences" : "ct 7/20/2021 20:13",
"refreshMessages" : "ct 6/11/2021 14:26",
"refreshMessagesColor" : "ct 1/10/2023 18:39",
"refreshMessagesHelp" : "ct 7/8/2021 13:14",
"refreshMessagesHelp" : "ct 5/15/2023 19:38",
"resetAllFilters" : "ct 7/2/2021 16:11",
"searchModel" : "ct 7/7/2021 20:02",
"searchResultsPreview" : "ct 7/22/2021 20:27",
Expand All @@ -139,7 +139,7 @@
"selectedConversationIndex:" : "ct 5/7/2021 18:17",
"sendFeedback" : "ct 10/15/2022 21:28",
"sendFeedbackTo:" : "ct 7/14/2021 18:33",
"setDownloadRange" : "ct 7/20/2021 00:08",
"setDownloadRange" : "ct 5/16/2023 23:31",
"showCredits" : "ct 7/20/2021 22:55",
"simpleContents" : "ct 7/22/2021 16:24",
"startComputingContents" : "ct 7/23/2021 17:41",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
*SqueakInboxTalk-UI-tools
explainTimezone

| their our |
their := self date printString asText.
our := self date asLocal printString asText.
their = our ifFalse:
[their
addAllAttributes: (((self userInterfaceTheme get: #removeTextAttributes for: #TextDiffBuilder)
select: [:attr | attr isKindOf: TextColor])
ifEmpty: [{TextColor blue}])
from: their size - 5 to: their size.
our
addAllAttributes: (((self userInterfaceTheme get: #insertTextAttributes for: #TextDiffBuilder)
select: [:attr | attr isKindOf: TextColor])
ifEmpty: [{TextColor red}])
from: our size - 5 to: our size].
Project uiManager
inform: ('<b>In their timezone ({1})</b>: {2}<br><b>In our timezone ({3}):</b> {4}' asTextFromHtml format:
{((TimeZone talkAllForOffset: self date offset) collect: #abbreviation) joinSeparatedBy: '/'.
their.
TimeZone local abbreviation.
our})
title: 'Unraveling Timezones'.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"conversation" : "ct 5/20/2021 18:54",
"dataKey" : "ct 5/7/2021 17:36",
"date" : "ct 5/7/2021 15:08",
"explainTimezone" : "ct 6/4/2023 01:04",
"hyperkittyUrl" : "ct 5/18/2023 19:04",
"hyperkittyUrlForThread" : "ct 6/1/2023 18:24",
"inbox" : "ct 5/20/2021 18:54",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*SqueakInboxTalk-UI-accessing
talkAllForOffset: aDuration

^ (self timeZones , self timeZonesDST) select: [:ea | ea offset = aDuration]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"class" : {
"talkAllForOffset:" : "ct 6/2/2023 20:07" },
"instance" : {
} }
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
"name" : "TimeZone" }
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
test - squeak-protocol
testTalkPrintString
testTalkPrettyPrintString

| date |
date := DateAndTime year: 2159 month: 3 day: 14 hour: 2 minute: 53 second: 59.

self assert: '2159-03-14 02:53:59' equals: date talkPrintString
self assert: '2159-03-14 02:53:59' equals: date talkPrettyPrintString
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"class" : {
},
"instance" : {
"testTalkPrintString" : "ct 6/9/2021 18:43" } }
"testTalkPrettyPrintString" : "ct 5/15/2023 19:37" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
tests
testExplainTimezone

| message text |
message := self classUnderTest new.

self
patch: message at: #date withValue: (DateAndTime fromString: '2023-06-04T00:53:27-07:00');
patch: TimeZone at: #local with: [TimeZone timeZones detect: [:tz | tz abbreviation = 'EST']];
patch: DateAndTime at: #localOffset withValue: -5 hours.

text := [message explainTimezone]
on: ProvideAnswerNotification
do: [:ex | ex messageText].

self assert: 'In their timezone (MST/PDT): 2023-06-04T00:53:27-07:00
In our timezone (EST): 2023-06-04T02:53:27-05:00' equals: text.
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
},
"instance" : {
"classUnderTest" : "ct 5/20/2021 18:59",
"testExplainTimezone" : "ct 6/4/2023 01:06",
"testPrintString" : "ct 5/20/2021 16:14",
"testSubject" : "ct 7/21/2021 01:00" } }
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
classToBeTested

^ TimeZone
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
tests
testAllForOffset

self assert: ((self classToBeTested talkAllForOffset: 0 hours) collect: #abbreviation) = #('UTC' 'GMT').
self assert: (self classToBeTested talkAllForOffset: -14 hours) isEmpty.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"class" : {
},
"instance" : {
"classToBeTested" : "ct 6/2/2023 20:09",
"testAllForOffset" : "ct 6/2/2023 20:08" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"category" : "SqueakInboxTalkTests-CoreExtensions",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "",
"instvars" : [
],
"name" : "TalkTimeZoneTest",
"pools" : [
],
"super" : "TalkTestCase",
"type" : "normal" }

1 comment on commit 9eac07e

@LinqLover
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

timezoneDisplay

Please sign in to comment.