diff --git a/LocalSettings.php b/LocalSettings.php index 3a44feb..7c087f5 100644 --- a/LocalSettings.php +++ b/LocalSettings.php @@ -34,7 +34,8 @@ ## The protocol and server name to use in fully-qualified URLs $wgServer = "http://wikipediaadventure.moonflare.com"; -# $wgServer = "http://localhost"; # For testing +# $wgServer = "http://localhost"; # For testing + ## The relative URL path to the skins directory $wgStylePath = "$wgScriptPath/skins"; @@ -42,6 +43,7 @@ ## The relative URL path to the logo. Make sure you change this from the default, ## or else you'll overwrite your logo when you upgrade! $wgLogo = "$wgStylePath/common/images/Wiki.png"; +$wgFavicon = "$wgScriptPath/favicon.ico"; ## UPO means: this is also a user preference option @@ -66,7 +68,7 @@ $wgSQLiteDataDir = "data"; ## Shared memory settings -$wgMainCacheType = CACHE_NONE; +$wgMainCacheType = CACHE_ACCEL; $wgMemCachedServers = array(); ## To enable image uploads, make sure the 'images' directory @@ -153,3 +155,6 @@ $wgDefaultSkin = 'vector'; $wgVectorUseIconWatch = true; $wgShowIPinHeader = false; + +# Caching stuff for performance +$wgCacheDirectory = "$IP/cache"; diff --git a/data/wikipediaadventure.db.sqlite b/data/wikipediaadventure.db.sqlite index 78eeaf3..4cb779d 100644 Binary files a/data/wikipediaadventure.db.sqlite and b/data/wikipediaadventure.db.sqlite differ diff --git a/favicon.ico b/favicon.ico new file mode 100644 index 0000000..31b0e38 Binary files /dev/null and b/favicon.ico differ diff --git a/skins/common/tutorial.js b/skins/common/tutorial.js index c840e03..e44fee5 100644 --- a/skins/common/tutorial.js +++ b/skins/common/tutorial.js @@ -1,3 +1,5 @@ +exit(); + // Based on http://www.codeproject.com/Tips/61476/Disable-all-links-on-the-page-via-Javascript function DisableEnableLinks(){ objLinks = document.links; @@ -56,22 +58,23 @@ function getOffset( el ) { return { top: _y, left: _x }; } -var updatePositions = function() { - if (arrowTarget) { - var marker=document.getElementById('twa-marker'); - offset = $(arrowTarget).offset(); - marker.style.left = '' + (offset.left + $(arrowTarget).width()/2 - $(marker).width()/2) + 'px'; // center - marker.style.top = '' + (offset.top + $(arrowTarget).height()) + 'px'; // right under pt-login - } -} - var getStep = function() { result = $.cookie("twa-step"); return result; } -var setStep = function(stepNum) { - $.cookie("twa-step", stepNum, { path: '/' }); +var setStep = function(stepName) { + if (stepName.indexOf("/") == -1) { + components = getStep().split('/'); + setStep(components[0] + "/" + stepName); + return; + } + $.cookie("twa-step", stepName, { path: '/' }); +} + +var goToStep = function(stepName) { + setStep(stepName); + updateOverlays(); } var centerElement = function(element) { @@ -83,11 +86,162 @@ var centerElement = function(element) { $(element).css('margin-left', '' + -$(element).width()/2 + 'px'); }; +// Visually highlights a given element - currently can only do one at a time +var highlightElement = function(target) { + var marker = document.getElementById('twa-marker'); + marker.innerHTML = ''; + offset = $(target).offset(); + marker.style.left = '' + (offset.left + $(target).width()/2 - $(marker).width()/2) + 'px'; // center + marker.style.top = '' + (offset.top + $(target).height()) + 'px'; // right under pt-login + return target; +}; + +var updateFirstEdit = function(step, instructions) { + switch(step) { + case 'Welcome': + instructions.innerHTML = + '
Log in
' + + '

Welcome to The Wikipedia Adventure, a tutorial for new Wikipedia users. Instructions will appear in the lower-right.

' + + '

Would you like to review how to make an edit to an article?

' + + '

Yes No

'; + centerElement(instructions); + break; + case "MainPageClickArticle": + instructions.innerHTML = + '

Begin by clicking on the George Tupou V link to visit the article on George Tupou V, King of Tonga.

'; + $(highlightElement('a[title="George Tupou V"]'))[0].onclick = function(){setStep('FindError')}; + break; + case 'FindError': + instructions.innerHTML = + '

You are now reading the article on George Tupou V. This article contains a small error in its first sentence. ' + + 'Try to find it and click on it.

'; + var content = $("div[class=mw-content-ltr]")[0]; + content.innerHTML = content.innerHTML.replace(" deth ", ' deth '); + break; + case 'ShowError': + instructions.innerHTML = + '

Nice spotting! The error is that "death" is misspelled as "deth". We\'re going to fix this.

' + + '

Next

