Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
feat:add ShowAvatar
Browse files Browse the repository at this point in the history
  • Loading branch information
ZoruaFox committed Sep 19, 2023
1 parent d648fa3 commit cd94f04
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Gadgets/Appearance/ShowAvatar/.options
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ShowAvatar[ResourceLoader|default|type=general|dependencies=mediawiki.Uri]|ShowAvatar.js|ShowAvatar.css
55 changes: 55 additions & 0 deletions src/Gadgets/Appearance/ShowAvatar/ShowAvatar.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* SPDX-License-Identifier: GPL-3.0
* _addText: '{{Gadget Header|license=GPL-3.0}}'
*
* @source <https://github.com/TopRealm/InterfaceCodes/tree/master/src/Gadgets/Appearance/ShowAvatar.css>
*/
/**
* +--------------------------------------------------------+
* | === WARNING: GLOBAL GADGET FILE === |
* +--------------------------------------------------------+
* | All changes should be made in the repository, |
* | otherwise they will be lost. |
* +--------------------------------------------------------+
* | Changes to this page may affect many users. |
* | Please discuss changes at talk page before editing. |
* +--------------------------------------------------------+
*/
/* <nowiki> */
#p-personal li {
margin-top: 1em;
margin-bottom: 0.2em;
}

#pt-userpage {
background: none !important;
padding-left: 0 !important;
}

#pt-avatar {
margin-top: 0.25em !important;
margin-bottom: 0 !important;
}

#pt-avatar img {
width: 2.5em;
border-radius: 50%;
}

.skin-citizen #user-rootpage-avatar {
border-radius: 5px;
top: 8px;
position: relative;
}

.skin-gongbi #user-rootpage-avatar {
border-radius: 10px;
padding: 4px;
}

/* 1.28+ Echo fix */
#p-personal #pt-notifications-alert,
#p-personal #pt-notifications-notice {
margin-top: 0.8em;
}
/* </nowiki> */
48 changes: 48 additions & 0 deletions src/Gadgets/Appearance/ShowAvatar/ShowAvatar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* SPDX-License-Identifier: GPL-3.0
* _addText: '{{Gadget Header|license=GPL-3.0}}'
*
* @source <https://github.com/TopRealm/InterfaceCodes/tree/master/src/Gadgets/Appearance/ShowAvatar.js>
*/
/**
* +--------------------------------------------------------+
* | === WARNING: GLOBAL GADGET FILE === |
* +--------------------------------------------------------+
* | All changes should be made in the repository, |
* | otherwise they will be lost. |
* +--------------------------------------------------------+
* | Changes to this page may affect many users. |
* | Please discuss changes at talk page before editing. |
* +--------------------------------------------------------+
*/
/* <nowiki> */
"use strict";
$(function () {
var avatarUrl = new mw.Uri("https://wiki.zorua.top/");
avatarUrl.query.user = mw.config.get("wgPageName").replace(/^user:/i, "");
avatarUrl.path = "/extensions/Avatar/avatar.php";
var imgUrl = new mw.Uri(avatarUrl);
imgUrl.query.user = mw.config.get("wgUserName");
var img = $("<img>").attr({
src: imgUrl,
title: "上传头像",
});
var link = $("<a>").attr("href", "https://wiki.zorua.top/wiki/Special:UploadAvatar").append(img);
$("#pt-userpage").before($('<li id="pt-avatar"></li>').append(link));
if (mw.config.get("wgNamespaceNumber") === 2 && !mw.config.get("wgPageName").includes("/")) {
var hrefUrl = new mw.Uri(avatarUrl);
hrefUrl.path = "/Special:Viewavatar";
var srcUrl = new mw.Uri(avatarUrl);
$(".ns-2 #firstHeading").prepend($("<a/>").attr({
href: hrefUrl,
title: "查看头像",
}).prepend($("<img/>").attr({
src: srcUrl,
id: "user-rootpage-avatar",
}).css({
width: "1.2em",
height: "1.2em",
})));
}
});
/* </nowiki> */

0 comments on commit cd94f04

Please sign in to comment.