r109184 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109183‎ | r109184 | r109185 >
Date:18:54, 17 January 2012
Author:varnent
Status:deferred
Tags:sopa 
Comment:
initial run at it - needs work - had to run to sudden friend emergency (yes - very bad timing) - will continue in a few hours - feel free to work on / improve / finish / whatever in my absence - deadline is later tonight to give sysadmins a few hours to load
Modified paths:
  • /trunk/extensions/Blackout/Blackout.body.php (added) (history)
  • /trunk/extensions/Blackout/Blackout.i18n.php (added) (history)
  • /trunk/extensions/Blackout/Blackout.php (added) (history)
  • /trunk/extensions/Blackout/RELEASE+NOTES (added) (history)
  • /trunk/extensions/Blackout/modules (added) (history)
  • /trunk/extensions/Blackout/modules/ext.blackout.css (added) (history)
  • /trunk/extensions/Blackout/modules/ext.blackout.js (added) (history)

Diff [purge]

Index: trunk/extensions/Blackout/Blackout.body.php
@@ -0,0 +1,28 @@
 2+<?php
 3+if ( !defined( 'MEDIAWIKI' ) ) {
 4+ die();
 5+}
 6+/**
 7+ * Class file for the Blackout extension
 8+ *
 9+ * @addtogroup Extensions
 10+ * @license GPL
 11+ */
 12+
 13+// Blackout
 14+class Blackout {
 15+
 16+ /**
 17+ * Function displaying banner
 18+ *
 19+ * @param $article Article
 20+ * @param $user User
 21+ * @param $summary
 22+ * @return bool
 23+ */
 24+ public static function fnMyHook( OutputPage &$out, Skin &$skin ) {
 25+ global $wgBlackout, $wgOut;
 26+ $wgOut->addModules( 'ext.blackout' );
 27+ return true;
 28+ }
 29+}
Property changes on: trunk/extensions/Blackout/Blackout.body.php
___________________________________________________________________
Added: svn:eol-style
130 + native
Index: trunk/extensions/Blackout/Blackout.i18n.php
@@ -0,0 +1,16 @@
 2+<?php
 3+/**
 4+ * Internationalisation file for extension Blackout
 5+ *
 6+ * @addtogroup Extensions
 7+ * @license GPL
 8+ */
 9+
 10+$messages = array();
 11+
 12+/** English
 13+ * @author Gregory Varnum
 14+ */
 15+$messages['en'] = array(
 16+ 'blackout-desc' => 'Tweets when a page is created or edited. Depending on preferences set for the entire wiki, either automatically or from the edit page.',
 17+);
\ No newline at end of file
Property changes on: trunk/extensions/Blackout/Blackout.i18n.php
___________________________________________________________________
Added: svn:eol-style
118 + native
Added: svn:executable
219 + *
Index: trunk/extensions/Blackout/modules/ext.blackout.css
@@ -0,0 +1,82 @@
 2+/**
 3+* Stylesheet for Blackout extension.
 4+*
 5+* You may modify the CSS code on the MediaWiki:Common.css
 6+* page to adjust padding, alignment, etc.
 7+*
 8+* @addtogroup Extensions
 9+* @license GPL
 10+*/
 11+
 12+#sopaOverlay {
 13+ position: fixed;
 14+ top: 0;
 15+ left: 0;
 16+ width: 100%;
 17+ height: 100%;
 18+ z-index: 2147483647; /* 32-bit max */·
 19+ color: #dedede;
 20+ background: black url(//upload.wikimedia.org/wikipedia/commons/9/98/WP_SOPA_Splash_Full.jpg) no-repeat 0 0;
 21+ overflow: auto;
 22+ }
 23+ #sopaColumn {
 24+ font-family:Times New Roman;
 25+ width:400px;
 26+ position:absolute;
 27+ top:80px;
 28+ left:420px;
 29+ color: #dedede;
 30+ padding-bottom: 30px;
 31+ }
 32+ #sopaHeadline {
 33+ font-size: 1.5em;
 34+ margin-bottom: 0.5em;
 35+ }
 36+ #sopaText {
 37+ text-align:justify;
 38+ }
 39+ #sopaColumn a {
 40+ color: #eeeeee;
 41+ text-decoration: underline;
 42+ cursor: pointer;
 43+ }
 44+ #sopaColumn a:hover {
 45+ color:#ffffff;
 46+ }
 47+ #sopaAction {
 48+ display: none;
 49+ }
 50+ #sopaColumn a.action {
 51+ padding-right: 15px;
 52+ margin-top: 2px;
 53+ background: url(//upload.wikimedia.org/wikipedia/commons/3/3a/WP_SOPA_Arrow_right_dedede.png) center right no-repeat;
 54+ }
 55+ #sopaColumn a.action:hover {
 56+ background: url(//upload.wikimedia.org/wikipedia/commons/6/63/WP_SOPA_Arrow_right_ffffff.png) center right no-repeat;
 57+ }
 58+
 59+ #sopaColumn a.action.open {
 60+ background: url(//upload.wikimedia.org/wikipedia/commons/e/ec/WP_SOPA_Arrow_down_dedede.png) center right no-repeat;
 61+ }
 62+ #sopaColumn a.action.open:hover {
 63+ background: url(//upload.wikimedia.org/wikipedia/commons/f/fb/WP_SOPA_Arrow_down_ffffff.png) center right no-repeat;
 64+ }
 65+ .sopaActionDiv {
 66+ margin-left: 1em;
 67+ margin-bottom: 1em;
 68+ }
 69+
 70+ .sopaActionHead {
 71+ font-weight: bold;
 72+ }
 73+ .sopaSocial {
 74+ float: left;
 75+ text-align: center;
 76+ margin-right: 12px;
 77+ margin-bottom: 3px;
 78+ font-size: small;
 79+ }
 80+ .sopaSocial a {
 81+ text-decoration: none;
 82+ }
 83+
