Module:AutoLinker/doc

From Nano World Order - Wiki

This is the documentation page for Module:AutoLinker

AutoLinker Documentation

This page documents the AutoLinker tool, which automatically finds and links existing wiki page titles in input text.

Installation Instructions

Step 1: Create the Lua Module

  1. Go to your wiki's Module namespace: Module:AutoLinker
  2. Copy the complete Lua code into the page (see the module page)
  3. Save

Step 2: Create the Template Wrapper

  1. Go to your wiki's Template namespace: Template:AutoLinker
  2. Copy the template code below into the page
  3. Save

Step 3: Customize the Page List

  1. Edit Module:AutoLinker
  2. Modify the p.getStaticPages() function
  3. Add/remove page titles that should be auto-linked
  4. Save

Basic Usage

Method 1: Direct Invoke (Recommended)

Use this syntax anywhere on your wiki:

<syntaxhighlight lang="wiki"> Lua error: Internal error: The interpreter exited with status 126. </syntaxhighlight>

The system will automatically link all matching page titles from your configured list.

Example:

Input: <syntaxhighlight lang="wiki"> Lua error: Internal error: The interpreter exited with status 126. </syntaxhighlight>

Output: <syntaxhighlight lang="wiki"> This discusses Targeted Individuals and Directed Energy Weapons. </syntaxhighlight>

Method 2: Using the Template

<syntaxhighlight lang="wiki"> Template:AutoLinker </syntaxhighlight>

This displays the form interface for processing text.

Method 3: Embedding in an Article

You can embed AutoLinker directly in article sections:

<syntaxhighlight lang="wiki">

Linked Section

Lua error: Internal error: The interpreter exited with status 126. </syntaxhighlight>

Advanced Parameters

When calling the module directly, you can use optional parameters:

<syntaxhighlight lang="wiki"> Lua error: Internal error: The interpreter exited with status 126. </syntaxhighlight>

text
The input text to process (required)
mode
Where to get the page list
  • static — Use curated list only (fast, requires maintenance)
  • dynamic — Query wiki API (slower, more complete)
  • auto — Try dynamic first, fall back to static (default)

Customizing the Page List

To add or remove pages from auto-linking:

  1. Edit Module:AutoLinker
  2. Find the p.getStaticPages() function
  3. Add new pages to the return table:

<syntaxhighlight lang="lua"> return {

   "Your Page Title",
   "Another Page",
   -- etc

} </syntaxhighlight>

Tips

  • Add both singular and plural forms if needed
  • Longer titles are automatically matched first
  • Use proper capitalization (must match your page titles exactly)
  • Test with Lua error: Internal error: The interpreter exited with status 126.

Finding Pages to Add

To find your actual wiki page titles:

  1. Go to Special:AllPages
  2. Review all pages
  3. Copy exact titles (watch capitalization!)
  4. Paste into the getStaticPages() function

Important: Page titles must match exactly, including capitalization and spacing.

Configuration Options

Edit Module:AutoLinker to adjust behavior:

<syntaxhighlight lang="lua"> local config = {

   caseSensitive = false,      -- Match "AI" and "ai"?
   wholeWordsOnly = true,      -- Must be standalone words
   skipAlreadyLinked = true,   -- Don't re-link existing links
   minLength = 2,              -- Skip 1-character matches
   maxMatches = 500,           -- Safety limit per invocation
   cacheExpiry = 3600,         -- Cache time in seconds

} </syntaxhighlight>

Recommended Settings

For most wikis:

  • wholeWordsOnly = true — Prevents matching partial words
  • skipAlreadyLinked = true — Prevents double-linking
  • maxMatches = 500 — Safe limit for performance

Debugging & Testing

View All Matched Pages

To see the complete list of pages that will be auto-linked:

<syntaxhighlight lang="wiki"> Lua error: Internal error: The interpreter exited with status 126. </syntaxhighlight>

This outputs a numbered list of all pages in the matching configuration.

Test with Sample Text

To test the module with sample text:

<syntaxhighlight lang="wiki"> Lua error: Internal error: The interpreter exited with status 126. </syntaxhighlight>

Test with Custom Text

To test with your own text:

<syntaxhighlight lang="wiki"> Lua error: Internal error: The interpreter exited with status 126. </syntaxhighlight>

Common Use Cases

Processing a New Article

Workflow:

  1. Write your article
  2. Use AutoLinker to add links to all relevant pages
  3. Copy the linked output
  4. Paste back into your article
  5. Save

Example:

<syntaxhighlight lang="wiki">

Draft Section

Original text: "This discusses surveillance programs, electromagnetic harassment, and targeted individuals."

Lua error: Internal error: The interpreter exited with status 126.

Result

Copy the output above and use it in your article. </syntaxhighlight>

Batch Processing Multiple Articles

Create a temporary page in your sandbox or user workspace for processing multiple texts:

<syntaxhighlight lang="wiki">

Text Processing Queue

