nodebb-plugin-pdf-secure 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-pdf-secure",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Secure PDF viewer plugin for NodeBB - prevents downloading, enables canvas-only rendering with Premium group support",
5
5
  "main": "library.js",
6
6
  "repository": {
@@ -2,7 +2,7 @@
2
2
 
3
3
  console.log('[PDF-Secure] main.js loaded');
4
4
 
5
- // Main plugin logic - PDF links open in fullscreen viewer
5
+ // Main plugin logic - PDF links become inline embedded viewers
6
6
  (async function () {
7
7
  try {
8
8
  var hooks = await app.require('hooks');
@@ -19,7 +19,7 @@ console.log('[PDF-Secure] main.js loaded');
19
19
  function interceptPdfLinks() {
20
20
  var postContents = document.querySelectorAll('[component="post/content"]');
21
21
 
22
- postContents.forEach(function (content, idx) {
22
+ postContents.forEach(function (content) {
23
23
  var pdfLinks = content.querySelectorAll('a[href$=".pdf"], a[href$=".PDF"]');
24
24
 
25
25
  pdfLinks.forEach(function (link) {
@@ -29,30 +29,50 @@ console.log('[PDF-Secure] main.js loaded');
29
29
  var href = link.getAttribute('href');
30
30
  var parts = href.split('/');
31
31
  var filename = parts[parts.length - 1];
32
- console.log('[PDF-Secure] Processing:', filename);
32
+ console.log('[PDF-Secure] Embedding:', filename);
33
33
 
34
- // Create PDF preview card with "View PDF" button
34
+ // Create inline viewer container
35
35
  var container = document.createElement('div');
36
- container.className = 'pdf-secure-card';
37
- container.innerHTML =
38
- '<div class="pdf-secure-card-icon">' +
36
+ container.className = 'pdf-secure-embed';
37
+
38
+ // Header with filename
39
+ var header = document.createElement('div');
40
+ header.className = 'pdf-secure-embed-header';
41
+ header.innerHTML =
42
+ '<div class="pdf-secure-embed-title">' +
39
43
  '<svg viewBox="0 0 24 24"><path d="M14 2H6c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6zm4 18H6V4h7v5h5v11z" fill="currentColor"/></svg>' +
44
+ '<span>' + escapeHtml(link.textContent || filename) + '</span>' +
40
45
  '</div>' +
41
- '<div class="pdf-secure-card-info">' +
42
- '<span class="pdf-secure-card-name">' + escapeHtml(link.textContent || filename) + '</span>' +
43
- '<span class="pdf-secure-card-type">PDF Dosyası</span>' +
44
- '</div>' +
45
- '<button class="pdf-secure-card-btn" data-filename="' + escapeHtml(filename) + '">' +
46
- '<svg viewBox="0 0 24 24"><path d="M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z" fill="currentColor"/></svg>' +
47
- '<span>Görüntüle</span>' +
48
- '</button>';
46
+ '<div class="pdf-secure-embed-actions">' +
47
+ '<button class="pdf-secure-fullscreen-btn" title="Tam Ekran">' +
48
+ '<svg viewBox="0 0 24 24"><path d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z" fill="currentColor"/></svg>' +
49
+ '</button>' +
50
+ '</div>';
51
+ container.appendChild(header);
52
+
53
+ // Iframe for viewer
54
+ var iframeWrapper = document.createElement('div');
55
+ iframeWrapper.className = 'pdf-secure-embed-body';
56
+
57
+ var iframe = document.createElement('iframe');
58
+ iframe.className = 'pdf-secure-iframe';
59
+ iframe.src = config.relative_path + '/plugins/pdf-secure/viewer?file=' + encodeURIComponent(filename);
60
+ iframe.setAttribute('frameborder', '0');
61
+ iframe.setAttribute('allowfullscreen', 'true');
62
+ iframe.setAttribute('loading', 'lazy');
63
+
64
+ iframeWrapper.appendChild(iframe);
65
+ container.appendChild(iframeWrapper);
49
66
 
50
- // Click handler - open viewer in new tab
51
- container.querySelector('.pdf-secure-card-btn').addEventListener('click', function (e) {
52
- e.preventDefault();
53
- var fname = this.dataset.filename;
54
- var viewerUrl = config.relative_path + '/plugins/pdf-secure/viewer?file=' + encodeURIComponent(fname);
55
- window.open(viewerUrl, '_blank', 'noopener,noreferrer');
67
+ // Fullscreen button handler
68
+ header.querySelector('.pdf-secure-fullscreen-btn').addEventListener('click', function () {
69
+ if (iframe.requestFullscreen) {
70
+ iframe.requestFullscreen();
71
+ } else if (iframe.webkitRequestFullscreen) {
72
+ iframe.webkitRequestFullscreen();
73
+ } else if (iframe.msRequestFullscreen) {
74
+ iframe.msRequestFullscreen();
75
+ }
56
76
  });
57
77
 
58
78
  link.replaceWith(container);
package/static/style.less CHANGED
@@ -1,132 +1,123 @@
1
- /* PDF Secure Viewer — Card Styles for NodeBB */
1
+ /* PDF Secure Viewer — Inline Embed Styles for NodeBB */
2
2
 
3
- /* PDF Card - shown in posts */
4
- .pdf-secure-card {
5
- display: flex;
6
- align-items: center;
7
- gap: 12px;
8
- padding: 12px 16px;
9
- margin: 12px 0;
10
- background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
11
- border: 1px solid rgba(255, 255, 255, 0.1);
3
+ /* Embedded PDF Container */
4
+ .pdf-secure-embed {
5
+ margin: 16px 0;
12
6
  border-radius: 12px;
13
- box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
14
- transition: transform 0.2s, box-shadow 0.2s;
15
- }
16
-
17
- .pdf-secure-card:hover {
18
- transform: translateY(-2px);
19
- box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
7
+ overflow: hidden;
8
+ background: #1f1f1f;
9
+ border: 1px solid rgba(255, 255, 255, 0.1);
10
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
20
11
  }
21
12
 
22
- .pdf-secure-card-icon {
13
+ /* Header */
14
+ .pdf-secure-embed-header {
23
15
  display: flex;
24
16
  align-items: center;
25
- justify-content: center;
26
- width: 48px;
27
- height: 48px;
28
- background: linear-gradient(135deg, #e81224 0%, #c0392b 100%);
29
- border-radius: 10px;
30
- flex-shrink: 0;
17
+ justify-content: space-between;
18
+ padding: 10px 16px;
19
+ background: linear-gradient(135deg, #2d2d2d 0%, #252525 100%);
20
+ border-bottom: 1px solid rgba(255, 255, 255, 0.08);
31
21
  }
32
22
 
33
- .pdf-secure-card-icon svg {
34
- width: 26px;
35
- height: 26px;
36
- fill: #fff;
23
+ .pdf-secure-embed-title {
24
+ display: flex;
25
+ align-items: center;
26
+ gap: 10px;
27
+ color: #fff;
28
+ font-size: 14px;
29
+ font-weight: 500;
37
30
  }
38
31
 
39
- .pdf-secure-card-info {
40
- display: flex;
41
- flex-direction: column;
42
- gap: 2px;
43
- flex: 1;
44
- min-width: 0;
32
+ .pdf-secure-embed-title svg {
33
+ width: 20px;
34
+ height: 20px;
35
+ fill: #e81224;
36
+ flex-shrink: 0;
45
37
  }
46
38
 
47
- .pdf-secure-card-name {
48
- font-size: 14px;
49
- font-weight: 600;
50
- color: #fff;
39
+ .pdf-secure-embed-title span {
51
40
  white-space: nowrap;
52
41
  overflow: hidden;
53
42
  text-overflow: ellipsis;
43
+ max-width: 400px;
54
44
  }
55
45
 
56
- .pdf-secure-card-type {
57
- font-size: 12px;
58
- color: rgba(255, 255, 255, 0.5);
46
+ .pdf-secure-embed-actions {
47
+ display: flex;
48
+ gap: 8px;
59
49
  }
60
50
 
61
- .pdf-secure-card-btn {
51
+ .pdf-secure-fullscreen-btn {
62
52
  display: flex;
63
53
  align-items: center;
64
- gap: 6px;
65
- padding: 10px 18px;
66
- background: linear-gradient(135deg, #0078d4 0%, #0066b8 100%);
54
+ justify-content: center;
55
+ width: 32px;
56
+ height: 32px;
57
+ background: rgba(255, 255, 255, 0.08);
67
58
  border: none;
68
- border-radius: 8px;
69
- color: #fff;
70
- font-size: 13px;
71
- font-weight: 600;
59
+ border-radius: 6px;
72
60
  cursor: pointer;
73
61
  transition: all 0.2s;
74
- flex-shrink: 0;
75
62
  }
76
63
 
77
- .pdf-secure-card-btn:hover {
78
- background: linear-gradient(135deg, #1a86dc 0%, #0078d4 100%);
79
- transform: scale(1.02);
64
+ .pdf-secure-fullscreen-btn:hover {
65
+ background: rgba(255, 255, 255, 0.15);
80
66
  }
81
67
 
82
- .pdf-secure-card-btn:active {
83
- transform: scale(0.98);
84
- }
85
-
86
- .pdf-secure-card-btn svg {
68
+ .pdf-secure-fullscreen-btn svg {
87
69
  width: 18px;
88
70
  height: 18px;
89
- fill: currentColor;
71
+ fill: #fff;
90
72
  }
91
73
 
92
- /* Mobile responsiveness */
93
- @media (max-width: 480px) {
94
- .pdf-secure-card {
95
- padding: 10px 12px;
96
- gap: 10px;
97
- }
74
+ /* Viewer Body */
75
+ .pdf-secure-embed-body {
76
+ position: relative;
77
+ width: 100%;
78
+ height: 600px;
79
+ background: #525659;
80
+ }
81
+
82
+ .pdf-secure-iframe {
83
+ width: 100%;
84
+ height: 100%;
85
+ border: none;
86
+ display: block;
87
+ }
98
88
 
99
- .pdf-secure-card-icon {
100
- width: 40px;
101
- height: 40px;
89
+ /* Responsive */
90
+ @media (max-width: 768px) {
91
+ .pdf-secure-embed-body {
92
+ height: 450px;
102
93
  }
103
94
 
104
- .pdf-secure-card-icon svg {
105
- width: 22px;
106
- height: 22px;
95
+ .pdf-secure-embed-title span {
96
+ max-width: 200px;
107
97
  }
98
+ }
108
99
 
109
- .pdf-secure-card-name {
110
- font-size: 13px;
100
+ @media (max-width: 480px) {
101
+ .pdf-secure-embed-body {
102
+ height: 350px;
111
103
  }
112
104
 
113
- .pdf-secure-card-btn {
114
- padding: 8px 14px;
115
- font-size: 12px;
105
+ .pdf-secure-embed-header {
106
+ padding: 8px 12px;
116
107
  }
117
108
 
118
- .pdf-secure-card-btn span {
119
- display: none;
109
+ .pdf-secure-embed-title {
110
+ font-size: 13px;
120
111
  }
121
112
 
122
- .pdf-secure-card-btn svg {
123
- margin: 0;
113
+ .pdf-secure-embed-title span {
114
+ max-width: 150px;
124
115
  }
125
116
  }
126
117
 
127
- /* Anti-print protection */
118
+ /* Anti-print */
128
119
  @media print {
129
- .pdf-secure-card {
120
+ .pdf-secure-embed {
130
121
  display: none !important;
131
122
  }
132
123
  }