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.
Files changed (2) hide show
  1. package/README.md +32 -50
  2. 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 Compiler</strong></p>
7
- <p><i>A premium, high-density Next.js utility for Wikipedia editors featuring SUL OAuth 2.0 Sandbox publishing and CORS-free repository README importing.</i></p>
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
- * [๐Ÿ“ The Project Vision](#-the-project-vision)
28
+ * [๐Ÿ“ Project Vision](#-project-vision)
29
29
  * [โœจ Key Features](#-key-features)
30
- * [๐Ÿš€ Quick Start (Local Setup)](#-quick-start-local-setup)
31
- * [๐Ÿ”’ OAuth 2.0 Credentials Setup](#-oauth-20-credentials-setup)
32
- * [๐Ÿ“ฆ Deployment to Toolforge](#-deployment-to-toolforge)
33
- * [๐Ÿ“‚ Project Structure](#-project-structure)
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
- ## ๐Ÿ“ The Project Vision
37
+ ## ๐Ÿ“ Project Vision
39
38
 
40
- Writing high-quality drafts or documentation offline in Markdown is standard practice for modern developers. However, publishing these drafts on Wikipedia talk pages, user sandboxes, or Meta-Wiki documentation requires manually converting markdown format to MediaWiki Wikitext markup.
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** solves this pain point. It serves as:
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 (Local Setup)
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 will run in **Mock SUL Mode** automatically if credentials are left blank):
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 Setup
106
+ ## ๐Ÿ”’ SUL OAuth 2.0 Credentials
110
107
 
111
- To write to Wikipedia Sandboxes on behalf of users, you must register the tool:
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 to Toolforge
119
+ ## ๐Ÿ“ฆ Toolforge Deployment
124
120
 
125
121
  Wikimedia Toolforge supports hosting Node.js Next.js web applications using Kubernetes.
126
122
 
127
- ### 1. Log in to Toolforge Bastion
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. Initialize the Node webservice
133
- Ensure your project files are cloned in your Toolforge home directory `$HOME/www/js/`:
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 your production `.env` file
141
- ```env
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 the service
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
- Toolforge automatically routes traffic to port `8000`. Next.js will serve the client pages and API routes at `https://md2wiki.toolforge.org/`.
146
+ Traffic is automatically routed to `https://<tool-name>.toolforge.org/`.
161
147
 
162
148
  ---
163
149
 
164
- ## ๐Ÿ“‚ Project Structure
150
+ ## ๐Ÿ’ป Command Line Interface (CLI)
165
151
 
166
- * `src/core/`: The core conversion engine. Contains the TS parser and test files.
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
- ## ๐Ÿงช Running Unit Tests
154
+ ```bash
155
+ npm run parse -- <path-to-markdown-file>
156
+ ```
176
157
 
177
- We use **Vitest** for running our unit tests. To verify the Markdown parser rules:
158
+ For example, to convert `draft.md` and save the Wikitext output:
178
159
  ```bash
179
- npm run test
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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "md2wiki",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Convert Markdown to MediaWiki Wikitext with SUL sandbox publishing.",
5
5
  "type": "module",
6
6
  "main": "./dist/parser.js",