Skip to content

Commit 7d27032

Browse files
committed
.script pseudo filename extension
1 parent 84e736d commit 7d27032

File tree

5 files changed

+30
-30
lines changed

5 files changed

+30
-30
lines changed

doc/SETTINGS.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,29 +57,28 @@ The ``pebSettings`` JavaScript object may have the following properties:
5757
``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.
5858

5959
## Perl Scripts API
60-
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.
60+
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 ``.script`` extension forms pseudo filename used to start the Perl script.
6161

6262
There are three methods to start a local Perl script:
6363

6464
* **Clicking a link to a settings pseudo filename:**
6565

6666
```html
67-
<a href="perl_script.settings">Start Perl script</a>
67+
<a href="test.script">Start Perl script</a>
6868
```
6969

7070
* **Submitting a form to a settings pseudo filename:**
7171

7272
```html
73-
<form action="perl_script.settings">
74-
<input type="text" name="input" id="test-script-input">
73+
<form action="test.script">
7574
<input type="submit" value="Start Perl script">
7675
</form>
7776
```
7877

7978
* **Calling a JavaScript function with a settings pseudo filename:**
8079

8180
```javascript
82-
peb.startScript('perl_script.settings');
81+
peb.startScript('test.script');
8382
```
8483

8584
This method creates an invisible form and submits it to the settings pseudo filename.
@@ -176,7 +175,7 @@ The following code shows how to start an interactive Perl script right after a l
176175
</head>
177176