Article 1

Lua error: Internal error: The interpreter exited with status 126.

Article 2

Lua error: Internal error: The interpreter exited with status 126.

Article 3

Lua error: Internal error: The interpreter exited with status 126. </syntaxhighlight>

Process all at once, then copy and distribute results.

Limitations & Behavior

  • Already linked text is skipped — won't double-link existing links
  • Maximum 500 matches per invocation — safety limit to prevent performance issues
  • Whole words only — matches "Energy Weapons" but not partial words
  • Static mode is fast — dynamic mode slower on large wikis
  • Case sensitivity — can be configured in the module

Performance Notes

Static mode (50-100 pages)
Instant
Static mode (500+ pages)
Noticeable delay (1-2 seconds)
Text length (10KB)
Fast
Text length (100KB+)
Consider breaking into chunks
Dynamic mode
1-5 seconds typical (not recommended)

Optimization Tip: If processing very long texts, run AutoLinker on sections separately.

Troubleshooting

Nothing is Getting Linked

Diagnosis: <syntaxhighlight lang="wiki"> Lua error: Internal error: The interpreter exited with status 126. </syntaxhighlight>

This shows all pages in the matching list.

Solutions:

  • Check that page titles in the static list exactly match your wiki pages
  • Verify the module is in the Module: namespace
  • Test with Lua error: Internal error: The interpreter exited with status 126.
  • Capitalization and spacing must match exactly

Too Many False Matches

Solution:

  • Remove overly generic terms from the list
  • Put longer, more specific titles first (already done by default)
  • Increase specificity of page titles
  • Adjust matching configuration options

Scribunto Error

Likely Cause: Syntax error in the Lua code or module not found

Fix:

  1. Go to Module:AutoLinker
  2. Look for red error text
  3. Click the error to see details
  4. Fix the Lua code or reinstall the module

Pages with Special Characters Not Linking

Pages with [, ], (, ), etc. need special handling.

Workaround: Add alternate titles to your list:

<syntaxhighlight lang="lua"> "The Radiohead Protocol", "Radiohead Protocol", -- Alternative for matching </syntaxhighlight>

Complete Workflow Example

Scenario: Processing an Article About Surveillance

Original Article Text:

This exposé examines Targeted Individuals, Gang Stalking, and Directed Energy Weapons technology. It draws on COINTELPRO documents and recent research into Psychotronics.

Processing:

<syntaxhighlight lang="wiki"> Lua error: Internal error: The interpreter exited with status 126. </syntaxhighlight>

Result (after saving):

This exposé examines [[Targeted Individuals|Targeted Individuals]], [[Gang Stalking|Gang Stalking]], and [[Directed Energy Weapons|Directed Energy Weapons]] technology. It draws on [[COINTELPRO|COINTELPRO]] documents and recent research into [[Psychotronics|Psychotronics]].

Final Step: Copy the result and paste it into your article.

Creating a Tool Page

To give all editors easy access to AutoLinker, create a page like Tools:AutoLinker or Help:AutoLinker:

<syntaxhighlight lang="wiki">


Auto-Linking Tool

This tool automatically links all matching page titles in your text.

How to Use

Paste your text into the invoke below and save the page to see the linked result:

Lua error: Internal error: The interpreter exited with status 126.

Instructions

  1. Write or paste your text after text=
  2. Save the page
  3. View the result with all matching pages linked
  4. Copy the linked text and paste into your article

Need Help?

  • Test the tool: Lua error: Internal error: The interpreter exited with status 126.
  • View all linkable pages: Lua error: Internal error: The interpreter exited with status 126.
  • See all configuration: Edit Module:AutoLinker

</syntaxhighlight>

Advanced: Modifying the Module

The module can be extended with custom features:

  • Add custom filters — Skip pages from certain categories
  • Change link format — Hide the page title in display text
  • Add exclusion list — Pages that should never be auto-linked
  • Implement dynamic page list — Query all wiki pages automatically

These modifications require editing the Lua code in Module:AutoLinker, but the structure is straightforward.

API Reference

Functions

linkify(frame)
Main function; takes text and mode parameters; returns linked text
getAllPages(mode)
Retrieves page list; mode can be "static", "dynamic", or "auto"
getStaticPages()
Returns curated page list for matching
getDynamicPages()
Queries wiki API for pages (currently simplified)
listPages(frame)
Debug function; lists all pages being matched
test(frame)
Test function; runs linkify with sample text

Configuration Variables

caseSensitive
Boolean; whether matching is case-sensitive (default: false)
wholeWordsOnly
Boolean; whether to match whole words only (default: true)
skipAlreadyLinked
Boolean; whether to skip already-linked text (default: true)
minLength
Number; minimum length of page titles to match (default: 2)
maxMatches
Number; maximum matches per invocation (default: 500)
cacheExpiry
Number; cache expiration time in seconds (default: 3600)

See Also

Questions or Issues?

For help with AutoLinker: