You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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``.
6
6
7
7
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.
8
8
@@ -27,6 +27,6 @@ PEB or any PEB-based application can be easily packed as a 64-bit single-file Li
27
27
28
28
In this case a PEB executable from an AppImage will try to find its application files and folders in the directory of the AppImage.
29
29
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.
31
31
32
32
[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.
Copy file name to clipboardExpand all lines: doc/SETTINGS.md
+73-37Lines changed: 73 additions & 37 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,8 +6,10 @@ The executable binary file of the browser, ``peb``, ``peb.app``, ``peb.dmg`` or
6
6
7
7
## HTML Page API
8
8
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
+
9
11
```javascript
10
-
var pebSettings = {};// 'pebSettings' object name is hard-coded.
``Array`` of Perl scripts that are started immediately after a local page is loaded
27
29
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
+
28
54
***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.
31
56
32
57
## 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.
34
59
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:**
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.
107
140
108
141
## 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.
110
143
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.
112
145
113
146
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.
114
147
@@ -133,7 +166,7 @@ The following code shows how to start an interactive Perl script right after a l
@@ -156,7 +189,7 @@ The [index.htm](https://github.com/ddmitov/perl-executing-browser/blob/master/re
156
189
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.
157
190
158
191
## 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:
160
193
161
194
```json
162
195
{
@@ -177,7 +210,7 @@ A [Mojolicious](http://mojolicious.org/) application or other local Perl server
177
210
```
178
211
179
212
***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}``
181
214
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.
182
215
*This element is mandatory.*
183
216
@@ -209,27 +242,30 @@ The ``#PORT#`` keyword within the command-line arguments is substituted with the
209
242
``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.
210
243
211
244
## 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.
213
246
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:
215
248
216
249
***type**
217
-
``String`` containing one of the following:
250
+
``String`` containing one of the following:
251
+
218
252
*``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.
220
254
221
255
*``multiple-files``
222
256
When multiple files are selected, different filenames are separated by a semicolon ``;``
223
257
224
258
*``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.
226
260
227
261
*``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.
230
264
231
265
***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:
0 commit comments