dev-ext / twitterjs

Automatically exported from code.google.com/p/twitterjs
MIT License
0 stars 0 forks source link

Patch -- a few new options and 'lazy' URLs #10

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Some small changes I've made to my copy of your excellent script; thought 
I'd share them...

- Adds new options maskLinkText and maxLinkLength. 
- Allows 'lazy' URLs.

  getTwitters('twitterFeed', { 
    // ...
    maskLinkText : "read more...", // false,
    maxLinkLength : 50;
    // ...
  });

Original issue reported on code.google.com by nick.m...@gmail.com on 20 Mar 2010 at 4:40

Attachments:

GoogleCodeExporter commented 9 years ago
should be a comma after 50, not a semicolon ;p

Original comment by nick.m...@gmail.com on 20 Mar 2010 at 4:49

GoogleCodeExporter commented 9 years ago
Here's a new patch (better than the last one)...

-- getTwitters is the only property attached to the window object
-- fixed truncating links one character too early with no ellipses
-- simplified 'ify' construct
-- fixed exclamation point in ify.link

Original comment by nick.m...@gmail.com on 20 Mar 2010 at 8:44

Attachments:

GoogleCodeExporter commented 9 years ago
This thing is getting a bit unwieldy for patches, so here's a full version. 
This 
version fixes the wrong time showing up on tweets, and adds another new option:

  relativeTime : {Boolean} Whether to use relative time stamps, defaults to true

Enjoy!

Original comment by nick.m...@gmail.com on 22 Mar 2010 at 12:56

Attachments:

GoogleCodeExporter commented 9 years ago
A few more changes...

-- Lazy URL linkifying not quite so lazy
-- Hashifying and Atifying not quite so lazy
-- 'prefix' option now works when 'template' option present
-- default options defined at top of file (easily pasteable)

I think I'm almost done mangling your script... thanks Remy ;)

Original comment by nick.m...@gmail.com on 22 Mar 2010 at 5:48

Attachments:

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Another round of changes, partly in response to comments from issue 9 and issue 
4. 
Check out the source for more info, all new options are documented and default 
values 
are located near the top of the script.

Options:

  maskLinks:     {Array} Array of arrays containing search and replacement 
                 values to selectively mask links with (see below). 

  relativeTime:  {Boolean|Integer} Whether to use relative time stamps OR 
                 number of hours before absolute time is used, defaults to 48

  linkTime:      {Boolean} Whether the time display should link to the user's 
                 twitter page, default false

Language options:

  monthNames:    {Array} Month names, default abbreviated English names

  amPm:          {Array} Values for AM and PM, default ['AM', 'PM']

  ordinalSuffix: {Function(Int)} Function returning an ordinal suffix 
                 given an integer (ex: 'th', 'st', 'nd', 'rd')

Example of maskLinks option:

var myOptions = {
  id : 'someone',
  count : 5,
  maskLinks : [

    // Simple replacement. Links containing 'bit.ly' will read 'more...' 
    // Entire text of link is replaced.

    ['bit.ly', 'more...'],

    // Regex replacement. Facebook links will read 'facebook/{username}'.
    // Only text matching regex is replaced. Second array member can be a function.

    [/^.*facebook\.com\/(?:people\/)?([^\/]+).*$/i , 'facebook/$1']
  ]
}

Original comment by nick.m...@gmail.com on 25 Mar 2010 at 10:13

Attachments:

GoogleCodeExporter commented 9 years ago
Updated...

This version allows tweets from multiple users to be aggregated into one list.

To make it work, use an array of usernames for the "id" option instead of a 
string.

Example:

  getTwitters('twitterDiv', { 
    id: ['someone', 'somebody', 'anotherguy'],
    count: 10
  });

Original comment by nick.m...@gmail.com on 27 Mar 2010 at 1:54

Attachments:

GoogleCodeExporter commented 9 years ago
Update: refactored, minor tweaks and fixes, made 'ify' filters accessible via 
options 
(you can add your own filters or override default ones).

I may start a fork of this somewhere if there's any demand for it; I've taken 
quite a 
bit of liberty with the script at this point. 

Original comment by nick.m...@gmail.com on 28 Mar 2010 at 12:14

Attachments:

GoogleCodeExporter commented 9 years ago
I think it would be a good idea to fork it given the facts that you've added so 
much and that the original script hasn't evolved.

Original comment by ofu...@gmail.com on 23 Nov 2010 at 9:27