MediaWiki Extension and GSoC 2014

I have been working on MediaWiki for my Google Summer of Code 2014 program. I am making an extension in MediaWiki which can store traits of materials in an organized way, display them, allow them to be searched, support import / export  and so on.  The project can be split up into two parts–Back-end and Front-end. The Back-end consists of a well structured database to store the material traits and the Front-end consists of making a web interface in MediaWiki using its special page functionality.

MediaWiki ExtensionAdd New Material - mikiwiki 2014-06-26 23-05-17

Technical details:

Overview:

MediaWiki is a free and open source wiki software, used to power wiki websites such as Wikipedia, Wiktionary and Commons, developed by the Wikimedia Foundation and others. It also runs thousands of other websites. It is written in the PHP programming language and uses a backend database.

There had been some work done on this project in the previous years but that was a standalone project in PHP not in MediaWiki. I have retained the primary database design and trying to port the whole previous work into MediaWiki extension. Whole of my MediaWiki extension is mainly written in PHP but it’s been wrapped in the functions of MediaWiki which means simple PHP , HTML , SQL etc. cannot be embedded as it is.

Progress:

The extension at present supports:

  • sign up and sign in using the MediaWiki modules.
  • adding a new material through a form,
  • adding  a new trait through a form,
  • adding a new trait-type through a form,
  • adding a new material-type through a form.
  • viewing all materials and their traits with values etc.
  • storing all the data in the database of MediaWiki.
  • keeping track of when a material/trait was added using timestamp.
  • keeping track of the user who added material/trait.

I have displayed the materials and their properties by storing the names of all the tables in an array-variable and then by using for loop and MediaWiki Joins, displayed the contents of all the tables. For preventing the user adding the same material or trait again and again, I have added the names of all the materials and traits in an array and then compared the value of the textfield in the form with the values at the array-indices. One of the biggest problem I faced was how to embed the code of various extensions into one extension to get all the functionalitites into a single extension. Finally I jumped over this pitfall by storing the new classes which extend SpecialPage class of MediaWiki into a single file using variables which are meant for this.

I have also deployed the extension on my college server which can be seen working here:

http://202.164.53.122/~albertcoder/mediawiki-1.22.6/index.php/Special:Mat_ext

The code is structured into five files which have all the coding to be executed,  loading classes,  displaying messages on wiki and  internationalization of extension and  the SQL file for defining database design respectively.

The hardest part encountered till date was displaying all the contents of all the tables by using MediaWiki joins and merging the code of various extensions to make it a single extension exhibiting all the functionalities. Also executing SQL queries according to MediaWiki is a bit tough to grab at once and trying to code anything at first seems hard as the documentation of MediaWiki is quite mature.

What keeps me motivated is my mentor and the beauty of mediawiki although it appears to be sophisticated sometimes but being deployed worldwide and used by giants like WikiPedia motivates me to learn it all.

Lines of code: 700 approximately (effective). Github shows 10 commits / 2,508 ++ / 1,501 — in the main repository and 4 commits / 276 ++ / 10 — in the testing repository. I have written this extension from scratch so no refactoring.

My next steps would include implementing features like:

  • editing the added data,
  • importing/exporting in CSV, JSON formats,
  • advanced search,
  • making the number of edits viewable for both
  • and a few other things like better search filters etc.

Assortment of Technologies and Tasks

Today I reached TCC at 9:10 am ,will reach tomorrow by 9:00 am  exact. Straightaway went out and opened LUA second day consecutively. Today me , Kamalpreet and Gurjot tried to make a bit sophisticated model in librecadv3 using LUA.

TODAY’S tasks:

1. After exercising adequately  how to make lines, circles etc. in librecadv3 through Lua Script, we ended up making a “limp stick man”. It was quite appealing to see but wasn’t that tough. :P

2. Explored object oriented PHP which I wish to deploy in GD-CAD materials database.

3. Helped colleagues with their problems esp. the one’s who couldn’t fathom compiling librecad3 even after reading the mail. I think that is just because they are totally laymen for Linux.

4. Looked for how to locate the points of our  choice on Google maps with the help of longitudes and latitudes.

