User talk:The Transhumanist/QuickPortal.js


 * This script is under development, and is not yet fully functional

This script is on once you install it. Anytime you click a redlink that is a portal, it creates the portal, putting it into preview mode. The new portal isn't saved until you click on the save button. In addition to this capability, the script provides 2 menu items: "Restart portal" and "Matching portal". See below for details.

= Script's workshop =
 * This is the work area for developing the script and its documentation. Even though this documentation is in user space, feel free to edit it. The talk page portion of this page starts at, below.

Description & instruction manual for

 * This script is under development, and is not yet fully functional

This script is on once you install it. Anytime you click a redlink that is a portal, it creates the portal, putting it into preview mode. The new portal isn't saved until you click on the save button.

QuickPortal.js is intended to apply \{\{subst:bpsp\}\} to create a portal, or overwrite an existing portal. (note: bpsp is a shortcut to Template:Basic portal start page, which creates a single-page portal)

IMPORTANT: BEFORE YOU RUN THIS SCRIPT, DEACTIVATE wikEd. QuickPortal WILL NOT RUN RIGHT OTHERWISE.

When you ctrl-click on a portal redlink (in Firefox or Chrome), a new portal is created in a new tab in preview mode waiting to be saved. So, if you ctrl-click on 20 such redlinks, you get 20 tabs each with a new portal in preview mode waiting for inspection. Regular clicking on a portal redlink creates a new portal for that subject in the current window.

The script also presents two menu items:

The "Restart portal" menu item appears when a portal base page is displayed. Clicking on that puts the portal in edit mode. Clicking it again (or when a portal is already in edit mode) will replace the portal's content with the new portal design, same as the feature that creates a new portal above.)

The "Matching portal" menu item jumps to the like-named portal title. (Development note: if there isn't an existing portal, create it. See the page creation url.)

General approach
The core program creates 2 menu items, and checks for a blank creation page. It calls a different subroutine for each of these.

The insertQuickPortal subroutine inserts  onto the blank page, and then autoclicks page preview.

More specifically, starting at the beginning...

Change log for

 * 2018-08-26
 * Started script
 * 2018
 * Main function
 * Restart menu item
 * Matching portal menu item
 * 2019-02-18
 * Started this Change log
 * Added guard clause so that Restart menu item shows up only when portal has a "Selected article" section

Bug reports

 * 2019-01-29 – This program does not work right when WikEd is turned on. When activated by, thus creating a new page in a tab, the script goes into an endless loop, creating the page in each tab over and over again. It works normally when WikEd is turned off.

Desired/completed features

 * Completed features are marked with ✅


 * Have Matching portal work from a template page.

Development notes for
Using this script gets portal creation down to about a minute, 5 minutes if you include link placement. The development goal is to get this down to seconds.

The most time consuming steps in portal creation now are:
 * 1) Topic selection (in order to become a portal, the topic needs adequate support in the form of a navbox template.
 * 2) Inspection
 * 3) Check for errors
 * 4) Check number of articles displaying in excerpt slideshow(s). Stubs don't show up, reducing the number displayed.
 * 5) Adjustment, by
 * 6) Changing templates (after save)
 * 7) Adding alternate content/parameters, like a different navbox template name
 * 8) Swapping out the main template for an alternate configuration in the event there are empty sections (before save)
 * 9) Or a combination of the above (different sections)
 * 10) Deorphanization, by placing links to the portal

Rough rough talk-through
The script generates a portal by inserting  onto a blank page. Then it loads a preview page (i.e., starts over).

Restart portal
Menu item "Restart portal" starts a process that replaces an existing portal with a new one.

It's a multi-page process.

First it invokes an edit page.

The script starts over on the edit page. Therefore, the script must be able to differentiate the intended edit page from all others. It also needs to be able to work independently of other instances of the same script being used, like when run in multiple tabs at the same time.

Tracking


 * localStorage.setItem('myCat', 'Tom');
 * var cat = localStorage.getItem('myCat');
 * localStorage.removeItem('myCat');

To make sure that instances don't clash, they have to use different localStorage items. Such as naming the item based on the page's title.

I've solved this problem for now, but it requires using the menu item twice: once to get to the page, and once while on the page.

Read up on this
https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API

It kind of works
The script will restart a portal, but it totally replaces what was there, rather than make use of it.

I'd like to figure out how to make use of what's there, one element at a time.

Add link placement functionality
After portal is saved, place links to the portal from: 1) Cooresponding root article's See also section, but only if it does not already exist 2) Cooresponding category page, but only if it does not already exist 3) The bottom of the corresponding navigation footer template, but only if it does not already exist

Under development as P-link.js.

Script dependencies
= Discussions =


 * This is where the actual talk page starts for User:. Please post your discussion threads below...