'; + $('#deth')[0].onclick = null; + highlightElement('#deth'); + break; + case 'ClickEditTab': + instructions.innerHTML = + '

Start by clicking on the Edit tab to edit the article.

'; + $(highlightElement('#ca-edit')).find('a')[0].onclick = function(){setStep('Editing');}; + break; + case 'Editing': + instructions.innerHTML = + '

You are now editing the article. Find the misspelled word deth and change it to "death", then click Next below.

' + + '

Next

'; + desired_value = $('#wpTextbox1')[0].value.replace(' deth ', ' death '); + break; + case 'DoneEditing': + if ($('#wpTextbox1')[0].value == desired_value) { + instructions.innerHTML = + '

Good job! Next, click on the Summary field and enter a short explanation for your edit, such as "fixed spelling error". ' + + 'This is called an edit summary, and every edit should have one. Then click Next below.

' + + '

Next

'; + highlightElement('#wpSummary'); + } else { + instructions.innerHTML = + '

You made the change incorrectly. Make sure you changed deth to "death" and made no other changes. ' + + 'Click Next below to try again.

' + + '

Next

'; + } + break; + case 'DoneSummary': + if ($('#wpSummary')[0].value.length > 0) { + instructions.innerHTML = + '

Great! Finally, click on Save page to save your changes to the article.

'; + $('#editform')[0].onsubmit = function(){ + // Don't really let them save - just redirect back to article, we'll fake the changes. + // TODO: if they attempt incorrectly more than once the message won't appear to change + setStep('ShowArticleWithChange'); + window.location.href = wgArticlePath.replace('$1', 'George_Tupou_V'); + return false; + } + highlightElement('#wpSave'); + } else { + instructions.innerHTML = + '

You did not enter a summary. ' + + 'Click on the Summary field indicated by the arrow and enter a short explanation for your edit, such as "fixed spelling error". ' + + 'Then click Next below.

' + + '

Next

'; + } + break; + case 'ShowArticleWithChange': + instructions.innerHTML = + '

Your changes to the article appear instantly to all readers. ' + + 'If your changes were incorrect, another user can always easily change it back. ' + + 'Click Next below for your Real Wikipedia Bonus Task.

' + + '

Next

'; + var content = $("div[class=mw-content-ltr]")[0]; + content.innerHTML = content.innerHTML.replace(" deth ", ' death '); + highlightElement('#death'); + break; + case 'RealWikipediaBonusTask': + instructions.innerHTML = + '

Real Wikipedia Bonus Task

' + + '

You\'re now ready to make a real edit to Wikipedia. ' + + 'Visit en.wikipedia.org and click on the Random article link (indicated). ' + + 'Look for a minor error in spelling, grammar, punctuation, or style and fix it. ' + + 'If you don\'t see one, click Random article again until you do. ' + + 'When done, click Next below.

' + + '

Next

'; + highlightElement('#n-randompage'); + break; + case 'LessonComplete': + instructions.innerHTML = + '

Great job! You have completed the first level. Click Level menu below to choose another level.

' + + '

Level menu

'; + centerElement(instructions); + break; + } +} + +var updateCreateUser = function(step, instructions) { + switch(step) { + case "Start": + instructions.innerHTML = + '

Do you already have a user account registered on Wikipedia?

' + + '

Yes No

'; + centerElement(instructions); + break; + case "MainPageClickLogIn": + instructions.innerHTML = + '

Under construction

'; + break; + } +} + +var updateTwa = function(step, instructions) { + switch(step) { + case 'LevelMenu': + instructions.innerHTML = + '

Select a level

' + + '

Making your first edit

' + + '

More levels to come!

'; + centerElement(instructions); + break; + case "CreateAccount": + instructions.innerHTML = + '

Under construction

'; + break; + case "Login": + instructions.innerHTML = + '

Under construction

'; + break; + } +} + var updateOverlays = function() { // Must call before enabling links selectively below DisableEnableLinks(); - arrowTarget = null; + // Hide marker initially, so it won't show if it's not used + var marker = document.getElementById('twa-marker'); + marker.innerHTML = ''; var instructions = document.getElementById('twa-instructions'); instructions.style.position='fixed'; @@ -99,99 +253,12 @@ var updateOverlays = function() { instructions.style.bottom = '10%'; instructions.innerHTML = ''; - var marker = document.getElementById('twa-marker'); - marker.innerHTML = ''; - arrowTarget = null; + var stepComponents = getStep().split('/'); + window["update" + stepComponents[0]](stepComponents[1], instructions); - if (getStep() == 'start') { - setStep("first-edit.welcome"); - } - - if (getStep() == "first-edit.welcome") { - instructions.innerHTML = '

Welcome to The Wikipedia Adventure, a tutorial for new Wikipedia users. Instructions will appear in the lower-right.

'; - instructions.innerHTML += '

Would you like to review how to make an edit to an article?

'; - instructions.innerHTML += '

Yes No

'; - centerElement(instructions); - } else if (getStep() == "first-edit.main-page-click-article") { - instructions.innerHTML = '

