Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New markdown feature: Mention a time #691

Closed
timabbott opened this issue Jun 17, 2020 · 1 comment
Closed

New markdown feature: Mention a time #691

timabbott opened this issue Jun 17, 2020 · 1 comment
Assignees
Labels
area: message rendering help wanted This issue should be clear enough to work on high priority should be done as soon as possible in progress
Milestone

Comments

@timabbott
Copy link
Sponsor Member

We added a new markdown syntax, !time(2020-06-18T17:32:00-07:00), that is meant to be a timezone-aware time displayed to all clients in local time (using the same mechanisms used in the timestamps in Zulip messages).

There's likely some discussion that will happen on how these should be rendered; my current leaning is that we should put a clock icon/emoji at the start of the pills. But what's important for now is the core logic to make this feature work at all. In the webapp, it's this part of rendered_markdown.js:

    content.find('span.timestamp').each(function () {                                      
        // Populate each timestamp span with mentioned time                                
        // in user's local timezone.                                                       
        const timestamp = moment.unix($(this).attr('data-timestamp'));                     
        if (timestamp.isValid() && $(this).attr('data-timestamp') !== null) {              
            const text = $(this).text();                                                   
            const rendered_time = timerender.render_markdown_timestamp(timestamp,          
                                                                       null, text);        
            $(this).text(rendered_time.text);                                              
            $(this).attr('title', rendered_time.title);                                    
        } else {                                                                           
            $(this).removeClass('timestamp');                                              
            $(this).attr('title', 'Could not parse timestamp.');                           
        }                                                                                  
    });                                                                               

     // Renders the timestamp returned by the !time() markdown syntax.                          
exports.render_markdown_timestamp = function (time, now, text) {                           
    now = now || moment();                                                                 
    if (page_params.timezone) {                                                            
        now = now.tz(page_params.timezone);                                                
        time = time.tz(page_params.timezone);                                              
    }                                                                                      
    const timestring = time.format('ddd, MMM D YYYY, h:mm A');                             
    const titlestring = "This time is in your timezone. Original text was '" + text + "'."\
;                                                                                          
    return {                                                                               
        text: timestring,                                                                  
        title: titlestring,                                                                
    };                                                                                     
};                                                                                         

Implementing this should be a priority, since the whole point is that the time gets rendered properly :).

@neiljp neiljp added area: message rendering help wanted This issue should be clear enough to work on high priority should be done as soon as possible labels Jun 17, 2020
@timabbott
Copy link
Sponsor Member Author

The markup has changed to <time>, which will likely be easier to deal with.

@neiljp neiljp added this to the Release after upcoming milestone Jul 30, 2020
@preetmishra preetmishra self-assigned this Aug 6, 2020
preetmishra added a commit to preetmishra/zulip-terminal that referenced this issue Aug 7, 2020
This adds support for rendering timezone-aware time mentions which were
recently added to the Zulip's markdown suite.

(See https://zulipchat.com/help/format-your-message-using-markdown#mention-a-time
for markdown details.)

Complimentary additions:
* 'msg_time' style in themes.py.
* 'TIME' symbol in symbols.py.

Test amended.

Fixes zulip#691.
preetmishra added a commit to preetmishra/zulip-terminal that referenced this issue Aug 10, 2020
This adds support for rendering timezone-aware time mentions which were
recently added to the Zulip's markdown suite.

(See https://zulipchat.com/help/format-your-message-using-markdown#mention-a-time
for markdown details.)

Complimentary additions:
* 'msg_time' style in themes.py.
* 'TIME_MENTION_MARKER' symbol in symbols.py.

Test amended.

Fixes zulip#691.
preetmishra added a commit to preetmishra/zulip-terminal that referenced this issue Aug 11, 2020
This adds support for rendering timezone-aware time mentions which were
recently added to the Zulip's markdown suite.

(See https://zulipchat.com/help/format-your-message-using-markdown#mention-a-time
for markdown details.)

Complimentary additions:
* 'msg_time' style in themes.py.
* 'TIME_MENTION_MARKER' symbol in symbols.py.

Test amended.

Fixes zulip#691.
preetmishra added a commit to preetmishra/zulip-terminal that referenced this issue Aug 11, 2020
This adds support for rendering timezone-aware time mentions which were
recently added to the Zulip's markdown suite.

See https://zulipchat.com/help/format-your-message-using-markdown#mention-a-time
for markdown details.

Complimentary additions:
* msg_time style in themes.py.
* TIME_MENTION_MARKER symbol in symbols.py.

Test amended.

Fixes zulip#691.
preetmishra added a commit to preetmishra/zulip-terminal that referenced this issue Aug 11, 2020
This adds support for rendering timezone-aware time mentions which were
recently added to the Zulip's markdown suite.

See https://zulipchat.com/help/format-your-message-using-markdown#mention-a-time
for markdown details.

Complimentary additions:
* msg_time style in themes.py.
* TIME_MENTION_MARKER symbol in symbols.py.

Test amended.

Fixes zulip#691.
@neiljp neiljp closed this as completed in e01aca5 Aug 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: message rendering help wanted This issue should be clear enough to work on high priority should be done as soon as possible in progress
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants