Jump to content

User:Asked42/LeadManager

From Wikinews, the free news source you can write!

The Lead Manager script is designed to simplify the process of updating and creating lead articles, which are displayed on the main page. Manually updating all five leads one by one can be time-consuming. This script streamlines the entire process, making it faster and easier to manage.

All you need to do is provide the title of an article. The script will automatically extract the image, summary, and the article type from it. It will shuffle the existing leads sequentially and insert the new content into your selected lead template.

In addition to the full-sequence update, the script also offers customization options. If you only want to update a specific lead, you can do that without affecting the others. You can also define a custom shuffle pattern — for example, update just Lead 1 and Lead 2, or even reverse the order of updates from Lead 5 to Lead 1. The tool is flexible and adapts to different use cases with ease.

If you need any help using the script or have any confusion, feel free to ask your questions on the talk page. Enjoy!

Installation

[edit]

To install the script, copy the following code and paste it into your common.js page in your user space.

mw.loader.load('//en.wikinews.org/w/index.php?title=User:Asked42/LeadManager.js&action=raw&ctype=text/javascript');

Once the script is installed, return to this page. You will now find a form under the Lead Manager Form section below.

Alternatively, after installing the script, you can access the lead manager form by using <div id="lead-manager-container"></div> on any other page as well, such as in your sandbox.

Usage

[edit]

Instructions

[edit]
A screen recorded video demonstrating basic usage of the form.
  • Click on the Title field. You'll see five recently published articles listed as recommendations. Select the one you want to use for updating the lead template.
  • Choose how many sentences you want in the summary. Click the "Fetch Automatically" button. Wait a few seconds — the tool will extract the summary and image from the selected article.
  • Additional options:
    • Image Size: Example format 150x150px (100x100px). The first size (150x150px) is for Lead Template 1. The size in brackets (100x100px) is used for Lead Templates 2–5. Want to use the same image size for all? Remove the value inside the brackets (know more).
    • Lead Article Template: Choose which Lead Template you want to update (e.g., Lead 2). Shuffling will begin from the selected lead (e.g., selecting Lead 2 means existing content will shift from Lead 2 onwards).
    • Single Update: Check this box to update only the selected lead template. All other lead templates will remain unchanged.
    • Explicit Update: Use this to create a custom shuffle pattern. When checked, an input box appears. Example: 1->2, 2->3 this will moves content from Lead 1 to Lead 2, Lead 2 to Lead 3 and Inserts new content into Lead 1. Lead 4 and 5 remain unchanged (See more examples and conditions.)
  • Finally, click the "Start Update!" button. Confirm the changes, and the tool will update the templates automatically.


Lead Manger Form

[edit]


The Lead Manager script has not been loaded or installed. Once loaded, a form will appear here. For a preview see File:Lead Manager Usage en wn version April 2025.webm



More description and examples

[edit]

Fetching Methods

[edit]

Using the Article's Title: On this method, the user enters the article's title in the title field. By clicking the "Fetch Automatically" button, the article's first image, summary, and type will be extracted and used to fill the corresponding fields in the form.

If the user initially selects "4 sentences" for the summary and finds it too long after extraction, they can choose a smaller number of sentences and click the button again. The previous summary will be replaced with the new one based on the updated selection.

Using Shortcut Keywords: This method offers an alternative to entering the article's title manually. Users can enter the "ML<number>" keyword to refer to the most recently added articles in the published category. For example: "ML1" represents the latest article in the category. "ML2" refers to the second latest, and so on, up to ML5.

After clicking "Fetch Automatically", the keyword will be replaced with the actual article's title, and the corresponding image and summary will be populated in the form.

From Current Lead Contents: This method allows users to extract content directly from a current lead template instead of an article. Users can use the Lead<number> keyword to refer to a specific lead template. For example, Lead1 fetches data from lead template 1, Lead2 fetches from lead template 2, and so on

The Image Size

[edit]

The image size field can have two values: one for the selected lead template (as per the "Lead Article Template" dropdown) and another for the other lead templates.

For example, if the image size is set to "150x150px (100x100px)" and the selected lead template is Lead 1, then the size 150x150px will be used for Lead 1, while the size 100x100px will be used for Lead 2 through Lead 5.

If the "Single Update" option is selected, the value in brackets will be ignored, and the size 150x150px will only apply to the selected lead template.

If you don't use a value in brackets and only enter "150x150px", this size will be used for all lead templates, regardless of the update mode.

Explicit Update

[edit]

The "Explicit Update" option allows you to define a custom pattern for shuffling content between lead templates.

For example, a pattern like "1->2" moves the content of Lead 1 to Lead 2 and adds new content to Lead 1, leaving other leads unchanged.

You can specify multiple moves separated by commas, such as "1->3, 3->2, 2->5". This means:

  • Content from Lead 1 moves to Lead 3
  • Content from Lead 3 moves to Lead 2
  • Content from Lead 2 moves to Lead 5
  • Lead 4 remains unchanged


Conditions for Valid Patterns:

  • First Number Matches the Selected Template: The first number in the pattern must match the lead template selected in the "Lead Article Template" dropdown. For example, if Lead 1 is selected, a pattern like "2->1, 1->3" is invalid because it starts with 2 instead of 1.
  • No Empty Templates: All templates must remain filled after the update. For example, the pattern "1->3, 4->5" is invalid because Lead 4 would end up empty.

Other Scripts

[edit]
  • QuickCat: This script is designed to make the creation of date and month categories, as well as date and month list pages, quick and easy.