-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): ✨ add last modified to sidebar
- Loading branch information
1 parent
4f7e3a4
commit 89b5ff1
Showing
10 changed files
with
133 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?php | ||
/** | ||
* Citizen - A responsive skin developed for the Star Citizen Wiki | ||
* | ||
* This file is part of Citizen. | ||
* | ||
* Citizen is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Citizen is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Citizen. If not, see <https://www.gnu.org/licenses/>. | ||
* | ||
* @file | ||
* @ingroup Skins | ||
*/ | ||
|
||
declare( strict_types=1 ); | ||
|
||
namespace MediaWiki\Skins\Citizen\Partials; | ||
|
||
/** | ||
* Based on SkinComponentLastModified.php in MediaWiki core | ||
* TODO: Use core instead when update to MW 1.43 | ||
*/ | ||
final class Sidebar extends Partial { | ||
/** @var Language */ | ||
private $language; | ||
|
||
/** @var string|null|false */ | ||
private $timestamp; | ||
|
||
/** | ||
* Get sidebar template data | ||
* | ||
* @param array $parentData | ||
* @return array html | ||
*/ | ||
public function getSidebarData( $parentData ): array { | ||
$data = [ | ||
'data-sidebar-lastmod' => $this->getLastModData() | ||
]; | ||
|
||
return $data; | ||
} | ||
|
||
/** | ||
* Build last modified template data | ||
* TODO: Use relative time instead (#700) | ||
* | ||
* @return array|null | ||
*/ | ||
private function getLastModData() { | ||
$skin = $this->skin; | ||
$out = $this->out; | ||
$user = $this->user; | ||
$title = $this->title; | ||
$language = $skin->getLanguage(); | ||
$timestamp = $out->getRevisionTimestamp(); | ||
|
||
if ( $timestamp ) { | ||
$d = $language->userDate( $timestamp, $user ); | ||
$t = $language->userTime( $timestamp, $user ); | ||
$s = ' ' . $skin->msg( 'lastmodifiedat', $d, $t )->parse(); | ||
} else { | ||
return; | ||
} | ||
|
||
$items = [ | ||
'id' => 'lm-time', | ||
'class' => 'mw-list-item', | ||
'array-links' => [ | ||
'array-attributes' => [ | ||
[ | ||
'key' => 'href', | ||
'value' => $title->getLocalURL( [ 'diff' => '' ] ) | ||
], | ||
[ | ||
'key' => 'title', | ||
'value' => $s | ||
], | ||
[ | ||
'key' => 'data-timestamp', | ||
'value' => wfTimestamp( TS_UNIX, $timestamp ) | ||
] | ||
], | ||
'icon' => 'history', | ||
'text' => sprintf( '%s - %s', $d, $t ) | ||
] | ||
]; | ||
|
||
return [ | ||
'id' => 'citizen-sidebar-lastmod', | ||
'label' => $skin->msg( 'citizen-page-info-lastmod' ), | ||
'array-list-items' => $items | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
.citizen-toc { | ||
--size-icon: 1rem; | ||
font-size: var( --font-size-small ); | ||
line-height: var( --line-height-xs ); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<span class="citizen-ui-icon mw-ui-icon-{{.}} mw-ui-icon-wikimedia-{{.}}"></span> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<a data-mw="interface"{{#array-attributes}} {{key}}="{{value}}"{{/array-attributes}}>{{! | ||
}}{{#icon}}{{>Icon}}{{/icon}}{{! | ||
}}<span>{{text}}</span>{{! | ||
}}</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<li id="{{id}}" class="{{class}}">{{! | ||
}}{{#array-links}}{{! | ||
}}{{>Link}}{{! | ||
}}{{/array-links}}{{! | ||
}}{{text}}{{! | ||
}}</li> |