-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add some sites --------- Co-authored-by: hxsf <i@hxsf.me> Co-authored-by: CzBiX <CzBiX@users.noreply.github.com>
- Loading branch information
1 parent
083b896
commit a28c31e
Showing
21 changed files
with
186 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* eslint-disable no-console */ | ||
import path from 'path' | ||
import fs from 'fs/promises' | ||
import { execSync } from 'child_process' | ||
|
||
const ICON_DIR = 'src/assets/site_icons' | ||
const ICON_SIZE = 48 | ||
|
||
function execShell(command) { | ||
const output = execSync(command) | ||
return output.toString().trim() | ||
} | ||
|
||
function isIconFile(iconPath) { | ||
const output = execShell(`file -b --mime-type ${iconPath}`) | ||
return output.includes('image/vnd.microsoft.icon') | ||
} | ||
|
||
function getIconIndex(iconPath) { | ||
const output = execShell(`magick identify -format "%s:%w\\n" ${iconPath}`) | ||
let lastIndex = 0 | ||
for (const line of output.split('\n')) { | ||
const [index, width] = line.split(':') | ||
const size = parseInt(width) | ||
if (size >= ICON_SIZE) { | ||
return index | ||
} | ||
|
||
lastIndex = index | ||
} | ||
|
||
return lastIndex | ||
} | ||
|
||
function convertIcon(iconPath, outputPath) { | ||
const iconIndex = getIconIndex(iconPath) | ||
execShell(`magick convert -thumbnail "${ICON_SIZE}x${ICON_SIZE}>" ${iconPath}[${iconIndex}] ${outputPath}`) | ||
} | ||
|
||
async function fixSiteIcon(name) { | ||
const iconPath = path.join(ICON_DIR, name) | ||
if (!isIconFile(iconPath)) { | ||
return | ||
} | ||
|
||
const tmpPath = path.join(ICON_DIR, '_tmp.ico') | ||
await fs.copyFile(iconPath, tmpPath) | ||
try { | ||
convertIcon(tmpPath, iconPath) | ||
} finally { | ||
await fs.unlink(tmpPath) | ||
} | ||
|
||
console.log(`Converted ${name}`) | ||
} | ||
|
||
async function main() { | ||
let files = [] | ||
if (process.argv.length > 2) { | ||
files = process.argv.slice(2) | ||
} else { | ||
files = await fs.readdir(ICON_DIR) | ||
} | ||
|
||
files = files.filter(name => { | ||
return name.endsWith('.png') | ||
}) | ||
|
||
for (const name of files) { | ||
await fixSiteIcon(name) | ||
} | ||
} | ||
|
||
main() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file renamed
BIN
+1.23 KB
src/assets/site_icons/hdhome.png → src/assets/site_icons/nexusphp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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