Topic on Extension talk:TweetANew

Blacklisting some pages

1
FrankSoyer (talkcontribs)

Hi staff, I just install your extension and I must say : Bravo ! For my own use, I just made a change : I use a main page called "Accueil" as an index for all other pages. I don't want that additions or modifications on this page to be twitted. So I added an field to the array $wgTweetANewEditpage in LocalSettings.php:

'Blacklist' => array('Accueil',)

and in TweetANew.body.php :

75a76
> 				$article,
193a195
> 				$article,
227a230
> 	 * @param $article Article
232,233c235,236
< 	public static function makeSendTweet( $tweet_text, $finalurl ) {
< 		global $wgTweetANewTwitter, $wgLang;
---
> 	public static function makeSendTweet( $article, $tweet_text, $finalurl ) {
> 		global $wgTweetANewTwitter, $wgTweetANewEditpage, $wgLang;
235,240c238,244
< 		# Calculate length of tweet factoring in longURL
< 		if ( strlen( $finalurl ) > 20 ) {
< 			$tweet_text_count = ( strlen( $finalurl ) - 20 ) + 140;
< 		} else {
< 			$tweet_text_count = 140;
< 		}
---
> 		if ( !in_array($article->getTitle()->getText(), $wgTweetANewEditpage['Blacklist']) ) { 
> 			# Calculate length of tweet factoring in longURL
> 			if ( strlen( $finalurl ) > 20 ) {
> 				$tweet_text_count = ( strlen( $finalurl ) - 20 ) + 140;
> 			} else {
> 				$tweet_text_count = 140;
> 			}
242,244c246,263
< 		# Check if length of tweet is beyond 140 characters and shorten if necessary
<  		if ( strlen( $tweet_text ) > $tweet_text_count ) {
< 			$tweet_text = $wgLang->truncate( $tweet_text, $tweet_text_count );
---
> 			# Check if length of tweet is beyond 140 characters and shorten if necessary
> 			if ( strlen( $tweet_text ) > $tweet_text_count ) {
> 				$tweet_text = $wgLang->truncate( $tweet_text, $tweet_text_count );
> 			}
> 
> 			# Make connection to Twitter
> 			$tmhOAuth = new tmhOAuth( array(
> 				'consumer_key' => $wgTweetANewTwitter['ConsumerKey'],
> 				'consumer_secret' => $wgTweetANewTwitter['ConsumerSecret'],
> 				'user_token' => $wgTweetANewTwitter['AccessToken'],
> 				'user_secret' => $wgTweetANewTwitter['AccessTokenSecret'],
> 			) );
> 
> 			# Make tweet message
> 			$tmhOAuth->request( 'POST',
> 				$tmhOAuth->url( '1.1/statuses/update' ),
> 				array( 'status' => $tweet_text )
> 			);
246,259d264
< 
< 		# Make connection to Twitter
< 		$tmhOAuth = new tmhOAuth( array(
< 			'consumer_key' => $wgTweetANewTwitter['ConsumerKey'],
< 			'consumer_secret' => $wgTweetANewTwitter['ConsumerSecret'],
< 			'user_token' => $wgTweetANewTwitter['AccessToken'],
< 			'user_secret' => $wgTweetANewTwitter['AccessTokenSecret'],
< 		) );
< 
< 		# Make tweet message
< 		$tmhOAuth->request( 'POST',
< 			$tmhOAuth->url( '1/statuses/update' ),
< 			array( 'status' => $tweet_text )
< 		);
Reply to "Blacklisting some pages"