Skip to content

Commit

Permalink
add minecraft.wiki to dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus-Rost committed Nov 4, 2023
1 parent 7bb14e0 commit b7ef99b
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 464 deletions.
8 changes: 8 additions & 0 deletions dashboard/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ const enabledOAuth2 = [
};
} )
];
if ( process.env['oauth_minecraft.wiki'] && process.env['oauth_minecraft.wiki_secret'] ) {
enabledOAuth2.unshift({
id: 'minecraft.wiki',
name: 'Minecraft Wiki',
url: 'https://minecraft.wiki/',
manage: 'https://minecraft.wiki/w/Special:OAuthManageMyGrants'
});
}
if ( process.env.oauth_telepedia && process.env.oauth_telepedia_secret ) {
enabledOAuth2.unshift({
id: 'telepedia',
Expand Down
9 changes: 4 additions & 5 deletions functions/parse_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,9 @@ export default function parse_page(lang, msg, content, embed, wiki, reaction, {n
embed.setThumbnail( wiki.toLink('Special:FilePath/' + response.body.parse.images[response.body.parse.images.length - 1]) );
}
else if ( embed.data.thumbnail?.url === thumbnail ) {
response.body.parse.images = response.body.parse.images.map( pageimage => pageimage.toString() );
let image = response.body.parse.images.find( pageimage => ( /\.(?:png|jpg|jpeg|gif)$/.test(pageimage.toLowerCase()) && pageimage.toLowerCase().includes( title.toLowerCase().replaceAll( ' ', wiki.spaceReplacement ?? '_' ) ) ) );
response.body.parse.images = response.body.parse.images.map( pageimage => pageimage.toString() ).filter( pageimage => /\.(?:png|jpg|jpeg|gif)$/.test(pageimage.toLowerCase()) );
let image = response.body.parse.images.find( pageimage => pageimage.toLowerCase().replace( /\.(?:png|jpg|jpeg|gif)$/, '' ) === title.toLowerCase().replaceAll( ' ', wiki.spaceReplacement ?? '_' ) );
if ( !image ) image = response.body.parse.images.find( pageimage => pageimage.toLowerCase().includes( title.toLowerCase().replaceAll( ' ', wiki.spaceReplacement ?? '_' ) ) );
if ( !image ) {
let first = $(infoboxList.join(', ')).find('img').filter( (i, img) => {
let imgURL = ( img.attribs.src?.startsWith?.( 'data:' ) ? img.attribs['data-src'] : img.attribs.src );
Expand All @@ -431,9 +432,7 @@ export default function parse_page(lang, msg, content, embed, wiki, reaction, {n
if ( first.attr('data-image-name')?.toLowerCase().endsWith( '.gif' ) ) image = first.attr('data-image-name');
else thumbnail = ( first.attr('src')?.startsWith?.( 'data:' ) ? first.attr('data-src') : first.prop('src') );
}
else image = response.body.parse.images.find( pageimage => {
return /\.(?:png|jpg|jpeg|gif)$/.test(pageimage.toLowerCase());
} );
else image = response.body.parse.images[0];
}
if ( image ) thumbnail = wiki.toLink('Special:FilePath/' + image);
if ( thumbnail ) {
Expand Down
Loading

0 comments on commit b7ef99b

Please sign in to comment.