Skip to content

Commit

Permalink
fix message preview
Browse files Browse the repository at this point in the history
add SMF 2.1 support
  • Loading branch information
realdigger committed Apr 29, 2016
1 parent c41e560 commit 7ed054b
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 20 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.idea/
.idea/
todo.txt
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SMF MathJax mod
* **Author:** digger http://mysmf.ru
* **License:** GPLv3
* **Compatible with:** SMF 2.0
* **Compatible with:** SMF 2.0, SMF 2.1

## Description
This mod integrates the MathJax library into SMF forum. MathJax is the modern JavaScript-based LaTeX rendering solution for the Internet. Mod uses the MathJax CDN. The CDN will automatically arrange for your readers to download MathJax files from a fast, nearby server. And since bug fixes and patches are deployed to the CDN as soon as they become available, your pages will always be up to date with the latest browser and devices.
Expand Down
12 changes: 7 additions & 5 deletions Sources/Mod-MathJax.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
/**
* @package SMF MathJax Mod
* @author digger
* @copyright 2011—2015
* @copyright 2011—2016
* @license GPLv3
* @file Mod-MathJax.php
* @version 1.3
* @version 1.4
*/

if (!defined('SMF')) {
Expand All @@ -30,10 +30,12 @@ function loadMathJaxHooks()
*/
function loadMathJaxJs()
{
global $context;
global $context, $txt;

//$txt['shortcuts_firefox'] .= '';

$context['insert_after_template'] .= '
<script type="text/javascript" src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=default"></script>';
<script type="text/javascript" src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=default,Safe"></script>';
}


Expand Down Expand Up @@ -89,6 +91,6 @@ function addMathjaxCopyright()
global $context;

if ($context['current_action'] == 'credits') {
$context['copyrights']['mods'][] = '<a href="http://mysmf.ru/mods/mathjax" title="SMF MathJax Mod" target="_blank">MathJax for SMF</a> &copy; 2011—2015, digger | <a href="http://www.mathjax.org" title="Powered by MathJax" target="_blank">Powered by MathJax</a>';
$context['copyrights']['mods'][] = '<a href="http://mysmf.ru/mods/mathjax" title="SMF MathJax Mod" target="_blank">MathJax for SMF</a> &copy; 2011—2016, digger | <a href="http://www.mathjax.org" title="Powered by MathJax" target="_blank">Powered by MathJax</a>';
}
}
4 changes: 2 additions & 2 deletions hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
/**
* @package SMF MathJax Mod
* @author digger
* @copyright 2011—2015
* @copyright 2011—2016
* @license GPLv3
* @file hooks.php
* @version 1.3
* @version 1.4
*
* To run this install manually please make sure you place this
* in the same place and SSI.php and index.php
Expand Down
21 changes: 21 additions & 0 deletions modification.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0"?>
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">
<modification xmlns="http://www.simplemachines.org/xml/modification">

<id>digger:mathjax</id>
<name>MathJax</name>
<version>1.4</version>
<type>modification</type>

<file name="$themedir/Post.template.php">
<operation>
<search position="after"><![CDATA[ if (typeof(smf_codeFix) != \'undefined\')]]></search>
<add><![CDATA[
var math = document.getElementById(\'preview_body\');
MathJax.Hub.Queue([\'Typeset\', MathJax.Hub, math]);
]]></add>
</operation>
</file>

</modification>
28 changes: 25 additions & 3 deletions package-info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,42 @@
<package-info xmlns="http://www.simplemachines.org/xml/package-info">
<id>digger:mathjax</id>
<name>MathJax</name>
<version>1.3</version>
<version>1.4</version>
<type>modification</type>

<install for="2.0 - 2.0.99">
<readme parsebbc="true">readme.txt</readme>
<readme parsebbc="true">readme/english.txt</readme>
<readme parsebbc="true" lang="russian">readme/russian.txt</readme>
<readme parsebbc="true" lang="russian-utf8">readme/russian-utf8.txt</readme>
<require-dir name="Sources" destination="$boarddir"/>
<require-dir name="Themes" destination="$boarddir"/>
<require-dir name="Themes-2.0/default" destination="$boarddir/Themes"/>
<modification>modification.xml</modification>
<code>hooks.php</code>
</install>

<uninstall for="2.0 - 2.0.99">
<remove-file name="$sourcedir/Mod-MathJax.php"/>
<remove-file name="$imagesdir/bbc/latex.gif"/>
<remove-file name="$imagesdir/bbc/latex_inline.gif"/>
<modification reverse="true">modification.xml</modification>
<code>hooks.php</code>
</uninstall>

<install for="2.1 Beta 2, 2.1 - 2.1.99">
<readme parsebbc="true">readme/english.txt</readme>
<readme parsebbc="true" lang="russian">readme/russian.txt</readme>
<readme parsebbc="true" lang="russian-utf8">readme/russian-utf8.txt</readme>
<require-dir name="Sources" destination="$boarddir"/>
<require-dir name="Themes-2.1/default" destination="$boarddir/Themes"/>
<modification>modification.xml</modification>
<code>hooks.php</code>
</install>

<uninstall for="2.1 Beta 2, 2.1 - 2.1.99">
<remove-file name="$sourcedir/Mod-MathJax.php"/>
<remove-file name="$imagesdir/bbc/latex.png"/>
<remove-file name="$imagesdir/bbc/latex_inline.png"/>
<modification reverse="true">modification.xml</modification>
<code>hooks.php</code>
</uninstall>

Expand Down
18 changes: 10 additions & 8 deletions readme.txt → readme/english.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
[center][b]MathJax[/b][/center]

This mod integrates the MathJax library into SMF forum. MathJax is the modern JavaScript-based LaTeX rendering solution for the Internet. Mod uses the MathJax CDN. The CDN will automatically arrange for your readers to download MathJax files from a fast, nearby server. And since bug fixes and patches are deployed to the CDN as soon as they become available, your pages will always be up to date with the latest browser and devices.
[url=https://www.mathjax.org]MathJax official site[/url]
[url=https://github.com/realdigger/SMF-MathJax-Mod]Mod support page[/url]
[hr]
MathJax is an open source JavaScript display engine for mathematics that works in all modern browsers.

High-quality typography. MathJaxTM uses modern CSS and web fonts, instead of equation images or Flash, so equations scale with surrounding text at all zoom levels. See how this works in the scaling math demo.

Works in all modern browsers. This allows the math in your content to be seen clearly by virtually all readers, even those using smart phones. See supported browsers.
High-quality typography. MathJaxTM uses modern CSS and web fonts, instead of equation images or Flash, so equations scale with surrounding text at all zoom levels. See how this works in the scaling math demo.

Simple integration. Using MathJax with blogs, wikis, web pages and other web apps is easy. Learn more about installing MathJax with popular platforms like WordPress, MediaWiki, Drupal, and more.
Works in all modern browsers. This allows the math in your content to be seen clearly by virtually all readers, even those using smart phones. See supported browsers.

Copy and paste math. Let readers copy equations from your web pages into Word and LaTeX documents, science blogs, research wikis, calculation software like Maple, Mathematica and more. Watch the copy and paste demo.
Simple integration. Using MathJax with blogs, wikis, web pages and other web apps is easy. Learn more about installing MathJax with popular platforms like WordPress, MediaWiki, Drupal, and more.

A rich API. Allows developers to create interactive course materials, advanced authoring tools, and math-enabled web apps. Learn how more about programming with MathJax.
Copy and paste math. Let readers copy equations from your web pages into Word and LaTeX documents, science blogs, research wikis, calculation software like Maple, Mathematica and more. Watch the copy and paste demo.

Accessible math. MathJax is compatible with screenreaders used by people with vision disabilities, and the Zoom feature allows all readers to see small details like scripts, primes and hats. See how to make your math accessible.
A rich API. Allows developers to create interactive course materials, advanced authoring tools, and math-enabled web apps. Learn how more about programming with MathJax.

[url]https://www.mathjax.org[/url]
Accessible math. MathJax is compatible with screenreaders used by people with vision disabilities, and the Zoom feature allows all readers to see small details like scripts, primes and hats. See how to make your math accessible.
5 changes: 5 additions & 0 deletions readme/russian-utf8.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[center][b]MathJax[/b][/center]

Этот мод интегрирует библиотеку MathJax в SMF. MathJax это современное решение для рендеринга формул LaTeXis посредством JS в браузерах. Мод загружает библиотеку из официальной CDN разработчиков, так что у вас всегда будет самая актуальная версия с последними обновлениями и исправлениями.
[url=https://www.mathjax.org]Официальный сайт MathJax[/url]
[url=https://github.com/realdigger/SMF-MathJax-Mod]Страница разработчиков мода[/url]
5 changes: 5 additions & 0 deletions readme/russian.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[center][b]MathJax[/b][/center]

���� ��� ����������� ���������� MathJax � SMF. MathJax ��� ����������� ������� ��� ���������� ������ LaTeXis ����������� JS � ���������. ��� ��������� ���������� �� ����������� CDN �������������, ��� ��� � ��� ������ ����� ����� ���������� ������ � ���������� ������������ � �������������.
[url=https://www.mathjax.org]����������� ���� MathJax[/url]
[url=https://github.com/realdigger/SMF-MathJax-Mod]�������� ������������� ����[/url]

0 comments on commit 7ed054b

Please sign in to comment.