-
Notifications
You must be signed in to change notification settings - Fork 57
Online XML Editor for SPDX Licenses, Google Summer of Code 2018
The objective of this GSoC'18 project is to add an XML editor the SPDX Online Tools using which users can easily edit the SPDX licenses and also create new ones from scratch.
Although there are other XML editors available online, the purpose of this project was to make the editor beginner friendly and comply with SPDX license schema, so that a person with minimal knowledge of XML can edit the documents and submit their changes to be reviewed by the SPDX team.
To make it beginner friendly the user is provided with a text based and a tree based editor. The tree based editor will show the XML document in an expand/collapse tree manner, which will be easier to use for the beginners. But the tree format can only be generated if the XML document is valid, so to overcome this problem a text based editor is also included which is a conventional XML editor.
The code for the project can be found at: #29, #30, #33, #35, #36, #37, #41
The live version of the project can be seen here: http://13.57.134.254/app/xml_upload/
Demo video explaining about all the features: YouTube Video
This section includes the details of how all the features are implemented.
There are 4 ways by which the user can give the XML input. He can write the XML text in the textarea, upload the XML file, give the license name which he wants to edit, can create a new XML document. When the user inputs the license name the license text is fetched from the license-list-xml
repository. When the user inputs the info he is then redirected to the editor page. The input information is handled using Django and a session is created, this is done so that the user can have multiple editors tabs at the same time and the changes are not lost even when the page is refreshed. #29
The text editor is implemented using CodeMirror, and comprises of many features such as autocomplete, code folding, xml beautify, code highlighting, fullscreen editing, trailing space detection etc. #30
The tree editor is suitable for user with little to no experience with XML format. The XML string is first converted to a jquery object then all the children and siblings are traversed using a recursive function. This generates a tree view of the XML document. Using this user can do almost anything such as adding, editing or deleting nodes, attributes and the text inside the tags.
This view contains both the text and tree editor side-by-side, so if the user wants to use both editors at the same time. This can be helpful as the user can use the tree editor for editing the XML and can review the resulting XML using the text editor. #33
This feature enables the user to make a pull request to the SPDX license-list-XML
repository, so that he can get his changes merged into the repository. They first have to authenticate with the SPDX GitHub app, then fill in the branch name, file name, commit message, PR title, PR body. This information is then validated and then using the user's access token and GitHub API the pull request is made. #37
Apart from XML editing there are also some extra features included, like the user can download the edited XML document, they can generate a diff which will show them what changes they have made in the initial XML text, and the validate feature which validates the XML against the SPDX License Schema.