Skip to content

Import From Wikipedia

Shashank Khanna edited this page Sep 1, 2016 · 1 revision

#Import from Wikipedia Using the ‘W’ key from above the text editor, we can import existing Wikipedia articles into the editor

Technical Implementation

Editor.ejs:

  • Inside the div, editor_window, form element wikiSearchForm, causes the function searchWiki to run on submitting the form.

Wikigrab.js:

  • searchWiki performs an ajax call to the Wikipedia’s search api : https://en.wikipedia.org/w/api.php
  • using regex, it seperates the wiki code, from the main content
  • the contents variable is then set to just the body of the wiki markdown, without the headers and footers
  • The references/citations are then removed from the content
  • This is then sent via an ajax call (post request) to an internal api – that sends the contents to pandoc
  • Upon receiving it after conversion to html via pandoc, it uses regex to append the citations in the format that ckeditor accepts