Start setting everything up
This commit is contained in:
parent
76ba0ed404
commit
353d3f43db
11 changed files with 3464 additions and 1 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
dist/
|
||||
# ---> Node
|
||||
# Logs
|
||||
logs
|
||||
|
@ -75,4 +76,3 @@ typings/
|
|||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
|
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
[submodule "lantern-build-engine"]
|
||||
path = lantern-build-engine
|
||||
url = https://gitlab.com/sbrl/lantern-build-engine.git
|
2
Sections/01-Welcome/01-Title.md
Normal file
2
Sections/01-Welcome/01-Title.md
Normal file
|
@ -0,0 +1,2 @@
|
|||
# Linux 101
|
||||
## Freeside
|
126
build
Executable file
126
build
Executable file
|
@ -0,0 +1,126 @@
|
|||
#!/usr/bin/env bash
|
||||
# Make sure the current directory is the location of this script to simplify matters
|
||||
cd "$(dirname $(readlink -f $0))";
|
||||
################
|
||||
### Settings ###
|
||||
################
|
||||
|
||||
# The name of this project
|
||||
project_name="micro-lanterns";
|
||||
|
||||
# The path to the lantern build engine git submodule
|
||||
lantern_path="./lantern-build-engine";
|
||||
|
||||
###
|
||||
# Custom Settings
|
||||
###
|
||||
|
||||
# Put any custom settings here.
|
||||
build_output_folder="./dist";
|
||||
|
||||
###############################################################################
|
||||
|
||||
# Check out the lantern git submodule if needed
|
||||
if [ ! -f "${lantern_path}/lantern.sh" ]; then git submodule update --init "${lantern_path}"; fi
|
||||
|
||||
source "${lantern_path}/lantern.sh";
|
||||
|
||||
if [[ "$#" -lt 1 ]]; then
|
||||
echo -e "${FBLE}${project_name}${RS} build script";
|
||||
echo -e " by Starbeamrainbowlabs";
|
||||
echo -e "${LC}Powered by the lantern build engine, v${version}${RS}";
|
||||
echo -e "";
|
||||
echo -e "${CSECTION}Usage${RS}";
|
||||
echo -e " ./build ${CTOKEN}{action}${RS} ${CTOKEN}{action}${RS} ${CTOKEN}{action}${RS} ...";
|
||||
echo -e "";
|
||||
echo -e "${CSECTION}Available actions${RS}";
|
||||
echo -e " ${CACTION}setup${RS} - Perform initial setup";
|
||||
echo -e " ${CACTION}main${RS} - Build the slide deck";
|
||||
echo -e " ${CACTION}slides${RS} - Build the slides HTML";
|
||||
echo -e " ${CACTION}js-css${RS} - Build the javascript / css";
|
||||
echo -e " ${CACTION}dev-server${RS} - Start a development server";
|
||||
echo -e " ${CACTION}dev-server-stop${RS} - Stop the currently running development server";
|
||||
echo -e "";
|
||||
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
###############################################################################
|
||||
|
||||
task_setup() {
|
||||
task_begin "Setting up";
|
||||
|
||||
check_command git true;
|
||||
check_command node true;
|
||||
check_command npm true;
|
||||
|
||||
subtask_begin "Creating build output directory";
|
||||
mkdir -p "${build_output_folder}";
|
||||
subtask_end $?;
|
||||
|
||||
subtask_begin "Initialising submodules";
|
||||
git submodule update --init;
|
||||
subtask_end $?;
|
||||
|
||||
task_end 0;
|
||||
}
|
||||
|
||||
|
||||
# ██████ ███████ ██ ██ ███████ ███████ ██████ ██ ██ ███████ ██████
|
||||
# ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
||||
# ██ ██ █████ ██ ██ █████ ███████ █████ ██████ ██ ██ █████ ██████
|
||||
# ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
||||
# ██████ ███████ ████ ███████ ███████ ██ ██ ████ ███████ ██ ██
|
||||
task_dev-server() {
|
||||
task_begin "Starting development server";
|
||||
php -S [::1]:40482 -t "${build_output_folder}" &
|
||||
exit_code=$?;
|
||||
echo $! >/tmp/micro-lantern-dev-server.pid;
|
||||
task_end $?; # Should be 0 unless php died for some reason
|
||||
sleep 1;
|
||||
}
|
||||
|
||||
task_dev-server-stop() {
|
||||
task_begin "Stopping development server";
|
||||
|
||||
kill "$(cat /tmp/micro-lantern-dev-server.pid)";
|
||||
rm /tmp/micro-lantern-dev-server.pid;
|
||||
|
||||
task_end $?;
|
||||
}
|
||||
|
||||
|
||||
task_main() {
|
||||
tasks_run js-css slides;
|
||||
|
||||
task_begin "Copying html";
|
||||
cp index.html "${build_output_folder}";
|
||||
task_end $?;
|
||||
|
||||
task_begin "Copying css";
|
||||
cp theme.css "${build_output_folder}";
|
||||
task_end $?;
|
||||
}
|
||||
|
||||
task_slides() {
|
||||
task_begin "Creating temporary directory";
|
||||
temp_dir="$(mktemp -d --suffix "linux-101-slides")";
|
||||
task_end $?;
|
||||
|
||||
echo "[${SECONDS}] Created temporary directory ${HC}${temp_dir}${RS}.";
|
||||
|
||||
task_begin "Rendering slides";
|
||||
find ./Sections -print0 -type f -iname "*.md" | xargs -t -P4 -0 -n1 -I{} pandoc {} -o {}.html;
|
||||
task_end $?;
|
||||
}
|
||||
|
||||
task_js-css() {
|
||||
task_begin "Packaging Javascript & CSS";
|
||||
node_modules/rollup/bin/rollup --sourcemap --config rollup.config.js;
|
||||
task_end $? "Error: rollup packing failed!";
|
||||
}
|
||||
|
||||
|
||||
###############################################################################
|
||||
|
||||
tasks_run $@;
|
0
css/theme.css
Normal file
0
css/theme.css
Normal file
17
index.html
Normal file
17
index.html
Normal file
|
@ -0,0 +1,17 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset='utf-8' />
|
||||
<title>Linux 101 • Freeside</title>
|
||||
</head>
|
||||
<body>
|
||||
<main class="js-deck3000">
|
||||
${SLIDE_CONTENT}
|
||||
</main>
|
||||
|
||||
<!---------------->
|
||||
<link rel="stylesheet" href="linux101.css" />
|
||||
<script src="linux101.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
19
js/index.mjs
Normal file
19
js/index.mjs
Normal file
|
@ -0,0 +1,19 @@
|
|||
import "../css/theme.css";
|
||||
|
||||
import Deck3000 from 'deck3000';
|
||||
|
||||
|
||||
window.addEventListener("load", function(_event) {
|
||||
console.log("__BUILD_DATE__");
|
||||
|
||||
const Slideshow = new Deck3000({
|
||||
slideSelector: "article",
|
||||
resetSlides: true,
|
||||
keyboardEvents: true,
|
||||
updateURL: true
|
||||
});
|
||||
|
||||
Slideshow.Emitter.on("navigate", (event) => {
|
||||
console.debug(event);
|
||||
})
|
||||
});
|
1
lantern-build-engine
Submodule
1
lantern-build-engine
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit c797b1c77772b1f1719b100a6b6895f69a5f7057
|
3176
package-lock.json
generated
Normal file
3176
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
29
package.json
Normal file
29
package.json
Normal file
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"private": true,
|
||||
"name": "linux-101",
|
||||
"version": "1.0.0",
|
||||
"description": "The slide desk for the Linux 101 workshop.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://git.starbeamrainbowlabs.com/sbrl/Linux101"
|
||||
},
|
||||
"author": "Starbeamrainbowlabs",
|
||||
"license": "MPL-2.0",
|
||||
"dependencies": {
|
||||
"deck3000": "^1.0.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"postcss-copy": "^7.1.0",
|
||||
"postcss-import": "^12.0.1",
|
||||
"rollup": "^1.6.0",
|
||||
"rollup-plugin-commonjs": "^9.2.1",
|
||||
"rollup-plugin-node-resolve": "^4.0.1",
|
||||
"rollup-plugin-postcss": "^2.0.3",
|
||||
"rollup-plugin-replace": "^2.1.0",
|
||||
"rollup-plugin-terser": "^4.0.4"
|
||||
}
|
||||
}
|
90
rollup.config.js
Normal file
90
rollup.config.js
Normal file
|
@ -0,0 +1,90 @@
|
|||
import os from 'os';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
|
||||
import resolve from 'rollup-plugin-node-resolve';
|
||||
import commonjs from 'rollup-plugin-commonjs';
|
||||
import postcss from 'rollup-plugin-postcss';
|
||||
import { terser } from "rollup-plugin-terser";
|
||||
import replace from 'rollup-plugin-replace';
|
||||
|
||||
import postcss_import from 'postcss-import';
|
||||
import postcss_copy from 'postcss-copy';
|
||||
|
||||
let plugins = [
|
||||
resolve({
|
||||
// use "module" field for ES6 module if possible
|
||||
module: true, // Default: true
|
||||
|
||||
// use "jsnext:main" if possible
|
||||
// – see https://github.com/rollup/rollup/wiki/jsnext:main
|
||||
jsnext: true, // Default: false
|
||||
|
||||
// use "main" field or index.js, even if it's not an ES6 module
|
||||
// (needs to be converted from CommonJS to ES6
|
||||
// – see https://github.com/rollup/rollup-plugin-commonjs
|
||||
main: true, // Default: true
|
||||
|
||||
// some package.json files have a `browser` field which
|
||||
// specifies alternative files to load for people bundling
|
||||
// for the browser. If that's you, use this option, otherwise
|
||||
// pkg.browser will be ignored
|
||||
browser: true, // Default: false
|
||||
|
||||
// not all files you want to resolve are .js files
|
||||
extensions: ['.mjs', '.js', '.jsx', '.json'], // Default: [ '.mjs', '.js', '.json', '.node' ]
|
||||
}),
|
||||
|
||||
|
||||
replace({
|
||||
exclude: 'node_modules/**',
|
||||
values: {
|
||||
"__BUILD_DATE__": () => new Date().toISOString(),
|
||||
// "__VERSION__": fs.readFileSync("version", "utf8").trim()
|
||||
}
|
||||
}),
|
||||
|
||||
commonjs({
|
||||
|
||||
}),
|
||||
|
||||
postcss({
|
||||
plugins: [
|
||||
postcss_import({}),
|
||||
postcss_copy({
|
||||
dest: "app",
|
||||
template: "resources/[name].[ext]"
|
||||
})
|
||||
// postcss_url(),
|
||||
// postcss_url({
|
||||
// url: "copy",
|
||||
// basePath: path.resolve("."),
|
||||
// assetPath: "resources"
|
||||
// })
|
||||
],
|
||||
// Save it to a .css file - we'll reference it ourselves thank you
|
||||
// very much
|
||||
extract: true,
|
||||
sourceMap: true,
|
||||
//minimize: true, // Causes an error at the moment for some reason
|
||||
})
|
||||
];
|
||||
|
||||
if(process.env.NODE_ENV == "production") {
|
||||
console.log("[config] In production environment - minifying JS");
|
||||
plugins.push(terser({
|
||||
numWorkers: os.cpus().length,
|
||||
compress: {
|
||||
ecma: 6
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
export default {
|
||||
input: 'js/index.mjs',
|
||||
output: {
|
||||
file: 'dist/linux101.js',
|
||||
format: 'esm'
|
||||
},
|
||||
plugins
|
||||
};
|
Loading…
Reference in a new issue