Extension:TweetANew

From mediawiki.org
MediaWiki extensions manual
TweetANew
Release status: stable
Implementation Notify, Data extraction, Skin
Description Tweets when a page is created or edited. Depending on preferences set for the entire wiki, either automatically or from the edit page.
Author(s) Gregory Varnum merging extensions by Joachim De Schrijver, Andrew Fitzgerald, Wendell Gaudencio, and Rohit Keshwani
Latest version 1.1.0 (2017-10-30)
MediaWiki 1.23+
License GNU General Public License 2.0 or later
Download
Release notes
Example MountWiki.com + twitter
  • $wgTweetANewCatBlocklist
  • $wgTweetANewBlacklist
  • $wgTweetANewTwitter
  • $wgTweetANewBitly
  • $wgTweetANewEditpage
  • $wgTweetANewTweet
  • $wgTweetANewText
  • $wgTweetANewGoogl
  • $wgTweetANewBlocklist
Quarterly downloads 0
Translate the TweetANew extension if it is available at translatewiki.net
Issues Open tasks · Report a bug

Description[edit]

Updates a predefined Twitter account each time a new article is created or edited. URLs are shortened using bitly service. Settings allow you to enable automatic tweets for either edits or new articles. You can then allow a checkbox to be placed on the edit page to enable a tweet to be sent.

Download instructions[edit]

The extension can be retrieved directly from Git [?]:

  • Browse code
  • Some extensions have tags for stable releases.
  • Each branch is associated with a past MediaWiki release. There is also a "master" branch containing the latest alpha version (might require an alpha version of MediaWiki).

Extract the snapshot and place it in the extensions/TweetANew/ directory of your MediaWiki installation.

If you are familiar with Git and have shell access to your server, you can also obtain the extension as follows:

cd extensions/ git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/TweetANew.git

Installation[edit]

Requirements[edit]

The following requirements must be satisfied for the TweetANew extension to work.

Install the extension[edit]

1. Add the following to LocalSettings.php :

require_once("$IP/extensions/TweetANew/TweetANew.php");


2. Users should have a Twitter account and request API permissions (OAuth settings and tokens). You can register at http://dev.twitter.com. Be sure to have write and read permissions for both OAuth settings and Your access token.

Detailed instructions:
  1. If you don't have one already, create a Twitter application on https://dev.twitter.com/apps
  2. Be sure to have write and read permissions by selecting Read and Write as the Application Type under your application's Settings tab
  3. From the application details page use the consumer key and consumer secret in the places marked with (YOUR_CONSUMER_KEY and YOUR_CONSUMER_SECRET) in the next step
  4. From the application details page use the access token and access token secret in the places marked with (A_USER_TOKEN and A_USER_SECRET) in the next step


3. Set Twitter OAuth Settings and Access Tokens in your LocalSettings.php:

$wgTweetANewTwitter['ConsumerKey'] = 'YOUR_CONSUMER_KEY';
$wgTweetANewTwitter['ConsumerSecret'] = 'YOUR_CONSUMER_SECRET';
$wgTweetANewTwitter['AccessToken'] = 'A_USER_TOKEN';
$wgTweetANewTwitter['AccessTokenSecret'] = 'A_USER_SECRET';


4a. Users wishing to enable use of bitly URL shortening should have a bitly account and API key.

