[BETA] MathJax phpBB Integration

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment!
Scam Warning
sergio91pt
Registered User
Posts: 62
Joined: Thu Jul 07, 2011 11:03 am

Re: [ALPHA] MathJax phpBB Integration

Post by sergio91pt »

You're using Chrome? They added restrictions on opening local files. If you have Firefox installed you can use it or you can upload the xml and open it given a non-local url.

Anyway I'll copy-paste the code, as reading it from XML is hard (miss a '}' and it wont work). Use "SELECT ALL" to copy.

Open: includes/acp/acp_bbcodes.php
Find (notice the bracket):

Code: Select all

					if (isset($rowset[$bbcode_id]))
					{
Replace with:

Code: Select all

					global $config;

					if (isset($rowset[$bbcode_id]))
					{
						if (!empty($config['mathjax_enable']) && !empty($rowset[$bbcode_id]['is_math'])) 
						{
							$template->assign_var('S_ENABLE_MATHJAX', true);
						}
Open: includes/functions.php
Find:

Code: Select all

		$s_search_hidden_fields['sid'] = $_SID;
	}
Add after (on a new line):

Code: Select all

	// Start 'building' Mathjax url
	if (!empty($config['mathjax_enable']))
	{
		$mathjax_file = (!empty($config['mathjax_config'])) ? '/MathJax.js?config=' . $config['mathjax_config'] : '/MathJax.js';
		
		if(!empty($config['mathjax_use_cdn']))
		{
			if(!empty($config['mathjax_cdn_force_ssl']))
			{
				$mathjax_uri = $config['mathjax_cdn_ssl'];
			}
			else
			{
				$server_protocol = ($config['server_protocol']) ? $config['server_protocol'] : (($config['cookie_secure']) ? 'https://' : 'http://');
				$mathjax_uri = ($server_protocol === 'http://') ? $config['mathjax_cdn'] : $config['mathjax_cdn_ssl'];
			}
			$mathjax_uri_fallback = (!empty($config['mathjax_uri'])) ? ($config['mathjax_uri'] . $mathjax_file) : ''; 
		}
		else
		{
			$mathjax_uri = isset($config['mathjax_uri']) ? $config['mathjax_uri'] : '';
		}

		$mathjax_uri = $mathjax_uri . $mathjax_file;
		
		if(empty($config['mathjax_dynamic_load']))
		{
			$template->assign_var('S_ENABLE_MATHJAX', true);
		}
	}
Find:

Code: Select all

		'U_FEED'				=> generate_board_url() . "/feed.$phpEx",
Add after (on a new line):

Code: Select all

		'U_MATHJAX'				=> (isset($mathjax_uri)) ? $mathjax_uri : '',
		'UA_MATHJAX_FALLBACK'	=> (isset($mathjax_uri_fallback)) ? $mathjax_uri_fallback : '',

		'S_MATHJAX_HAS_FALLBACK'=> (!empty($mathjax_uri_fallback)) ? true : false,
Find:

Code: Select all

		'S_SEARCH_HIDDEN_FIELDS'	=> build_hidden_fields($s_search_hidden_fields),
Add after (on a new line):

Code: Select all

		'T_ASSETS_PATH'      	=> "{$web_path}assets",
Kleineganz
Registered User
Posts: 27
Joined: Sat Feb 23, 2013 3:53 am

Re: [ALPHA] MathJax phpBB Integration

Post by Kleineganz »

Alright, I actually just opted to uninstall and reinstall the MathJax mod through AutoMod - I figured that might help force the file mods that were missing, and finally I'm making some progress. Now I'm seeing this on my test post:

Image
sergio91pt
Registered User
Posts: 62
Joined: Thu Jul 07, 2011 11:03 am

Re: [ALPHA] MathJax phpBB Integration

Post by sergio91pt »

Ignore my comment about chrome, didn't saw the image.

Finally, working! That error is espected as you putted LaTeX code and [math] expects MathML (you can change it to LaTeX if you want)
Kleineganz
Registered User
Posts: 27
Joined: Sat Feb 23, 2013 3:53 am

Re: [ALPHA] MathJax phpBB Integration

Post by Kleineganz »

sergio91pt wrote:Ignore my comment about chrome, didn't saw the image.

Finally, working! That error is espected as you putted LaTeX code and [math] expects MathML (you can change it to LaTeX if you want)
Sweet, thanks.

Do you have a link to a resource for MathML BBcodes so I can see an example notation and test it? I just want to get a sample in there. I tried googling for one but couldn't find any ...
User avatar
muggins
Registered User
Posts: 1183
Joined: Fri Feb 22, 2008 5:12 pm
Location: Texas
Name: Donovan

Re: [ALPHA] MathJax phpBB Integration

Post by muggins »

Sorry about my last post. I was trying to do too many things at once.

I made sure all the file and directory permissions are correct, and double-checked the edits.

No joy with either CDN or local copy. "[math]" is all that shows up either way.
Muggins
sergio91pt
Registered User
Posts: 62
Joined: Thu Jul 07, 2011 11:03 am

Re: [ALPHA] MathJax phpBB Integration

Post by sergio91pt »

Kleineganz wrote: Sweet, thanks.

Do you have a link to a resource for MathML BBcodes so I can see an example notation and test it? I just want to get a sample in there. I tried googling for one but couldn't find any ...
You can right click in any LaTeX code, and in the menu go to Show Math As -> MathML code

Some links:
http://www.mathjax.org/demos/mathml-samples/
http://www.w3.org/Math/XSL/csmall2.xml
http://gorupec.awardspace.com/mathml.xhtml
http://www.dessci.com/en/products/mathp ... amples.htm
http://www.xmlmind.com/tutorials/MathML/index.html
sergio91pt
Registered User
Posts: 62
Joined: Thu Jul 07, 2011 11:03 am

Re: [ALPHA] MathJax phpBB Integration

Post by sergio91pt »

muggins wrote:Sorry about my last post. I was trying to do too many things at once.

I made sure all the file and directory permissions are correct, and double-checked the edits.

No joy with either CDN or local copy. "[math]" is all that shows up either way.
Can you check with dynamic loading disabled and the permissions of styles/prosilver/template/mathjax.html?
User avatar
muggins
Registered User
Posts: 1183
Joined: Fri Feb 22, 2008 5:12 pm
Location: Texas
Name: Donovan

Re: [ALPHA] MathJax phpBB Integration

Post by muggins »

Dynamic loading is disabled, the file permission are 644.

In the phpbb_config table I have this:

Code: Select all

mathjax_enable 	1 	0
mathjax_dynamic_load 	0 	0
mathjax_use_cdn 	1 	0
mathjax_uri 	mathjax 	0
mathjax_cdn 	http://cdn.mathjax.org/mathjax/latest 	0
mathjax_cdn_ssl 	https://d3eoax9i5htok0.cloudfront.net/mathjax/late... 	0
mathjax_config 	TeX-AMS-MML_HTMLorMML 	0
I also tried with mathjax_use_cdn 0 0.

The mathjax folder is in the forum root and the .Mods tab for the path reads 'mathjax'.

I'm just about ready to give up. Have a look at the test site, if you don't mind. http://saposjoint.net/Test

If you need a login, let me know.
Muggins
Kleineganz
Registered User
Posts: 27
Joined: Sat Feb 23, 2013 3:53 am

Re: [ALPHA] MathJax phpBB Integration

Post by Kleineganz »

sergio91pt wrote:
Kleineganz wrote: Sweet, thanks.

Do you have a link to a resource for MathML BBcodes so I can see an example notation and test it? I just want to get a sample in there. I tried googling for one but couldn't find any ...
You can right click in any LaTeX code, and in the menu go to Show Math As -> MathML code

Some links:
http://www.mathjax.org/demos/mathml-samples/
http://www.w3.org/Math/XSL/csmall2.xml
http://gorupec.awardspace.com/mathml.xhtml
http://www.dessci.com/en/products/mathp ... amples.htm
http://www.xmlmind.com/tutorials/MathML/index.html
Those links helped tremendously. Thank you so much! Final link to my now fully functioning MathJax test post. :)

