Wikipedia:Simple News/Microchip08/1

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
The Simple News
Article 1
Wikimarkup & Javascript

This is my first article for Simple News, and I thought I would make a little column with no real focus, just exploring anything that comes to mind, and of course, my obligatory Wikibooks plug. I'm not generally a writer, so please bear with me! This issue, I will be covering some simple Wikimarkup shorthand, that people may find useful, along with some rudimentary javascript you can use to customise your viewing experience, although this is very basic and there are probably better ways of doing things.

Wikitext-wiki markup-wikipedia.png

Wikimarkup[change source]

Wikimarkup can be as basic as two apostrophes, or can be as complicated as intricate parser functions on templates. It is a wide ranging subject, and is extremely versatile. It is easy to pick up, and supports a limited amount of HTML. Everyone who edits Wikipedia regularly knows the way to make '''bold''' and ''italics'', so I'm not going to dwell on those: instead I'm going to delve into the world of [[wikilink]]s. The normal wikilink, as we all know, is created by placing a double pair of square brackets either side of an article name, making [[apple]] into the infinitely more useful apple. Then we get slightly more advanced, creating better links, utilising the "pipe" (that's that character that is swapped round on keyboards for random reasons, the ¦ key that, when pressed, creates a |), and so [[pear|better links]].

MediaWiki comes with many different nuances for links, allowing shorthand when linking to subpages, and easy crossnamespace inline linking. Most of us know that [[/header]], if written on this page, for example, will link to Wikipedia:Simple News/Microchip08/1/header. Slightly annoyingly, however, it appears as "/header", although something a little neater, without the slash, is preferable. It's a very easy shortcut: instead of writing [[/header|header]], we can write [[/header/]]. This creates the nice and simple header, which is a lot easier to write, and trims the wikimarkup, making it easier for the next editor to change their page.

That's not the only corner you can cut: when someone wants to link to a namespace, there are easier ways to link to a page without including the prefix (so, if you wanted to mention me on AN, most people would link to User:Microchip08). Of course, and I support User:Microchip08's ban is rather 'clunky' — Now then, Microchip08 is a rather nice guy is a lot nicer to look at, and it's only one extra character — the legendary pipe. Write [[User:Microchip08|]], and it automatically removes the namespace. [[Wikipedia:Simple Talk|]] creates Simple Talk. It works with anything with a colon too: [[WP:AN|]] turns into AN, and [[:de:Zimmer|]] turns into Zimmer.

.js[change source]

Javascript icon.svg

Javascript is the main way to alter the appearance of Wikipedia on a per-user basis. Quite simply, all you need to do is to edit your monobook.js (if you are using the default skin), which can be found at Special:Mypage/monobook.js. If you're using another skin, you need to edit the page with your skin name, with a few exceptions. All javascript pages are lowercase, and end in .js. Here's a few code snippets that I have in my monobook.js, that currently are not gadgets.

One of the most useful snippets, in my opinion, changes a redlinked discussion tab to, when clicked, go to a new section as supposed to the standard edit page. It was based on English Wikipedia's User Scripts WikiProject.

function talkpageplus()
{
    var talkpagelink = document.getElementById('ca-talk'); // This line finds the talk tab on the page
    if (talkpagelink.className == 'new') // And checks if it is a redlink
    {
        talkpagelink.firstChild.href += '&section=new'; // add &section=new to the end of the link
    var tab = document.getElementById('ca-talk'); // and then looks for it again
    if(!tab) return;
    var tablink = tab.getElementsByTagName('a')[0];
    if(!tablink) return;
    tablink.firstChild.nodeValue = '+'; // now change it to a + instead of the normal "discussion"
    tablink.style.paddingLeft = ".4em";
    tablink.style.paddingRight = ".4em";
    } // not a redlink? jump to here
} //end
 
addOnloadHook(talkpageplus); // execute function above
//

Another thing that I use (and I made this one all by myself), alters the sidebar, amongst other things.

addOnloadHook(function () {
   addPortletLink ('p-personal', '/wiki/Special:MyPage/monobook.js', 'My monobook.js'); // ONE
   addPortletLink ('p-navigation', '/wiki/WP:AN', 'WP:AN', 'ani', 'Go to the Admin Noticeboard');
   var el = document.getElementById('n-portal'); // TWO
   if (el) el.style.display = 'none';
   var el = document.getElementById('n-sitesupport'); // TWO
   if (el) el.style.display = 'none';
   var el = document.getElementById('p-coll-create_a_book');  // THREE
   if (el) el.style.display = 'none';
   var el = document.getElementById('n-help');  // TWO
   if (el) el.style.display = 'none';
   var el = document.getElementById('siteSub'); // FOUR
   if (el) el.style.display = 'none';
});

What the above snippet does is add a link to my "personal" toolbar, which is the bar at the top of the screen that says "my talk, my settings" etc., that gives a link to my monobook.js. You can easily adapt this for your own purposes: just copy the following:

addOnloadHook(function () {
   addPortletLink ('ONE', '/wiki/TWO', 'THREE');
});

and replace TWO with the page you want linking to, THREE with whatever you want the text to be when you hover over it, and ONE with one of the following, depending on where you want the link to appear:

p-logo p-personal name my talk my preferences
p-cactions article discussion edit this page

p-navigation

 Main page …

p-search

 

p-tb
What links here…


p-lang
(interwikis)

The other section of the javascript removes certain aspects, such as the infuriating (for me), create a book section, the Community Portal, that I never use, and the Donate link. It also removes the "From Wikipedia" section: I know what website I am on. This is relatively easy to adapt: find the source of the page (View > Source), search for the correct part of the webpage, and look to see what the ID is (id=???). Then stick it in to the line (instead of n-portal), but leave the quotation marks intact, and make sure you copy both lines.

I hope this enlightens you slightly, and I hope it's been worthwhile. To finish it off, here's one more snippet of Javascript, which adds tabs to the top of the page, giving you a link to the same page in all the sister projects, and en. I've got Wikipedia on there as my wikt: profile synchronises with my Wikipedia javascript. You can change the location of the links by changing p-cactions for one of the other options outlined above.

addOnloadHook(function () {
   addPortletLink ('p-cactions', '/wiki/wikt:' + wgPageName, 'wikt'); //wiktionary
   addPortletLink ('p-cactions', '/wiki/b:' + wgPageName, 'books');   //wikibooks
   addPortletLink ('p-cactions', '/wiki/q:' + wgPageName, 'quote');   //wikiquote
   addPortletLink ('p-cactions', '/wiki/w:' + wgPageName, 'pedia');   //wikipedia
   addPortletLink ('p-cactions', '/wiki/:en:' + wgPageName, 'en');   // en
});

Thanks.