Closed (fixed)
Project:
Drupal.org CVS applications
Component:
new project application
Priority:
Normal
Category:
Task
Assigned:
Issue tags:
Reporter:
Created:
5 Jan 2011 at 10:38 UTC
Updated:
13 Apr 2019 at 18:49 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
julou commentedFirst version of the module as requested… Still very preliminary (no settings), but already functional.
Compared with other latex rendering solutions in Drupal, MathJax has several advantages:
As stated by MathJax authors (http://www.mathjax.org/about/):
MathJax grew out of the popular jsMath project, an earlier Ajax-based math rendering system developed by Davide Cervone in 2004. In the intervening time, there have been many significant developments relevant for web publication of mathematics: consolidation of browser support for CSS 2.1, Web Font technology, adoption of math accessibility standards, and increasing usage of XML workflows for scientific publication. Consequently, Cervone and others are designing and developing MathJax from the ground up as a “next-generation” platform, while still benefitting from the extensive real-world experience gained from jsMath.
Thanks for reviewing.
Comment #2
aidanlis commentedHi julou,
Thanks for your initial work, there are a few problems with your module:
a) Please don't use $(document).ready, use Drupal.behaviours for adding javascript functionality.
b) I'm not sure why you're using hook_preprocess ... I think hook_init is probably a better choice, then all you'd need is the two drupal_add_js lines.
c) Please use the Libraries API for installing and downloading the MathJAX library, http://drupal.org/project/libraries
If you could make the above changes, the module is great and I'm looking forward to your next version.
Comment #3
avpadernoHello, and thank you for applying for a CVS account.
As per requirements, the motivation needs to include more than two sentences (possibly a paragraph) that describe the module features (the description should make clear what the module features are without to look at the code), and a comparison with the existing solutions.
I will report here a little checklist:
Comment #4
julou commentedThanks for the feedback, I'll do my best to fix your points.
Regards, T.
Comment #5
julou commentedHere is the revised version:
- rely on libraries API to locate the MathJax folder.
- use Drupal.behaviours instead of $(document).ready
- keep using hook_preprocess, in order to activate it only on node and profile pages. hook_init was active on the admin pages as well
- removed license file
- passed coder validation.
Thank you for your feedback.
Comment #6
aidanlis commentedHi julou,
Getting better, but you've still got some things to do!
- Try hook_init with
if (arg(0) === 'node'), it really doesn't make sense to be using preprocess there- Add a hook_requirements check for the mathjax library (I think the library name should be lowercase)
- Extra points: add a drush command to download the mathjax library (like the ckeditor module)
Thanks and keep up the good work.
Comment #7
julou commentedI'll do it…
As far as choosing between init and preprocess is concerned, I was using preprocess also because I was in mind to allow for specific node-type activation.
Is it possible to retrieve the node type with hook_init?
Thanks for your help. I must say that this "tutoring" process is really a good thing! :)
Comment #8
aidanlis commentedYes, you can check what node type is being used with if (node_load(arg(1))->type === 'page') { ...
Comment #9
julou commentedGreat!
Where can I find the list of arguments?
By the way, how can I detect a profile page using this hook_init?
requirements and drush are working now, I'll post them with the revised version of hook_init…
Comment #10
aidanlis commentedThe arguments come from the url, so yoursite.com/node/1/edit would have arg(0) = node, arg(1) = 1, arg(2) = edit. This is true even the page is aliased.
A user profile page is /user/1 so you can check for this with arg(0) = user, numeric(arg(1)) and !arg(2).
If you're doing these checks you might want to add an administration page where you can control the choices, it will help meat out your module too.
Comment #11
julou commentedHere is modified version with your requests…
I'll definitely add the admin page to enable mathjax by node type (and possibly to set mathjax option with a form), but later. I really don't have time for this now.
Comment #12
aidanlis commentedLooks great, I'm happy. kiamlaluno has the final say here :)
Comment #13
avpadernoThere are just two things that should be changed:
t()is not used inside the installation file;get_t()should be used inhook_requirements(), and the strings should not be translated in thehook_update_N()implementations.Comment #14
julou commentedCould you explain me:
Thanks in advance.
Comment #15
avpadernot()is not used in an installation file; I specified what should be done inhook_requirements(), and outsidehook_requirements()to avoid the misunderstanding thatget_t()should be used in all the code contained in the installation file.document.createElement(); the jQuery library has its own manipulation functions.Comment #16
aidanlis commentedI think the hook_requirements check should be a runtime check (move it into the .module file) which also moots the get_t problem :)
Also, I think, the document.createElement is fine - it's for asynchronous loading rather than standard manipulation, and it's a straight copy of the JS recommended by MathJax - I think it makes sense to keep that standard instead of maintaining our own.
Thanks for running the gauntlet julou, looking forward to good things :)
Comment #17
avpadernohook_requirements()is in the installation file as it should; see what is done from Drupal core modules.Comment #18
julou commentedSo I propose to keep hook_requirements() in the install file, replacing t() by get_t().
And to leave document.createElement() as is…
Is it fine with you?
P.S.: As far as jQ is concerned, would you like me to use getScript and a callback function?
http://api.jquery.com/jQuery.getScript
Apparently most people rely on document.createElement() and jQ append()
http://stackoverflow.com/questions/1199676/can-i-create-script-tag-by-jq...
Comment #21
avpadernoI am giving credits to the users who participated in this issue.