5. Thoroughly enjoyed the presentation of Hitesh Sofat, got to learn many a new thing about frameworks, MVC, bootstrap and so on. Looking forward not to miss any of such presentations. :)

6. Honestly after reading Sir’s mail in brlcad mailing list, I really feel need to manage time so so judiciously because I feel the time after coming from TCC is not sufficient to complete my GSoC project in time as I am still a novice in programming. Need to do things wisely esp. time management.

The Dawn of Training

Today was the second day my training officially and I wish the dusk of my training does not  follow the dawn. I had been waiting for this period from so long with all my eagerness. I have been assigned to work on the GUI of GD-CAD throughout my 6 months training and not merely only this. CAD is the area of my interest I think as I am an admirer of maths, a lover infact. So today I did the following:

1. Learnt many a new things from Gagan’s presentation. Got a feeling that everything is tough till we get over it with our hard-work. We need to be consistent in our hard-work and devotion. And I personally feel I need to rebuild the self destructed castles. :) Got a very decent view of how all CAD softwares work.

2. Walked further on the road of LUA, pretty pleasant language which itself endeavours to be understood.

3. Enjoyed various other presentations of other GD members. Got to learn many a new thing.  Rejoicing the CAD-fest. :)

4. Felt elated to be of help to all my GD family members. In a way I feel challenged to answer the things and queries of my fellow-mates. I am persuaded to learn the things or concepts I might have skipped.

5. Installed linux OS on various systems. It’s a two way learning. Felt good that even a new junior GD member taught me how to make a bootable pendrive from ubuntu startup disk creator. There is no shame in learning from juniors. Knowledge gaining is irrespective of seniority or juniority. :)

“Awesome” Mediawiki Extension

I have been studying about how to make an extension in MediaWiki. Recently I came across an extension called “Awesome”. What it does is that is simply boldens all the words which have the occurrence of the word-pattern “awesome”.

Procedure to install an extension in MediaWiki

Generally, at the end of the LocalSettings.php file (but above the PHP end-of-code delimiter, “?>“, if present), the following line should be added:
require_once "$IP/extensions/extension_name/extension_name.php";
(Here $IP is the absolute path where your MediaWiki is installed).
This line-code forces the PHP interpreter to read the extension file, and thereby make it accessible to MediaWiki.
Some extensions can conflict with maintenance scripts, for example if they directly access $_SERVER (not recommended).
In this case they can be wrapped in the conditional so maintenance scripts can still run.
if (!$wgCommandLineMode) {
   require_once "$IP/extensions/extension_name/extension_name.php";
}

 

Ensure that required permissions are set for extensions!
While this installation procedure is sufficient for most extensions, some require a different installation procedure. Check your extension’s documentation for details.
If you want to alter configuration variables in LocalSettings.php, you have to do this typically after including the extension. Otherwise defaults defined in the extension will overwrite your settings.
Caution! Caution: While extension declaration can be placed in other places within the LocalSettings.php file, never place extensions before the require_once "includes/DefaultSettings.php"; line for MediaWiki versions below 1.17 . Doing so will blank the extension setup function arrays, causing no extensions to be installed, and probably will make your wiki inaccessible until you fix it!

We can see the extension working via the following images, see the “awesome” word being boldened:

 army

awesome

 

 

 

STEP(ISO 10303-21)

STEP-File is the most widely used data exchange form of STEP. Due to its ASCII structure it is easy to read with typically one instance per line. The format of a STEP-File is defined in ISO 10303-21 Clear Text Encoding of the Exchange Structure.[1]

A STEP-File is also called p21-File and STEP Physical File. The file extensions .stp and .step indicates that the file contain data conforming to STEP Application Protocols while the extension .p21 should be used for all other purposes.

The STEPcode project is a collection of open source libraries, tools, and resources that revolve around the technologies of ISO 10303, a.k.a. STEP, the STandard for the Exchange of Product model data. It provides a cross-platform (Linux, OSX, and Windows) implementation of an EXPRESS schema parser with bindings provided in C, C++, and Python; library that allows STEP Part 21 files to be read and written various utilities and so on. In simple words we can say that STEP provides support neutral file exchange or as a basis for data sharing or archiving in areas such as drafting, mechanical and assembly design, computational fluid dynamics, finite element analysis and so on.

