This commit is contained in:
2025-05-12 05:38:44 +09:00
parent dced21c3f8
commit 6d78bfa46e
8120 changed files with 1161564 additions and 0 deletions

35
book/node_modules/tiny-lr/examples/express/app.js generated vendored Normal file
View File

@ -0,0 +1,35 @@
const path = require('path');
const express = require('express');
const tinylr = require('../..');
const debug = require('debug')('tinylr:server');
const gaze = require('gaze');
process.env.DEBUG = process.env.DEBUG || 'tinylr*';
var app = module.exports = express();
function logger (fmt) {
fmt = fmt || '%s - %s';
return function logger (req, res, next) {
debug(fmt, req.method, req.url);
next();
};
}
(function watch (em) {
em = em || new (require('events').EventEmitter)();
gaze(path.join(__dirname, 'styles/site.css'), function () {
this.on('changed', function (filepath) {
tinylr.changed(filepath);
});
});
return watch;
})();
app
.use(logger())
.use('/', express.static(path.join(__dirname)))
.use(tinylr.middleware({ app: app }));

38
book/node_modules/tiny-lr/examples/express/index.html generated vendored Normal file
View File

@ -0,0 +1,38 @@
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8">
<title>WD Tests</title>
<link rel="stylesheet" href="styles/site.css">
</head>
<body>
<div class="test-lr">
Testing livereload thing
<a href="#" class="fun">fun</a>
</div>
<script>document.write('<script src="http://'
+ location.host
+ '/livereload.js?snipver=1"></'
+ 'script>')</script>
<script>
(function() {
window.onload = function() {
var fun = document.querySelector('.fun');
var lr = document.querySelector('.test-lr');
fun.addEventListener('click', function(e) {
e.preventDefault();
var d3 = /d3/.test(lr.className) ? '' : 'd3';
lr.className = 'test-lr ' + d3;
});
};
})();
</script>
</body>
</html>

View File

@ -0,0 +1,10 @@
{
"name": "express-lr-sample",
"version": "0.0.0",
"description": "ERROR: No README.md file found!",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "DEBUG='tinylr tinylr:*' node server.js"
}
}

12
book/node_modules/tiny-lr/examples/express/server.js generated vendored Normal file
View File

@ -0,0 +1,12 @@
const port = process.env.LR_PORT || process.env.PORT || 35729;
process.env.DEBUG = process.env.DEBUG || 'tinylr*';
const debug = require('debug')('tinylr:server');
const app = require('./app');
debug('Starting server');
app.listen(port, function (err) {
if (err) throw err;
debug('listening on %d', port);
});

View File

@ -0,0 +1,15 @@
body {
padding: 50px;
font-family: sans-serif;
font-size: 14px;
}
.test-lr {
padding: 4em;
color: #444;
/* color: red; */
font-weight: bolder;
border: #ccc;
background-color: #dedede;
}