md2wiki 1.0.0 โ 1.0.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/README.md +32 -50
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
<img src="public/logo.svg" alt="md2wiki logo" width="160" />
|
|
4
4
|
<br />
|
|
5
5
|
<h1>๐ MD2WIKI</h1>
|
|
6
|
-
<p><strong>Real-Time Markdown to MediaWiki Wikitext
|
|
7
|
-
<p><i>A premium
|
|
6
|
+
<p><strong>Real-Time Markdown to MediaWiki Wikitext Converter</strong></p>
|
|
7
|
+
<p><i>A premium Next.js utility for Wikipedia editors featuring SUL OAuth 2.0 Sandbox publishing and CORS-free repository README importing.</i></p>
|
|
8
8
|
|
|
9
9
|
<br />
|
|
10
10
|
|
|
@@ -25,23 +25,20 @@
|
|
|
25
25
|
|
|
26
26
|
## ๐งญ Navigation
|
|
27
27
|
|
|
28
|
-
* [๐
|
|
28
|
+
* [๐ Project Vision](#-project-vision)
|
|
29
29
|
* [โจ Key Features](#-key-features)
|
|
30
|
-
* [๐ Quick Start
|
|
31
|
-
* [๐ OAuth 2.0 Credentials
|
|
32
|
-
* [๐ฆ Deployment
|
|
33
|
-
* [
|
|
34
|
-
* [๐งช Running Unit Tests](#-running-unit-tests)
|
|
30
|
+
* [๐ Local Quick Start](#-local-quick-start)
|
|
31
|
+
* [๐ SUL OAuth 2.0 Credentials](#-sul-oauth-20-credentials)
|
|
32
|
+
* [๐ฆ Toolforge Deployment](#-toolforge-deployment)
|
|
33
|
+
* [๐ป Command Line Interface (CLI)](#-command-line-interface-cli)
|
|
35
34
|
|
|
36
35
|
---
|
|
37
36
|
|
|
38
|
-
## ๐
|
|
37
|
+
## ๐ Project Vision
|
|
39
38
|
|
|
40
|
-
|
|
39
|
+
Publishing Markdown drafts (offline notes, documentation, readmes) onto Wikipedia talk pages, user sandboxes, or Meta-Wiki requires translating the content into MediaWiki Wikitext markup.
|
|
41
40
|
|
|
42
|
-
**md2wiki**
|
|
43
|
-
1. **An NPM-ready parser module** (`src/core/parser.ts`) that compiles Markdown to wikitext with smart rules.
|
|
44
|
-
2. **A SUL-integrated Toolforge service** that allows editors to paste raw Markdown (or fetch direct GitHub/GitLab READMEs) and publish the compiled Wikitext straight to their Wikipedia Sandbox with a single click.
|
|
41
|
+
**md2wiki** is a high-density, real-time translator that processes markdown formatting on the fly and integrates securely with your Wikipedia single user login (SUL) to write the output directly to your user sandbox page with one click.
|
|
45
42
|
|
|
46
43
|
---
|
|
47
44
|
|
|
@@ -74,7 +71,7 @@ Writing high-quality drafts or documentation offline in Markdown is standard pra
|
|
|
74
71
|
|
|
75
72
|
---
|
|
76
73
|
|
|
77
|
-
## ๐ Quick Start
|
|
74
|
+
## ๐ Local Quick Start
|
|
78
75
|
|
|
79
76
|
Follow these steps to run the application on your local machine:
|
|
80
77
|
|
|
@@ -90,7 +87,7 @@ npm install
|
|
|
90
87
|
```
|
|
91
88
|
|
|
92
89
|
### 3. Set up environment variables
|
|
93
|
-
Create a `.env` file in the root directory (the application
|
|
90
|
+
Create a `.env` file in the root directory (the application runs in **Mock SUL Mode** automatically if credentials are left blank):
|
|
94
91
|
```env
|
|
95
92
|
WIKIMEDIA_CLIENT_ID=your_oauth_consumer_token
|
|
96
93
|
WIKIMEDIA_CLIENT_SECRET=your_oauth_secret_token
|
|
@@ -106,75 +103,60 @@ Open **[http://localhost:8000](http://localhost:8000)** in your browser.
|
|
|
106
103
|
|
|
107
104
|
---
|
|
108
105
|
|
|
109
|
-
## ๐ OAuth 2.0 Credentials
|
|
106
|
+
## ๐ SUL OAuth 2.0 Credentials
|
|
110
107
|
|
|
111
|
-
To
|
|
108
|
+
To enable sandbox publishing, register the tool:
|
|
112
109
|
|
|
113
110
|
1. Log in to [Meta-Wiki](https://meta.wikimedia.org/).
|
|
114
111
|
2. Navigate to [Special:OAuthConsumerRegistration/propose/oauth2](https://meta.wikimedia.org/wiki/Special:OAuthConsumerRegistration/propose/oauth2).
|
|
115
112
|
3. Set the parameters:
|
|
116
113
|
* **OAuth callback URL**: `https://md2wiki.toolforge.org/api/auth/callback` (or `http://localhost:8000/api/auth/callback` for dev).
|
|
117
114
|
* **Grants**: Select **Basic rights** (`basic`), **Edit existing pages** (`edit`), and **Create, edit, and move pages** (`writepage` / `create`).
|
|
118
|
-
* **Allowed pages**: Leave blank to allow editing of all pages (required since sandbox pages reside under user namespaces).
|
|
119
115
|
4. Submit and record your **Consumer Token** and **Secret Token**.
|
|
120
116
|
|
|
121
117
|
---
|
|
122
118
|
|
|
123
|
-
## ๐ฆ Deployment
|
|
119
|
+
## ๐ฆ Toolforge Deployment
|
|
124
120
|
|
|
125
121
|
Wikimedia Toolforge supports hosting Node.js Next.js web applications using Kubernetes.
|
|
126
122
|
|
|
127
|
-
### 1.
|
|
123
|
+
### 1. SSH into Toolforge Bastion
|
|
128
124
|
```bash
|
|
129
125
|
ssh <username>@login.toolforge.org
|
|
126
|
+
become <tool-name>
|
|
130
127
|
```
|
|
131
128
|
|
|
132
|
-
### 2.
|
|
133
|
-
Ensure
|
|
129
|
+
### 2. Clone and install dependencies
|
|
130
|
+
Ensure files are cloned in your Toolforge home directory `www/js/`:
|
|
134
131
|
```bash
|
|
132
|
+
cd $HOME
|
|
135
133
|
git clone https://github.com/your-username/md2wiki.git www/js
|
|
136
134
|
cd www/js
|
|
137
135
|
npm install
|
|
138
136
|
```
|
|
139
137
|
|
|
140
|
-
### 3. Create
|
|
141
|
-
|
|
142
|
-
WIKIMEDIA_CLIENT_ID=your_production_consumer_token
|
|
143
|
-
WIKIMEDIA_CLIENT_SECRET=your_production_secret_token
|
|
144
|
-
SESSION_SECRET=another_long_production_secret
|
|
145
|
-
WIKIMEDIA_REDIRECT_URI=https://md2wiki.toolforge.org/api/auth/callback
|
|
146
|
-
NODE_ENV=production
|
|
147
|
-
PORT=8000
|
|
148
|
-
```
|
|
138
|
+
### 3. Create production `.env` file
|
|
139
|
+
Include your Toolforge OAuth credentials, secret, and port details inside `www/js/.env`.
|
|
149
140
|
|
|
150
|
-
### 4. Build and start
|
|
151
|
-
Build the Next.js assets:
|
|
141
|
+
### 4. Build and start
|
|
152
142
|
```bash
|
|
153
143
|
npm run build
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
Configure Toolforge to start the Next.js production server:
|
|
157
|
-
```bash
|
|
158
144
|
toolforge webservice node18 start
|
|
159
145
|
```
|
|
160
|
-
|
|
146
|
+
Traffic is automatically routed to `https://<tool-name>.toolforge.org/`.
|
|
161
147
|
|
|
162
148
|
---
|
|
163
149
|
|
|
164
|
-
##
|
|
150
|
+
## ๐ป Command Line Interface (CLI)
|
|
165
151
|
|
|
166
|
-
|
|
167
|
-
* `src/app/`: The Next.js App Router containing:
|
|
168
|
-
* `api/`: API Route Handlers for SUL OAuth redirects, proxy readmes, and sandbox edits.
|
|
169
|
-
* `utils/`: File helper wrappers (session encryptor, raw README URL resolver).
|
|
170
|
-
* `globals.css` / `layout.tsx` / `page.tsx`: The styling baseline and frontend editor layout.
|
|
171
|
-
* `toolinfo.json`: Toolhub scraper metadata.
|
|
152
|
+
You can run the translator locally via command line to parse files:
|
|
172
153
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
154
|
+
```bash
|
|
155
|
+
npm run parse -- <path-to-markdown-file>
|
|
156
|
+
```
|
|
176
157
|
|
|
177
|
-
|
|
158
|
+
For example, to convert `draft.md` and save the Wikitext output:
|
|
178
159
|
```bash
|
|
179
|
-
npm run
|
|
160
|
+
npm run parse -- draft.md > draft.wiki
|
|
180
161
|
```
|
|
162
|
+
Smart heading shifts and internal wiki link translation are enabled by default in CLI runs.
|