\ No newline at end of file
Property changes on: trunk/extensions/Blackout/modules/ext.blackout.css
___________________________________________________________________
Added: svn:eol-style
184 + native
Index: trunk/extensions/Blackout/modules/ext.blackout.js
@@ -0,0 +1,144 @@
 2+/**
 3+* Javascript for Blackout extension.
 4+*
 5+* You may modify the Javascript code on the MediaWiki:Common.js
 6+*
 7+* @addtogroup Extensions
 8+* @license GPL
 9+*/
 10+
 11+( function ($) {
 12+ var namespaceWhitelist = ['Special']; // n.b. community has decided for full blackout including Special pages, but it is hard to do stuff in the meantime without this.
 13+ var pageWhitelist = [
 14+ 'Stop Online Piracy Act',
 15+ 'PROTECT IP Act',
 16+ 'Online Protection and Enforcement of Digital Trade Act',
 17+ 'Censorship',
 18+ 'Special:CongressLookup',
 19+ 'Special:NoticeTemplate',
 20+ 'Special:NoticeTemplate/view'
 21+ ];
 22+ var geoHasUsRep = [
 23+ 'US', // USA
 24+ 'PR', // Puerto Rico
 25+ 'VI', // Virgin Islands
 26+ 'MP', // Northern Mariana Islands
 27+ 'AS', // American Samoa
 28+ 'GU' // Guam
 29+ ];
 30+
 31+ // Exclude some namespaces
 32+ for ( var i = 0; i < namespaceWhitelist.length; i++ ) {
 33+ if ( namespaceWhitelist[i] == wgCanonicalNamespace ) {
 34+ return;
 35+ }
 36+ }
 37+
 38+ // Exclude some individual pages
 39+ for ( var i = 0; i < pageWhitelist.length; i++ ) {
 40+ if ( pageWhitelist[i] == wgPageName || pageWhitelist[i] == wgPageName.replace( /_/g, ' ' ) ) {
 41+ return;
 42+ }
 43+ }
 44+
 45+ var hasUsRep = false;
 46+ for ( var i = 0; i < geoHasUsRep.length; i ++ ) {
 47+ if ( geoHasUsRep[i] == Geo.country ) {
 48+ hasUsRep = true;
 49+ break;
 50+ }
 51+ }
 52+
 53+ var overlayHeight = $(document).height();
 54+
 55+ var overlay = $('<div id="sopaOverlay"></div>');
 56+ var column = $('<div id="sopaColumn"></div>');
 57+ var headline = $('<div id="sopaHeadline">{{{wp-sopa-title}}}</div>');
 58+ var intro = $('<div id="sopaText">{{{wp-sopa-blocktext}}}</div>');
 59+
 60+ var takeActionLink = $('<a class="action">{{{wp-sopa-takeaction}}}</a>').click( function() {
 61+ takeActionLink.toggleClass( 'open' );
 62+ action.slideToggle();
 63+ } );
 64+ var takeAction = $('<div id="sopaTakeAction"></div>').append( takeActionLink );
 65+ var action = $('<div id="sopaAction"></div>');
 66+ if ( hasUsRep ) {
 67+ action.append( $('<div class="sopaActionDiv"><p class="sopaActionHead">{{{wp-sopa-zipform-intro}}}</p><div class="sopaActionDiv"><form action="/wiki/Special:CongressLookup" action="GET"><label for="zip">{{{wp-sopa-zipform-label}}}</label> <input name="zip" type="text" size="5"> <input type="submit" name="submit" value="{{{wp-sopa-zipform-submit}}}"></form></div></div>' ) );
 68+ }
 69+
 70+var $socialDiv = $('<div></div>');
 71+
 72+
 73+var socialSites = [
 74+ {
 75+ url: 'https://www.facebook.com/sharer.php?u=' + encodeURIComponent( '{{{wp-sopa-facebook-link}}}' ),
 76+ title: '{{{wp-sopa-facebook-button}}}',
 77+ hi: '//upload.wikimedia.org/wikipedia/commons/b/b9/WP_SOPA_sm_icon_facebook_ffffff.png',
 78+ icon: '//upload.wikimedia.org/wikipedia/commons/2/2a/WP_SOPA_sm_icon_facebook_dedede.png'
 79+ },
 80+ {
 81+ url: 'https://m.google.com/app/plus/x/?v=compose&content=' + encodeURIComponent( '{{{wp-sopa-google-plus-post}}}' ),
 82+ title: '{{{wp-sopa-google-plus-button}}}',
 83+ hi: '//upload.wikimedia.org/wikipedia/commons/a/a1/WP_SOPA_sm_icon_gplus_ffffff.png',
 84+ icon: '//upload.wikimedia.org/wikipedia/commons/0/08/WP_SOPA_sm_icon_gplus_dedede.png'
 85+ },
 86+ {
 87+ url: 'https://twitter.com/intent/tweet?original_referer=' + encodeURIComponent( window.location ) + '&text=' + encodeURIComponent( '{{{wp-sopa-tweet}}}' ),
 88+ title: '{{{wp-sopa-twitter-button}}}',
 89+ hi: '//upload.wikimedia.org/wikipedia/commons/8/8a/WP_SOPA_sm_icon_twitter_ffffff.png',
 90+ icon: '//upload.wikimedia.org/wikipedia/commons/4/45/WP_SOPA_sm_icon_twitter_dedede.png'
 91+ }
 92+];
 93+
 94+
 95+for (var i = 0; i < socialSites.length; i++ ) {
 96+ ( function ( site ) {
 97+ function linkify( $item ) {
 98+ return $( '<a></a>' )
 99+ .css( 'text-decoration', 'none' )
 100+ .attr( 'href', site.url )
 101+ .click( function() {
 102+ window.open(
 103+ site.url,
 104+ 'wpblackout_' + site.title + '_share' ,
 105+ 'width=500,height=300,left=' + (screen.availWidth/2-250) + ',top=' + (screen.availHeight/2-150)
 106+ );
 107+ return false;
 108+ } ).append( $item );
 109+ }
 110+ var $icon = $( '<img></img>' ).attr( { 'width': 33, 'height': 33, 'src': site.icon } );
 111+ var $iconLink = linkify( $icon );
 112+ var $wordLink = linkify( site.title );
 113+ var $div = $( '<div class="sopaSocial"></div>' );
 114+ $div.hover(
 115+ function() {
 116+ $icon.attr( 'src', site.hi );
 117+ $wordLink.css( 'color', '#ffffff' );
 118+ },
 119+ function() {
 120+ $icon.attr( 'src', site.icon );
 121+ $wordLink.css( 'color', '#dedede' );
 122+ }
 123+ );
 124+ $div.append( $iconLink, $('<br>'), $wordLink );
 125+ $socialDiv.append($div);
 126+ } )( socialSites[i] );
 127+}
 128+
 129+ action.append( $( '<div class="sopaActionDiv"></div>' ).append(
 130+ $( '<p class="sopaActionHead">{{{wp-sopa-social-media-intro}}}</p>' ),
 131+ $( '<div class="sopaActionDiv"></div>' ).append(
 132+ $socialDiv,
 133+ $( '<div style="clear:both;"/>' )
 134+ )
 135+ ) );
 136+
 137+
 138+ var learnMore = $('<div id="sopaLearnMore"><a class="action" href="{{{wp-sopa-learnmoreurl}}}">{{{wp-sopa-learnmore}}}</a></div>');
 139+
 140+ column.append( headline, intro, takeAction, action, learnMore );
 141+ overlay.append( column );
 142+
 143+ $('body').append(overlay);
 144+ $('body').css('overflow','hidden'); // hide scrollbar for underlaying article
 145+} )(jQuery);
