Fixed Jekyll support for uncompiled PCjs apps

This commit is contained in:
Jeff Parsons 2017-06-21 10:29:10 -07:00 committed by Jeff Parsons
commit 7271046b1b
10 changed files with 119 additions and 89 deletions

View file

@ -1,6 +1,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width initial-scale=1" />
<meta name="viewport" content="width=device-width initial-scale=1">
<meta http-equiv="content-language" content="en-US">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>{% if page.title %}PCjs: {{ page.title }}{% else %}{{ site.title }}{% endif %}</title>
<meta name="description" content="{{ site.description }}">

View file

@ -90,9 +90,9 @@ of our Markdown or XML documents. Examples: 'automount' becomes 'autoMount', 'a
{% assign machine_autoStart = "" %}
{% endif %}
{% if machine.autotype != nil %}
{% capture machine_autoType %},autoType:"{{ machine.autotype }}"{% endcapture %}
{% capture machine_autoType %},autoType:"{{ machine.autotype | replace:"\r":"\\\\r" | replace:"\n":"\\\\n" | replace:"\t":"\\\\t" | replace:"\x":"\\\\x" }}"{% endcapture %}
{% elsif machine.autoType != nil %}
{% capture machine_autoType %},autoType:"{{ machine.autoType }}"{% endcapture %}
{% capture machine_autoType %},autoType:"{{ machine.autoType | replace:"\r":"\\\\r" | replace:"\n":"\\\\n" | replace:"\t":"\\\\t" | replace:"\x":"\\\\x" }}"{% endcapture %}
{% else %}
{% assign machine_autoType = "" %}
{% endif %}
@ -122,37 +122,61 @@ of our Markdown or XML documents. Examples: 'automount' becomes 'autoMount', 'a
{% capture machine_template %}{{ site.baseurl }}/versions/{{ machine_app }}/{{ site.pcjs.version }}/components.xsl{% endcapture %}
{% endif %}
{% else %}
{% if machine_type == "c1p" %}{% assign array_scripts = site.pcjs.c1p_scripts %}{% endif %}
{% if machine_type == "pcx86" %}{% assign array_scripts = site.pcjs.pcx86_scripts %}{% endif %}
{% if machine_type == "pc8080" %}{% assign array_scripts = site.pcjs.pc8080_scripts %}{% endif %}
{% if machine_type == "pdp10" %}{% assign array_scripts = site.pcjs.pdp10_scripts %}{% endif %}
{% if machine_type == "pdp11" %}{% assign array_scripts = site.pcjs.pdp11_scripts %}{% endif %}
{% for script in array_scripts %}
{% if script != "/modules/shared/lib/nodebug.js" or machine.debug != true and site.pcjs.debug != true %}
{% capture machine_script %}<script type="text/javascript" src="{{ site.baseurl }}{{ script }}"></script>{% endcapture %}
{% unless machine_scripts contains machine_script %}
{{ machine_script }}
{% if script contains "shared/lib/defines.js" %}
{% if site.pcjs.private %}
{{ machine_script | replace:"defines.js","private.js" }}
{% endif %}
{% endif %}
{% if script contains "js/lib/defines.js" %}
{% if machine_debugger != true %}
{{ machine_script | replace:"defines.js","nodebugger.js" }}
{% endif %}
{% endif %}
{% endunless %}
{% capture machine_scripts %}{{ machine_scripts }}{{ machine_script }}{% endcapture %}
{% endif %}
{% endfor %}
{% capture machine_file_uncompiled %}{{ machine_file | remove:"-dbg" | append:"-uncompiled" }}{% endcapture %}
{% capture machine_script %}
<script type="text/javascript" src="{{ site.baseurl }}/versions/{{ machine_app }}/{{ site.pcjs.version }}/{{ machine_file_uncompiled }}.js"></script>{% endcapture %}
{% unless machine_scripts contains machine_script %}
{{ machine_script }}
{% endunless %}
{% capture machine_scripts %}{{ machine_scripts }}{{ machine_script }}{% endcapture %}
{% if machine_template == "" %}
{% if machine_app != "c1pjs" %}
{% capture machine_template %}{{ site.baseurl }}/modules/shared/templates/components.xsl{% endcapture %}
{% else %}
{% capture machine_template %}{{ site.baseurl }}/modules/{{ machine_app }}/templates/components.xsl{% endcapture %}
{% endif %}
{% capture machine_template %}{{ site.baseurl }}/versions/{{ machine_app }}/{{ site.pcjs.version }}/components.xsl{% endcapture %}
{% endif %}
{% comment %}
The following approach worked well before we converted most of the code to ES6 classes. Unfortunately, ES6 classes
don't coexist well with the conditional Node require() statements inside the individual scripts. Since we were already
stripping all the Node-related code from the scripts to build monolithic scripts that we could feed into the Closure
Compiler, we have simply moved those monolithic scripts from the /tmp folder to the /versions folder, with "-uncompiled"
suffixes. And since they are now checked in alongside the compiled files, there's the added benefit that we can always
reference them from source maps.
So, the following template code is no longer of any use, but we'll leave it here for historical reference. Note that
our Node web server still serves up individual scripts, because it has the ability to strip all Node references from the
scripts before delivering them to the web browser. But that's not really feasible in the Jekyll environment.
{% if machine_type == "c1p" %}{% assign array_scripts = site.pcjs.c1p_scripts %}{% endif %}
{% if machine_type == "pcx86" %}{% assign array_scripts = site.pcjs.pcx86_scripts %}{% endif %}
{% if machine_type == "pc8080" %}{% assign array_scripts = site.pcjs.pc8080_scripts %}{% endif %}
{% if machine_type == "pdp10" %}{% assign array_scripts = site.pcjs.pdp10_scripts %}{% endif %}
{% if machine_type == "pdp11" %}{% assign array_scripts = site.pcjs.pdp11_scripts %}{% endif %}
{% for script in array_scripts %}
{% if script != "/modules/shared/lib/nodebug.js" or machine.debug != true and site.pcjs.debug != true %}
{% capture machine_script %}<script type="text/javascript" src="{{ site.baseurl }}{{ script }}"></script>{% endcapture %}
{% unless machine_scripts contains machine_script %}
{{ machine_script }}
{% if script contains "shared/lib/defines.js" %}
{% if site.pcjs.private %}
{{ machine_script | replace:"defines.js","private.js" }}
{% endif %}
{% endif %}
{% if script contains "js/lib/defines.js" %}
{% if machine_debugger != true %}
{{ machine_script | replace:"defines.js","nodebugger.js" }}
{% endif %}
{% endif %}
{% endunless %}
{% capture machine_scripts %}{{ machine_scripts }}{{ machine_script }}{% endcapture %}
{% endif %}
{% endfor %}
{% if machine_template == "" %}
{% if machine_app != "c1pjs" %}
{% capture machine_template %}{{ site.baseurl }}/modules/shared/templates/components.xsl{% endcapture %}
{% else %}
{% capture machine_template %}{{ site.baseurl }}/modules/{{ machine_app }}/templates/components.xsl{% endcapture %}
{% endif %}
{% endif %}
{% endcomment %}
{% endif %}
<script type="text/javascript">{{ machine_embed }}('{{ machine.id }}','{{ machine_config }}','{{ machine_template }}','{{ machine_parms }}');</script>
{% if machine.sticky == "top" %}