Skip to content

Commit 03013a2

Browse files
authored
Merge pull request #164 from annkots/master
Imunify doc updates
2 parents 03018db + 22003af commit 03013a2

File tree

6 files changed

+102
-8
lines changed

6 files changed

+102
-8
lines changed

docs/.vuepress/client.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import {provide} from "vue";
2-
import {defineClientConfig} from "@vuepress/client";
1+
import { provide } from "vue";
2+
import { defineClientConfig } from "@vuepress/client";
33
import mitt from 'mitt';
4+
import copyCodeMixin from './mixins/copyCodeMixin.js';
45

56
import Layout from "./theme/layouts/Layout.vue";
67
import HomeLayout from "./theme/layouts/HomeLayout.vue";
@@ -16,11 +17,12 @@ import CodeTabs from "./components/CodeTabs.vue";
1617
import CodeWithCopy from "./components/CodeWithCopy.vue";
1718

1819
export default defineClientConfig({
19-
rootComponents: [
20+
rootComponents: [
2021
Chat,
2122
],
2223
async enhance({ app }) {
2324
app.config.globalProperties.$eventBus = mitt();
25+
app.mixin(copyCodeMixin);
2426
},
2527
layouts: {
2628
Layout,
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// Auto-add copy buttons to all code blocks
2+
export default {
3+
mounted() {
4+
this.addCopyButtons();
5+
},
6+
updated() {
7+
this.addCopyButtons();
8+
},
9+
methods: {
10+
addCopyButtons() {
11+
// Find all code blocks that don't already have a copy button
12+
const codeBlocks = document.querySelectorAll('div[class*="language-"]:not(.has-copy-button)');
13+
14+
codeBlocks.forEach((block) => {
15+
// Mark this block as having a copy button
16+
block.classList.add('has-copy-button');
17+
18+
// Create copy button
19+
const button = document.createElement('button');
20+
button.className = 'copy-code-button';
21+
button.setAttribute('aria-label', 'Copy code');
22+
button.innerHTML = `
23+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16" class="copy-icon">
24+
<path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"></path>
25+
<path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path>
26+
</svg>
27+
`;
28+
29+
// Add click handler
30+
button.addEventListener('click', () => {
31+
const code = block.querySelector('pre code');
32+
if (code) {
33+
const text = code.innerText;
34+
navigator.clipboard.writeText(text).then(() => {
35+
// Show success state
36+
button.innerHTML = `
37+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16" class="copy-icon copied">
38+
<path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"></path>
39+
</svg>
40+
`;
41+
button.classList.add('copied');
42+
43+
// Reset after 2 seconds
44+
setTimeout(() => {
45+
button.innerHTML = `
46+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16" class="copy-icon">
47+
<path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"></path>
48+
<path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path>
49+
</svg>
50+
`;
51+
button.classList.remove('copied');
52+
}, 2000);
53+
});
54+
}
55+
});
56+
57+
// Add button to code block
58+
block.style.position = 'relative';
59+
block.appendChild(button);
60+
});
61+
}
62+
}
63+
};
14.9 KB
Loading

docs/.vuepress/styles/theme.styl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,35 @@ badge[type="danger"]
242242
&:before
243243
content: attr(text);
244244

245+
// Copy code button styling
246+
.copy-code-button
247+
position: absolute
248+
top: 0.5rem
249+
right: 0.5rem
250+
background: transparent
251+
border: none
252+
cursor: pointer
253+
padding: 0.25rem
254+
z-index: 10
255+
opacity: 0
256+
transition: opacity 0.2s ease
257+
258+
.copy-icon
259+
fill: #ccc
260+
width: 18px
261+
height: 18px
262+
transition: fill 0.2s ease
263+
264+
&:hover .copy-icon
265+
fill: $mainColor
266+
267+
&.copied .copy-icon
268+
fill: $mainColor
269+
270+
div[class*="language-"]
271+
&:hover .copy-code-button
272+
opacity: 1
273+
245274
@media (max-width: $mobileBreakpoint)
246275
.content:not(.custom)
247276
width 100%

docs/command_line_interface/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,7 +1567,7 @@ The general structure of the <span class="notranslate">`imunify360-agent notific
15671567

15681568
<div class="notranslate">
15691569

1570-
```json
1570+
```
15711571
{
15721572
"rules": {
15731573
"SCRIPT_BLOCKED": {
@@ -1671,7 +1671,7 @@ Let's review all options for a specific event on the <span class="notranslate">R
16711671

16721672
<div class="notranslate">
16731673

1674-
```json
1674+
```
16751675
"REALTIME_MALWARE_FOUND": {
16761676
"SCRIPT": {
16771677
"scripts": [],
@@ -1725,7 +1725,7 @@ The <span class="notranslate">`imunify360-agent notifications-config show`</span
17251725

17261726
<div class="notranslate">
17271727

1728-
```json
1728+
```
17291729
{
17301730
"rules": {
17311731
"SCRIPT_BLOCKED": {
@@ -1833,7 +1833,7 @@ The <span class="notranslate">`imunify360-agent notifications-config show`</span
18331833

18341834
<div class="notranslate">
18351835

1836-
```json
1836+
```
18371837
{
18381838
"rules": {
18391839
"CUSTOM_SCAN_MALWARE_FOUND": {

docs/dashboard/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ Proactive Defense requires [Hardened PHP](/dashboard/#installation) (alt-php) to
778778

779779
Go to <span class="notranslate">Imunify360 → Proactive Defense</span>.
780780

781-
![](/images/proactivedefensemain_zoom70.png)
781+
![](/images/proactivedefenseui.png)
782782

783783
Here you can set a mode, view detected events and perform actions on them.
784784

0 commit comments

Comments
 (0)