Skip to content

Commit f4848a5

Browse files
committed
documentation update
1 parent 9ebcc10 commit f4848a5

File tree

3 files changed

+75
-46
lines changed

3 files changed

+75
-46
lines changed

doc/PACKAGING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Perl Executing Browser - Packaging
22
--------------------------------------------------------------------------------
33

44
## Minimal Relocatable Perl Distribution for PEB
5-
Minimizing the size of a relocatable (or portable) Perl distribution used by a PEB-based application is vital for reducing the size of the final distribution package. [Perl Distribution Compactor](https://github.com/ddmitov/perl-executing-browser/blob/master/sdk/compactor.pl) is one solution for this problem. It finds all dependencies of all Perl scripts in the ``{PEB_executable_directory}/resources/app`` directory and copies them in a new ``{PEB_executable_directory}/perl/lib`` folder, a new ``{PEB_executable_directory}/perl/bin`` is also created. Any unnecessary modules are left behind and the original ``bin`` and ``lib`` folders may be saved as ``bin-original`` and ``lib-original``.
5+
Minimizing the size of a relocatable (or portable) Perl distribution used by a PEB-based application is vital for reducing the size of its distribution package. [Perl Distribution Compactor](https://github.com/ddmitov/perl-executing-browser/blob/master/sdk/compactor.pl) is one solution for this problem. It finds all dependencies of all Perl scripts in the ``{PEB_executable_directory}/resources/app`` directory and copies them in a new ``{PEB_executable_directory}/perl/lib`` folder, a new ``{PEB_executable_directory}/perl/bin`` is also created. Any unnecessary modules are left behind and the original ``bin`` and ``lib`` folders are saved as ``bin-original`` and ``lib-original``.
66

77
Perl Distribution Compactor must be started from the ``{PEB_executable_directory}/sdk/lib`` folder using [compactor.sh](https://github.com/ddmitov/perl-executing-browser/blob/master/sdk/compactor.sh) on a Linux machine or [compactor.cmd](https://github.com/ddmitov/perl-executing-browser/blob/master/sdk/compactor.cmd) on a Windows machine to ensure that only the relocatable Perl distribution of PEB is used. This is necessary to avoid dependency mismatches with any other Perl on PATH.
88

@@ -27,6 +27,6 @@ PEB or any PEB-based application can be easily packed as a 64-bit single-file Li
2727

2828
In this case a PEB executable from an AppImage will try to find its application files and folders in the directory of the AppImage.
2929

30-
In both modes of operation of the [AppImage Maker](https://github.com/ddmitov/perl-executing-browser/blob/master/sdk/appimage-maker.sh) script all Qt dependencies of PEB are detected and the final image is built by the [linuxdeployqt](https://github.com/probonopd/linuxdeployqt/releases/) tool.
30+
In both modes of operation the [AppImage Maker](https://github.com/ddmitov/perl-executing-browser/blob/master/sdk/appimage-maker.sh) uses the [linuxdeployqt](https://github.com/probonopd/linuxdeployqt/releases/) tool to detect all Qt dependencies of PEB and build the final image.
3131

3232
[AppImage Maker](https://github.com/ddmitov/perl-executing-browser/blob/master/sdk/appimage-maker.sh) script must be started from the ``{PEB_executable_directory}/sdk`` directory.

doc/SETTINGS.md

Lines changed: 73 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ The executable binary file of the browser, ``peb``, ``peb.app``, ``peb.dmg`` or
66

77
## HTML Page API
88

9+
All local HTML page settings for PEB are stored in a single JavaScript object named ``pebSettings``. This name is mandatory and hard-coded in C++ code. If ``pebSettings`` JavaScript object is not found, no Perl scripts are started automatically, default labels are used for all context menus and JavaScript popup boxes and no warning is displayed for unsaved data in local HTML forms.
10+
911
```javascript
10-
var pebSettings = {}; // 'pebSettings' object name is hard-coded.
12+
var pebSettings = {};
1113
pebSettings.autoStartScripts = ['interactive_one', 'interactive_two'];
1214
pebSettings.cutLabel = "Custom Cut Label";
1315
pebSettings.copyLabel = "Custom Copy Label";
@@ -25,41 +27,72 @@ pebSettings.closeConfirmation =
2527
* **autoStartScripts**
2628
``Array`` of Perl scripts that are started immediately after a local page is loaded
2729

30+
* **cutLabel**
31+
``String`` displayed as a label for the 'Cut' action on context menus.
32+
33+
* **copyLabel**
34+
``String`` displayed as a label for the 'Copy' action on context menus.
35+
36+
* **pasteLabel**
37+
``String`` displayed as a label for the 'Paste' action on context menus.
38+
39+
* **selectAllLabel**
40+
``String`` displayed as a label for the 'Select All' action on context menus.
41+
42+
* **okLabel**
43+
``String`` displayed as a label for the 'Ok' button on JavaScript Alert and Prompt popup boxes.
44+
45+
* **cancelLabel**
46+
``String`` displayed as a label for the 'Cancel' button on JavaScript Prompt popup box.
47+
48+
* **yesLabel**
49+
``String`` displayed as a label for the 'Yes' button on JavaScript Confirm popup box.
50+
51+
* **noLabel**
52+
``String`` displayed as a label for the 'No' button on JavaScript Confirm popup box.
53+
2854
* **closeConfirmation**
29-
``String`` displayed when the close button is pressed, but unsaved data in local HTML forms is detected.
30-
If no warning text is found, PEB exits immediately.
55+
``String`` displayed in a JavaScript Confirm popup box when the close button is pressed, but unsaved data in local HTML forms is detected. If no ``closeConfirmation`` object property is found, PEB exits immediately.
3156

3257
## Perl Scripts API
33-
Every Perl script run by PEB is called by clicking a link or submitting a form to a pseudo filename composed of the name of the JavaScript object with the settings of the Perl script and a ``.settings`` extension.
58+
Every Perl script run by PEB has a JavaScript settings object with an arbitrary name and fixed object properties. The name of the JavaScript settings object with a ``.settings`` extension forms pseudo filename used to start the Perl script.
3459

35-
A minimal example of a Perl script settings object:
60+
There are three methods to start a local Perl script:
61+
62+
* **Clicking a link to a settings pseudo filename:**
63+
64+
```html
65+
<a href="perl_script.settings">Start Perl script</a>
66+
```
67+
68+
* **Submitting a form to a settings pseudo filename:**
69+
70+
```html
71+
<form action="perl_script.settings">
72+
<input type="text" name="input" id="test-script-input">
73+
<input type="submit" value="Start Perl script">
74+
</form>
75+
```
76+
77+
* **Calling a JavaScript function with a settings pseudo filename:**
78+
79+
```javascript
80+
peb.startScript('perl_script.settings');
81+
```
82+
83+
This method creates an invisible form and submits it to the settings pseudo filename.
84+
85+
A minimal example of a JavaScript settings object for a Perl script run by PEB:
3686

3787
```javascript
3888
var perl_script = {};
3989
perl_script.scriptRelativePath = 'perl/test.pl';
4090
perl_script.stdoutFunction = function (stdout) {
4191
var container = document.getElementById('tests');
42-
container.innerHTML = stdout;
92+
container.innerText = stdout;
4393
}
4494
```
4595

46-
Three methods to start a local Perl script:
47-
48-
```html
49-
<a href="perl_script.settings">Start Perl script</a>
50-
```
51-
52-
```html
53-
<form action="perl_script.settings">
54-
<input type="text" name="input" id="test-script-input">
55-
<input type="submit" value="Start Perl script">
56-
</form>
57-
```
58-
59-
```javascript
60-
peb.startScript('perl_script.settings');
61-
```
62-
6396
* **scriptRelativePath**
6497
``String`` for the relative path of a Perl script run by PEB
6598
The script relative path is converted to a full path using the ``{PEB_app_directory}`` as a root folder.
@@ -106,9 +139,9 @@ peb.startScript('perl_script.settings');
106139
Perl scripts running for a long time should have ``$|=1;`` among their first lines to disable the built-in buffering of the Perl interpreter. Some builds of Perl may not give any output until the script has ended when buffering is enabled.
107140

108141
## Interactive Perl Scripts
109-
Each PEB interactive Perl script must have its own event loop waiting constantly for new data on STDIN for a bidirectional connection with PEB. Many interactive scripts can be started simultaneously in one browser window. One script may be started in many instances, provided that it has a JavaScript settings object with a unique name. Interactive scripts must also have the ``scriptExitCommand`` object property. The ``scriptExitConfirmation`` object property is not mandatory, but highly recommended for a quick shutdown of PEB.
142+
Each PEB interactive Perl script must have its own event loop waiting constantly for new data on STDIN for a bidirectional connection with PEB. Many interactive scripts can be started simultaneously in one browser window. One script may be started in many instances, provided that it has a JavaScript settings object with an unique name. Interactive scripts must also have the ``scriptExitCommand`` object property. The ``scriptExitConfirmation`` object property is not mandatory, but highly recommended for a quick shutdown of PEB.
110143

111-
Please note that interactive Perl scripts are not supported on any Windows build of PEB.
144+
Please note that interactive Perl scripts are not supported by the Windows builds of PEB.
112145

113146
Please also note that if a PEB instance crashes, it will leave its interactive scripts as zombie processes and they will start consuming large amounts of memory! Exhaustive stability testing has to be done when interactive scripts are selected for use with PEB! Even during normal operation interactive scripts use more memory than non-interactive scripts and their use should be carefully considered.
114147

@@ -133,7 +166,7 @@ The following code shows how to start an interactive Perl script right after a l
133166
}
134167
interactive_script.stdoutFunction = function (stdout) {
135168
var container = document.getElementById('interactive-script-output');
136-
container.innerHTML = stdout;
169+
container.innerText = stdout;
137170
}
138171
interactive_script.scriptExitCommand = '_close_';
139172
interactive_script.scriptExitConfirmation = '_closed_';
@@ -156,7 +189,7 @@ The [index.htm](https://github.com/ddmitov/perl-executing-browser/blob/master/re
156189
The [interactive.pl](https://github.com/ddmitov/perl-executing-browser/blob/master/resources/app/perl/interactive.pl) script of the demo package is an example of a Perl interactive script for PEB.
157190

158191
## Starting Local Server
159-
A [Mojolicious](http://mojolicious.org/) application or other local Perl server can be started by PEB provided that a ``{PEB_resources_directory}/app/local-server.json`` file is found instead of ``{PEB_resources_directory}/app/index.html`` with the following structure:
192+
A [Mojolicious](http://mojolicious.org/) application or other local Perl server can be started by PEB provided that a ``{PEB_app_directory}/local-server.json`` file is found instead of ``{PEB_app_directory}/index.html`` with the following structure:
160193

161194
```json
162195
{
@@ -177,7 +210,7 @@ A [Mojolicious](http://mojolicious.org/) application or other local Perl server
177210
```
178211

179212
* **file**
180-
``String`` resolved to a full pathname using the ``{PEB_resources_directory}/app`` folder
213+
``String`` resolved to a full pathname using the ``{PEB_app_directory}``
181214
All Perl servers started by PEB must be up and running within 5 seconds from being launched or PEB will display a timeout message. Servers being unable to start will also timeout.
182215
*This element is mandatory.*
183216

@@ -209,27 +242,30 @@ The ``#PORT#`` keyword within the command-line arguments is substituted with the
209242
``shutdown_command`` is not needed if the local server uses a WebSocket connection to detect when PEB is disconnected and shut down on its own - see the [Tabula](https://github.com/ddmitov/tabula) application for an example.
210243

211244
## Selecting Files and Folders
212-
Selecting files or folders with their full paths is performed by clicking a link to a pseudo filename composed from the name of the JavaScript object with the settings of the wanted dialog and a ``.dialog`` extension.
245+
Selecting files or folders with their full paths is performed by clicking a link to a pseudo filename composed of the name of the JavaScript settings object for the wanted dialog and a ``.dialog`` extension.
213246

214-
A JavaScript settings object for a filesystem dialog takes only two arguments:
247+
A JavaScript settings object for a filesystem dialog has only two object properties:
215248

216249
* **type**
217-
``String`` containing one of the following:
250+
``String`` containing one of the following:
251+
218252
* ``single-file``
219-
The actual opening of any existing file is performed by a Perl script and not by PEB.
253+
The actual opening of an existing file is performed by a Perl script and not by PEB.
220254

221255
* ``multiple-files``
222256
When multiple files are selected, different filenames are separated by a semicolon ``;``
223257

224258
* ``new-file-name``
225-
The actual creation of any new file is performed by a Perl script and not by PEB.
259+
The actual creation of a new file is performed by a Perl script and not by PEB.
226260

227261
* ``directory``
228-
When using the ``directory`` type of dialog, an existing or a new directory may be selected.
229-
Any new directory will be created immediately by PEB.
262+
When ``directory`` type of dialog is used, an existing or a new directory may be selected.
263+
Any new directory will be immediately created by PEB.
230264

231265
* **receiverFunction**
232-
executed by PEB after the user has selected files or folders, takes selected files or folders as its only argument
266+
It is executed by PEB after the user has selected files or folders and takes them as its only argument.
267+
268+
An example code of a dialog for selecting a single file:
233269

234270
```html
235271
<a href="select_file.dialog">Select existing file</a>
@@ -240,6 +276,6 @@ var select_file = {};
240276
select_file.type = 'single-file';
241277
select_file.receiverFunction = function (file) {
242278
var container = document.getElementById('single-file-test');
243-
container.innerHTML = file;
279+
container.innerText = file;
244280
}
245281
```

sdk/compactor.pl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Cwd qw(getcwd);
99
use File::Basename qw(basename);
1010
use File::Copy;
11-
use File::Path qw(rmtree);
1211
use File::Spec;
1312
use File::Spec::Functions qw(catdir);
1413
use FindBin qw($Bin);
@@ -95,12 +94,6 @@
9594

9695
rename $lib_original, catdir($perl_directory, "lib-original");
9796
rename $lib_compacted, catdir($perl_directory, "lib");
98-
99-
# Remove backup directories if the script is started with the '--no-backup' flag.
100-
if ($ARGV[0] and $ARGV[0] =~ /^--no-backup$/) {
101-
rmtree(catdir($perl_directory, "bin-original"));
102-
rmtree(catdir($perl_directory, "lib-original"));
103-
}
10497
}
10598

10699
# Perl scripts recursive lister subroutine:

0 commit comments

Comments
 (0)