updated style
This commit is contained in:
@@ -98,6 +98,8 @@ button:disabled { opacity: 0.55; cursor: not-allowed; }
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
width: calc(100vw - 3rem);
|
||||
margin-left: calc(50% - 50vw + 1.5rem);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
@@ -248,7 +250,12 @@ textarea#content::placeholder { color: var(--text-muted); }
|
||||
.hidden { display: none !important; }
|
||||
|
||||
/* ─── Paste View ─── */
|
||||
.paste-view { padding-top: 1.25rem; }
|
||||
.paste-view {
|
||||
padding-top: 1.25rem;
|
||||
max-width: none;
|
||||
width: calc(100vw - 3rem);
|
||||
margin-left: calc(50% - 50vw + 1.5rem);
|
||||
}
|
||||
|
||||
.paste-meta {
|
||||
display: flex;
|
||||
@@ -336,6 +343,8 @@ textarea#content::placeholder { color: var(--text-muted); }
|
||||
overflow: auto;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
width: calc(100vw - 3rem);
|
||||
margin-left: calc(50% - 50vw + 1.5rem);
|
||||
}
|
||||
|
||||
#paste-content pre {
|
||||
|
||||
@@ -44,6 +44,29 @@ function parseExpiryOption(expiresIn) {
|
||||
return new Date(Date.now() + ms).toISOString();
|
||||
}
|
||||
|
||||
function normalizeClientIp(ip) {
|
||||
if (typeof ip !== 'string' || ip.length === 0) {
|
||||
return 'unknown';
|
||||
}
|
||||
|
||||
let normalized = ip.trim();
|
||||
if (normalized.startsWith('::ffff:')) {
|
||||
normalized = normalized.slice(7);
|
||||
}
|
||||
|
||||
return normalized.replace(/[^0-9a-fA-F:.]/g, '').slice(0, 64) || 'unknown';
|
||||
}
|
||||
|
||||
async function setPasteTags(id, tags) {
|
||||
if (typeof client.setObjectTagging === 'function') {
|
||||
await client.setObjectTagging(BUCKET, id, tags);
|
||||
return;
|
||||
}
|
||||
if (typeof client.putObjectTagging === 'function') {
|
||||
await client.putObjectTagging(BUCKET, id, tags);
|
||||
}
|
||||
}
|
||||
|
||||
function getExpiryFromMeta(metaData) {
|
||||
return (
|
||||
metaData['x-amz-meta-expires-at'] ||
|
||||
@@ -99,6 +122,7 @@ router.post('/', wrap(async (req, res) => {
|
||||
|
||||
const id = generateId();
|
||||
const buf = Buffer.from(content, 'utf8');
|
||||
const clientIp = normalizeClientIp(req.ip);
|
||||
|
||||
const meta = { 'Content-Type': 'text/plain; charset=utf-8' };
|
||||
if (typeof lang === 'string' && lang.length > 0) {
|
||||
@@ -116,6 +140,7 @@ router.post('/', wrap(async (req, res) => {
|
||||
}
|
||||
|
||||
await client.putObject(BUCKET, id, buf, buf.length, meta);
|
||||
await setPasteTags(id, { client_ip: clientIp });
|
||||
res.status(201).json({ id, url: `/p/${id}`, expiresAt });
|
||||
}));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user