Merge branch 'pages_for_v0.09-beta' into gh-pages

gh-pages
Hauke D 7 years ago
commit 03a4888669

@ -0,0 +1,52 @@
#!/usr/bin/env perl
use warnings;
use 5.026;
use FindBin ();
use Path::Class qw/dir file/;
# A quick and dirty script for importing stuff from webperl/master to gh-pages
sub edit (&$$) {
my ($code,$source,$dest) = @_;
state $basedir = dir($FindBin::Bin)->parent->parent;
local $_ = file($source)->absolute($basedir)->slurp(iomode=>'<:raw:encoding(UTF-8)');
$code->();
file($dest)->absolute($basedir)->spew(iomode=>'>:raw:encoding(UTF-8)', $_);
}
edit {
s{ iframe.perleditor\s*\{ [^\}]* border: \s* \K \N* (?=\n) }{1px dotted lightgrey;}xmsg==1 or die;
s{ <!--(?<x>script\s+src="http.+?iframeResizer.min.js"[^>]+crossorigin[^>]+></script)--> }{<$+{x}>}xmsg==1 or die;
s{ ^ \s* \K /[/*] (?= \s* iFrameResize ) }{}xmsg==2 or die;
} 'web/democode/demo.html', 'pages/democode/index.html';
edit {
s{ <!-- [^>]* \K demo.html (?= [^>]* --> ) }{index.html}xmsg==1 or die;
s{ <!--(?<x>script\s+src="http.+?iframeResizer.contentWindow.min.js"[^>]+crossorigin[^>]+></script)--> }{<$+{x}>}xmsg==1 or die;
} 'web/democode/perleditor.html', 'pages/democode/perleditor.html';
edit {
s{ <!-- [^>]* \K demo.html (?= [^>]* --> ) }{index.html}xmsg==1 or die;
s{ <(?<x>script\s+src="[^"]*webperl\.js"\s*></script)> }{<!--$+{x}-->}xmsg==1 or die;
s{ <!--(?<x>script\s+src="http.+?webperl\.js"[^>]+crossorigin[^>]+></script)--> }{<$+{x}>}xmsg==1 or die;
} 'web/democode/perlrunner.html', 'pages/democode/perlrunner.html';
edit {
} 'web/democode/perleditor.css', 'pages/democode/perleditor.css';
edit {
my $msg = <<'ENDMSG';
This is essentially a copy of
https://github.com/haukex/webperl/blob/master/web/regex_tester.html
with the following differences:
- webperl.js from CDN
- $RUN_CODE_IN_IFRAME enabled
- URL updated to https://github.com/haukex/webperl/blob/gh-pages/regex.html
(see import_regex_tester.pl)
ENDMSG
s{ <(?<x>script\s+src="(?:webperl\.js|__WEBPERLURL__)"\s*></scr_*ipt)> }{<!--$+{x}-->}xmsg==2 or die;
s{ <!--(?<x>script\s+src="http.+?webperl\.js"[^>]+crossorigin[^>]+></scr_*ipt)--> }{<$+{x}>}xmsg==2 or die;
s{ ^ \s* our \s+ \$RUN_CODE_IN_IFRAME\s*=\s*\K[01](?=\s*;\s*) }{1}xmsg==1 or die;
s{ https?://github.com/haukex/webperl/blob/\Kmaster/web/regex_tester.html }{gh-pages/regex.html}xmsg==1 or die;
s{ \#\#\#\#\#\s*-->\n\K }{\n<!-- $msg-->\n}xmsg==1 or die;
} 'web/regex_tester.html', 'pages/regex.html';

@ -1,31 +0,0 @@
#!/usr/bin/env perl
use warnings;
use strict;
use FindBin ();
# A quick and dirty script for importing regex_tester.html to pages
my $infn = "$FindBin::Bin/../../web/regex_tester.html";
my $outfn = "$FindBin::Bin/../regex.html";
my $html = do { open my $ifh, '<:encoding(UTF-8)', $infn or die "$infn: $!"; local $/; <$ifh> };
my $msg = <<'ENDMSG';
This is essentially a copy of
https://github.com/haukex/webperl/blob/master/web/regex_tester.html
with the following differences:
- webperl.js from CDN
- $RUN_CODE_IN_IFRAME enabled
- URL updated to https://github.com/haukex/webperl/blob/gh-pages/regex.html
(see import_regex_tester.pl)
ENDMSG
( $html =~ s{ <(?<x>script\s+src="(?:webperl\.js|__WEBPERLURL__)"\s*></scr_*ipt)> }{<!--$+{x}-->}xmsg )==2 or die;
( $html =~ s{ <!--(?<x>script\s+src="http.+?webperl\.js"[^>]+crossorigin[^>]+></scr_*ipt)--> }{<$+{x}>}xmsg )==2 or die;
( $html =~ s{ ^ \s* our \s+ \$RUN_CODE_IN_IFRAME\s*=\s*\K[01](?=\s*;\s*) }{1}xmsg )==1 or die;
( $html =~ s{ https?://github.com/haukex/webperl/blob/\Kmaster/web/regex_tester.html }{gh-pages/regex.html}xmsg )==1 or die;
( $html =~ s{ \#\#\#\#\#\s*-->\n\K }{\n<!-- $msg-->\n}xmsg )==1 or die;
open my $ofh, '>:encoding(UTF-8)', $outfn or die "$outfn: $!";
print $ofh $html;
close $ofh;

@ -30,12 +30,12 @@ Prerequisites
- [Emscripten](http://emscripten.org) SDK, 1.38.10 and up,
please see the prerequisites and installation instructions at
<http://kripken.github.io/emscripten-site/docs/getting_started/downloads.html#installation-instructions>
- The build script has several CPAN dependencies. One way to install them
is using [lazy](https://metacpan.org/pod/lazy): first,
install "lazy", then run e.g. `perl -Mlazy build.pl --help`.
Otherwise, the modules used by `build.pl` can be seen in
[its source](https://github.com/haukex/webperl/blob/master/build/build.pl)
grouped near the top of the file.
- The build script has several CPAN dependencies. You can install these
via [`cpanm`](https://metacpan.org/pod/App::cpanminus) and the provided
`cpanfile`: `cd` to the `build` directory, then run `cpanm --installdeps .`
(Otherwise, see the `cpanfile` or the source of `build.pl` and install these
modules with the installer of your choice. Another possibility is to use
[`lazy`](https://metacpan.org/pod/lazy), e.g. `perl -Mlazy build.pl --help`)
- A working Internet connection is needed for installation and the first build.
@ -55,10 +55,10 @@ is checked out by the build script.
Some of the central source files of WebPerl are:
- [`webperl/build/build.pl`](https://github.com/haukex/webperl/blob/master/build/build.pl)
- [`emperl5/hints/emscripten.sh`](https://github.com/haukex/emperl5/blob/emperl_v5.28.0/hints/emscripten.sh)
- [`emperl5/perlmain_noexit_patch`](https://github.com/haukex/emperl5/blob/emperl_v5.28.0/perlmain_noexit_patch)
- [`emperl5/ext/WebPerl/WebPerl.xs`](https://github.com/haukex/emperl5/blob/emperl_v5.28.0/ext/WebPerl/WebPerl.xs)
- [`emperl5/ext/WebPerl/lib/WebPerl.pm`](https://github.com/haukex/emperl5/blob/emperl_v5.28.0/ext/WebPerl/lib/WebPerl.pm)
- [`emperl5/hints/emscripten.sh`](https://github.com/haukex/emperl5/blob/emperl_v5.28.1/hints/emscripten.sh)
- [`emperl5/perlmain_noexit_patch`](https://github.com/haukex/emperl5/blob/emperl_v5.28.1/perlmain_noexit_patch)
- [`emperl5/ext/WebPerl/WebPerl.xs`](https://github.com/haukex/emperl5/blob/emperl_v5.28.1/ext/WebPerl/WebPerl.xs)
- [`emperl5/ext/WebPerl/lib/WebPerl.pm`](https://github.com/haukex/emperl5/blob/emperl_v5.28.1/ext/WebPerl/lib/WebPerl.pm)
- [`webperl/web/webperl.js`](https://github.com/haukex/webperl/blob/master/web/webperl.js)

@ -58,10 +58,8 @@ function makeCM (textarea,plain,ro) {
function runnerState (text) {
$('#runnerstate').text( text
/* not available until WebPerl v0.09-beta:
+ (lastExitStatus ? ' (last exit status was '+lastExitStatus+')'
: '') );
*/ );
}
function updateButtonState () {

@ -39,8 +39,8 @@ If not, see http://perldoc.perl.org/index-licence.html
-->
<!--script src="../webperl.js"></script-->
<script src="https://webperlcdn.zero-g.net/v0.07-beta/webperl.js"
integrity="sha256-jL8SB7St5ou4+hb0frK0k6VCQXsWQ1wolDrdU7i4juc=" crossorigin="anonymous"></script>
<script src="https://webperlcdn.zero-g.net/v0.09-beta/webperl.js"
integrity="sha256-1RaYAh/WfDl3WZl+BDpSuSycg4x88pfkAFSxhWjBONk=" crossorigin="anonymous"></script>
<script>
"use strict";
@ -60,7 +60,6 @@ function reportErr (err) {
}
Perl.addStateChangeListener(function (from,to) {
if (from==to) return; // won't be needed as of v0.09-beta
if (to=="Ended" && currentClient) {
for (var chan=1;chan<=2;chan++) // flush buffers
if (stdbuf[chan].length) {

@ -36,7 +36,7 @@ js('document')->getElementById('my_button')
</script>
```
- [**Download `webperl_prebuilt_v0.07-beta.zip`**](https://github.com/haukex/webperl/releases/download/v0.07-beta/webperl_prebuilt_v0.07-beta.zip)
- [**Download `webperl_prebuilt_v0.09-beta.zip`**](https://github.com/haukex/webperl/releases/download/v0.09-beta/webperl_prebuilt_v0.09-beta.zip)
- [**Get the sources on GitHub**](https://github.com/haukex/webperl)
For web applications written with WebPerl, see:
@ -49,14 +49,16 @@ Quick Start
-----------
- Prerequisites: `perl` (a recent version is recommended, e.g. v5.26 and up),
[`plackup` from Plack](https://metacpan.org/pod/distribution/Plack/script/plackup),
and [Cpanel::JSON::XS](https://metacpan.org/pod/Cpanel::JSON::XS).
and [`cpanm`](https://metacpan.org/pod/App::cpanminus) to easily install
dependencies (otherwise, see the file `cpanfile` for the dependencies and
use the module installer of your choce).
- In a shell:
$ wget https://github.com/haukex/webperl/releases/download/v0.07-beta/webperl_prebuilt_v0.07-beta.zip
$ unzip webperl_prebuilt_v0.07-beta.zip
$ cd webperl_prebuilt_v0.07-beta
$ wget https://github.com/haukex/webperl/releases/download/v0.09-beta/webperl_prebuilt_v0.09-beta.zip
$ unzip webperl_prebuilt_v0.09-beta.zip
$ cd webperl_prebuilt_v0.09-beta
$ cpanm --installdeps .
$ plackup webperl.psgi
HTTP::Server::PSGI: Accepting connections at http://0:5000/

@ -154,8 +154,8 @@ Release Checklist
- Update version numbers everywhere; use `grep` to find them, for example:
$ grep -Er --exclude-dir=work --exclude-dir=.git --exclude-dir=emperl5 --exclude=emperl.* '0\.0[0-9]' .
$ ( cd emperl5; grep -Er '0\.0[0-9]' `git diff --numstat --diff-filter=A v5.28.0 HEAD | cut -f3` )
$ grep -Er --exclude-dir=hostperl --exclude-dir=.git --exclude-dir=emperl5 --exclude=emperl.* '0\.[01][0-9]' .
$ ( cd emperl5; grep -Er '0\.[01][0-9]' `git diff --numstat --diff-filter=ACMRT v5.28.1 HEAD | cut -f3` )
At a minimum there is:
- `web/webperl.js` - `Perl.WebPerlVersion`

@ -47,8 +47,8 @@ Quick Start
$ git clone https://github.com/haukex/webperl.git
$ cd webperl
$ wget https://github.com/haukex/webperl/releases/download/v0.07-beta/webperl_prebuilt_v0.07-beta.zip
$ unzip -j webperl_prebuilt_v0.07-beta.zip '*/emperl.*' -d web
$ wget https://github.com/haukex/webperl/releases/download/v0.09-beta/webperl_prebuilt_v0.09-beta.zip
$ unzip -j webperl_prebuilt_v0.09-beta.zip '*/emperl.*' -d web
$ cpanm --installdeps .
$ cd experiments ; cpanm --installdeps . ; cd ..
$ experiments/p6/6init.pl # this patches Perl 6 support in

@ -35,8 +35,7 @@ with the following differences:
-->
<meta name="viewport" content="width=600" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css"
integrity="sha256-oSrCnRYXvHG31SBifqP2PM1uje7SJUyX0nTwO2RJV54=" crossorigin="anonymous" />
<!--cacheable--><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css" integrity="sha256-oSrCnRYXvHG31SBifqP2PM1uje7SJUyX0nTwO2RJV54=" crossorigin="anonymous" />
<style>
body {
margin: 0.4em;
@ -110,10 +109,9 @@ textarea.samp_ta {
</style>
<!--script src="webperl.js"></script-->
<script src="https://webperlcdn.zero-g.net/v0.07-beta/webperl.js"
integrity="sha256-jL8SB7St5ou4+hb0frK0k6VCQXsWQ1wolDrdU7i4juc=" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script src="https://webperlcdn.zero-g.net/v0.09-beta/webperl.js"
integrity="sha256-1RaYAh/WfDl3WZl+BDpSuSycg4x88pfkAFSxhWjBONk=" crossorigin="anonymous"></script>
<!--cacheable--><script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script type="text/perl">
use warnings;
@ -127,6 +125,10 @@ sub pp { Data::Dumper->new([@_])->Useqq(1)->Terse(1)->Pair('=>')
our $RUN_CODE_IN_IFRAME=1;
# Possible To-Do for Later: Subs in preamble code produce "subroutine redefined" warnings.
# I could think about whether there's a decent way around that.
# Example: https://www.perlmonks.org/?node_id=1225457
my $run_code_body = <<'END_CODE';
my (@warns,@output);
@ -161,11 +163,18 @@ END_CODE
my $runcode_iframe;
my $runcode_message_callback; # assume a single callback for now
if ($RUN_CODE_IN_IFRAME) { # https://www.html5rocks.com/en/tutorials/security/sandboxed-iframes/
my $webperlurl;
$jq->('script')->each(sub { $webperlurl=$_[1]->{src} if $_[1]->{src}=~/\bwebperl\.js\z/ });
if (!$webperlurl) {
warn "Warning: Could not determine URL of webperl.js\n";
$webperlurl = 'webperl.js'; # probably won't work due to same-origin
}
my $iframe_html = <<~'END_IFRAME_HTML';
<html>
<head>
<script src="https://webperlcdn.zero-g.net/v0.07-beta/webperl.js"
integrity="sha256-jL8SB7St5ou4+hb0frK0k6VCQXsWQ1wolDrdU7i4juc=" crossorigin="anonymous"></scr__ipt>
<!--script src="__WEBPERLURL__"></scr__ipt-->
<script src="https://webperlcdn.zero-g.net/v0.09-beta/webperl.js"
integrity="sha256-1RaYAh/WfDl3WZl+BDpSuSycg4x88pfkAFSxhWjBONk=" crossorigin="anonymous"></scr__ipt>
<script>
Perl.noMountIdbfs=true; // we're sandboxed
</scr__ipt>
@ -190,8 +199,10 @@ if ($RUN_CODE_IN_IFRAME) { # https://www.html5rocks.com/en/tutorials/security/sa
END_IFRAME_HTML
$iframe_html=~s#</\w+\K__(?=\w+>)##ig;
$iframe_html=~s/__RUNCODEBODY__/$run_code_body/;
$iframe_html=~s/__WEBPERLURL__/$webperlurl/g;
my $iframe_blob_url = js('URL')->createObjectURL(
WebPerl::js_new('Blob',[$iframe_html],{type=>"text/html;charset=utf-8"}) );
#TODO Later: Why does the message passing not work when I remove the "sandbox" attr?
my $iframe = $jq->('<iframe/>', {id=>'PerlEval_IFrame', sandbox=>'allow-scripts',
src=>$iframe_blob_url} )->hide->appendTo('body');
$runcode_iframe = $iframe->[0]{contentWindow};
@ -217,14 +228,20 @@ if ($RUN_CODE_IN_IFRAME) { # https://www.html5rocks.com/en/tutorials/security/sa
my $start_time = time;
my $intid; $intid = $window->setInterval(sub {
if (time-$start_time>10) {
$window->alert("Failed to get response from Perl in IFrame, loading failed?");
$window->clearInterval($intid);
if ($window->confirm("Perl does not appear to have loaded yet, keep waiting?\n"
."(If you are on a slow connection, click OK to keep waiting.)")) {
$start_time = time;
}
else {
$window->clearInterval($intid);
}
}
elsif ($got_response)
{ $window->clearInterval($intid) }
else { update() }
}, 500);
}
$jq->('#loading')->text('Loading (Stage 2/2)...');
sub sample_init {
my $samp = shift;
@ -276,6 +293,7 @@ sub newsamp {
update();
return $samp;
}
#TODO: Adding samples causes the code table to grow, but not shrink when they are removed
$addsamp->click(sub { newsamp('')->click });
# $re_debug is actually a parameter to update()/actual_update(), but since
@ -344,6 +362,7 @@ $ta_flags->keyup( \&update);
js('$(window)')->on('hashchange',\&hashchange);
#TODO: The auto-sizing causes the textarea to grow on Chrome mobile
$ta_regex->on('input', sub { # autoexpand for new lines
$ta_regex->height($ta_regex->[0]{scrollHeight});
});
@ -582,7 +601,7 @@ sub hashchange {
<div style="margin-bottom:1em;font-size:1.2em;text-align:center;"><b>Perl Regex Tester</b>
- powered by <a href="http://webperl.zero-g.net" target="_blank">WebPerl</a> (beta)</div>
<div id="loading" style="position:absolute;left:40%;font-size:1.2em;font-weight:bold;color:red;">Loading...</div>
<div id="loading" style="position:absolute;left:40%;font-size:1.2em;font-weight:bold;color:red;">Loading (Stage 1/2)...</div>
<div style="margin-bottom:1em;">
<div>

@ -39,7 +39,7 @@ If you plan on building WebPerl, for example if you'd like to add more CPAN
modules, then head on over to [Building WebPerl](building.html). Otherwise, if
you'd just like to get started quickly and work with the prebuilt WebPerl
(includes many of the Perl core modules plus a couple extras), then download
[`webperl_prebuilt_v0.07-beta.zip`](https://github.com/haukex/webperl/releases/download/v0.07-beta/webperl_prebuilt_v0.07-beta.zip)
[`webperl_prebuilt_v0.09-beta.zip`](https://github.com/haukex/webperl/releases/download/v0.09-beta/webperl_prebuilt_v0.09-beta.zip)
and unpack it. This ZIP file includes the contents of the
[`web`](https://github.com/haukex/webperl/tree/master/web) directory of the
source code, as well as the build products `emperl.*` (currently three files).
@ -399,11 +399,20 @@ The states currently are:
- `"Initializing"` - `Perl.init` is currently operating.
- `"Ready"` - `Perl.init` is finished and `Perl.start` can be called.
- `"Running"` - The Perl interpreter is running, `Perl.eval` and `Perl.end` may be called
- `"Ended"` - The Perl interpreter has ended. You might receive several
state change notifications for this state.
- `"Ended"` - The Perl interpreter has ended.
~~You might receive several state change notifications for this state.~~
This is no longer the case as of WebPerl `v0.09-beta`:
you should only receive one event per state change.
This function was added in WebPerl `v0.05-beta`.
#### `Perl.exitStatus`
This property should be **read only**! After Perl's state has changed
to `Ended`, you can retrieve the exit code here.
This property was added in WebPerl `v0.09-beta`.
#### `Perl.stateChanged`
**Deprecated** in WebPerl `v0.05-beta`. Use `Perl.addStateChangeListener` instead.

Loading…
Cancel
Save