Changeset 1244467
- Timestamp:
- 09/13/2015 11:28:03 AM (10 years ago)
- Location:
- mathematica-toolbox
- Files:
-
- 3 edited
-
tags/1.0.1/README.txt (modified) (1 diff)
-
trunk/README.txt (modified) (3 diffs)
-
trunk/public/Mathematica-WP-Toolbox-public.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
mathematica-toolbox/tags/1.0.1/README.txt
r1200694 r1244467 22 22 23 23 The highlighting feature can be triggered in two ways. In the editor `[wlcode]Wolfram Language code here[/wlcode]` can be used to place a code block directly into the text, however it is often desirable to put the code elsewhere and refer to it instead of putting it into the text itself. This is achieved by the shortcode `[wlcode field="name"]` where `name` refers to a custom post field that holds the code that should be inserted at that point. You may have to go to "screen options" at the top of the editor page to enable custom post fields before you can see the custom post field form. 24 25 To write code as a part of a sentence, that is, inline, you can use the shortcode `[wlinline]code[/wlinline]`. This will wrap the code with the `<code>` tag and thus (in many themes) distinguish the code visually. 24 26 25 27 **Embed Wolfram technologies** -
mathematica-toolbox/trunk/README.txt
r1200692 r1244467 17 17 **Syntax highlighting and formatting** 18 18 19 * Uses the same highlighting script that is used on Mathematica.StackExchange.com and on Wolfram Community.19 * Uses the same highlighting script that is used on [Mathematica.StackExchange.com](http://mathematica.stackexchange.com) and on [Wolfram Community](http://community.wolfram.com). 20 20 * Preserves code indentation and prevents WordPress from inserting `<br>` and `<p>` into code. 21 21 * Replaces Wolfram Language character codes such as `\[Alpha]`, `\[Gamma]` etc. with their corresponding characters. 22 22 23 23 The highlighting feature can be triggered in two ways. In the editor `[wlcode]Wolfram Language code here[/wlcode]` can be used to place a code block directly into the text, however it is often desirable to put the code elsewhere and refer to it instead of putting it into the text itself. This is achieved by the shortcode `[wlcode field="name"]` where `name` refers to a custom post field that holds the code that should be inserted at that point. You may have to go to "screen options" at the top of the editor page to enable custom post fields before you can see the custom post field form. 24 25 To write code as a part of a sentence, that is, inline, you can use the shortcode `[wlinline]code[/wlinline]`. This will wrap the code with the `<code>` tag and thus (in many themes) distinguish the code visually. 24 26 25 27 **Embed Wolfram technologies** … … 30 32 * Display a link to the documentation of a Wolfram Language function. 31 33 32 The [official plugin](https://wordpress.org/plugins/wolfram-cdf-plugin/) from Wolfram Research that embeds CDFs [does not work](http://mathematica.stackexchange.com/q/66311/731) since WordPress 4.0.1. The shortcode in this plugin takes exactly the same arguments, so the instructions for that plugin are still valid . There is a button beneath the text editor in the post admin area that inserts a template that is straightforward to fill out. You can upload the CDF and its backup image, which you get if you use the CDF export wizard in Mathematica, via the media uploader. Remember to take note of the dimension that the export wizard tells you that the CDF has, because you will need it later.34 The [official plugin](https://wordpress.org/plugins/wolfram-cdf-plugin/) from Wolfram Research that embeds CDFs [does not work](http://mathematica.stackexchange.com/q/66311/731) since WordPress 4.0.1. The shortcode in this plugin takes exactly the same arguments, so the instructions for that plugin are still valid and migration is painless. 33 35 34 When you create an "instant API" in the Wolfram Cloud using `CloudDeploy` and `APIFunction` Mathematica gives you a URL. `[WolframCloudAPI id=""]` accepts the ID part of that URL as a parameter and will output the API's return value. Any other parameters will be passed on to the API. By default `[WolframCloudAPI]` assumes that the return value of the API is an image. If it is data you should add `image="false"` as a parameter. 36 The shortcode is `[WolframCDF source="" width="" height="" altimage="" altimagewidth="" altimageheight=""]`, and the parameters and the alternative image (that is shown to those that don't have the CDF player) can be retrieve from the export wizard in Mathematica. The CDF file and the image can be uploaded to WordPress' media library. `source` and `altimage` refer to the URLs of these two files. 37 38 The Wolfram Language functions `CloudDeploy` and `APIFunction` can be used to deploy so called *instant APIs*. The url to an instant API includes an ID number that identifies that particular API. `[WolframCloudAPI id=""]` can be used to display the result of calling the API if it is an image, and `[WolframCloudAPI id="" image="false"]` if it isn't. Any extra parameters that the API needs can also be passed along There are two working examples for this feature under FAQ. 35 39 36 40 The shortcode `[wldoc]function[/wldoc]` generates a link to the online documentation page of `function`. … … 38 42 **Retrieve posts from Mathematica.StackExchange.com** 39 43 40 `[mma_se_questions ids="11350;3345;3646"]` retrieves the questions with the given IDs. Note that the IDs are separated by semicolons. Answers can be retrieved similarly by `[mma_se_answers ids="25616;259"]`. The display format in each case is an unordered list.44 The shortcode `[mma_se_questions ids="11350;3345;3646"]` retrieves the questions with the given IDs. Note that the IDs are separated by semicolons. Answers can be retrieved similarly by `[mma_se_answers ids="25616;259"]`. The display format in each case is an unordered list. 41 45 42 46 **Retrieve profile information from Mathematica.StackExchange.com** 43 47 44 `[mma_se_user user_id="731"]` displays a link to the Mathematica.StackExchange user profile of user 731. The link text is the user's name. `[mma_se_user user_id="731" link="false"]` displays the name without turning it into a link.48 The shortcode `[mma_se_user user_id="731"]` displays a link to the Mathematica.StackExchange user profile of user 731. The link text is the user's name. `[mma_se_user user_id="731" link="false"]` displays the name without turning it into a link. 45 49 46 `[mma_se_profile_box user_id="731"]` displays a box with basic facts about user 731. Please see the screenshots page for a better understanding of what the result is.50 The shortcode `[mma_se_profile_box user_id="731"]` displays a box with basic facts about user 731. Please see the screenshots page for a better understanding of what the result is. 47 51 48 `[mma_se_user_questions user_id="731"]` and `[mma_se_user_answers user_id="731"]` displays lists of questions and answers respectively written by user 731. This shortcode is a direct interface between WordPress and the Stack Exchange API: any parameter in API can be added to the shortcode. For example `[mma_se_user_questions user_id="731" pagesize="5" sort="votes"]` returns the five questions asked by user 731 that have the most votes. You can see the full set of parameters in the [documentation](http://api.stackexchange.com/docs/answers-by-ids) for the Stack Exchange API.52 The shortcode `[mma_se_user_questions user_id="731"]` and `[mma_se_user_answers user_id="731"]` displays lists of questions and answers respectively written by user 731. This shortcode is a direct interface between WordPress and the Stack Exchange API: any parameter in the API can be added to the shortcode. For example `[mma_se_user_questions user_id="731" pagesize="5" sort="votes"]` returns the five questions asked by user 731 that have the most votes. The full set of parameters is in the [documentation](http://api.stackexchange.com/docs/answers-by-ids) for the Stack Exchange API. 49 53 50 54 **Caching of results** 51 Note that queries sent to the Stack Exchange API are cached in the background, so for example `[mma_se_user user_id="731"]` will only look that user up once a week at most, because a week is the default expiration time of the cache. It's good to let the cache expire because sometimes users change their names. However if you want you can add the `expiration` parameter to any of the `mma_se_*` calls andspecify the expiration time in seconds.55 Note that queries sent to the Stack Exchange API are cached in the background, so for example `[mma_se_user user_id="731"]` will only look that user up once a week at most, because a week is the default expiration time of the cache. It's good to let the cache expire because sometimes users change their names. All `mma_se_` shortcodes accept a parameter called `expiration` that can be used to specify the expiration time in seconds. 52 56 53 57 **Credits** -
mathematica-toolbox/trunk/public/Mathematica-WP-Toolbox-public.php
r1200690 r1244467 436 436 */ 437 437 add_shortcode( 'WolframCloudAPI', function( $parameters, $content = '' ) { 438 439 $parameters = shortcode_atts(array( 440 'id' => '', 441 'image' => true 442 ), $parameters); 443 444 $parameters['image'] = ($parameters['image'] === "false" || !$parameters['image']) ? false : true; 445 446 if( $parameters['image'] ) { 447 return "<img src='https://www.wolframcloud.com/objects/{$parameters['id']}'>"; 448 } 449 450 if( $parameters['id'] == '' ) { 451 return; 438 439 if( !isset($parameters['image']) ) { 440 $parameters['image'] = true; 441 } 442 if( $parameters['image'] === "false" || !$parameters['image'] ) { 443 $parameters['image'] = false; 444 } 445 else { 446 $parameters['image'] = true; 452 447 } 453 448 454 449 $query = "https://www.wolframcloud.com/objects/{$parameters['id']}?"; 450 451 if( !isset($parameters['id']) || $parameters['id'] == '' ) { 452 return 'The ID parameters is required.'; 453 } 455 454 456 455 foreach( $parameters as $parameter => $value ) { 457 456 458 if( $parameter == 'id' ) {457 if( $parameter == 'id' || $parameter == 'image' ) { 459 458 continue; 460 459 } … … 465 464 466 465 $query = trim( $query, '&' ); 466 467 if( $parameters['image'] ) { 468 return "<img src='$query'>"; 469 } 467 470 468 471 $response = wp_remote_get( $query );
Note: See TracChangeset
for help on using the changeset viewer.