Detailed instructions:
  1. If you don't have one already, create a bitly user account at: http://www.bitly.com/a/sign_up
  2. Use your username in the place marked with (BITLY_USERNAME) in the next step
  3. From your API key page (http://www.bitly.com/a/your_api_key) use the API key in the place marked with (BITLY_API_KEY) in the next step

4a.1. Add the following 2 lines to your LocalSettings.php:

$wgTweetANewBitly['Enable'] = true;
$wgTweetANewBitly['Login'] = 'BITLY_USERNAME';
$wgTweetANewBitly['API'] = 'BITLY_API_KEY';

4b. Users wishing to enable use of Goo.gl URL shortening should have a Google account, API key, and Google shortener API enabled.

Detailed instructions:
  1. If you don't have one already, create a Google user account at: http://www.google.com
  2. From your APIs tab on the Developers Console (http://code.google.com/apis/console/), enable the URL Shortener API
  3. Use API key provided on the Credential tab in the place marked with (GOOGLE_API_KEY) in the next step

4.1. Add the following 2 lines to your LocalSettings.php:

$wgTweetANewGoogl['Enable'] = true;
$wgTweetANewGoogl['API'] = 'GOOGLE_API_KEY';


Additional configuration parameters are below.

Default configuration[edit]

Defaults
$wgTweetANewTweet = array(
	'New' => true,
	'Edit' => true,
	'LessMinutesOld' => 5,
	'SkipMinor' => true,
);

$wgTweetANewText = array(
	'Minor' => false, // Only applies if $wgTweetANewTweet['SkipMinor'] = false
	'MinorSpace' => true, // Only applies if $wgTweetANewTweet['SkipMinor'] = false and $wgTweetANewTweet['Minor'] = true
	'NewRandom' => true,
	'NewRandomMax' => 3,
	'NewAuthor' => false,
	'NewSummary' => false,
	'EditRandom' => true,
	'EditRandomMax' => 3,
	'EditAuthor' => false,
	'EditSummary' => false,
	'RealName' => false,
);

$wgTweetANewEditpage = array(
	'Enable' => false, // Only applies if $wgTweetANewTweet['New'] = false or $wgTweetANewTweet['Edit'] = false
	'Checked' => false, // Only applies if $wgTweetANewEditpage['Enable'] = true
);

$wgTweetANewTwitter = array(
	'ConsumerKey' => '',
	'ConsumerSecret' => '',
	'AccessToken' => '',
	'AccessTokenSecret' => '',
);

$wgTweetANewBitly = array(
	'Enable' => false,
	'Login' => '',
	'API' => '',
);

Configuration parameters[edit]

Parameter Default Description
$wgTweetANewTweet['New'] true Automatically tweet about new articles
$wgTweetANewTweet['Edit'] true Automatically tweet about articles when edited
$wgTweetANewTweet['LessMinutesOld'] 5 Minutes since last edit to wait before tweeting about a new edit
$wgTweetANewTweet['SkipMinor'] true Skip minor edits
$wgTweetANewText['Minor'] false Indicate in tweet if edit is marked as minor - Only applies if $wgTweetANewTweet['SkipMinor'] = false
$wgTweetANewText['MinorSpace'] true Include a space after minor edit indicator - Only applies if $wgTweetANewTweet['SkipMinor'] = false and $wgTweetANewText['Minor'] = true
$wgTweetANewText['NewRandom'] true Use a mix of random messages in body of tweets about new articles
$wgTweetANewText['NewRandomMax'] 3 Maximum number of random messages to use - Set any additional (beyond 3) using MediaWiki:Tweetanew-new4, MediaWiki:Tweetanew-new5, etc.
$wgTweetANewText['NewAuthor'] false Display the author of the new article
$wgTweetANewText['NewSummary'] false Display content entered into new article's summary box
$wgTweetANewText['EditRandom'] true Use a mix of random messages in body of tweets about article edits
$wgTweetANewText['EditRandomMax'] 3 Maximum number of random messages to use - Set any additional (beyond 3) using MediaWiki:Tweetanew-edit4, MediaWiki:Tweetanew-edit5, etc.
$wgTweetANewText['EditAuthor'] false Display the author of the edit
$wgTweetANewText['EditSummary'] false Display content entered into edit's summary box
$wgTweetANewText['RealName'] false Determine if user's real name will be displayed instead of their username
$wgTweetANewEditpage['Enable'] false Determine if checkbox to tweet from edit page if $wgTweetANewTweet['New'] = false or $wgTweetANewTweet['Edit'] = false
$wgTweetANewEditpage['Checked'] false Determine if checkbox to tweet from edit page is automatically checked
$wgTweetANewBlacklist Array of pages blacklisted - Example: $wgTweetANewBlacklist = array('BadPage1','BadPage2');
$wgTweetANewTwitter['ConsumerKey'] Twitter consumer key - see above for detailed Twitter setup instructions
$wgTweetANewTwitter['ConsumerSecret'] Twitter consumer secret - see above for detailed Twitter setup instructions
$wgTweetANewTwitter['AccessToken'] Twitter access token provided by OAuth tool - see above for detailed Twitter setup instructions
$wgTweetANewTwitter['AccessTokenSecret'] Twitter access token secret provided by OAuth tool - see above for detailed Twitter setup instructions
$wgTweetANewBitly['Enable'] false Display URL as bitly link - otherwise defaults to use of Twitter's t.co service
$wgTweetANewBitly['Login'] If bitly link display is enabled, enter your bitly user account - see above for detailed bitly installation instructions
$wgTweetANewBitly['API'] If bitly link display is enabled, enter your bitly API key - see above for detailed bitly installation instructions
$wgTweetANewGoogl['Enable'] false Display URL as Goo.gl link - otherwise defaults to use of Twitter's t.co service
$wgTweetANewGoogl['API'] If Goo.gl link display is enabled, enter your Google API key - see above for detailed Goo.gl installation instructions

Example custom configurations[edit]

Recent changes setup[edit]

Mimic the Special:RecentChanges output so your tweet displays as:

m URL - PAGENAME; . . USERNAME (SUMMARY)

Example tweet:

http://www.examplewiki.org/w/Test1 - Test1; . . Jimbo - Added a section talking about the history of test1

Example tweet for a minor edit:

m http://www.examplewiki.org/w/Test1 - Test1; . . Jimbo - Fixed a typo in the history section


Follow these steps: 1. Change your LocalSettings.php to disable random tweet messages, display the author, display the summary:

$wgTweetANewText['NewRandom'] = false;
$wgTweetANewText['EditRandom'] = false;
$wgTweetANewText['NewAuthor'] = true;
$wgTweetANewText['EditAuthor'] = true;
$wgTweetANewText['NewSummary'] = true;
$wgTweetANewText['EditSummary'] = true;


2. If you'd like to output minor edits as well, also change your LocalSettings.php by adding:

$wgTweetANewTweet['SkipMinor'] = false;
$wgTweetANewText['Minor'] = true;


3. Change the look of the default message settings in MediaWiki:Tweetanew-newdefault and MediaWiki:Tweetanew-editdefault to customize the appearance. Use these parameters:

  • $1 is title of the new page
  • $2 is the final URL of the new page - shortened if a service is enabled via this extension


Custom look for tweets about minor edits[edit]

Customize the indicator used for tweets about minor edits. Example tweet:

minor:NEW PAGE: Test1- http://www.examplewiki.org/w/Test1


Follow these steps: 1. Change your LocalSettings.php to enable tweets about minor edits and, for the above example, use the default tweet message rather than random tweet messages and remove the space after the minor edit indicator

$wgTweetANewTweet['SkipMinor'] = false;
$wgTweetANewText['Minor'] = true;
$wgTweetANewText['NewRandom'] = false;
$wgTweetANewText['EditRandom'] = false;
$wgTweetANewText['MinorSpace'] = false;


2. Change the look of the default minor edits indicator in MediaWiki:Tweetanew-minoredit.


Upgrading[edit]

Upgrading from TweetANew 0.2[edit]

Aside from the new features, the main differences between the two versions are the formatting of settings and use of bitly being disabled by default.

You will need to update these settings in your LocalSettings.php:

$wgConsumerKey = 'YOUR_CONSUMER_KEY';
$wgConsumerSecret = 'YOUR_CONSUMER_SECRET';
$wgAccessToken = 'A_USER_TOKEN';
$wgAccessTokenSecret = 'A_USER_SECRET';

To:

$wgTweetANewTwitter['ConsumerKey'] = 'YOUR_CONSUMER_KEY';
$wgTweetANewTwitter['ConsumerSecret'] = 'YOUR_CONSUMER_SECRET';
$wgTweetANewTwitter['AccessToken'] = 'A_USER_TOKEN';
$wgTweetANewTwitter['AccessTokenSecret'] = 'A_USER_SECRET';


Twitter's t.co service performs a similar task as bitly. It also provides analytics (although the Twitter Web Analytics tool is not yet available) and is automatically applied by Twitter's API to any submitted URL. You can still choose to use bitly rather than t.co by setting:

$wgTweetANewBitly['Enable'] = true;

You will also need to update these settings in your LocalSettings.php:

$bitly_login = 'BITLY_USERNAME';
$bitly_api = 'BITLY_API_KEY';

To:

$wgTweetANewBitly['Login'] = 'BITLY_USERNAME';
$wgTweetANewBitly['API'] = 'BITLY_API_KEY';


Upgrading from SendToTwitter[edit]

SendToTwitter's use of Twitter username and password, rather than this extension's use of Twitter's API, means you'll need to do a fresh installation in regards to your settings. Please see installation section.

The wiki URL settings are no longer required.


Upgrading from SendToTwitter2[edit]

SendToTwitter2's use of Twitter username and password, rather than this extension's use of Twitter's API, means you'll need to do a fresh installation in regards to your settings. Please see installation section.

The wiki URL settings are no longer required.

The edit page checkbox is only enabled if auto-tweets for either new or edited pages is disabled (see #). To keep SendToTwitter2's checkbox settings, update these entries in your LocalSettings.php:

$wgSendToTwitterUseCheckBox = true; 
$wgSendToTwitterChecked = false;

To:

$wgTweetANewEditpage['Enable'] = true;

The default for $wgTweetANewBitly['Checked'] is already 'false' - so there's no reason to update your LocalSettings.php to retain that setting.


Upgrading from Wiki2twitter[edit]

Wiki2twitter's use of a separate settings file, rather than this extension's use of LocalSettings.php, means you'll need to do a fresh installation in regards to your settings. Please see installation section.


Development[edit]

Release notes[edit]

1.0.20140209
09 February 2014
Call Twitter API 1.1 instead of 1.0 (Thank you Dereckson!)
Improve UTF-8 and links support (Thank you ISAKA Yoji and Dereckson!)
Added Blacklist (Thank you FrankSoyer)
Added support for Goo.gl URL shortener (Requested by WhiteTigerItaly)
Bug fixes
1.0.20111229-beta
30 December 2011
Updated coding to meet MediaWiki coding conventions
General code cleanup
Moved extension to code repository for extensions for collaborative developer editing and maintenance
Localisation integration for easier use by foreign-language wikis
Merged original TweetANew (by Joachim De Schrijver) with the Wiki2twitter (by Wendell Gaudencio), SendToTwitter (by Rohit Keshwani) and SendToTwitter2 (by Rohit Keshwani and Andrew Fitzgerald) extensions
Now tweets edited articles (if last edit was made 5+ minutes - unless $wgTweetANewTweet['LessMinutesOld'] setting overrides the default)
Ability to use LocalSettings.php settings to enable or disable both the tweets about new and edited pages
Checkbox on edit page can be enabled if either "auto-tweeting" of new or edited pages is disabled - if checked a tweet will then be sent
Checkbox overrides $wgTweetANewTweet['SkipMinor']
Use of ResourceLoader for importing OAuth script - which is now included in the extension
Ability to indicate minor edits (if $wgTweetANewTweet['SkipMinor'] = false)
Ability to append tweets with edit summary excerpt
Use of random tweet messages
Default tweet message can now be set in MediaWiki:Tweetanew-newdefault and MediaWiki:Tweetanew-editdefault
Other customizations and features from merger of Wiki2twitter, SendToTwitter and SendToTwitter2 features
Thank you to Johnduhart, Reedy, SPQRobin, krinkle, Nikerabbit, Raymond and others for feedback, bug reporting and cleaning up code for this beta version
0.2
12 September 2011 by Joachim De Schrijver
Ignoring images (jpg/png)
Using URL shortener
Added 'efficiency tracing parameters' to the URL
0.1
23 July 2011 by Joachim De Schrijver
First version

Planned features[edit]

  • Additional short-url services

Wish list[edit]

  • Your requests and ideas are welcome
  • Option to only tweet if $user has an EditCount > X (to prevent tweeting about articles made by spammers)
  • More control over which edits results in twitter posts. Could for example be controlled at group level (has to be member of... or ignore groups....) In my particular case I have a bot creating new articles and they are actually the only ones I want posted - in other words for me a memberof=bot would do the trick. An alternative could be control at category level - ie. only posts from certain categories.

Ideas being considered[edit]

Time will be spent on these if folks show interest on the wish list or talk page

  • Addition of "efficiency tracing parameters" to the URL
    • Previous setup seemed to conflict with certain setups
    • Suggest use of bitly or Twitter's t.co analytics as alternative solutions
  • Allow customization of how summary is displayed in tweet

Requests by developer[edit]

  • Add any wishes to wish list or request on talk page
  • Please test on wikis and report back via talk page
  • Suggestions from developers are especially welcome! Contributions included will be credited as co-authors
  • Language translations will be credited

See also[edit]