feat: slideout editor new new new!
This commit is contained in:
parent
c175a610da
commit
48ac1249c8
10 changed files with 482 additions and 112 deletions
27
index.js
27
index.js
|
|
@ -16,7 +16,7 @@ const app = express();
|
|||
const _expressWs = require("express-ws")(app);
|
||||
const bodyParser = require("body-parser");
|
||||
const model = require("./db");
|
||||
const PORT = 3000;
|
||||
const PORT = process.env.PORT || 3000;
|
||||
|
||||
const db = model.db;
|
||||
const wsRouter = express.Router()
|
||||
|
|
@ -340,6 +340,7 @@ function headChrome(headInjection) {
|
|||
<script src="/js/hyperscript.js"></script>
|
||||
<script src="/js/tailwind.js"></script>
|
||||
<script src="/js/htmx.js"></script>
|
||||
<script src="/js/ace/ace.js"></script>
|
||||
<script src="https://unpkg.com/htmx.org@1.9.12/dist/ext/ws.js"></script>
|
||||
<script src="/js/bliss_inspector.js"></script>
|
||||
<script>
|
||||
|
|
@ -362,7 +363,17 @@ function blissAttrs(source) {
|
|||
const attrs = {
|
||||
"data-bliss-route": `/workshop/${source.structureId}/route/${source.routeId}`,
|
||||
"data-bliss-clone": `/workshop/${source.structureId}/clone_modal/`,
|
||||
"data-bliss-structure-id": String(source.structureId),
|
||||
"data-bliss-structure-name": source.structureName,
|
||||
"data-bliss-route-id": String(source.routeId),
|
||||
"data-bliss-route-name": `${source.verb} ${source.path}`,
|
||||
"data-bliss-method": source.verb,
|
||||
"data-bliss-request-url": source.requestUrl,
|
||||
};
|
||||
if (source.templateId) {
|
||||
attrs["data-bliss-template-id"] = String(source.templateId);
|
||||
attrs["data-bliss-template-name"] = source.templateName;
|
||||
}
|
||||
if (source.copyUrl) attrs["data-bliss-copy"] = source.copyUrl;
|
||||
return attrs;
|
||||
}
|
||||
|
|
@ -435,10 +446,20 @@ function renderTemplate(structureId, templateName, context) {
|
|||
|
||||
// Provenance for a rendered response: GET routes are re-embeddable, so they
|
||||
// carry the copy-embed snippet; other verbs don't.
|
||||
function sourceFor(route, req) {
|
||||
function sourceFor(route, req, templateName = null) {
|
||||
const structure = model.getStructure(route.structure_id);
|
||||
const template = templateName
|
||||
? model.getTemplateByName(route.structure_id, templateName)
|
||||
: null;
|
||||
return {
|
||||
structureId: route.structure_id,
|
||||
structureName: structure.name,
|
||||
routeId: route.id,
|
||||
verb: route.verb,
|
||||
path: route.path,
|
||||
requestUrl: req.originalUrl,
|
||||
templateId: template?.id,
|
||||
templateName: template?.name,
|
||||
copyUrl: route.verb === "GET" ? embedHTML(req.originalUrl) : null,
|
||||
};
|
||||
}
|
||||
|
|
@ -862,7 +883,7 @@ app.all("*", async (req, res) => {
|
|||
res.send(
|
||||
decorate(renderTemplate(route.structure_id, template, context), {
|
||||
headInjection: structure.head_injection,
|
||||
source: sourceFor(route, req),
|
||||
source: sourceFor(route, req, template),
|
||||
fragment: req.headers["hx-request"],
|
||||
}),
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue