Skip to content

Commit 81265fb

Browse files
committed
DOC-2582: Replace duplicated content with partials, cleaned up lvl headings in sidebar.
1 parent faeb835 commit 81265fb

8 files changed

+174
-462
lines changed

modules/ROOT/nav.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,16 +312,16 @@
312312
**** xref:mediaembed-server-integration.adoc[Integrate Enhanced Media Embed Server]
313313
*** xref:advtable.adoc[Enhanced Tables]
314314
*** xref:exportpdf.adoc[Export to PDF]
315-
**** xref:export-to-pdf-with-jwt-authentication-nodejs.adoc[Export to PDF with JWT authentication (Nodejs)]
316315
**** xref:html-to-pdf-converter-api.adoc[HTML to PDF Converter API]
316+
**** xref:export-to-pdf-with-jwt-authentication-nodejs.adoc[Export to PDF with JWT authentication (Nodejs)]
317317
*** xref:exportword.adoc[Export to Word]
318-
**** xref:export-to-word-with-jwt-authentication-nodejs.adoc[Export to Word with JWT authentication (Nodejs)]
319318
**** xref:html-to-docx-converter-api.adoc[HTML to DOCX Converter API]
319+
**** xref:export-to-word-with-jwt-authentication-nodejs.adoc[Export to Word with JWT authentication (Nodejs)]
320320
*** xref:footnotes.adoc[Footnotes]
321321
*** xref:formatpainter.adoc[Format Painter]
322322
*** xref:importword.adoc[Import from Word]
323-
**** xref:importword-with-jwt-authentication-nodejs.adoc[Import from Word with JWT authentication (Nodejs)]
324323
**** xref:docx-to-html-converter-api.adoc[DOCX to HTML Converter API]
324+
**** xref:importword-with-jwt-authentication-nodejs.adoc[Import from Word with JWT authentication (Nodejs)]
325325
*** xref:editimage.adoc[Image Editing]
326326
*** xref:inline-css.adoc[Inline CSS]
327327
*** xref:linkchecker.adoc[Link Checker]

modules/ROOT/pages/export-to-pdf-with-jwt-authentication-nodejs.adoc

Lines changed: 6 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -6,92 +6,13 @@
66
:plugincode: exportpdf
77

88

9-
== Introduction
9+
include::partial$auth/document-converters/intro-and-prerequisites.adoc[]
1010

11-
{pluginname} requires setting up JSON Web Token (JWT) authentication to maintain control over file security. A JWT endpoint generates and provides authorization tokens that verify submitted content is sent by authorized users, preventing unauthorized access. As a standard web services authorization solution, JWT is documented extensively at link:https://jwt.io/[https://jwt.io/].
11+
include::partial$auth/document-converters/initial-project-setup.adoc[]
1212

13-
This guide provides a comprehensive walkthrough for integrating {pluginname} with {productname}, including {pluginname} functionality, by using a Node.js server for JWT token generation. It covers project setup, server configuration, and {productname} customization.
13+
== Setup
1414

