Skip to content

Instantly share code, notes, and snippets.

View jdlrobson's full-sized avatar

Jon Robson jdlrobson

View GitHub Profile
@jdlrobson
jdlrobson / greasemonkey-portal-styles-script
Created August 3, 2012 23:47
This is a hacked up greasemonkey script that navigates to problematic pages and replaces inline styles with classes - run it on a page with links to articles with inline styles 2 column layouts it will then fix those up and you simply have to click save t
// ==UserScript==
// @name Cleanup
// @namespace /
// @description aasas
// @include http://en.wikipedia.org/*
// @include http://www.mediawiki.org/wiki/List_of_Problematic_portal_pages_with_two_column_layouts
// @version 1
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js
// ==/UserScript==
@jdlrobson
jdlrobson / codereviewexample.html
Last active October 9, 2015 06:18
This is bad code. Tell me why.
<!DOCTYPE HTML>
<html>
<body>
<ul id="list1">
<li><span>apple</span></li>
<li><span>banana</span></li>
<li id="last"><span>carrot</span></li>
</ul>
<script type="text/javascript">
// given a parent
@jdlrobson
jdlrobson / wlm-widget-us
Created September 1, 2012 02:07
wiki loves monuments widget for http://wikilovesmonuments.us/
( function( $ ) {
$( '<link rel="stylesheet" >' ).attr( 'href', 'http://jonrobson.me.uk/wlm/p.css' ).appendTo( document.head );
var $container = $( '<div>' ).css( {
height: $('#primary').height(),
width: 250,
position: 'relative',
display: 'block',
'float': 'right'
} ).insertAfter( '#secondary' );
$.getScript( 'http://jonrobson.me.uk/wlm/polaroiderizer.js', function() {
( function( $ ) {
$('<div id="wlm-stream-widget" style="position:relative;display:block;float:right;width:250px;height:500px;display:block;"></div>').appendTo( '#secondary' );
$( '<link rel="stylesheet" >' ).attr( 'href', 'http://jonrobson.me.uk/wlm/p.css' ).appendTo( document.head );
$.getScript( 'http://jonrobson.me.uk/wlm/polaroiderizer.js', function() {
polaroiderizer( $( '#wlm-stream-widget' ),
{
iiurlwidth: '320px',
action: 'query',
gcmsort: 'timestamp', gcmdir: 'desc',
@jdlrobson
jdlrobson / Sample config file
Created October 30, 2012 17:59
Email digest for Wikipedia Feedback
config = {
'sender': 'a@b.com',
'mailer':{'smtp':'xxx','pop':'xxxx','username':'xxxx','password':'xxxx' },
'receiver': {
'site': [ 'x@y.com' ],
'app': [ 'x@y.com' ],
'spam': [ 'x@y.com' ]
}
}
@jdlrobson
jdlrobson / Less file for Brion
Created October 31, 2012 22:33
Less file for Brion
#mw-mf-watchlist {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-o-user-select: none;
user-select: none;
.mw-mf-watchlist-selector {
text-align: center;
padding: 8px 0px;
diff --git a/includes/MobileContext.php b/includes/MobileContext.php
index de0c1d7..2b9fb1e 100644
--- a/includes/MobileContext.php
+++ b/includes/MobileContext.php
@@ -32,7 +32,6 @@ class MobileContext extends ContextSource {
protected $mobileAction;
private $forceMobileView = false;
- private $forceLeftMenu = false;
private $contentTransformations = true;
@jdlrobson
jdlrobson / gist:5439509
Last active December 16, 2015 13:08
Using a hook to do mobile formatting on section level basis
diff --git a/MobileFrontend.php b/MobileFrontend.php
index 55f8718..2a83d33 100644
--- a/MobileFrontend.php
+++ b/MobileFrontend.php
@@ -107,6 +107,7 @@ $wgHooks['UserLoginComplete'][] = 'MobileFrontendHooks::onUserLoginComplete';
$wgHooks['UserLoginForm'][] = 'MobileFrontendHooks::onUserLoginForm';
$wgHooks['UserCreateForm'][] = 'MobileFrontendHooks::onUserCreateForm';
$wgHooks['BeforePageDisplay'][] = 'MobileFrontendHooks::onBeforePageDisplay';
+$wgHooks['OutputPageParserOutput'][] = 'MobileFrontendHooks::onOutputPageParserOutput';
@jdlrobson
jdlrobson / cachedpage.sh
Created May 1, 2013 11:23
check cached pages
#usage ./scripts/cachedpage.sh 1bd5bc53ebb04fff7f508712a29fdf1f1d7fe14f
#must be run an a branch with no stashed changes
#git stash - only do this if local changes
cur_branch=`git rev-parse --abbrev-ref HEAD`
# fIXME: if current branch is HEAD then create a tmp branch here and set it to cur_branch...
git checkout $1 #go to last known deployed commit
wget http://localhost/w/index.php/Main_Page -O cached.html
wget http://localhost/w/index.php/Special:MobileOptions -O cached_special.html
git checkout $cur_branch
open http://localhost/w/extensions/MobileFrontend/cached.html
@jdlrobson
jdlrobson / crêpe.html
Created June 17, 2013 22:31
When run from http (not file uri) the address bar is updated to be "crêpe.html" (Chrome and Firefox)
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript" src="javascripts/externals/history.js"></script>
<script type="text/javascript" src="javascripts/externals/history.adapter.jquery.js"></script>
</head>
<body>
<script type="text/javascript">