Begin by clicking on the George Tupou V link to visit the article on George Tupou V, King of Tonga.

'; - arrowTarget = 'a[title="George Tupou V"]'; - $(arrowTarget)[0].onclick = function(){setStep('first-edit.find-error')}; - } else if (getStep() == 'first-edit.find-error') { - instructions.innerHTML = '

You are now reading the article on George Tupou V. This article contains a small error in its first sentence. Try to find it and click on it.

'; - var content = $("div[class=mw-content-ltr]")[0]; - content.innerHTML = content.innerHTML.replace(" deth ", ' deth '); - } else if (getStep() == 'first-edit.show-error') { - instructions.innerHTML = '

Nice spotting! The error is that "death" is misspelled as "deth". We\'re going to fix this.

'; - instructions.innerHTML += '

Next

'; - $('#deth')[0].onclick = null; - arrowTarget = '#deth'; - } else if (getStep() == 'first-edit.click-edit-tab') { - instructions.innerHTML = '

Start by clicking on the Edit tab to edit the article.

'; - arrowTarget = '#ca-edit'; - $(arrowTarget).find('a')[0].onclick = function(){setStep('first-edit.editing');}; - } else if (getStep() == 'first-edit.editing') { - instructions.innerHTML = '

You are now editing the article. Find the misspelled word deth and change it to "death", then click Next below.

'; - instructions.innerHTML += '

Next

'; - desired_value = $('#wpTextbox1')[0].value.replace(' deth ', ' death '); - } else if (getStep() == 'first-edit.done-editing') { - if ($('#wpTextbox1')[0].value == desired_value) { - instructions.innerHTML = '

Good job! Next, click on the Summary field and enter a short explanation for your edit, such as "fixed spelling error". This is called an edit summary, and every edit should have one. Then click Next below.

'; - instructions.innerHTML += '

Next

'; - arrowTarget = '#wpSummary'; - } else { - instructions.innerHTML = '

You made the change incorrectly. Make sure you changed deth to "death" and made no other changes. Click Next below to try again.

'; - instructions.innerHTML += '

Next

'; - } - } else if (getStep() == 'first-edit.done-summary') { - if ($('#wpSummary')[0].value.length > 0) { - instructions.innerHTML = '

Great! Finally, click on Save page to save your changes to the article.

'; - $('#editform')[0].onsubmit = function(){ - // Don't really let them save - just redirect back to article, we'll fake the changes. - setStep('first-edit.show-article-with-change'); - window.location.href = wgArticlePath.replace('$1', 'George_Tupou_V'); - return false; - } - arrowTarget = '#wpSave'; - } else { - instructions.innerHTML = '

You did not enter a summary. Click on the Summary field indicated by the arrow and enter a short explanation for your edit, such as "fixed spelling error". Then click Next below.

'; - instructions.innerHTML += '

Next

'; - } - } else if (getStep() == 'first-edit.show-article-with-change') { - instructions.innerHTML = '

Your changes to the article appear instantly to all readers. If your changes were incorrect, another user can always easily change it back. Click Next below for your Real Wikipedia Bonus Task.

'; - instructions.innerHTML += '

Next

'; - var content = $("div[class=mw-content-ltr]")[0]; - content.innerHTML = content.innerHTML.replace(" deth ", ' death '); - arrowTarget = '#death'; - } else if (getStep() == 'first-edit.real-wikipedia-bonus-task') { - instructions.innerHTML = '

Real Wikipedia Bonus Task

'; - instructions.innerHTML += '

You\'re now ready to make a real edit to Wikipedia. '; - instructions.innerHTML += 'Visit en.wikipedia.org and click on the Random article link (indicated). '; - instructions.innerHTML += 'Look for a minor error in spelling, grammar, punctuation, or style and fix it. If you don\'t see one, click Random article again until you do. When done, click Next below.

'; - instructions.innerHTML += '

Next

'; - arrowTarget = '#n-randompage'; - } else if (getStep() == 'first-edit.lesson-complete') { - instructions.innerHTML = '

Great job! You have completed the first level. Click Level menu below to choose another level.

'; - instructions.innerHTML += '

Level menu

'; - centerElement(instructions); - } else if (getStep() == 'level-menu') { - instructions.innerHTML = '

Select a level

'; - instructions.innerHTML += '

Making your first edit

'; - instructions.innerHTML += '

More levels to come!

'; - centerElement(instructions); - } else { + if (instructions.innerHTML === '') { instructions.innerHTML = '

Unknown step name: ' + getStep() + '

'; } - - if (arrowTarget) { - marker.innerHTML = 'Click here'; - } - - updatePositions(); -} - -var goToStep = function(stepNum) { - setStep(stepNum); - updateOverlays(); } window.onresize = function(event) { @@ -215,6 +282,6 @@ marker.style.position='absolute'; root.appendChild(marker); if (document.URL.indexOf("/Main_Page") != -1) { - setStep('start'); + setStep("FirstEdit/Welcome"); } updateOverlays();