scipy / SciPyCentral

SciPy Central
http://scipy-central.org
BSD 3-Clause "New" or "Revised" License
16 stars 12 forks source link

New editor & viewer #156

Closed ksurya closed 10 years ago

ksurya commented 10 years ago

ACE editor website: http://ace.c9.io/ Use ACE - JavaScript based editor for writing new submissions, view snippets when viewing submissions

Changes

  1. Use ACE editor in place of default textarea box while writing new submissions
  2. Use ACE editor to view code snippets in submissions instead of Pygments syntax highlighter
  3. Remove submission.models.Revision.item_highlighted_code field
  4. Remove submission.models.DisplayFile, submission.views.get_display, submission.views.show_file

    Notes

  5. Pygments package is no longer used for syntax highlighting code snippets.
  6. Redundant storage of snippet is removed in Revision model
  7. Server load to syntax highlight is reduced. However, page load time is increased little bit to load ACE editor
  8. submission.views.show_file and its related methods, models appears to be broken and not used anywhere. This is discussed in the below comments

    Preview

    Snippet view

code1

Submission editor

code2

ksurya commented 10 years ago

While removing usage of Pygments, I see the following use it apart from create_or_edit_submission_revision() in scipy_central.submission.views module.

  1. get_display()
  2. show_file() (view)

From what I understand the show_file() view corresponding to the URL configuration r'^(?P<item_id>\d+)/(?P<rev_id>\d+)/show/(?P<filename>.*?)$' is not mentioned anywhere in front-end.

A quick test on what it does tells me that the view returns data of files (snippets or images) used inside a submission. This probably intended to give access to raw data (snippets or images) for users. However, the view when serving snippet file doesn't generate raw data but highlighted HTML code.

submission.models.DisplayFile is used here (and nowhere else) to help easy access of data instead of reading it every time from filesystem.

I think we can deprecate (or remove) this view and the supported function, model used in it. The below are the following reasons:

  1. The view has not been used anywhere in HTML so far. I am not even understanding why the current live-deployment raises 404 (when accessing images), redirects (when accessing snippet file) to respective submission page.
  2. The view seems to be broken. The reason why accessing images raises 404 is that, the view is searching the wrong directory for the file. Also, the uploaded images in a revision are stored as media files. Its best not to serve them from django.
  3. For generation raw snippet data from files, a simple front-end script in javascript can do the job. Since we are deprecating Pygments and only technically using plain-text snippet data, this is possible. However, we can have a separate view that does the job of serving raw snippet data but it may only bring load to the server which can be avoided. It is also to be noted that there another view that lets people download snippets.
ksurya commented 10 years ago

@pv If there is no problem with deprecating the above mentioned & the new features, I will go ahead.