Skip to content

Commit

Permalink
feat(core): expand user page tagline and allow citizen-tagline to be …
Browse files Browse the repository at this point in the history
…parsed (#657)

* Add registration date to user tagline
* Add contribution link to edit count in user tagline
* Add gender to user tagline
* Allow `citizen-tagline` to be fully parsed

---------

Co-authored-by: alistair3149 <alistair3149@users.noreply.github.com>
  • Loading branch information
Dringsim and alistair3149 committed Jun 8, 2023
1 parent 8351aa5 commit 25d25e3
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 15 deletions.
11 changes: 11 additions & 0 deletions i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,24 @@
"citizen-search-empty-desc": "Type to start searching",
"citizen-search-noresults-title": "Uh oh! No results for $1",
"citizen-search-noresults-desc": "Maybe try the options below?",
"citizen-tagline": "-",
"citizen-tagline-ns-talk": "Discussion page of {{SUBJECTPAGENAME}}",
"citizen-tagline-ns-project": "Information about {{SITENAME}}",
"citizen-tagline-ns-file": "File on {{SITENAME}}",
"citizen-tagline-ns-mediawiki": "MediaWiki interface page",
"citizen-tagline-ns-template": "Template page",
"citizen-tagline-ns-help": "Help page",
"citizen-tagline-ns-category": "Category page",
"citizen-tagline-user-regdate": "Joined $1",
"citizen-pronouns-subjective-male": "He",
"citizen-pronouns-objective-male": "Him",
"citizen-pronouns-possessive-male": "His",
"citizen-pronouns-subjective-female": "She",
"citizen-pronouns-objective-female": "Her",
"citizen-pronouns-possessive-female": "Hers",
"citizen-pronouns-subjective-notknown": "They",
"citizen-pronouns-objective-notknown": "Them",
"citizen-pronouns-possessive-notknown": "Theirs",
"prefs-citizen-theme-label": "Theme",
"prefs-citizen-theme-option-auto": "Auto",
"prefs-citizen-theme-option-light": "Light",
Expand Down
11 changes: 11 additions & 0 deletions i18n/qqq.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,24 @@
"citizen-search-empty-desc": "Helper text in the search suggestion when there are no search query",
"citizen-search-noresults-title": "Title in the search suggestion when there are no search results",
"citizen-search-noresults-desc": "Description in the search suggestion when there are no search results",
"citizen-tagline": "{{notranslate}}\n\nTagline for Citizen skin only",
"citizen-tagline-ns-talk": "Tagline for pages in talk namespace",
"citizen-tagline-ns-project": "Tagline for pages in project namespace",
"citizen-tagline-ns-file": "Tagline for pages in file namespace",
"citizen-tagline-ns-mediawiki": "Tagline for pages in MediaWiki namespace",
"citizen-tagline-ns-template": "Tagline for pages in template namespace",
"citizen-tagline-ns-help": "Tagline for pages in help namespace",
"citizen-tagline-ns-category": "Tagline for pages in category namespace",
"citizen-tagline-user-regdate": "Label for registration date in taglines on userpages",
"citizen-pronouns-subjective-male": "Male subjective pronoun",
"citizen-pronouns-objective-male": "Male objective pronoun",
"citizen-pronouns-possessive-male": "Male possessive pronoun",
"citizen-pronouns-subjective-female": "Female subjective pronoun",
"citizen-pronouns-objective-female": "Female objective pronoun",
"citizen-pronouns-possessive-female": "Female possessive pronoun",
"citizen-pronouns-subjective-notknown": "Neutral subjective pronoun",
"citizen-pronouns-objective-notknown": "Neutral objective pronoun",
"citizen-pronouns-possessive-notknown": "Neutral possessive pronoun",
"prefs-citizen-theme-label": "Tooltip for the theme dropdown in Special:Preferences",
"prefs-citizen-theme-option-auto": "Label for the auto theme option",
"prefs-citizen-theme-option-light": "Label for the light theme option",
Expand Down
46 changes: 35 additions & 11 deletions includes/Partials/Tagline.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
namespace MediaWiki\Skins\Citizen\Partials;

use MediaWiki\MediaWikiServices;
use MWTimestamp;
use SpecialPage;
use Title;
use User;
use Wikimedia\IPUtils;
Expand Down Expand Up @@ -61,23 +63,26 @@ public function getTagline() {
$msg = $skin->msg( 'citizen-tagline-ns-' . strtolower( $namespaceText ) );
// Use custom message if exists
if ( !$msg->isDisabled() ) {
$tagline = $msg->text();
$tagline = $msg->parse();
} else {
if ( $title->isSpecialPage() ) {
// No tagline if special page
$tagline = '';
} elseif ( $title->isTalkPage() ) {
// Use generic talk page message if talk page
$tagline = $skin->msg( 'citizen-tagline-ns-talk' )->text();

} elseif ( $title->inNamespace( NS_USER ) && !$title->isSubpage() ) {
$tagline = $skin->msg( 'citizen-tagline-ns-talk' )->parse();
} elseif ( ( $title->inNamespace( NS_USER ) || ( defined( 'NS_USER_WIKI' ) && $title->inNamespace( NS_USER_WIKI ) ) || ( defined( 'NS_USER_WIKI' ) && $title->inNamespace( NS_USER_PROFILE ) ) ) && !$title->isSubpage() ) {
// Build user tagline if it is a top-level user page
$tagline = $this->buildUserTagline( $title );
} elseif ( !$skin->msg( 'citizen-tagline' )->isDisabled() ) {
$tagline = $skin->msg( 'citizen-tagline' )->parse();
} else {
// Fallback to site tagline
$tagline = $skin->msg( 'tagline' )->text();
}
}
} elseif ( !$skin->msg( 'citizen-tagline' )->isDisabled() ) {
$tagline = $skin->msg( 'citizen-tagline' )->parse();
} else {
$tagline = $skin->msg( 'tagline' )->text();
}
Expand Down Expand Up @@ -105,16 +110,35 @@ public function getTagline() {
private function buildUserTagline( $title ) {
$user = $this->buildPageUserObject( $title );
if ( $user ) {
$skin = $this->skin;
$tagline = '<div id="citizen-tagline-user">';
$editCount = $user->getEditCount();
$regDate = $user->getRegistration();
$gender = MediaWikiServices::getInstance()->getGenderCache()->getGenderOf( $user, __METHOD__ );

$msgGender = sprintf(
'%s / %s / %s',
$skin->msg( 'citizen-pronouns-subjective-' . $gender )->text(),
$skin->msg( 'citizen-pronouns-objective-' . $gender )->text(),
$skin->msg( 'citizen-pronouns-possessive-' . $gender )->text()
);

$tagline .= "<span id=\"citizen-tagline-user-gender\" data-user-gender=\"$gender\">$msgGender</span>";

if ( $editCount ) {
$skin = $this->skin;
// TODO: Figure out a waw to get registration duration,
// like Langauge::getHumanTimestamp()
//$registration = $user->getRegistration();
$msgEditCount = $skin->msg( 'usereditcount' )
->numParams( sprintf( '%s', number_format( $editCount, 0 ) ) );
return $msgEditCount;
$msgEditCount = $skin->msg( 'usereditcount' )->numParams( sprintf( '%s', number_format( $editCount, 0 ) ) );
$editCountHref = SpecialPage::getTitleFor( 'Contributions', $user )->getLocalURL();
$tagline .= "<span id=\"citizen-tagline-user-editcount\" data-user-editcount=\"$editCount\"><a href=\"$editCountHref\">$msgEditCount</a></span>";
}

if ( is_string( $regDate ) ) {
$regDateTs = wfTimestamp( TS_UNIX, $regDate );
$msgRegDate = $skin->msg( 'citizen-tagline-user-regdate', $skin->getLanguage()->userDate( new MWTimestamp( $regDate ), $skin->getUser() ), $user );
$tagline .= "<span id=\"citizen-tagline-user-regdate\" data-user-regdate=\"$regDateTs\">$msgRegDate</span>";
}

$tagline .= '</div>';
return $tagline;
}
return null;
}
Expand Down
15 changes: 13 additions & 2 deletions resources/skins.citizen.styles/skinning/interface-subtitle.less
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* Module: mediawiki.skinning.interface-subtitle
* Version: REL1_39
*
* Date: 2022-11-15
*/
* Date: 2023-06-06
*/

#siteSub {
display: block;
Expand All @@ -30,6 +30,17 @@
margin-top: ~'calc( var( --space-xs ) * -1 )';
}

#citizen-tagline-user > span::after {
content: "·";
margin: 0 var( --space-xxs );
-webkit-user-select: none;
user-select: none;
}

#citizen-tagline-user > span:last-child:after {
display: none;
}

span.subpages {
display: block;
}
4 changes: 2 additions & 2 deletions templates/ContentHeader.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
{{{html-title-heading--formatted}}}
{{>Indicators}}
</div>
<div id="siteSub">{{html-tagline}}</div>
<div id="siteSub">{{{html-tagline}}}</div>
<a href="#top" class="citizen-jumptotop" title="{{html-citizen-jumptotop}}"></a>
</div>
{{>PageTools}}
</header>
<div id="citizen-body-header-sticky-sentinel"></div>
<div id="citizen-body-header-sticky-sentinel"></div>

0 comments on commit 25d25e3

Please sign in to comment.