STEP follows the EXPRESS schema which we need to learn before proceeding further. ISO 10303-21(STEP) defines the encoding mechanism on how to represent data according to a given EXPRESS schema, but not the EXPRESS schema itself. EXPRESS is a standard data modeling language for product data. A simple example of EXPRESS data model is as follows:

SCHEMA Family;

ENTITY Person
   ABSTRACT SUPERTYPE OF (ONEOF (Male, Female));
     name: STRING;
     mother: OPTIONAL Female;
     father: OPTIONAL Male;
END_ENTITY;

ENTITY Female
   SUBTYPE OF (Person);
END_ENTITY;

ENTITY Male
   SUBTYPE of (Person);
END_ENTITY;

END_SCHEMA; 

EXPRESS-G_diagram_for_Family_schema

An example of STEP-File which uses the above mentioned EXPRESS schema:

ISO-10303-21;
HEADER;
FILE_DESCRIPTION(
/* description */ ('A minimal AP214 example with a single part'),
/* implementation_level */ '2;1');
FILE_NAME(
/* name */ 'demo',
/* time_stamp */ '2003-12-27T11:57:53',
/* author */ ('Lothar Klein'),
/* organization */ ('LKSoft'),
/* preprocessor_version */ ' ',
/* originating_system */ 'IDA-STEP',
/* authorization */ ' ');
FILE_SCHEMA (('AUTOMOTIVE_DESIGN { 1 0 10303 214 2 1 1}'));
ENDSEC;
DATA;
#10=ORGANIZATION('O0001','LKSoft','company');
#11=PRODUCT_DEFINITION_CONTEXT('part definition',#12,'manufacturing');
#12=APPLICATION_CONTEXT('mechanical design');
#13=APPLICATION_PROTOCOL_DEFINITION('','automotive_design',2003,#12);
#14=PRODUCT_DEFINITION('0',$,#15,#11);
#15=PRODUCT_DEFINITION_FORMATION('1',$,#16);
#16=PRODUCT('A0001','Test Part 1','',(#18));
#17=PRODUCT_RELATED_PRODUCT_CATEGORY('part',$,(#16));
#18=PRODUCT_CONTEXT('',#12,'');
#19=APPLIED_ORGANIZATION_ASSIGNMENT(#10,#20,(#16));
#20=ORGANIZATION_ROLE('id owner');
ENDSEC;
END-ISO-10303-21;

A second edition of STEP AP209, renamed “Multidisciplinary analysis and design“, is in final stage of development.  It is currently at the Draft International Standard (DIS) level at ISO. I guess this has some connection with openMDAO.

STEP AP209 ed2(edition2) has enlarged its coverage beyond the STEP AP209 ed1(edition1) which primarily focussed on classical Finite Element Analysis (FEA) capabilities. Following are the disciplines that STEP AP209 ed2 covers:

  • Computational Fluid Dynamics (CFD), mainly based upon the CGNS standard;
  • Materials Database;
  • Generic structured and unstructured analysis and mesh capabilities, developed under the European Union GEM program;
  • Meshless numerical analyses;
  • Complete discrete/continuous mathematical field representation capability, based upon the David Taylor Labs/Boeing DT-NURBS package, to represent discrete and continuous scalar, vector and tensor fields (properties, loads, results);
  • Kinematics Analysis.

Out of all these disciplines my main focus is to study STEP implementation on materials database.

Materials database

Complementing STEP AP235 (Engineering properties for product design and verification), STEP AP209 ed2 offers functions related to engineering materials database for simulation, both for composite and homogeneous (metallic) materials. Among the functionalities described in the scope of the standard, there is:

  • Materials and their composition of chemical substance;
  • The identification of material specifications from internal and external sources and their properties for a specific operating environment;
  • Composite material structure and shape;
  • The depiction of composite laminate tables describing the material, stacking sequence, ply orientation, and constituents of the composite or a portion of the composite with a defined shape;
  • Catalogue data characterised by proper

I have also gone through an implementation of AP209 ed2 for “composite and metallic structural analysis and related design”. This also provides import / export functionality:

