Skip to main content

Learning to build Gadgets in Wikipedia

Building gadgets in MediaWiki is awesomely simple and real fun. Well, I wasn't actually aware of it, until I attended the Gadget building workshop in GNUnify last week, taken by Yuvi, Sucheta and Harsh. Initial step didn't sound much interesting to me, as they were mostly talking stuff which I was already aware of and tried hands on, but Yuvi probably understood my disappointment, and soon came to my rescue with some really cool and interesting stuff. Writing JavaScript files in my own MediaWiki was a regular job which I had tried a few times already, but blending some cool Ajax codes in those JavaScript files was a real fun thing to learn. It was like mixing some cream in my rich coffee :P
Learning to make use of Special:ApiSandbox made life so much easier for me. Coding made so much easy using the multiple options here.
Sitting right there, did manage to put some Ajax codes into a js file and make it work fine. 
The learning didn't stop there. The fun continued as Yuvi went ahead to teach, how to package our codes and make it available for anyone across Wikipedia platform. So much work done in such simple ways and made so easily available for others too.

Here I will go ahead and give you a small example for a small task that can be done so easily using the perfect blend of Ajax and JavaScript:

$.get("/w/api.php?action=query&meta=userinfo&format=json&uiprop=editcount") 
.done(function(data){alert(data.query.userinfo.editcount);});

#I had added this small code in a JavaScript file that I had created. This code will basically give an alert of the user's edit count every time.

I had simply called this JavaScript page from my common.js file. If any other user wants to use my code, all he needs to do is import the required JavaScript file like:
importScript("User:Priyanka Nag/EditPage.js");
 
This is how simple making and packaging a Gadget is in Wikipedia. Well, I am calling it simple cause I did a very simple job here. Now, depending on your codes and purpose of your gadget, your gadget can be simple or complicated.

Comments

Post a Comment

Popular posts from this blog

Embedding Scrollback on your personal website

If you are not already aware of what Scrollback is, here is a small introduction to Scrollback. "Scrollback is a beautiful, open source text chat service designed for communities. Scrollback chat rooms can be embedded in websites and linked with Twitter hashtags or IRC channels." [You can visit the Scrollback site for a better understanding]. Many community websites and personal websites have adopted Scrollback and embedded it into their sites. A great example for this is the Mozilla India website . Here are a few simple steps following which you can easily embed Scrollback in your personal website. Step 1: On the Scrollback website, create your own chat room. This chat-room will be the one which will get embedded into your site. The modal window where you can name your room as per your needs Step 2: Once the room is created, you will automatically be re-directed to your room's page. On your room’s page, the left column will have all information about y...

Quarantining Alone - A Once in a Lifetime Opportunity

This Covid-19 virus has turned the entire world upside down. It has broken a lot of older habits and set a lot of new normals. Towards the early days of this lockdown, I had written a blog - An Extrovert in Isolation . The early lockdown days were extremely difficult for me. That was the phase of breaking old habits. An extrovert by nature, couldn't accept the sudden change of being locked alone inside my house. I am writing this blog again after being locked at home for more than 100 days now. Most of the older habits are broken by now. A few new habits have become a part of my new normal. What seemed to have been painful 100 days back has now turned to be blissful. Here, I am sharing my story of how quarantining alone has ended up being the greatest opportunity and a huge transformation in my life.  I have been struggling for years to fix my sleep patterns. Going to bed late and waking up late had been a habit for a really long time. My struggles to change this habit had...

RASCI model - the responsibility assignment matrix

In the last few days, both at my workplace as well as while dealing with a few activities around me, I have realized the importance of implementing a better responsibility assignment matrix, to get things done in a less messed up way. A few months back, during some random conversation, a friend of mine had introduced me to the RASCI model, one of the responsibility assignment matrices. Wikipedia says that the responsibility assignment matrix 'describes the participation by various roles in completing tasks or deliverables for a project or business process.'  In simple words, for any project, if we can divide each person's role and responsibility, it not only ensures a better end product, but also saves the time, otherwise lost in discussions (which organizations like to call as meetings). A RASCI implementation ensures that each person is responsible for only and only the task assigned to him (or her) and will not need to interfere with another person's task, un...