New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

auto-cms-server

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

auto-cms-server - npm Package Compare versions

Comparing version 0.6.0 to 0.7.0

48

dist/server.js

@@ -195,11 +195,17 @@ "use strict";

return next();
if (req.session.auto_cms_enabled && file.endsWith('.html')) {
res.setHeader('Content-Type', 'text/html');
res.write((0, fs_1.readFileSync)(file));
res.write('<script src="/auto-cms.js"></script>');
res.end();
if (filename.endsWith('.html')) {
let content = (0, fs_1.readFileSync)(file);
sendHTML(req, res, content);
return;
}
else {
res.sendFile(file);
if ((0, path_1.extname)(filename) == '') {
let content = (0, fs_1.readFileSync)(file);
if (isHTMLInBuffer(content)) {
sendHTML(req, res, content);
return;
}
sendBuffer(res, content);
return;
}
sendFile(res, file);
}

@@ -210,2 +216,30 @@ catch (error) {

});
let prefix_doctype = '<!DOCTYPE html>'.toLowerCase();
let prefix_html = '<html'.toLowerCase();
function isHTMLInBuffer(content) {
return (isBufferStartsWith(content, prefix_doctype) ||
isBufferStartsWith(content, prefix_html));
}
function isBufferStartsWith(content, prefix) {
if (content.length < prefix.length)
return false;
return content.subarray(0, prefix.length).toString().toLowerCase() == prefix;
}
function sendHTML(req, res, content) {
res.setHeader('Content-Type', 'text/html');
res.write(content);
if (req.session.auto_cms_enabled) {
res.write('<script src="/auto-cms.js"></script>');
}
res.end();
}
function sendBuffer(res, content) {
// FIXME need to set content-type manually?
res.write(content);
res.end();
}
function sendFile(res, file) {
// FIXME need to set content-type manually?
res.sendFile(file);
}
let port = env_1.env.PORT;

@@ -212,0 +246,0 @@ app.listen(port, () => {

2

package.json
{
"name": "auto-cms-server",
"version": "0.6.0",
"version": "0.7.0",
"description": "Auto turn any webpage into editable CMS without coding.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -24,7 +24,11 @@ "use strict";

}
function ask(message, e, key) {
if (e.hasAttribute(key)) {
function ask(message, e, key, flag) {
if (e instanceof Element && e.hasAttribute(key)) {
let ans = prompt(message, e.getAttribute(key));
if (ans == null)
return;
if (ans) {
e.setAttribute(key, ans);
} else if (flag == "remove") {
e.removeAttribute(key);
}

@@ -165,6 +169,12 @@ } else {

let updateSection = this.addSection("Update");
if (target.children.length == 0 && target.innerText) {
this.addMenuItem(updateSection, "Text", (event) => {
ask("text content", target, "innerText");
});
for (let node of target.childNodes) {
if (node.nodeType === Node.TEXT_NODE && node.nodeValue?.trim()) {
let text = node.nodeValue.trim();
if (text.length > 7) {
text = text.slice(0, 7) + "...";
}
this.addMenuItem(updateSection, "Text: " + text, (event) => {
ask("text content", node, "nodeValue");
});
}
}

@@ -178,14 +188,6 @@ const a = target.closest("a");

if (target instanceof HTMLImageElement) {
let src = target.src;
let srcset = target.getAttribute("srcset");
if (src || srcset) {
this.addMenuItem(updateSection, "Image", (event) => {
if (src) {
ask("image link", target, "src");
}
if (srcset) {
ask("image link", target, "srcset");
}
});
}
this.addMenuItem(updateSection, "Image", (event) => {
ask("image src", target, "src");
ask("image srcset", target, "srcset", "remove");
});
}

@@ -415,2 +417,3 @@ if (target instanceof HTMLAudioElement) {

opacity: 0.8;
z-index: ${getHighestZIndex() + 1};
}

@@ -430,3 +433,5 @@ auto-cms-status:hover {

customElements.define("auto-cms-status", AutoCMSStatus);
document.body.appendChild(new AutoCMSStatus());
setTimeout(() => {
document.body.appendChild(new AutoCMSStatus());
});
{

@@ -433,0 +438,0 @@ let style = document.createElement("style");

@@ -36,3 +36,9 @@ # auto-cms

- [x] Auto setup `.env` file
- [x] Robust
- Correctly set Content-Type even when the filename of the HTML file is not ending with `.html`
## Enhancement
- [x] support editing element with multiple text nodes with br
## Usage

@@ -39,0 +45,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc