=**Profile Information**=
Name: Akanksha Gupta
Preferred pronoun: she
Email: akanksha2879@gmail.com
irc nick: akangupt
Mediawiki User: [[ https://meta.wikimediawww.mediawiki.org/wiki/User:Akangupt |Akangupt]]
Location: Mandi, Himachal Pradesh, India
Time Zone: UTC+5:30
Typical working hours: (Indian Standard Time)
5PM to 1AM - before 7th December 2015
10AM to 6PM - 7th December 2015 - 21st February 2015
5PM to 1AM - After 21st February 2015
=Synopsis
It’s convenient to get the information from wiki pages directly rather than searching in git repositories for documentation and code snippets. To facilitate this, developers end up dumping the git-docs on wiki.
Wiki pages of git-docs are always either outdated or wrong. This is intuitive because developers are not required to keep track of every commit/merge in corresponding repositories and then update the wiki-pages accordingly.
=== Solution:
In order to avoid outdated, wrong documentations and facilitate the ease of inserting code snippets from git repositories to wiki, the proposal is to create an extension, which would transclude the git content in wiki and update them when corresponding git-docs get updated.
This extension will be allowed to access the data in extension.json (Required) and hooks.yaml (Optional). This data will be fed to wiki template that creates extension infobox and hook pages respectively.
=Possible mentors
# [[https://meta.wikimedia.org/wiki/User:SPage_(WMF)|S Page]] (@spage)
# [[https://en.wikipedia.org/wiki/User:Tgr_(WMF)|Gergő Tisza]] (@Tgr)
# [[https://www.mediawiki.org/wiki/User:Ankitashukla|Ankita Shukla]] (@ankitashukla)
=The plan
===Step-1 :
Create an extension which can transclude content from git in wiki pages . This involves:
- Creating the parser function '#GitAtWiki'.
Git server can be requested for :
- A file
- Part of the file by specifying start and end line numbersa regex.
- Code snippet in a file.
Parser function will have a syntax like:
```
{{#GitAtWiki: FILENAME|repo=REPOSITORY|commitID=COMMITID}}branch=BRANCHNAME|from:STARTPATTERN|to:ENDPATTERN|code:YES}}
```
Parameters for the parser function:
- **filename:** Required. The filename whose content is going to be displayed.
- **repo:** Required. The URL of the git repository. (only whitelisted URLs are allowed)For example : `{{#GitAtWiki: docs/hooks.txt}}`
- **commitID:** Required.repo:** Optional. Repository name. Default: The default repository will be set using the`$egGitAtWikiDefaultRepo` setting in LocalSetting file. For example, Commit ID on whichfor Mediawiki corresponding file content will be considered.e: `$egGitHubDefaultRepo = 'wikimedia/mediawiki';`
- **branch:** Optional. The branch to look for the file. Default = master.
- **startlinefrom:** Optional. The startline number regex pattern from where content will be pulled. Default = Start of file.
- **endlineto:** Optional. The endline number regex pattern till where the content will be pulled. Default = End of file.
- **code:** Optional. Specify code = yes'yes' to display the content inhighlight the form ofetched code snippete. Default = No'no'.
- **lang:** Optional. Language of the code snippet. Code snippet will be highlighted according to the lang. This parameter can take one of the value defined for [[https://en.wikipedia.org/wiki/Template:Syntaxhighlight|lang parameter ]]. By Default, code snippet will not be highlighted. It will only be displayed in a monospace format similar to <code> tag- Requesting the file over [[ https://doc.wikimedia.org/mediawiki-core/master/php/classHttp.html#a5d0c351bd4437f17dc083bc14f0c5749 | HTTP ]] or [[http://php.net/manual/en/function.file-get-contents.php | file_get_contents]] and caching the response with an expiration time (approximately 3 days) and commit-id as a source url.
- Requesting the file over [[ https://doc.wikimedia.org/mediawiki-core/master/php/classHttp.html#a5d0c351bd4437f17dc083bc14f0c5749 | HTTP ]] and caching the response with an expiration time (approximately 3 days) and commit-id as a caching key.```
$sourceUrl = "https://raw.githubusercontent.com/".$repo."/".$branch."/".$filename ;
```$fetchedValue = \Http::get( $sourceUrl );
```
- Making the received content renderable after sanitizing it.
| **File Format** | Rendering Method
| -- | --
| Code snippet | These will be rendered using <source> or <syntaxhighlight> tags.
| MarkDown files | Example : Readme.md. These files will be converted to html using [[ https://github.com/covex-nn/moodle/tree/2.8/lib/markdown | Michelf\Markdown ]] or similar methods.
| Mediawiki files and Wiki files| Example : [[ https://github.com/wikimedia/mediawiki#readme | Readme.mediawiki]] and [[ https://phabricator.wikimedia.org/diffusion/EWBA/browse/master/docs/lua.wiki | lua.wiki ]] . These files will be rendered as it is.
| Text files etc.| Example : Readme.txt. These files will be rendered using <prepoem> and <nowiki> tags.
**For mediawiki files, wiki files and code snippets : **
```$output = '<syntaxhighlight>' .```return array( $fileContents, 'nowiki' => false, htmlspecialchars( $fileContents ) .'noparse' => true, '</syntaxhighlight>';'isHTML' => false );```
return array( $output, 'nowiki' => true, 'noparse' => true, 'isHTML' => true );```
**For text files : **
```$output = '<pre>'oem>' . htmlspecialchars( $fileContents ) . '</pre>';oem>';
return array( $output, 'nowiki' => true, 'noparse' => true, 'isHTML' => true );```
===Step-2 :
Updating the wiki pages when git-docs get updated.
Idea is to maintain a mapping/database of source (git-doc), destination (wiki-page), commit-id (from which the content is taken), start line number (The start line number from where the content was pulled) and end line number (The end line number till where content was pulled). Then by using post-commit hook in git repository which checks for the difference between **the content of git-doc between start line and end line of commit-id (saved in mapping)** and **the content of git-doc between start line and end line patterns in the most recent commit**.
( **Why patterns? :** It might be the case that start line and end line numbers get modified after the most recent commit. By comparing the content using the line numbers might give a false information. Hence, the solution is to search for the pattern, which are present at git-doc' start line and at end line (for the saved commit-id in mapping), in the most recent commit.)
If a difference is reported by above comparison then previously saved commit-id, startline and endline will be replaced by present commit-id, start line and end line number.
**Note: **
The approach of using start line and end line numbers in the syntax
```
{{#GitAtWiki: FILENAME|repo = REPOSITORY|commitID = COMMITID | startline = STARTLINE | endline = ENDLINE}}
```
might be moved to the syntax
```
{{#GitAtWiki: FILENAME|repo = REPOSITORY|commitID = COMMITID | startpattern = STARTPATTERN | endpattern = ENDPATTERN}}
```
on the basis of use cases and efficiency of both methodsgit-doc) and destination (wiki-page) and adding a post commit hook which triggers the update remotely from Jenkins.
===Step-3:
CreaWrite a lua modulePHP script to process the text given by extension. Extension will fetch the text from hooks.yaml and lua will process the text and return the information about a specific hook with the help of PHP and lua. SoHence, this extension will be used to create the [[ https://www.mediawiki.org/wiki/Manual:Hooks | individual hook pages ]] easily.
===Phases
**Phase I:** Request for a repository, wikimedia lab instance and explore existing parser functions and their code culture.
**Phase II:** Create the extension which satisfies the use cases when the git server is requested for a file or code snippet. **(THE MVP)**
**Phase III:** Make the extension to follow the use cases when the git server is requested for the part of a file by specifying the start and end line numbersregex patterns.
**Phase IV:** Create a mechanismbot to update the wiki-pages. (step-2)
**Phase V:** Write a lua modulemechanism to process the text. (step-3)
**Phase VI:** Deploy and test the final extension and document the extension.
=Deliverables
# **Required.** The extension which satisfies the use cases when the git server is requested for a file or a code snippet. (phase II) **(THE MVP)**
# **Required.** A feature in the extension for the use cases when the git server is requested for the part of file by specifying the start and end line numbersregex patterns. (phase III)
# **Required.** A mechanismbot to update the wiki-pages. (phase IV)
# **Optional.** A lua modulemechanism to process the text given by the extension. (phase V)
# **Required.** Deploy and test the final extensocumentation on wikimedia labs and document thefor the GitAtWiki extension. (Phase VI)
=Timeline
| Period | Task
| ----- | -----
| Before December 7 | Request for a repository, get a wikimedia lab instance and explore existing parser functions and their code culture. (Phase I)
| December 7 - December 11 10 | Create the basic setup/files for extension like internationalisation etc.
| December 12 11 - December 27 28 | Write the script for the parser function which satisfies the use cases when the git server is requested a file or a code snippet. (Phase II)
| December 28 29 - January 4 | Test the code, send for 6 | Write the code reviewunit tests and addresstest the issues/bugscode.
| January 5 - January 11 | 7 - Jan 16 | Get the security review, code review, address the issues/bugs and deploy the extension **(THE MVP)** . Start the documentation for the extension. Create a feature in the extension for the use cases when the git server is requested for the part of file by specifying the start and end line numbersregex pattern. (Phase III)
| January 12 17 - January 16 | Test the code , send for code review 22 | Write the unit tests and addresstest the issues/bugscode.
| January 17 - January 24 | 23 - Jan 30 | Send the code for review and address the issues/bugs. Create the basic setup for the mechanism to update the wiki-pages.
| January 25 31 - February 14 17 | Write the script to execute the functionalities of a mechanism which updates the wiki-pages. (Phase IV)
| February 15 18 - February 25 | Try to add 26 | Write the lua module, if complexity of workunit tests and time permits. (Phase V)est the code.
| February 26 27 - March 7 | Test,Send the code for review, fix the bugs, deploy the extension and document the final extension. deploy(Phase VI)
**NOTE** : Try to add the lua module, fix the bugs and document the final extensionif complexity of work and time permits. (Phase VI)
=Additional Information About The Project
===Existing extensions :
| Extension | Pitfalls
| ----- | -----
| [[ https://www.mediawiki.org/wiki/Extension:Git2Pages | Git2Pages]] | Execs git clone and other commands to create local files which takes more space. It doesn’t have the option of only allowing a whitelist of sites, which can create a security hazard.
|[[ https://www.mediawiki.org/wiki/Extension:Gitweb |Gitweb]] and [[ https://www.mediawiki.org/wiki/Extension:GitHub | GitHub]] | Sends a HTTP request to the git server but doesn’t satisfy the use cases when git server is requested for : (1) Part of the file by specifying start and end line numbers. (2) Code snippet in a file.
===After the project :
A bot, which can fetch all the information of a hook with the help of the lua module created in this project, can be built to create the missing hook pages . (T93043)
=Participation
- The project report will be updated on phabricator regularlygess report of the project will be updated weekly [[https://www.mediawiki.org/wiki/Transclude_Git_Content_into_Wiki_Pages|on this page]].
- The source code will be published on gerrit.
- I will ask for help/doubts on #mediawiki, #wikimedia-dev and #wikimedia-tech irc channels as I've already been doing.
- To get an opinion/feedback, I will use wikitech-I mailing list.
=About Me
**Education:** I'm an undergraduate student of computer science at IIT Mandi, India.
**How did you hear about the program?**
From my friends who have already done an outreachy internship.
**Do you meet the eligibility requirements outlined at https://wiki.gnome.org/Outreachy#Eligibility (if no, explain why not)?**
Yes, I am eligible.
**Will you have any other time commitments, such as school work, another job, planned vacation, etc., during the duration of the program?**
1st December 2015 - 21st February 2016 : Winter vacations. I will not have any other commitments.
22nd February 2016 - 7th March 2016 : College will take 20 hours per week including the examination time.(Also, These days will be the starting 15 days of the college, hence the schedule is going to be very light as we are supposed to spend this time in examining and choosing the courses.)
I will dedicate at least 42 hours per week during my internship.
**We advise all candidates eligible to Google Summer of Code and FOSS Outreach Program for Women to apply for both programs. Are you planning to apply to both programs and, if so, with what organization(s)?**
Only OPW, for Wikimedia
**What makes you want to make this the most awesomest wiki enhancement ever?**
Seeing the ever growing community of developers and contributors in wiki motivates me. It becomes the platform to train the new generation of developers by its huge knowledge database but a problem arises, as I found, while in process of exploring the wiki for learning. Sometimes if information is available in a big amount it’s always advisable to keep your data at one place or at least only in one copy so as to reduce and minimise the inconsistencies in various data sources for the same information. Currently no extension provides the functionalities to auto modify the pages for all wikis and at least inform the end user that the content is revised or deprecated. I think with the implementation of this project this problem can be solved and its effect will be long lasting and far reaching.
**Why did you choose wikimedia?**
Wikimedia was the source of my initial knowledge about the internet world and was my first step into the cyber world and since then there has not been a day when I don’t go to Wikipedia or some other wiki for one or the other type of information. It is a dawn of the new era of learning through the internet and undeniably wiki is a major contributor to that learning process and in some terms defines the present day internet. I have always admired the elegance and at the same time the simplicity of the idea and admired its contributors for the wonderful piece of idea. It always has been on my wishlist to contribute to the growth of internet and the knowledge pool at large of the world and by this project this might just be true, to make the internet and the cyber age a better thing than it was a day ago.
=Past Experience
I have done many coding [[ https://github.com/akangupt | projects]] during my graduation and implemented various algorithms and data structures. As part of my industrial internship I worked with [[http://www.amazon.in/ | Amazon India]] during summer of 2015.
**Academic Projects :**
- Remote Directory Editor : Multiple clients can connect to the server and use various features. It provides you with simple shell interface and supports features mainly including removing, renaming, adding files, listing the files, moving and changing mode of the working directory.
- Chat-room: A user signs in. User can see online users, add/remove/block/unblock them in local address book, change his status (online/busy), see his statistics, use admin features, configure account, message/file transfer. **(Using PHP, MySQL, HTML-CSS, Javascript)**
- Web-email : A user signs up with additional features as user profile, contact address list. User can mail to all domain email addresses and can receive mails from same domain addresses. **(using hmail server , PHP, MySQL, HTML-CSS, Javascript)**
- [[ https://www.youtube.com/watch?v=mZOa_KS5YZk&list=PLfVOWYgP1cu-8Je1NbkRAp_QgRvONlgtl | A Fiery Vengeance]] : A Japanese role playing game(JRPG) with features like save game, inventory, Health interface, dynamic fights, turn-based fights and other small games. **(using Python, Tiled and open source library [[ http://pygame.org/tags/opensource | pygame]] )**
- Voice Guided Dehumidifier : A voice commanded system which will dehumidify the room with the help of desiccant material like silica gel.
**Microtask completed :** T115388