http://geek-central.net/viewtopic.php?f ... 337#p58337

Thanks again! :)
User avatar
muggins
Registered User
Posts: 1183
Joined: Fri Feb 22, 2008 5:12 pm
Location: Texas
Name: Donovan

Re: [ALPHA] MathJax phpBB Integration

Post by muggins »

This interesting bit is what I see when I view the source of the index page:

Code: Select all

<script type="text/javascript" src="./assets/javascript/phpbb2jax-combined-min.js"></script>
<script type="text/x-mathjax-config">
// <![CDATA[
MathJax.Hub.PreProcess.disabled = true;
MathJax.Hub.Config({messageStyle:"none"});
ready(function() {phpbb2jax()});
// ]]>
</script>
<script type="text/javascript" src="mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
Why does it pick up the assets path when I specified (forum_root)/mathjax? What am I doing wrong? :?

Kleineganz's source is using the CDN, right?

Code: Select all

<script type="text/x-mathjax-config">
// <![CDATA[
MathJax.Hub.PreProcess.disabled = true;
MathJax.Hub.Config({messageStyle:"none"});
ready(function() {phpbb2jax()});
// ]]>
</script>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>

<script type="text/javascript">
// <![CDATA[
	!window.MathJax && document.write('<script type="text\/javascript" src="mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"><\/script>');