ftp://ftp.mscsoftware.com/pub/msc-products/PATRAN/v9.0/all/ap209_doc.pdf

Then there is the CAx Implementor Forum. It checks the STEP-files for ‘syntax’ and ‘structure’, to be in conformance with the Application Protocols (EXPRESS schemas) they are instantiated against. The CAx Implementor Forum is significantly improving STEP translator quality and decreasing translator time-to-market. The BRL-CAD translator for STEP, based on STEPcode, could be expanded to support the CAx-IF material identification capability which can be a key to material properties.

We can have a look at the following URL if detailed description is sought for CAx-IF http://www.cax-if.org/library/index.html .


			

Creating CIRCLE using Qt Creator 2.7.2(based on QT 5.1.0) in UBUNTU 13.04

Qt Creator is an integrated development environment (IDE) that provides you with tools to design and develop applications with the Qt application framework. Qt is designed for developing applications and user interfaces once and deploying them across several desktop and mobile operating systems. Qt Creator provides you with tools for accomplishing your tasks throughout the whole application development life-cycle, from creating a project to deploying the application on the target platforms.

"Qt Creator overview"

I have created  simple circles using Qt-Creator in two ways.

1.)using Qt Gui Application(using Qwidget)

2.)using non-Qt project(using Qmainwindow)

PREREQUISITES:

Before you need to self-perform the task,you need to do any one of the following(a> or b>):

a>clone my repository from github(in case you do not wish to indulge in writing a programs) using this link:

https://github.com/albertcoder/Qt

Once you have cloned this repository, you can directly open the project in Qt-Creator from its location. In this case you will only need to “build” and “run”.

b>write your own C++ program(since this example is based on C++) for circle(or any figure of your choice) prior to proceeding.

PROCEDURE TO DRAW THE CIRCLES:

1.)using Qt Gui Application(using Qwidget):

i.)Open file>New File or Project>Applications>Qt Gui Application.

ii.)Then select “choose”. After that set the name and location of your project and click “next”.

iii.)Then a window titled “Qt Gui Application” will appear asking Kit Selection, click “next”.

iv.)This will follow a window again titled “Qt Gui Application” asking for Class Information. Here in the Base class option we have to select “Qwidget” as we desire to make a widget and use it for displaying the output of our program.

v.)After this click “next”  click “finish” (we can also select git or mercurial from Add to version control) and we are almost done.

vi.)Now write your code for circle in file “widget.cpp” which you can open by clicking on sources from the left vertical pane after expanding your project(master). See this screen shot in case you are new to Qt-aura(this might help).

widget.cpp

vii.)Then select the “build” option(hammer shaped button in leftmost vertical column/pane).

viii.)Now select “run” option(green colored triangular button like play button in music players).

You can also do the steps vii.) and viii.) using build option from toolbar(horizontal pane on the top) .

Once you run your program(step viii), a widget will appear with circles(or any other output according to your program) drawn on it.

2.)using non-Qt project(using Qmainwindow):The procedure is almost same as above.

i.)Open file>New File or Project>Non-Qt Project>Plain C++ Project.

ii.)Then select “choose”. After that set the name and location of your project and click “next”.

iii.)Then a window titled “Plain C++ Project” will appear asking for Kit Selection,just click “next”.

iv.)After this click “next” and click “finish” (we can also select git or mercurial from Add to version control) and we are done.

v.)Now write your code for circle in file “main.cpp”(as you wrote in widget.cpp in the above example,step vi).

vi.)Then select the “build” option(hammer shaped button in leftmost vertical column/pane).

vii.)Now select “run” option(green colored triangular button like play button in music players).

You can also do the steps vi.) and vii.) using build option from toolbar(horizontal pane on the top) .

Once you run your program(step vii), a qmainwindow will appear with circles(or any other output according to your program) drawn on it.

And this is the screen-shot of the circles drawn: The rectangular window(on your left) denotes “Qmainwindow”as you can see and the square window(on your right) titled circle denotes “widget”

Image

In case you need to know more about the difference between a widget and qmainwindow refer to the following:

http://qt-project.org/doc/qt-4.8/application-windows.html

http://ubuntuforums.org/showthread.php?t=1428639

Thanks