[MediaWiki-commits] [Gerrit] mediawiki...JsonConfig[master]: Override license messages for edit
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/325732 ) Change subject: Override license messages for edit .. Override license messages for edit * Add config->license config string field to specify default content license * New messages are shown at the bottom of the pages, edit notice, and edit copyright msg To enable, config object in $wgJsonConfigs must contain 'license': 'CC0-1.0+' value In the future, we have an easy way of implementing it per-page rather than per content handler. Bug: T152553 Change-Id: Ife272fbdd4b67a040f8c7753e82f4d461129fa70 --- M extension.json M i18n/en.json M i18n/qqq.json M includes/JCDataContent.php M includes/JCSingleton.php M modules/JsonConfig.css M tests/phpunit/JCLoaderTest.php 7 files changed, 114 insertions(+), 22 deletions(-) Approvals: JGirault: Looks good to me, approved jenkins-bot: Verified diff --git a/extension.json b/extension.json index 292610b..82ede04 100644 --- a/extension.json +++ b/extension.json @@ -112,6 +112,9 @@ "EditFilterMergedContent": [ "JsonConfig\\JCSingleton::onEditFilterMergedContent" ], + "EditPageCopyrightWarning": [ + "JsonConfig\\JCSingleton::onEditPageCopyrightWarning" + ], "MovePageIsValidMove": [ "JsonConfig\\JCSingleton::onMovePageIsValidMove" ], @@ -121,6 +124,12 @@ "ScribuntoExternalLibraries": [ "JsonConfig\\JCLuaLibrary::onScribuntoExternalLibraries" ], + "SkinCopyrightFooter": [ + "JsonConfig\\JCSingleton::onSkinCopyrightFooter" + ], + "TitleGetEditNotices": [ + "JsonConfig\\JCSingleton::onTitleGetEditNotices" + ], "TitleMoveComplete": [ "JsonConfig\\JCSingleton::onTitleMoveComplete" ], diff --git a/i18n/en.json b/i18n/en.json index e4e452f..e6f1988 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -39,10 +39,12 @@ "jsonconfig-type-name-number": "number", "jsonconfig-type-abbr-boolean": "(B)", "jsonconfig-type-name-boolean": "boolean", - "jsonconfig-license": "Data available under $1", - "jsonconfig-license-or-later": "$1, or (at your option) any later version", - "jsonconfig-license-CC0-1.0": "Creative Commons Zero", - "jsonconfig-license-url-CC0-1.0": "https://creativecommons.org/publicdomain/zero/1.0/;, + "jsonconfig-license": "Data available under $1.", + "jsonconfig-license-name-CC0-1.0+": "Creative Commons Zero", + "jsonconfig-license-url-CC0-1.0+": "https://creativecommons.org/publicdomain/zero/1.0/;, + "jsonconfig-license-copyrightwarning-CC0-1.0+": "By saving changes, you agree to the [https://wikimediafoundation.org/wiki/Terms_of_Use Terms of Use], and you irrevocably agree to release your contribution to the public domain under [https://creativecommons.org/publicdomain/zero/1.0/ CC0].", + "jsonconfig-license-notice-box-CC0-1.0+": "{| class='mw-jsonconfig-editnotice'\n| style='mw-jsonconfig-editnotice-icon' | [[Image:PD-icon.svg|30px|link=|PD]]\n| $1\n| style='mw-jsonconfig-editnotice-icon' | [[Image:PD-icon.svg|30px|link=|PD]]\n|}", + "jsonconfig-license-notice-CC0-1.0+": "'''Note:''' When you edit this page, you agree to release your contribution under the [https://creativecommons.org/publicdomain/zero/1.0/ CC0].", "right-jsonconfig-flush": "Manipulate JsonConfig via API", "apihelp-jsonconfig-description": "Allows direct access to JsonConfig subsystem.", "apihelp-jsonconfig-param-command": "Which sub-action to perform on JsonConfig:\n;status:Shows JsonConfig configuration.\n;reset:Clears configurations from cache. Requires $1title parameter and jsonconfig-reset right.\n;reload:Reloads and caches configurations from config store. Requires $1title parameter and jsonconfig-reset right.", diff --git a/i18n/qqq.json b/i18n/qqq.json index c6aea8e..0566d4a 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -48,9 +48,11 @@ "jsonconfig-type-abbr-boolean": "A very short indicator of the type of data contained in this column. Shown for columns that contain booleans (true or false)", "jsonconfig-type-name-boolean": "Description of the type of data contained in this column. Shown for columns that contain booleans (true or false)\n{{Identical|Boolean}}", "jsonconfig-license": "Shows license text prefix before giving the specific license.\n\nParameters:\n* $1 - * {{msg-mw|jsonconfig-license-or-later}} or {{msg-mw|jsonconfig-license-CC0-1.0}} or other similar license messages", - "jsonconfig-license-or-later": "In case the data can be used with any future versions of a license, this
[MediaWiki-commits] [Gerrit] mediawiki...JsonConfig[master]: Override license messages for edit
Yurik has uploaded a new change for review. https://gerrit.wikimedia.org/r/325732 Change subject: Override license messages for edit .. Override license messages for edit * Add store->license config string field to specify default content license * Add jsonconfig-license-edit-CC0-1.0 message Bug: T152553 Change-Id: Ife272fbdd4b67a040f8c7753e82f4d461129fa70 --- M extension.json M i18n/en.json M i18n/qqq.json M includes/JCSingleton.php 4 files changed, 28 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/JsonConfig refs/changes/32/325732/1 diff --git a/extension.json b/extension.json index 292610b..38a5ef3 100644 --- a/extension.json +++ b/extension.json @@ -112,6 +112,9 @@ "EditFilterMergedContent": [ "JsonConfig\\JCSingleton::onEditFilterMergedContent" ], + "EditPageCopyrightWarning": [ + "JsonConfig\\JCSingleton::onEditPageCopyrightWarning" + ], "MovePageIsValidMove": [ "JsonConfig\\JCSingleton::onMovePageIsValidMove" ], diff --git a/i18n/en.json b/i18n/en.json index e4e452f..521ae5d 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -42,6 +42,7 @@ "jsonconfig-license": "Data available under $1", "jsonconfig-license-or-later": "$1, or (at your option) any later version", "jsonconfig-license-CC0-1.0": "Creative Commons Zero", + "jsonconfig-license-edit-CC0-1.0": "By saving changes, you agree to the [https://wikimediafoundation.org/wiki/Terms_of_Use Terms of Use], and you irrevocably agree to release your contribution to the public domain under [https://creativecommons.org/publicdomain/zero/1.0/ CC0].", "jsonconfig-license-url-CC0-1.0": "https://creativecommons.org/publicdomain/zero/1.0/;, "right-jsonconfig-flush": "Manipulate JsonConfig via API", "apihelp-jsonconfig-description": "Allows direct access to JsonConfig subsystem.", diff --git a/i18n/qqq.json b/i18n/qqq.json index c6aea8e..f8da2b5 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -50,6 +50,7 @@ "jsonconfig-license": "Shows license text prefix before giving the specific license.\n\nParameters:\n* $1 - * {{msg-mw|jsonconfig-license-or-later}} or {{msg-mw|jsonconfig-license-CC0-1.0}} or other similar license messages", "jsonconfig-license-or-later": "In case the data can be used with any future versions of a license, this string will be used instead of 'jsonconfig-license-*' message.\n\nParameters:\n* $1 - license name, as defined in the {{msg-mw|jsonconfig-license-CC0-1.0}} and similar messages", "jsonconfig-license-CC0-1.0": "Name of the license", + "jsonconfig-license-edit-CC0-1.0": "Wiki markup of the message to show instead of {{msg-mw|Wikimedia-copyrightwarning}}", "jsonconfig-license-url-CC0-1.0": "URL to the license description, localized if available", "right-jsonconfig-flush": "{{doc-right|jsonconfig-flush}}", "apihelp-jsonconfig-description": "{{doc-apihelp-description|jsonconfig}}", diff --git a/includes/JCSingleton.php b/includes/JCSingleton.php index 555b1fc..1b4efec 100644 --- a/includes/JCSingleton.php +++ b/includes/JCSingleton.php @@ -165,6 +165,7 @@ self::getConfVal( $store, 'notifyUrl', '' ); self::getConfVal( $store, 'notifyUsername', '' ); self::getConfVal( $store, 'notifyPassword', '' ); + self::getConfVal( $store, 'license', false ); } // Too lazy to write proper error messages for all parameters. @@ -667,6 +668,28 @@ } /** +* Override with per-page specific edit message +* +* @param Title $title +* @param string[] $msg +* +* @return bool +*/ + public static function onEditPageCopyrightWarning( $title, &$msg ) { + + if ( self::jsonConfigIsStorage() ) { + $jct = self::parseTitle( $title ); + if ( $jct && $jct->getConfig()->store && $jct->getConfig()->store->license ) { + $code = $jct->getConfig()->store->license; + $code = substr( $code, -1 ) === '+' ? substr( $code, 0, - 1 ) : $code; + $msg = [ 'jsonconfig-license-edit-' . $code ]; + return false; // Do not allow any other hook handler to override this + } + } + return true; + } + + /** * Adds CSS for pretty-printing configuration on NS_CONFIG pages. * @param \OutputPage &$out * @param \Skin &$skin -- To view, visit https://gerrit.wikimedia.org/r/325732