\ No newline at end of file
Property changes on: trunk/extensions/Blackout/modules/ext.blackout.js
___________________________________________________________________
Added: svn:eol-style
1146 + native
Index: trunk/extensions/Blackout/RELEASE NOTES
@@ -0,0 +1,2 @@
 2+For the latest release notes, please see:
 3+https://www.mediawiki.org/wiki/Extension:Blackout#Release_notes
\ No newline at end of file
Index: trunk/extensions/Blackout/Blackout.php
@@ -0,0 +1,73 @@
 2+<?php
 3+/**
 4+ * MediaWiki extension to protest, and raise awareness of, Internet censorship.
 5+ * Installation instructions can be found on
 6+ * https://www.mediawiki.org/wiki/Extension:Blackout
 7+ *
 8+ * @addtogroup Extensions
 9+ * @author Gregory Varnum utilizing work by jorm and MediaWiki developers for the Wikimedia Foundation's SOPA/PIPA protest
 10+ * @license GPL
 11+ *
 12+ * Thank you to *** for feedback, bug reporting and cleaning up code
 13+ * Thank you to Raymond and others mentioned in TweetANew.i18n.php for translation work
 14+ *
 15+ */
 16+
 17+/**
 18+ * Exit if called outside of MediaWiki
 19+ */
 20+ if( !defined( 'MEDIAWIKI' ) ) {
 21+ echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" );
 22+ die( 1 );
 23+}
 24+
 25+/**
 26+ * SETTINGS
 27+ * --------
 28+ * The following variables may be reset in your LocalSettings.php file.
 29+ *
 30+ * $wgBlackout['Enable']
 31+ * - Enables blackout message
 32+ * Default is true
 33+ *
 34+ */
 35+
 36+$wgBlackout = array(
 37+ 'Enable' => true,
 38+);
 39+
 40+/**
 41+ * Class and localisation
 42+ *
 43+ */
 44+
 45+$dir = dirname(__FILE__) . '/';
 46+$wgAutoloadClasses['Blackout'] = $dir . 'Blackout.body.php';
 47+$wgExtensionMessagesFiles['Blackout'] = $dir . 'Blackout.i18n.php';
 48+
 49+$wgResourceModules['ext.blackout'] = array(
 50+ 'styles' => 'ext.blackout.css',
 51+ 'scripts' => 'ext.blackout.js',
 52+ 'localBasePath' => dirname(__FILE__) . '/modules',
 53+ 'remoteExtPath' => 'Blackout/modules'
 54+);
 55+
 56+/**
 57+ * Credits
 58+ *
 59+ */
 60+
 61+ $wgExtensionCredits['other'][] = array(
 62+ 'name' => 'Blackout',
 63+ 'version' => '1.0.20120117',
 64+ 'author' => '[https://www.mediawiki.org/wiki/User:Varnent Gregory Varnum] utilizing work by [https://www.mediawiki.org/wiki/Extension:Blackout#Credits these fantastic MediaWiki developers]',
 65+ 'description' => 'For use during blackouts in protest to SOPA/PIPA and Internet censorship.',
 66+ 'url' => 'https://www.mediawiki.org/wiki/Extension:Blackout',
 67+);
 68+
 69+/**
 70+ * Call the hooks
 71+ *
 72+ */
 73+
 74+$wgHooks['BeforePageDisplay'][] = 'Blackout::BlackoutBanner';
Property changes on: trunk/extensions/Blackout/Blackout.php
___________________________________________________________________
Added: svn:eol-style
175 + native

Status & tagging log