The Regnus Parser For The Web
About
The Regnus Parser for the Web is a hosted copy of the Regnus Parser for PHP, allowing you to use Regnus scripts to generate random text, images and content on your own webpages, or in forum signatures or other places on the web where you might want to include random content, without needing access to or knowledge of PHP or your own webspace.
For example, the quoted text displayed below is randomised each time the page is refreshed:
Ian Mitchel, known by many as Ian the Small, was a deceitfully buck-toothed man. Having been brought up in the boring depths of the former USSR by his son, he was well used to peace. But even Ian was not prepared for the day when the Navy Seals came for him. Despite his best efforts, he was captured and forced to do his new masters' bidding. His first mission was to prod the HQ of the navy in Korea. Having proven himself in this task, he was sent to Japan, where he sold secrets to Venus, saving many Zoroastrian Priests on the way. He finally met his match, however, when ordered to crap all over Fred Johnson, the head of the airforce. Fred easily defeated him, and, having retired from active service, he spent the rest of his days living in a forest before finally dying of getting hit by a train in 1945.Generated by the Regnus script Something Completely Different, by
The parser can output content generated from a Regnus script in two different formats: either as an image, or as text. The text method is more powerful, as it allows you to seamlessly transclude Regnus-generated random content into your own page, to be displayed using your own styling rules. However, if you are not familiar with the basics of server-side scripting, or you do not have access to a properly configured server-side scripting language (such as PHP), you may find that the image method is much easier to implement in your site.
The image output method also allows you to generate content in situations where the use of PHP scripts is not possible - for example in a forum signature.
Note: If you do have access to your own webspace and are comfortable with the very basics of PHP, you would be recommended to use a copy of the Regnus Parser for PHP, as this ensures that the parser will run as fast as your webpages need, especially if your scripts are also hosted on the same server. Otherwise, you are welcome to use the hosted Regnus Parser for the Web, writing its output to your own webpages. This is of course slower (as it will use further HTTP requests between servers to deliver the content), and will also rely on this server's uptime, but it does have the advantage of being very easy even if you are not experienced in PHP, or even if your server doesn't support PHP in the first place.
Note: the Regnus Parser for the Web is fully supports UTF-8 character encoding, so scripts parsed using this parser are recommended to be encoded in this format.
Using The Regnus Parser For The Web
The hosted parser will, of course, be slower than a script running on your own site's server, but using it is nevertheless very simple, and perhaps more convenient for some uses. As the parser itself is hosted here at the Regnus homepage, all you have to do is call it from your own scripts, pass it the appropriate parameters, and the generated content will appear on your pages.
Generating Image Output
In order to include an image on your site displaying random text generated using Regnus, you can simply add an image tag to your (X)HTML with its src attribute set to point to the hosted parser's location on this server.
For example, copy and paste the following code into your page, replacing the highlighted variables with your own parameters:
<img src="http://www.regnus-scripting.info/parsers/web/Regnus.php?output=image&imagewidth=YourWidth&script=YourScript&label=YourLabel" alt="Random text generated using Regnus: www.regnus-scripting.info" />
Note: The example above assumes that your site is marked up with (X)HTML, but the method should be easy enough to convert to another markup language.
YourWidth should be replaced by the width (in pixels) of the image you want to generate. The height of the image is determined automatically by the amount of text generated. YourWidth must be at least 150px. Also, it should always be at least long enough to accomodate the longest single word appearing in the script you want to use. It is recommended that you give the image a width of at least 320px for most scripts.
YourScript should be replaced by the full path of the script which you want to use, which can be a URI (for example if you have uploaded the script you want to use to your own server).
YourLabel should be replaced by the name of the Label in your chosen script from which you would like to generate text.
Note: if your script or Label names include any spaces, you must replace these with "%20" in the URI.
So, if you wanted to generate a 400px-wide image from the "RANDOM PICK" Label of the script Something Completely Different hosted here, you could use:
<img src="http://www.regnus-scripting.info/parsers/web/Regnus.php?output=image&imagewidth=400&script=http://www.regnus-scripting.info/scripts/Something%20Completely%20Different.rsf&label=RANDOM%20PICK" alt="Random text generated using Regnus: www.regnus-scripting.info" />
And if you wanted to generate a 600px-wide image from the "Story" Label of the script The Storyteller, you would use:
<img src="http://www.regnus-scripting.info/parsers/web/Regnus.php?output=image&imagewidth=600&script=http://www.regnus-scripting.info/scripts/The%20Storyteller.rsf&label=Story" alt="Random text generated using Regnus: www.regnus-scripting.info" />
Note: by default, the image is output in PNG format.
Generating Text Output
Remotely generating text content using the hosted Regnus parser is possible using any scripting language which allows content to be requested via HTTP, but for simplicity, the examples given here use PHP (though of course in most cases, if you have access to a PHP installation, you would be better off uploading the Regnus Parser for PHP to your own server and using it locally!)
Assuming you are using PHP, simply copy the following code into your page wherever you want to generate random content, replacing YourScript with the name of your script, and YourLabel with the name of the Label in that script from which you'd like to generate text:
<?php
@readfile("http://www.regnus-scripting.info/parsers/web/Regnus.php?script=YourScript&label=YourLabel");
?>
The script you specify as YourScript must have a full path, which can be a URI. Assuming that, for example, you want to include text from the script Proverbs on your site, from the Label "Wise Proverb", you could use the following:
<?php
@readfile("http://www.regnus-scripting.info/parsers/web/Regnus.php?output=text&script=http://www.regnus-scripting.info/scripts/Proverbs.rsf&label=Wise%20Proverb");
?>
In fact, if you paste the above code into your page with no changes, you should hopefully see that your page now includes text generated from the Proverbs script.
Note: if your script or Label names include any spaces, you must replace these with "%20" in the URI, as shown above in the example Label "Wise Proverb"!
Additional Parameters
The Regnus Parser for the Web supports various parameters to control its behaviour, all of which can be set using command-line arguments in the URI when accessing the parser via HTTP.
The following parameters are supported:
- Script
-
- URI Parameter
- script
- Description
- Contains the path and filename of the Regnus script from which you would like to generate text.
- Label
-
- URI Parameter
- label
- Description
- Contains the name of the Label in the specified script from which you would like to start parsing.
- Script Information
-
- URI Parameter
- information
- Values
-
- blurb
- title
- Description
- If this parameter is set, the parser will output the chosen meta-information (either the script's Title or Blurb) instead of generating text from the specified Label.
- Output Type
-
- URI Parameter
- output
- Values
-
- text
- image
- Description
- Specifies whether the parser should output the generated text as text content or a PNG image. The default if unspecified is "text".
- Image Width
-
- URI Parameter
- imagewidth
- Description
- This parameter sets the width (in pixels) of the image generated when outputting an image. If unspecified, the default is "150" (the minimum allowed width).
- (X)HTML New Lines
-
- URI Parameter
- newlines
- Values
-
- br
- Description
- If this parameter is set to "br", the parser will replace standard new-line characters in the generated text with the (X)HTML tag "<br />", which can be useful if you are displaying the generated text directly on a web document and need to markup the newlines as such.
- Escape Ampersands
-
- URI Parameter
- escapeampersands
- Values
-
- true
- false
- Description
- If "true", this parameter replaces all ampersands within the generated content with (X)HTML entities. By default, this is "true" if outputting text, and "false" if outputting an image.
- Strip Tags
-
- URI Parameter
- striptags
- Values
-
- true
- false
- Description
- If "true", this parameter removes all (X)HTML tags from the generated content. By default, this is "true" if outputting an image, and "false" if outputting text.
Attribution
Please feel free to use the following link to let people know that your page is powered by Regnus!
<p>Random content on this page generated by the <a href="http://www.regnus-scripting.info/">Regnus</a> scripting language.</p>