178177
<body>
179-
<form action="interactive_script.settings">
178+
<form action="interactive_script.script">
180179
<input type="text" name="input" id="interactive-script-input">
181180
<input type="submit" value="Submit">
182181
</form>
@@ -191,8 +190,9 @@ The [index.htm](https://github.com/ddmitov/perl-executing-browser/blob/master/re
191190
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.
192191

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

197197
```json
198198
{
@@ -245,7 +245,7 @@ The ``#PORT#`` keyword within the command-line arguments is substituted with the
245245
``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.
246246

247247
## Selecting Files and Folders
248-
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.
248+
Selecting files or folders with their full paths is performed by clicking a link to a pseudo filename composed of the name of a JavaScript settings object for the wanted dialog and a ``.dialog`` extension.
249249

250250
A JavaScript settings object for a filesystem dialog has only two object properties:
251251

resources/app/index-windows.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
select_file.type = 'single-file';
8585
select_file.receiverFunction = function (fileName) {
8686
open_files.inputData = fileName;
87-
peb.startScript('open_files.settings');
87+
peb.startScript('open_files.script');
8888
}
8989

9090
var new_file_name = {};
@@ -100,14 +100,14 @@
100100
select_files.type = 'multiple-files';
101101
select_files.receiverFunction = function (fileNames) {
102102
open_files.inputData = fileNames;
103-
peb.startScript('open_files.settings');
103+
peb.startScript('open_files.script');
104104
}
105105

106106
var select_directory = {};
107107
select_directory.type = 'directory';
108108
select_directory.receiverFunction = function (directoryName) {
109109
open_directory.inputData = directoryName;
110-
peb.startScript('open_directory.settings');
110+
peb.startScript('open_directory.script');
111111
}
112112

113113
function clearTargetElement() {
@@ -193,11 +193,11 @@
193193
</li>
194194

195195
<li>
196-
<a href="perl_info.settings">Perl Basic Information</a>
196+
<a href="perl_info.script">Perl Basic Information</a>
197197
</li>
198198

199199
<li>
200-
<a href="sqlite.settings">SQLite Test</a>
200+
<a href="sqlite.script">SQLite Test</a>
201201
</li>
202202

203203
<li>
@@ -255,7 +255,7 @@ <h2>Perl Executing Browser</h2>
255255

256256
<div class="row">
257257
<div class="col-xs-12 form-group">
258-
<form action="perl_input.settings" id="perl-input">
258+
<form action="perl_input.script" id="perl-input">
259259
<div class="input-group">
260260
<input type="text" id="perl-input-box" class="form-control"
261261
placeholder="Press Enter to send data to Perl script">

resources/app/index.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
select_file.type = 'single-file';
8181
select_file.receiverFunction = function (fileName) {
8282
open_files.inputData = fileName;
83-
peb.startScript('open_files.settings');
83+
peb.startScript('open_files.script');
8484
}
8585

8686
var new_file_name = {};
@@ -96,14 +96,14 @@
9696
select_files.type = 'multiple-files';
9797
select_files.receiverFunction = function (fileNames) {
9898
open_files.inputData = fileNames;
99-
peb.startScript('open_files.settings');
99+
peb.startScript('open_files.script');
100100
}
101101

102102
var select_directory = {};
103103
select_directory.type = 'directory';
104104
select_directory.receiverFunction = function (directoryName) {
105105
open_directory.inputData = directoryName;
106-
peb.startScript('open_directory.settings');
106+
peb.startScript('open_directory.script');
107107
}
108108

109109
function clearTargetElement() {
@@ -189,11 +189,11 @@
189189
</li>
190190

191191
<li>
192-
<a href="perl_info.settings">Perl Basic Information</a>
192+
<a href="perl_info.script">Perl Basic Information</a>
193193
</li>
194194

195195
<li>
196-
<a href="sqlite.settings">SQLite Test</a>
196+
<a href="sqlite.script">SQLite Test</a>
197197
</li>
198198

199199
<li>
@@ -253,7 +253,7 @@ <h3>Interactive Script Demo</h3>
253253

254254
<div class="row">
255255
<div class="col-xs-12 form-group">
256-
<form action="interactive_one.settings" id="form-one">
256+
<form action="interactive_one.script" id="form-one">
257257
<div class="input-group">
258258
<input type="hidden" name="mode" value="unix-epoch">
259259

@@ -278,7 +278,7 @@ <h3>Interactive Script Demo</h3>
278278

279279
<div class="row">
280280
<div class="col-xs-12 form-group">
281-
<form action="interactive_two.settings" id="form-two">
281+
<form action="interactive_two.script" id="form-two">
282282
<div class="input-group">
283283
<input type="hidden" name="mode" value="local-time">
284284

src/webengine-page.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ bool QPage::acceptNavigationRequest(const QUrl &url,
7676
if (url.scheme() == "file" and isMainFrame == true) {
7777
// Local forms submission:
7878
if (type == QWebEnginePage::NavigationTypeFormSubmitted) {
79-
if (url.fileName().contains(".settings")) {
80-
qHandleScripts(url.fileName().replace(".settings", ""));
79+
if (url.fileName().contains(".script")) {
80+
qHandleScripts(url.fileName().replace(".script", ""));
8181
return false;
8282
} else {
8383
return false;
@@ -92,8 +92,8 @@ bool QPage::acceptNavigationRequest(const QUrl &url,
9292
}
9393

9494
// Handle local Perl scripts:
95-
if (url.fileName().contains(".settings")) {
96-
qHandleScripts(url.fileName().replace(".settings", ""));
95+
if (url.fileName().contains(".script")) {
96+
qHandleScripts(url.fileName().replace(".script", ""));
9797
return false;
9898
}
9999

src/webkit-page.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,9 +422,9 @@ public slots:
422422
if (request.url().scheme() == "file") {
423423
// Local forms submission:
424424
if (navigationType == QWebPage::NavigationTypeFormSubmitted) {
425-
if (request.url().fileName().contains(".settings")) {
425+
if (request.url().fileName().contains(".script")) {
426426
qHandleScripts(request.url().fileName()
427-
.replace(".settings", ""));
427+
.replace(".script", ""));
428428
return false;
429429
} else {
430430
return false;
@@ -440,9 +440,9 @@ public slots:
440440
}
441441

442442
// Handle local Perl scripts:
443-
if (request.url().fileName().contains(".settings")) {
443+
if (request.url().fileName().contains(".script")) {
444444
qHandleScripts(request.url().fileName()
445-
.replace(".settings", ""));
445+
.replace(".script", ""));
446446
return false;
447447
}
448448

0 commit comments

Comments
 (0)