Author Topic: Preview  (Read 25450 times)

Brian Bi

  • Full Member
  • ***
  • Posts: 31
  • Karma: 13
    • View Profile
Preview
« on: February 01, 2013, 10:44:54 AM »
The preview post feature doesn't work at all. It just gets stuck at "Fetching preview..."

Victor Ivrii

  • Administrator
  • Elder Member
  • *****
  • Posts: 2607
  • Karma: 0
    • View Profile
    • Personal website of Victor Ivrii
Re: Preview
« Reply #1 on: February 01, 2013, 11:07:36 AM »
The preview post feature doesn't work at all. It just gets stuck at "Fetching preview..."

I know this--I hacked forum (adding lines to Sources/Subs.php) to enable MathJax and it broke preview in non-Webkit browsers:

http://weyl.math.toronto.edu/APM346-2011F-forum/index.php?topic=3.0

I guess that there is some Javascript conflict.  However you can modify your post.
« Last Edit: February 01, 2013, 11:13:00 AM by Victor Ivrii »

Brian Bi

  • Full Member
  • ***
  • Posts: 31
  • Karma: 13
    • View Profile
Re: Preview
« Reply #2 on: February 03, 2013, 01:38:36 AM »
After two hours of debugging, I've figured out the problem. The async endpoint is not sending back valid XML. Instead it sends something like this:

Code: [Select]
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
    MathJax.Hub.Config({
        tex2jax: {
            inlineMath: [ ['$','$'] ],
            displayMath: [ ['$$','$$'] ],},
        TeX: {equationNumbers: {
            autoNumber: "AMS"
            }, Augment: {  Definitions: {
           macros: {
             overbracket:  ['UnderOver','23B4',1],
             underbracket: ['UnderOver','23B5',1],
           }
         }}},
    });
</script>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script> <link href="http://aimath.org/knowlstyle.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="http://aimath.org/knowl.js"></script><?xml version="1.0" encoding="UTF-8"?>
<smf>
<preview>
<subject><![CDATA[Re: Previous years resources]]></subject>
<body><![CDATA[testing]]></body>
</preview>
<errors serious="0" topic_locked="0">
<caption name="guestname" class="" />
<caption name="email" class="" />
<caption name="evtitle" class="" />
<caption name="subject" class="" />
<caption name="question" class="" />
</errors>
<last_msg>1111</last_msg>
</smf>

This is not valid XML because it contains multiple root nodes. Only the <smf> node is actually desired in the response, I believe.

Actually, both Chrome and Firefox are "broken" because of this. Chrome sees that the XML is invalid and falls back to reloading the page (which it shouldn't have to do if the XML was correct, I think). On the other hand, Firefox thinks that XML was returned, and chokes on trying to process it.

Victor Ivrii

  • Administrator
  • Elder Member
  • *****
  • Posts: 2607
  • Karma: 0
    • View Profile
    • Personal website of Victor Ivrii
Re: Preview
« Reply #3 on: February 03, 2013, 03:44:40 AM »
It is exactly the hookup of MathJax (you could ask me and I would tell you the hookup).

However I don't think you are correct about Chrome: Preview works for me in Chrome and it is Webkit. I just checked with Opera--Preview works, and with Maxthon--Preview works too! Only Firefox chokes. If I recall correctly  Preview worked only with Webkit based browsers two years ago but now it works with both Opera and Maxthon which are not. Checked even with the latest Exploder (on friend' computer)--works too (AFAIK Maxthon is based on MSIE so it was a bit excessive). So, the only different engine which fails is one of Firefox. Too bad--I checked with 19b3--it still fails.

But again, it is only Preview which fails and I set up forum to allow ordinary users to modify their posts.

PS I found on the web hook-up of MathJax via index.template.php:
http://www.simplemachines.ru/index.php?topic=13287.msg108457#msg108457
but it also results in the failure of Preview under Firefox.

PPS I split the topic as this one is clearly distinct.
« Last Edit: February 03, 2013, 09:57:58 AM by Victor Ivrii »

Brian Bi

  • Full Member
  • ***
  • Posts: 31
  • Karma: 13
    • View Profile
Re: Preview
« Reply #4 on: February 03, 2013, 07:53:50 PM »
However I don't think you are correct about Chrome: Preview works for me in Chrome and it is Webkit. I just checked with Opera--Preview works, and with Maxthon--Preview works too!

I didn't say that it doesn't work---I said that it reloads the page when you click "Preview". If everything were working properly then it wouldn't have to reload the page, but would insert the preview directly into the current page. This is evidence that none of the browsers really do what they're supposed to do. Only Firefox has a weird bug that causes the preview not to work at all. Even still, fixing the XML would improve the user experience on all browsers.

Victor Ivrii

  • Administrator
  • Elder Member
  • *****
  • Posts: 2607
  • Karma: 0
    • View Profile
    • Personal website of Victor Ivrii
Re: Preview
« Reply #5 on: February 11, 2013, 07:09:56 PM »
However I don't think you are correct about Chrome: Preview works for me in Chrome and it is Webkit. I just checked with Opera--Preview works, and with Maxthon--Preview works too!

I didn't say that it doesn't work---I said that it reloads the page when you click "Preview". If everything were working properly then it wouldn't have to reload the page, but would insert the preview directly into the current page. This is evidence that none of the browsers really do what they're supposed to do. Only Firefox has a weird bug that causes the preview not to work at all. Even still, fixing the XML would improve the user experience on all browsers.


I checked: out of the box SMF does not seem to reload page but inserts preview, and with MJ hookup it reloads. I am afraid it is unavoidable.

Unfortunately there is no real interaction between MJ and SMF developers. Davide Cervone, lead developer of MJ, who is usually extremely helpful, wrote that he knows very little about SMF.

On the other hand, mediawiki even without MJ seems to always reload page for preview and AFAIK nobody objects (I agree: reloading is an annoyance but rather minor).