changes to lcp-button and icon uploader
This commit is contained in:
@ -1,8 +1,21 @@
|
||||
<?php
|
||||
|
||||
// Path to the input JSON file
|
||||
$inputFile = 'material-icons-baseline.json';
|
||||
// Path to the output JSON file
|
||||
$outputFile = 'material-icons-baseline-unescaped.json';
|
||||
$outputFile = 'material-icons-baseline-unescaped-with-ids.json';
|
||||
|
||||
// Function to generate a MySQL-style UUID
|
||||
function generateUUID() {
|
||||
// Generates a version 4 UUID (random)
|
||||
return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
|
||||
mt_rand(0, 0xffff), mt_rand(0, 0xffff),
|
||||
mt_rand(0, 0xffff),
|
||||
mt_rand(0, 0x0fff) | 0x4000,
|
||||
mt_rand(0, 0x3fff) | 0x8000,
|
||||
mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
|
||||
);
|
||||
}
|
||||
|
||||
// Step 1: Load the JSON data
|
||||
$jsonData = file_get_contents($inputFile);
|
||||
@ -20,10 +33,13 @@ if ($data === null) {
|
||||
die("Error decoding the JSON data.");
|
||||
}
|
||||
|
||||
// Step 3: Iterate through each item and unescape the 'paths' key
|
||||
// Step 3: Iterate through each item and unescape the 'paths' key, and generate a new 'id'
|
||||
foreach ($data as &$icon) {
|
||||
// Unescape only HTML entities (without affecting forward slashes)
|
||||
$icon['paths'] = html_entity_decode($icon['paths'], ENT_QUOTES | ENT_HTML5);
|
||||
|
||||
// Generate a new MySQL-style UUID for each 'id'
|
||||
$icon['id'] = generateUUID();
|
||||
}
|
||||
|
||||
// Step 4: Encode the modified data back into JSON format
|
||||
@ -42,5 +58,6 @@ if (file_put_contents($outputFile, $newJsonData) === false) {
|
||||
die("Error saving the modified JSON data.");
|
||||
}
|
||||
|
||||
echo "Paths have been unescaped and saved to '$outputFile'.\n";
|
||||
echo "Paths have been unescaped, IDs have been added, and saved to '$outputFile'.\n";
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user