{"id":25765353,"url":"https://github.com/professionalwiki/automatedvalues","last_synced_at":"2025-02-26T22:18:15.450Z","repository":{"id":42524321,"uuid":"468790994","full_name":"ProfessionalWiki/AutomatedValues","owner":"ProfessionalWiki","description":"Wikibase extension that allows defining rules to automatically set labels or aliases based on Statement values","archived":false,"fork":false,"pushed_at":"2025-02-25T13:49:48.000Z","size":348,"stargazers_count":6,"open_issues_count":9,"forks_count":3,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-02-25T14:39:45.121Z","etag":null,"topics":["automation","mediawiki","mediawiki-extension","wikibase","wikibase-extension"],"latest_commit_sha":null,"homepage":"https://wikibase.consulting/automating-values-in-wikibase","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ProfessionalWiki.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"JeroenDeDauw","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2022-03-11T14:53:27.000Z","updated_at":"2025-01-19T22:19:26.000Z","dependencies_parsed_at":"2024-07-29T15:30:16.311Z","dependency_job_id":"fbbc5402-5f6e-4d08-846f-3a12afe791ee","html_url":"https://github.com/ProfessionalWiki/AutomatedValues","commit_stats":{"total_commits":86,"total_committers":5,"mean_commits":17.2,"dds":0.2441860465116279,"last_synced_commit":"c39bafb18f147c937cbcf96bb02ce4b1ee0e4d33"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProfessionalWiki%2FAutomatedValues","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProfessionalWiki%2FAutomatedValues/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProfessionalWiki%2FAutomatedValues/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProfessionalWiki%2FAutomatedValues/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ProfessionalWiki","download_url":"https://codeload.github.com/ProfessionalWiki/AutomatedValues/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240941514,"owners_count":19882063,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","mediawiki","mediawiki-extension","wikibase","wikibase-extension"],"created_at":"2025-02-26T22:18:14.092Z","updated_at":"2025-02-26T22:18:15.440Z","avatar_url":"https://github.com/ProfessionalWiki.png","language":"PHP","funding_links":["https://github.com/sponsors/JeroenDeDauw"],"categories":[],"sub_categories":[],"readme":"# Automated Values\n\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/ProfessionalWiki/AutomatedValues/ci.yml?branch=master)](https://github.com/ProfessionalWiki/AutomatedValues/actions?query=workflow%3ACI)\n[![codecov](https://codecov.io/gh/ProfessionalWiki/AutomatedValues/branch/master/graph/badge.svg?token=GnOG3FF16Z)](https://codecov.io/gh/ProfessionalWiki/AutomatedValues)\n[![Type Coverage](https://shepherd.dev/github/ProfessionalWiki/AutomatedValues/coverage.svg)](https://shepherd.dev/github/ProfessionalWiki/AutomatedValues)\n[![Psalm level](https://shepherd.dev/github/ProfessionalWiki/AutomatedValues/level.svg)](psalm.xml)\n[![Latest Stable Version](https://poser.pugx.org/professional-wiki/wikibase-automated-values/v/stable)](https://packagist.org/packages/professional-wiki/wikibase-automated-values)\n[![Download count](https://poser.pugx.org/professional-wiki/wikibase-automated-values/downloads)](https://packagist.org/packages/professional-wiki/wikibase-automated-values)\n[![License](https://poser.pugx.org/professional-wiki/wikibase-automated-values/license)](LICENSE)\n\n[Wikibase] extension that allows defining rules to automatically set labels or aliases based on Statement values.\n\n[Professional Wiki] created and maintains Automated Values. We provide [Wikibase hosting], [Wikibase development], and [Wikibase consulting].\n\nAutomated Values was created for the Luxembourg Ministry of Culture, which funded initial development.\n\nYou can find a demo of this extension at https://automated.wikibase.wiki\n\n**Table of Contents**\n\n- [Usage](#usage)\n- [Installation](#installation)\n- [PHP Configuration](#php-configuration)\n- [Development](#development)\n- [Release notes](#release-notes)\n\n## Usage\n\n\u003ca href=\"https://www.youtube.com/watch?v=BO58wulCFVU\"\u003e\u003cimg src=\".github/youtube.png\" width=\"430px\" title=\"Play video\" /\u003e\u003c/a\u003e\n\nThe core building block of this extension are so-called \"Rules\".\n\nYou can read the bellow step-by-step explanation or look immediately at [example.json].\n\nA Rule consists of zero or more Entity Criteria, which allow you to specify\nwhich Wikibase entities the Rule applies to. For instance \"all entities where P1 is Q1\", which might translate to \"all entities instanceof Person\".\n\n```json\n{\n\t\"when\": [\n\t\t{\n\t\t\t\"statement\": \"P1\",\n\t\t\t\"equalTo\": \"Q1\"\n\t\t}\n\t]\n}\n```\n\nA rule can also have zero or more Build Specifications. These describe how to auto automatically build\nvalues on matching Entities, and which languages to update. They are available both for Labels and Aliases.\n\n```json\n{\n\t\"buildLabel\": {\n\t\t\"en\": {\n\t\t\t\"P2\": \"$\"\n\t\t}\n\t},\n\t\"buildAliases\": {\n\t\t\"*\": {\n\t\t\t\"P5.P3\": \"President \",\n\t\t\t\"P5\": \"$\",\n\t\t\t\"P5.P4\": \", $\"\n\t\t}\n\t}\n}\n```\n\nRules can be defined on page `MediaWiki:AutomatedValues`.  Alternatively they can be defined in LocalSettings.php, see the [PHP Configuration](#php-configuration) section.\n\nTo define rules for your wiki, simply head over to `MediaWiki:AutomatedValues` and create the page. This page only accepts JSON that\nadheres to the [JSON Schema]. If you enter invalid JSON, the page will refuse to save your changes.\n\nEditing of pages in the `MediaWiki` namespace, which includes `MediaWiki:AutomatedValues`, is likely restricted to users\nwith elevated permissions. By default, MediaWiki restricts editing in this namespace to people with the `editinterface` right.\nFor more information, go to the page `Special:ListGroupRights#Namespace_restrictions` on your wiki.\n\nYou can find a complete and valid example of a list of Rules, that could be placed on `MediaWiki:AutomatedValues`, at [example.json].\n\n### Supported Entity Criteria\n\nAt the moment it is only possible to check equality of statement main values, and only for Properties of type String or EntityId.\n\nA Rule can contain multiple Entity Criteria, in which case they all need to match for the Rule to be applied. A Rule\ncan also contain no Entity Criteria, in which case it will be applied to all Entities.\n\n### Build Specifications\n\nBuild Specifications are essentially templates that describe how to build the values.\n\nYou can have different Build Specifications for different languages:\n\n```json\n{\n\t\"buildLabel\": {\n\t\t\"en\": {\n\t\t\t\"P2\": \"$\"\n\t\t},\n\t\t\"de\": {\n\t\t\t\"P3\": \"$\"\n\t\t}\n\t}\n}\n```\n\nYou can also specify `*` instead of a language code, in which case the Build Specification will be applied to all default\nlanguages. See the [PHP Configuration](#php-configuration) section for how to set the default languages. If the default\nlanguages are not set, `*` will be ignored.\n\n```json\n{\n\t\"buildLabel\": {\n\t\t\"*\": {\n\t\t\t\"P2\": \"$\"\n\t\t},\n\t\t\"de\": {\n\t\t\t\"P3\": \"$\"\n\t\t}\n\t}\n}\n```\n\nThe `$` symbol is replaced by the Main Value of the first Statement with the specified Property. Currently only strings\nare supported. Preferred Statements will be used over those with a Normal rank. If there is no matching Statement, that\npart of the value is omitted. If the resulting value is an empty string, it will be ignored.\n\nIt is possible to combine multiple values and to include whitespace and other characters.\n\n```json\n{\n\t\"de\": {\n\t\t\"P3\": \"$ \",\n\t\t\"P4\": \"$\",\n\t\t\"P5\": \", $\"\n\t}\n}\n```\n\nAssuming P4 is `foo`, P5 is `bar` and there not being a P3 Statement, the above would result in `foo, bar`.\n\nYou can also get the value of Qualifiers. This is done via the `P1.P2` notation, where P1 is the Property of the Statement,\nand P2 is the Property of the Qualifier.\n\n```json\n{\n\t\"de\": {\n\t\t\"P3\": \"$ \",\n\t\t\"P3.P10\": \"$\",\n\t\t\"P3.P11\": \", $\"\n\t}\n}\n```\n\nIn case of Aliases, all matching Statements will be used, possibly resulting in multiple Aliases. The above snippet\nwould create two Aliases, if there are two Statements with Property P3. This is only supported for Build Specifications\nthat use a single Statement-level Property. The below snippet would result in only a single Alias, even if there are many\nStatements.\n\n```json\n{\n\t\"de\": {\n\t\t\"P3\": \"$\",\n\t\t\"P4\": \"$\"\n\t}\n}\n```\n\n### When Rules are applied\n\nRules are applied on every edit. They are not applied outside of edits. So if you are importing a dataset and wish\nthe Rules to be applied, you need to first define the Rules and then do the import. Alternatively you can trigger\nan edit of each page with some MediaWiki script, though this functionality is not provided by the Automated Values\nextension.\n\nRules are applied in order. In other words, the second Rule can override values set by the first Rule.\n\n### Limitations\n\n* When editing an Entity, the UI will not immediately show the updated generated values. A page reload is needed.\n* You can only filter Entities based on Statement Main Values of type String or Entity ID.\n* You can only generate Labels and Aliases.\n* Rules are only applied to Entities on edit. Changing a rule will not automatically apply it everywhere.\n* The editing UI is still present for automatically generated values, possibly causing confusion.\n\n## Installation\n\nPlatform requirements:\n\n* [PHP] 7.4 or later (tested up to 8.4)\n* [MediaWiki] 1.35 or later (tested up to 1.43)\n* [Wikibase] 1.35 or later (tested up to 1.43)\n\nThe recommended way to install Automated Values is using [Composer] with\n[MediaWiki's built-in support for Composer][Composer install].\n\nOn the commandline, go to your wikis root directory. Then run these two commands:\n\n```shell script\nCOMPOSER=composer.local.json composer require --no-update professional-wiki/wikibase-automated-values:~1.0\n```\n```shell script\ncomposer update professional-wiki/wikibase-automated-values --no-dev -o\n```\n\nThen enable the extension by adding the following to the bottom of your wikis [LocalSettings.php] file:\n\n```php\nwfLoadExtension( 'AutomatedValues' );\n```\n\nYou can verify the extension was enabled successfully by opening your wikis Special:Version page in your browser.\n\nTo enable more convenient editing of `MediaWiki:AutomatedValues`, you can optionally install the [CodeMirror extension].\n\n## PHP Configuration\n\nConfiguration can be changed via [LocalSettings.php].\n\n### Default languages\n\nList of languages to create values for via '*' build specifications.\n\nVariable: `$wgAutomatedValuesDefaultLanguages`\n\nDefault: `[]`\n\nExample: `[ 'en', 'de', 'nl' ]`\n\nIf the value of this configuration is an empty list, '*' build specifications will be ignored.\n\n### Rules\n\nList of rules applied to the wiki. In JSON format, following the JSON Schema at [schema.json].\nGets combined with rules defined on page `MediaWiki:AutomatedValues`.\n\nVariable: `$wgAutomatedValuesRules`\n\nDefault: `\"\"`\n\nExample:\n\n```php\n$wgAutomatedValuesRules = '\n[\n\t{\n\t\t\"buildLabel\": {\n\t\t\t\"en\": {\n\t\t\t\t\"P2\": \"$\"\n\t\t\t}\n\t\t}\n\t}\n]\n';\n```\n\n**Caution**: invalid JSON will be _ignored_. No error will be shown, the intended rules will just not be applied.\n\n### Enable in-wiki rules\n\nIf it should be possible to define rules via MediaWiki:AutomatedValues.\n\nVariable: `$wgAutomatedValuesEnableInWikiConfig`\n\nDefault: `true`\n\nExample: `false`\n\nThe page MediaWiki:AutomatedValues will always be available. If this configuration is set to `false`, its contents will be ignored.\n\n## Development\n\nTo ensure the dev dependencies get installed, have this in your `composer.local.json`:\n\n```json\n{\n\t\"require\": {\n\t\t\"vimeo/psalm\": \"^4\",\n\t\t\"phpstan/phpstan\": \"^1.4.9\"\n\t},\n\t\"extra\": {\n\t\t\"merge-plugin\": {\n\t\t\t\"include\": [\n\t\t\t\t\"extensions/AutomatedValues/composer.json\"\n\t\t\t]\n\t\t}\n\t}\n}\n```\n\n### Running tests and CI checks\n\nYou can use the `Makefile` by running make commands in the `AutomatedValues` directory.\n\n* `make ci`: Run everything\n* `make test`: Run all tests\n* `make cs`: Run all style checks and static analysis\n\nAlternatively, you can execute commands from the MediaWiki root directory:\n\n* PHPUnit: `php tests/phpunit/phpunit.php -c extensions/AutomatedValues/`\n* Style checks: `vendor/bin/phpcs -p -s --standard=extensions/AutomatedValues/phpcs.xml`\n* PHPStan: `vendor/bin/phpstan analyse --configuration=extensions/AutomatedValues/phpstan.neon --memory-limit=2G`\n* Psalm: `php vendor/bin/psalm --config=extensions/AutomatedValues/psalm.xml`\n\n### High-level design\n\nThe `Domain/` folder contains the domain model, which is both independent of MediaWiki code and wiki concepts beyond the\nWikibase DataModel. In other words, the `Domain/` folder is the core of the application, with no outgoing dependencies.\n\n`Hooks.php` acts as entry point. `AutomatedValuesFactory` is the top level factory, responsible for object graph construction.\n\n## Release notes\n\n### Version 1.1.0 - 2025-02-25\n\nFeature release with these enhancements:\n\n* Translation updates\n* Removed unused Resource Loader module (minute performance enhancement)\n* Verified support for MediaWiki up to 1.43 and PHP up to 8.4 (1.0.0 is already compatible)\n\n### Version 1.0.0 - 2022-04-29\n\nInitial release for Wikibase 1.35 - 1.37 ([Release announcement], [Demo video]) with these features:\n\n* Ability to build labels and aliases using segmented templates\n* Ability to use both Statement Main Values and Qualifier values\n* Ability to restrict application of Rules to Entities with specific String or EntityId values for a given Property\n* Ability to define Rules on-wiki via the MediaWiki:AutomatedValues page\n\n[Professional Wiki]: https://professional.wiki\n[Wikibase]: https://wikibase.consulting/what-is-wikibase/\n[Wikibase hosting]: https://professional.wiki/en/hosting/wikibase\n[Wikibase development]: https://professional.wiki/en/wikibase-software-development\n[Wikibase consulting]: https://wikibase.consulting/\n[MediaWiki]: https://www.mediawiki.org\n[PHP]: https://www.php.net\n[Composer]: https://getcomposer.org\n[Composer install]: https://professional.wiki/en/articles/installing-mediawiki-extensions-with-composer\n[LocalSettings.php]: https://www.mediawiki.org/wiki/Manual:LocalSettings.php\n[JSON Schema]: https://github.com/ProfessionalWiki/AutomatedValues/blob/master/schema.json\n[schema.json]: https://github.com/ProfessionalWiki/AutomatedValues/blob/master/schema.json\n[example.json]: https://github.com/ProfessionalWiki/AutomatedValues/blob/master/example.json\n[CodeMirror extension]: https://www.mediawiki.org/wiki/Extension:CodeMirror\n[Release announcement]: https://www.wikibase.consulting/automating-values-in-wikibase/\n[Demo video]: https://www.youtube.com/watch?v=BO58wulCFVU\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprofessionalwiki%2Fautomatedvalues","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprofessionalwiki%2Fautomatedvalues","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprofessionalwiki%2Fautomatedvalues/lists"}