// ]]>
</script>
Last edited by muggins on Fri Mar 01, 2013 7:22 pm, edited 1 time in total.
Muggins
User avatar
muggins
Registered User
Posts: 1183
Joined: Fri Feb 22, 2008 5:12 pm
Location: Texas
Name: Donovan

Re: [ALPHA] MathJax phpBB Integration

Post by muggins »

I am an idiot again today. The assets directory permissions were fubar. Fixed that and it's working. :oops:
Muggins
sergio91pt
Registered User
Posts: 62
Joined: Thu Jul 07, 2011 11:03 am

Re: [ALPHA] MathJax phpBB Integration

Post by sergio91pt »

muggins wrote:I am an idiot again today. The assets directory permissions were fubar. Fixed that and it's working. :oops:
Finally ;)
muggins wrote:Why does it pick up the assets path when I specified (forum_root)/mathjax?
Because the mod needs some javascript glue as it doesnt use the default pre-processors. The default pre-processors scan the whole page for text delimited by $. This is slower (than getElementsByClassName) and may break pages.
muggins wrote:Kleineganz's source is using the CDN, right?
Yes with the local copy as fallback.
User avatar
Citromon
Registered User
Posts: 129
Joined: Wed Feb 15, 2012 5:22 pm
Location: Minsk, Belarus

Re: [ALPHA] MathJax phpBB Integration

Post by Citromon »

When mod will be in RC stage?
Does it works with SEO Ultimate mod?

Whether is mod, which works with some apache2 module and converts [latex] bbcode to according images?
What the anvil? What dread grasp
Dare its deadly terrors clasp?
sergio91pt
Registered User
Posts: 62
Joined: Thu Jul 07, 2011 11:03 am

Re: [ALPHA] MathJax phpBB Integration

Post by sergio91pt »

Citromon wrote:When mod will be in RC stage?
Dunno, but I'll bump it to beta probably in the next release. The code is stable, regardless of the title tag.
Citromon wrote:Does it works with SEO Ultimate mod?
By looking at their modifications, yes it should work.
Citromon wrote:Whether is mod, which works with some apache2 module and converts [latex] bbcode to according images
This mod uses a Javascript library to parse and display LaTeX and MathML code, normally marked by [latex] and [math] bbcodes respectively (configurable).
User avatar
Citromon
Registered User
Posts: 129
Joined: Wed Feb 15, 2012 5:22 pm
Location: Minsk, Belarus

Re: [ALPHA] MathJax phpBB Integration

Post by Citromon »

Thanx 4 your work and reply, sergio91pt.

I understand, that your mod uses mathjax library. I easy want to know, is somewhere an alternative, which use apache module and makes images of formulas on server.
What the anvil? What dread grasp
Dare its deadly terrors clasp?

Return to “[3.0.x] MODs in Development”