15-
== What You'll Build
16-
17-
Before diving into the technical details, here's what you'll achieve with this guide:
18-
19-
* A working PDF export system for your {productname} editor
20-
* A secure authentication system using JWT tokens
21-
* A simple Node.js server to handle the authentication
22-
23-
[TIP]
24-
====
25-
This guide is designed for developers new to JWT authentication and {productname} integration.
26-
====
27-
28-
== Prerequisites
29-
30-
Before starting, ensure you have:
31-
32-
* Node.js installed on your computer
33-
* A {productname} API key (get one from link:https://www.tiny.cloud/signup[TinyMCE's website])
34-
* Basic familiarity with the command line
35-
36-
[IMPORTANT]
37-
====
38-
Make sure you have your API key ready before starting. You'll need it for both the server and client configuration.
39-
====
40-
41-
== Quick Start Guide
42-
43-
=== Project Setup (5 minutes)
44-
45-
[source,bash]
46-
----
47-
# Create and enter project directory
48-
mkdir tinymce-pdf-export
49-
cd tinymce-pdf-export
50-
51-
# Initialize project
52-
npm init -y
53-
54-
# Install required packages
55-
npm install express cors jsonwebtoken
56-
----
57-
58-
Verify that the `package.json` file includes the below required dependencies:
59-
60-
[source,json]
61-
----
62-
{
63-
"dependencies": {
64-
"cors": "^2.8.5",
65-
"express": "^4.21.0",
66-
"jsonwebtoken": "^9.0.2"
67-
}
68-
}
69-
----
70-
71-
=== Create Project Structure
72-
73-
[source,bash]
74-
----
75-
# Create the public folder for your web files
76-
mkdir public
77-
touch public/index.html
78-
touch jwt.js
79-
----
80-
81-
Your project should look like this:
82-
83-
[source]
84-
----
85-
/tinymce-pdf-export
86-
/public
87-
index.html (TinyMCE webpage)
88-
jwt.js (Server code)
89-
package.json (Project configuration)
90-
----
91-
92-
. Inside the `public` folder where you created the `index.html` file add the HTML setup code (refer to the *Setting up {productname} HTML* section).
93-
94-
==== Web Page Setup (public/index.html)
15+
=== Web Page (public/index.html)
9516

9617
[source,html]
9718
----
@@ -138,74 +59,6 @@ Your project should look like this:
13859

13960
. In the root directory, copy and paste the server setup code into the `jwt.js` file (refer to the *Configuring the Node.js Server for JWT Token Generation* section).
14061

141-
==== Server Setup (jwt.js)
142-
143-
[source,javascript]
144-
----
145-
const express = require('express'); // Sets up the web server.
146-
const jwt = require('jsonwebtoken'); // Generates and signs JWTs.
147-
const cors = require('cors'); // Allows cross-origin requests.
148-
const path = require('path'); // Handles file paths.
149-
150-
const app = express();
151-
app.use(cors());
152-
153-
// Your private key (Replace this with your actual key)
154-
const privateKey = `
155-
-----BEGIN PRIVATE KEY-----
156-
{Your private PKCS8 key goes here}
157-
-----END PRIVATE KEY-----
158-
`;
159-
160-
app.use(express.static(path.join(__dirname, 'public')));
161-
162-
// JWT token generation endpoint
163-
app.post('/jwt', (req, res) => {
164-
const payload = {
165-
aud: 'YOUR-API-KEY-HERE', // Replace with your actual API key
166-
iat: Math.floor(Date.now() / 1000), // Issue timestamp
167-
exp: Math.floor(Date.now() / 1000) + (60 * 10) // Expiration time (10 minutes)
168-
};
169-
170-
try {
171-
// Tokens are signed with the RS256 algorithm using your private key
172-
const token = jwt.sign(payload, privateKey, { algorithm: 'RS256' });
173-
res.json({ token });
174-
} catch (error) {
175-
res.status(500).send('Failed to generate JWT token.');
176-
console.error(error.message);
177-
}
178-
});
179-
180-
const PORT = 3000;
181-
app.listen(PORT, () => {
182-
console.log(`Server running at http://localhost:${PORT}`);
183-
});
184-
----
185-
186-
=== Configuration Steps
187-
188-
==== 1. Add Your API Key
189-
190-
* Replace `YOUR-API-KEY` in both files with your actual {productname} API key
191-
* The API key should be the same in both the HTML script source and the JWT payload
192-
193-
==== 2. Add Your Private Key
194-
195-
* Replace the private key placeholder in `jwt.js` with your actual private key
196-
* Make sure it's in `PKCS8` format
197-
* Keep this key secure and never share it publicly
198-
199-
=== Running Your Project
200-
201-
. Start the server:
202-
+
203-
[source,bash]
204-
----
205-
node jwt.js
206-
----
62+
include::partial$auth/document-converters/server-setup-jwt.adoc[]
20763

208-
. Open your browser to: `http://localhost:3000`
209-
. You should see:
210-
* The {productname} editor
211-
* An "Export to PDF" button in the toolbar
64+
include::partial$auth/document-converters/configuration-steps.adoc[]

modules/ROOT/pages/export-to-word-with-jwt-authentication-nodejs.adoc

Lines changed: 6 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -6,92 +6,13 @@
66
:plugincode: exportword
77

88

9-
== Introduction
9+
include::partial$auth/document-converters/intro-and-prerequisites.adoc[]
1010

11-
{pluginname} requires setting up JSON Web Token (JWT) authentication to maintain control over file security. A JWT endpoint generates and provides authorization tokens that verify submitted content is sent by authorized users, preventing unauthorized access. As a standard web services authorization solution, JWT is documented extensively at link:https://jwt.io/[https://jwt.io/].
11+
include::partial$auth/document-converters/initial-project-setup.adoc[]
1212

13-
This guide provides a comprehensive walkthrough for integrating {pluginname} with {productname}, including {pluginname} functionality, by using a Node.js server for JWT token generation. It covers project setup, server configuration, and {productname} customization.
13+
== Setup
1414

15-
== What You'll Build
16-
17-
Before diving into the technical details, here's what you'll achieve with this guide:
18-
19-
* A working {pluginname} system for your {productname} editor
20-
* A secure authentication system using JWT tokens
21-
* A simple Node.js server to handle the authentication
22-
23-
[TIP]
24-
====
25-
This guide is designed for developers new to JWT authentication and {productname} integration.
26-
====
27-
28-
== Prerequisites
29-
30-
Before starting, ensure you have:
31-
32-
* Node.js installed on your computer
33-
* A {productname} API key (get one from link:https://www.tiny.cloud/signup[TinyMCE's website])
34-
* Basic familiarity with the command line
35-
36-
[IMPORTANT]
37-
====
38-
Make sure you have your API key ready before starting. You'll need it for both the server and client configuration.
39-
====
40-
41-
== Quick Start Guide
42-
43-
=== Project Setup (5 minutes)
44-
45-
[source,bash]
46-
----
47-
# Create and enter project directory
48-
mkdir tinymce-export-to-word
49-
cd tinymce-export-to-word
50-
51-
# Initialize project
52-
npm init -y
53-
54-
# Install required packages
55-
npm install express cors jsonwebtoken
56-
----
57-
58-
Verify that the `package.json` file includes the below required dependencies:
59-
60-
[source,json]
61-
----
62-
{
63-
"dependencies": {
64-
"cors": "^2.8.5",
65-
"express": "^4.21.0",
66-
"jsonwebtoken": "^9.0.2"
67-
}
68-
}
69-
----
70-
71-
=== Create Project Structure
72-
73-
[source,bash]
74-
----
75-
# Create the public folder for your web files
76-
mkdir public
77-
touch public/index.html
78-
touch jwt.js
79-
----
80-
81-
Your project should look like this:
82-
83-
[source]
84-
----
85-
/tinymce-export-to-word
86-
/public
87-
index.html (TinyMCE webpage)
88-
jwt.js (Server code)
89-
package.json (Project configuration)
90-
----
91-
92-
. Inside the `public` folder where you created the `index.html` file add the HTML setup code (refer to the *Setting up {productname} HTML* section).
93-
94-
==== Web Page Setup (public/index.html)
15+
=== Web Page (public/index.html)
9516

9617
[source,html]
9718
----
@@ -136,74 +57,6 @@ Your project should look like this:
13657

13758
. In the root directory, copy and paste the server setup code into the `jwt.js` file (refer to the *Configuring the Node.js Server for JWT Token Generation* section).
13859

139-
==== Server Setup (jwt.js)
140-
141-
[source,javascript]
142-
----
143-
const express = require('express'); // Sets up the web server.
144-
const jwt = require('jsonwebtoken'); // Generates and signs JWTs.
145-
const cors = require('cors'); // Allows cross-origin requests.
146-
const path = require('path'); // Handles file paths.
147-
148-
const app = express();
149-
app.use(cors());
150-
151-
// Your private key (Replace this with your actual key)
152-
const privateKey = `
153-
-----BEGIN PRIVATE KEY-----
154-
{Your private PKCS8 key goes here}
155-
-----END PRIVATE KEY-----
156-
`;
157-
158-
app.use(express.static(path.join(__dirname, 'public')));
159-
160-
// JWT token generation endpoint
161-
app.post('/jwt', (req, res) => {
162-
const payload = {
163-
aud: 'YOUR-API-KEY-HERE', // Replace with your actual API key
164-
iat: Math.floor(Date.now() / 1000), // Issue timestamp
165-
exp: Math.floor(Date.now() / 1000) + (60 * 10) // Expiration time (10 minutes)
166-
};
167-
168-
try {
169-
// Tokens are signed with the RS256 algorithm using your private key
170-
const token = jwt.sign(payload, privateKey, { algorithm: 'RS256' });
171-
res.json({ token });
172-
} catch (error) {
173-
res.status(500).send('Failed to generate JWT token.');
174-
console.error(error.message);
175-
}
176-
});
177-
178-
const PORT = 3000;
179-
app.listen(PORT, () => {
180-
console.log(`Server running at http://localhost:${PORT}`);
181-
});
182-
----
183-
184-
=== Configuration Steps
185-
186-
==== 1. Add Your API Key
187-
188-
* Replace `YOUR-API-KEY` in both files with your actual {productname} API key
189-
* The API key should be the same in both the HTML script source and the JWT payload
190-
191-
==== 2. Add Your Private Key
192-
193-
* Replace the private key placeholder in `jwt.js` with your actual private key
194-
* Make sure it's in `PKCS8` format
195-
* Keep this key secure and never share it publicly
196-
197-
=== Running Your Project
198-
199-
. Start the server:
200-
+
201-
[source,bash]
202-
----
203-
node jwt.js
204-
----
60+
include::partial$auth/document-converters/server-setup-jwt.adoc[]
20561

206-
. Open your browser to: `http://localhost:3000`
207-
. You should see:
208-
* The {productname} editor
209-
* An "Export to Word" button in the toolbar
62+
include::partial$auth/document-converters/configuration-steps.adoc[]

0 commit comments

Comments
 (0)