Bug 168749 - Switch back to the Twitter API for the Tweet widget
Summary: Switch back to the Twitter API for the Tweet widget
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Website (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Jon Davis
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-02-22 15:30 PST by Jon Davis
Modified: 2017-03-10 17:01 PST (History)
3 users (show)

See Also:


Attachments
Patch (9.78 KB, patch)
2017-02-22 15:32 PST, Jon Davis
no flags Details | Formatted Diff | Diff
Patch (11.40 KB, patch)
2017-03-10 15:50 PST, Jon Davis
no flags Details | Formatted Diff | Diff
Patch (11.99 KB, patch)
2017-03-10 16:15 PST, Jon Davis
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jon Davis 2017-02-22 15:30:22 PST
Switch back to using the Twitter API, with the push-tweet-listener as a trigger for updates and fallback if the API fails.
Comment 1 Jon Davis 2017-02-22 15:32:13 PST
Created attachment 302451 [details]
Patch
Comment 2 Matt Baker 2017-02-24 21:15:01 PST
Comment on attachment 302451 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=302451&action=review

r=me, with many a nit!

This is largely a style review and rubber-stamp, as I'm not familiar with the Twitter API. And since PHP is C-like, most of our WebKit coding standards are applicable and should be followed, at least:

- $camelCaseIdentifiers
- No spaces after/before open/close parenthesis in expressions, function signatures, etc
- Function body open brace should start on a newline

> Websites/webkit.org/ChangeLog:6
> +        Reviewed by NOBODY (OOPS!).

A brief description of the change would be nice.

> Websites/webkit.org/wp-content/themes/webkit/style.css:672
> +    

Style: remove blank line.

> Websites/webkit.org/wp-content/themes/webkit/style.css:682
> +    width: auto;

Style: move width above height, to match the order of the max-width/height pair below.

> Websites/webkit.org/wp-content/themes/webkit/widgets/twitter.php:28
> +        

Style: remove whitespace.

> Websites/webkit.org/wp-content/themes/webkit/widgets/twitter.php:35
> +        //     return $this->follow_markup($options);

Remove commented code.

> Websites/webkit.org/wp-content/themes/webkit/widgets/twitter.php:50
> +            if ( preg_match('!webkit.org/.+?!', $entry->expanded_url) == 1 ) {

Style: no need for spaces after open parenthesis/before close parenthesis.

> Websites/webkit.org/wp-content/themes/webkit/widgets/twitter.php:60
>  

Style: remove blank line.

> Websites/webkit.org/wp-content/themes/webkit/widgets/twitter.php:85
> +                <li><a href="https://twitter.com/webkit" target="twitter-modal"><span class="twitter-icon">Twitter</span>@webkit</a></li>

Nice housekeeping.

> Websites/webkit.org/wp-content/themes/webkit/widgets/twitter.php:121
> +        $PushedTweet = false;

Style: $pushedTweet

> Websites/webkit.org/wp-content/themes/webkit/widgets/twitter.php:154
> +        $key = join('&', array_map('rawurlencode', array(

Should be all on one line.

> Websites/webkit.org/wp-content/themes/webkit/widgets/twitter.php:168
>          );

Style: add a blank line before "// Wrap..."

> Websites/webkit.org/wp-content/themes/webkit/widgets/twitter.php:169
> +        // Wrap values in double-quotes

Style: end comments in a period

> Websites/webkit.org/wp-content/themes/webkit/widgets/twitter.php:199
> +                && preg_match('!webkit.org/.+?!', $Tweet->entities->urls[0]->expanded_url) == 1 ); // links to webkit.org somewhere

This function could be rewritten to be more readable. My PHP is rusty, but I think `count` returns 0 for null arguments, so the `empty($tweet->entities->urls)` check can be eliminated:

function isWebKitLink($tweet) {
    if (empty($tweet->entities) || count($tweet->entities->urls != 1))
        return false;

    return preg_match('!webkit.org/.+?!', $tweet->entities->urls[0]->expanded_url) == 1;
}

The comments don't add much that isn't obvious by reading the code, and can be omitted.
Comment 3 Matt Baker 2017-02-24 21:21:40 PST
Mismatched parenthesis in my code above, should be:

if (empty($tweet->entities) || count($tweet->entities->urls) != 1)
    return false;
Comment 4 Jon Davis 2017-03-10 15:50:59 PST
Created attachment 304087 [details]
Patch
Comment 5 Lucas Forschler 2017-03-10 16:12:45 PST
Comment on attachment 304087 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=304087&action=review

r=me after fixing the leading whitespace.

> Websites/webkit.org/wp-content/themes/webkit/widgets/twitter.php:29
> +        

looks like some extra whitespace here
Comment 6 Jon Davis 2017-03-10 16:15:41 PST
Created attachment 304090 [details]
Patch
Comment 7 WebKit Commit Bot 2017-03-10 17:01:22 PST
Comment on attachment 304090 [details]
Patch

Clearing flags on attachment: 304090

Committed r213740: <http://trac.webkit.org/changeset/213740>
Comment 8 WebKit Commit Bot 2017-03-10 17:01:26 PST
All reviewed patches have been landed.  Closing bug.