Page MenuHomePhabricator

Allow storing Cat-a-lot preferences privately
Open, Needs TriagePublicFeature

Description

Feature summary (what you would like to be able to do and where):

Currently, Cat-a-lot provides two ways to save preferences: either temporarily, in the memory, or publicly, in the user’s common.js file. I suggest adding a third one (or maybe even replacing the latter): saving privately, in the user’s preferences. SettingsManager already supports this, via its method mw.libs.settingsManager.switchGadgetPref.

Use case(s) (list the steps that you performed to discover that problem, and describe the actual underlying problem which you want to solve. Do not describe only a solution):

Persisting preferences without making them public.

Benefits (why should this be implemented?):

  • More privacy. Just like it’s not public what skin one uses or how large their watchlist is by default, it shouldn’t be public either what Cat-a-lot preferences one has.
  • More reliable. The common.js solution relies on specially-crafted comments, and since the user may edit that page (to do unrelated things), they may screw up the syntax. In contrast, gadget preferences are only editable through the API, and belong only to Cat-a-lot, so it’s unlikely that people touch them in ways they shouldn’t.

Event Timeline

Hi @Tacsipacsi . This is my attempt on this task

Use Case: Presently, when users set up Cat-a-lot preferences, they have two storage options: temporary memory storage or saving to their common.js file. The second option makes these preferences publicly visible to anyone viewing the user's page.

I believe this creates a privacy concern. Users tool configurations and workflow preferences should be private by default, similar to how MediaWiki handles other user preferences like skin selection and watchlist settings.

Furthermore, the common.js storage method uses specially-formatted comments that can be accidentally broken when users edit their common.js file for unrelated purposes. This creates unnecessary fragility in the preference storage system.

The underlying problem is the lack of a private, robust method for persisting Cat-a-lot preferences between sessions without exposing them publicly.

What I would like to do: Add a third option for saving Cat-a-lot preferences privately in the user's MediaWiki preferences. This would provide users with a more private and reliable way to persist their settings between sessions.

Implementation: This can be achieved by utilizing the existing mw.libs.settingsManager.switchGadgetPref method, which already supports saving gadget preferences privately through the MediaWiki API. To add private preference storage to Cat-a-lot, the following changes would need to be made:

  1. In the Cat-a-lot code where preferences are loaded, this code could be added:
mw.libs.settingsManager.fetchGadgetSetting('CatALotOptions', ['option']).done(function(prefName, value) {
    if (value) {
        // Use these preferences if found
        window.CatALotPrefs = value;
    } else {
        // Fall back to existing methods (memory or common.js)
    }
});

It checks if there are any preferences stored privately in the user's MediaWiki preferences before falling back to the existing methods.

  1. The code that currently saves preferences to common.js coudl be replaceed with
mw.libs.settingsManager.switchGadgetPref('CatALotOptions', preferencesObject);

This would save the preferences privately to the user's MediaWiki preferences instead of publicly to common.js.

  1. Where the storage options are defined in the preferences dialog, a third radio button optiosn for users to choose pricate storage should be added:
'<div class="catal-pref-option">' +
'<input type="radio" name="catal_storage" id="catal_storage_private" value="private">' +
'<label for="catal_storage_private">Save to user preferences (private)</label>' +
'</div>'

This implementation uses the existing switchGadgetPref and fetchGadgetSetting methods from SettingsManager.js, which are already designed for this purpose. Can I go ahead and create an separate settings file for these so I can also test these changes.