diff --git a/_includes/build.html b/_includes/build.html new file mode 100644 index 000000000..f3ee7c59f --- /dev/null +++ b/_includes/build.html @@ -0,0 +1 @@ +
diff --git a/_includes/machine-engines.html b/_includes/machine-engines.html index 919931ff1..8c273a720 100644 --- a/_includes/machine-engines.html +++ b/_includes/machine-engines.html @@ -63,4 +63,8 @@ here and in markout.js. Examples include 'autopower' ('autoPower') and 'automou {% endif %} {% endif %} + {% if page.build %} + + + {% endif %} {% endfor %} diff --git a/devices/pc/machine/custom/README.md b/devices/pc/machine/custom/README.md index 56483c2de..d1bc4d1ca 100644 --- a/devices/pc/machine/custom/README.md +++ b/devices/pc/machine/custom/README.md @@ -4,11 +4,16 @@ title: Build Your Own PC permalink: /devices/pc/machine/custom/ machines: - type: pc - id: custom + name: Custom PC + id: custom-pc + uncompiled: true autopower: false +build: build-pc --- Build Your Own PC --- -{% include machine.html id="custom" %} +{% include build.html id="build-pc" %} + +{% include machine.html id="custom-pc" %} diff --git a/modules/htmlout/lib/htmlout.js b/modules/htmlout/lib/htmlout.js index 8b006ab55..af4d70a33 100644 --- a/modules/htmlout/lib/htmlout.js +++ b/modules/htmlout/lib/htmlout.js @@ -1451,7 +1451,7 @@ HTMLOut.prototype.getMachineXML = function(sToken, sIndent, aParms, sXMLFile, sS var m = new MarkOut(s, sIndent, obj.req, null, obj.fDebug); s = m.convertMD(" ").trim(); - obj.processMachines(m.getMachines(), function doneProcessXMLMachines() { + obj.processMachines(m.getMachines(), m.getBuildOptions(), function doneProcessXMLMachines() { obj.getMarkdownFile(obj.sFile, sToken, sIndent, aParms, s, true); }); return; @@ -1749,7 +1749,7 @@ HTMLOut.prototype.getMarkdownFile = function(sFile, sToken, sIndent, aParms, sPr * any duplicates from that array, and then call processMachines() at some later point, after * all tokens have been replaced. */ - obj.processMachines(m.getMachines(), function doneProcessMachines() { + obj.processMachines(m.getMachines(), m.getBuildOptions(), function doneProcessMachines() { if (sToken) { obj.aTokens[sToken] = sPrevious? (sPrevious + sIndent + s) : s; obj.replaceTokens(); @@ -1809,7 +1809,7 @@ HTMLOut.prototype.getRandomString = function(sIndent) }; /** - * processMachines(aMachines, done) + * processMachines(aMachines, buildOptions, done) * * At a minimum, each machine object should contain the following properties: * @@ -1819,9 +1819,10 @@ HTMLOut.prototype.getRandomString = function(sIndent) * * @this {HTMLOut} * @param {Array} aMachines is an array of objects containing information about each machine on the current page + * @param {Object} buildOptions * @param {function()} done */ -HTMLOut.prototype.processMachines = function(aMachines, done) +HTMLOut.prototype.processMachines = function(aMachines, buildOptions, done) { for (var iMachine = 0; iMachine < aMachines.length; iMachine++) { @@ -1905,6 +1906,12 @@ HTMLOut.prototype.processMachines = function(aMachines, done) } } this.addFilesToHTML(asFiles, sScriptEmbed); + if (buildOptions.id) { + asFiles = []; + asFiles.push("/modules/pcbuild/lib/build.js"); + sScriptEmbed = ''; + this.addFilesToHTML(asFiles, sScriptEmbed); + } } } } @@ -1912,7 +1919,7 @@ HTMLOut.prototype.processMachines = function(aMachines, done) }; /** - * addFilesToHTML(asFiles) + * addFilesToHTML(asFiles, sScriptEmbed) * * @this {HTMLOut} * @param {Array.} asFiles is a list of CSS and/or JS files to include in the HTML diff --git a/modules/markout/lib/markout.js b/modules/markout/lib/markout.js index bdcb975f7..fb127657b 100644 --- a/modules/markout/lib/markout.js +++ b/modules/markout/lib/markout.js @@ -116,6 +116,7 @@ function MarkOut(sMD, sIndent, req, aParms, fDebug, fMachineXML, fAutoHeading) this.sHTML = null; this.aIDs = []; // this keeps track of auto-generated ID attributes for page elements, to insure uniqueness this.aMachines = []; // this keeps track of embedded machines on the page + this.buildOptions = {}; // this keeps track of any build options specified on the page this.aMachineDefs = {}; // this keeps track of any machine definitions at the top of the file (as part of any Jekyll "Front Matter") } @@ -265,6 +266,17 @@ MarkOut.prototype.getMachines = function() return this.aMachines; }; +/** + * getBuildOptions() + * + * @this {MarkOut} + * @return {Object} containing build options, if any + */ +MarkOut.prototype.getBuildOptions = function() +{ + return this.buildOptions; +}; + /** * generateID(sText) * @@ -409,6 +421,7 @@ MarkOut.prototype.convertMD = function(sIndent) /* * Extract machine definitions, if any, from the Front Matter. */ + var aSubMatch; var aMachineDefs = aMatch[1].match(/\nmachines:([\s\S]*?)\n([^\s]|$)/); if (aMachineDefs) { var asMachines = aMachineDefs[1].split(/\n[ \t]+-\s*/); @@ -485,9 +498,14 @@ MarkOut.prototype.convertMD = function(sIndent) * heading with the same value. */ if (this.fAutoHeading) { - aMatch = aMatch[1].match(/title:\s*(.*?)\s*?\n/); - if (aMatch) sMD = aMatch[1] + "\n---\n\n" + sMD; + aSubMatch = aMatch[1].match(/title:\s*(.*?)\s*?\n/); + if (aSubMatch) sMD = aSubMatch[1] + "\n---\n\n" + sMD; } + /* + * If a "build" ID element existed in the Front Matter, capture it. + */ + aSubMatch = aMatch[1].match(/build:\s*(\S*)/); + if (aSubMatch) this.buildOptions.id = aSubMatch[1]; } } @@ -1094,11 +1112,12 @@ MarkOut.prototype.convertMDMachineLinks = function(sBlock) * Before we start looking for Markdown-style machine links, see if there are any Liquid-style machines, * (in case this Markdown file is part of a Jekyll installation) and convert them to Markdown-style links. */ - var reIncludes = /\{%\s*include machine\.html\s+id="(.*?)"\s*%}/g; + + var reIncludes = /\{%\s*include\s+machine\.html\s+id=(["'])(.*?)\1\s*%}/g; while ((aMatch = reIncludes.exec(sBlock))) { sReplacement = ""; - sMachineID = aMatch[1]; + sMachineID = aMatch[2]; if (!this.fMachineXML && this.aMachineDefs[sMachineID]) { var machine = this.aMachineDefs[sMachineID]; sMachine = machine['type'] || "pc"; @@ -1108,12 +1127,15 @@ MarkOut.prototype.convertMDMachineLinks = function(sBlock) sMachineXSLFile = machine['template'] || ""; sMachineVersion = (machine['uncompiled'] && machine['uncompiled'] == "true"? "uncompiled" : ""); sMachineParms = machine['parms'] || ""; - sReplacement = "[Embedded PC](" + sMachineXMLFile + ' "' + sMachine + 'js!' + sMachineID + '!' + sMachineXSLFile + '!!' + sMachineOptions + '!' + sMachineParms + '")'; + sReplacement = machine['name'] || "Embedded PC"; + sReplacement = "[" + sReplacement + "](" + sMachineXMLFile + ' "' + sMachine + 'js!' + sMachineID + '!' + sMachineXSLFile + '!!' + sMachineOptions + '!' + sMachineParms + '")'; } sBlock = sBlock.replace(aMatch[0], sReplacement); reIncludes.lastIndex = 0; // reset lastIndex, since we just modified the string that reIncludes is iterating over } + sBlock = sBlock.replace(/\{%\s*include\s+build\.html\s+id=(["'])(.*?)\1\s*%}/g, '
'); + /* * Start looking for Markdown-style machine links now... */ diff --git a/modules/pcbuild/lib/build.js b/modules/pcbuild/lib/build.js new file mode 100644 index 000000000..36401a3cd --- /dev/null +++ b/modules/pcbuild/lib/build.js @@ -0,0 +1,47 @@ +/** + * @fileoverview PCjs Build Options + * @author Jeff Parsons + * @version 1.0 + * Created 2016-Feb-10 + * + * Copyright © 2012-2016 Jeff Parsons + * + * This file is part of the JavaScript Machines Project (aka JSMachines) at + * and . + * + * JSMachines is free software: you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * JSMachines is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with JSMachines. + * If not, see . + * + * You are required to include the above copyright notice in every source code file of every + * copy or modified version of this work, and to display that copyright notice on every screen + * that loads or runs any version of this software (see Computer.COPYRIGHT). + * + * Some JSMachines files also attempt to load external resource files, such as character-image files, + * ROM files, and disk image files. Those external resource files are not considered part of the + * JSMachines Project for purposes of the GNU General Public License, and the author does not claim + * any copyright as to their contents. + */ + +"use strict"; + +/* + * This file provides all the UI options for building a functional PCjs PC. + */ + +/** + * buildPC(idElement) + * + * @param {string} idElement (the ID of the DIV where build UI options should be presented) + */ +function buildPC(idElement) +{ + alert("build.js loaded: " + idElement); +} diff --git a/modules/pcjs/lib/fdc.js b/modules/pcjs/lib/fdc.js index 92fba9e58..303a3d52d 100644 --- a/modules/pcjs/lib/fdc.js +++ b/modules/pcjs/lib/fdc.js @@ -1251,7 +1251,7 @@ FDC.prototype.loadSelectedDrive = function(sDisketteName, sDiskettePath, file) } return; } - this.notice("Nothing to load"); + this.notice("Unable to load the selected drive"); }; /**