Remove deprecated icons code

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling
2023-08-11 13:46:06 +02:00
parent db018a6d30
commit 37ec5cb1e0
6 changed files with 18 additions and 1362 deletions

View File

@ -13,7 +13,7 @@ user-manual-html:
cd user_manual && make html
@echo "User manual build finished; HTML is updated"
developer-manual-html: openapi-spec # icons-docs
developer-manual-html: openapi-spec
rm -rf developer_manual/_build/html/com
cd developer_manual && make html
@echo "Developer manual build finished; HTML is updated"
@ -41,12 +41,5 @@ openapi-spec: get-server-sources
wget https://unpkg.com/@stoplight/elements@7.7.17/styles.min.css -O stoplight-elements.css
icons-docs: clean-icons-docs get-server-sources
cd build && composer install && composer update
cd build && php generateIconsDoc.php
clean: clean-icons-docs
clean:
rm -r admin_manual/_build developer_manual/_build user_manual/_build user_manual_de_/_build
clean-icons-docs:
rm -rf developer_manual/design/img/

View File

@ -9,10 +9,13 @@
],
"require": {
"juliushaertl/phpdoc-to-rst": "dev-php7.0",
"phpdocumentor/reflection": "dev-php7.0",
"leafo/scssphp": "dev-master"
"phpdocumentor/reflection": "dev-php7.0"
},
"config": {
"github-protocols": ["https"]
"github-protocols": ["https"],
"platform": {
"php": "7.4"
},
"sort-packages": true
}
}

View File

@ -1,165 +0,0 @@
<?php
/**
* @copyright Copyright (c) 2018 John Molakvoæ <skjnldsv@protonmail.com>
*
* @author John Molakvoæ <skjnldsv@protonmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
include __DIR__ . '/vendor/autoload.php';
use Leafo\ScssPhp\Compiler;
use Leafo\ScssPhp\Formatter\Crunched;
function command_exist($cmd) {
$return = shell_exec(sprintf("which %s", escapeshellarg($cmd)));
return !empty($return);
}
// You need svgexport to run this script
if (!command_exist('svgexport')) {
print("\n\nYou need svgexport to run this script. Please install it with `npm install svgexport -g`\n\n");
exit(1);
}
$sourceDirectory = __DIR__ . '/server';
$destinationDirectory = __DIR__ . '/../developer_manual/html_css_design/';
// Init scss compiler
$scss = new Compiler();
$scss->setImportPaths([
__DIR__ . '/server/core/css'
]);
// Continue after throw
$scss->setIgnoreErrors(true);
$scss->setFormatter(Crunched::class);
$compiledScss = $scss->compile(
'@import "variables.scss";' .
'@import "functions.scss";' .
// override the path generator function
'@function icon-color-path($icon, $dir, $color, $version: 1, $core: false) {
$color: remove-hash-from-color($color);
@if $core {
@return "/core/img/#{$dir}/#{$icon}";
} @else {
@return "/apps/#{$dir}/img/#{$icon}";
}
}'.
'@import "icons.scss";'
);
$icons = [];
$lines = explode('}', $compiledScss);
$reIcon = '/^\.(icon-[a-z-]+)/i';
$reUrl = '/url\(\"([a-z0-9-.\/]+)/i';
print("\nParsing icons... \n");
// get all icons and urls
foreach($lines as $line) {
if (preg_match($reIcon, $line, $matches)) {
$icon = $matches[1];
if (preg_match($reUrl, $line, $matches)) {
$icons[$icon] = $matches[1];
}
}
}
$count = count($icons);
print(" - $count icons found!\n");
print("\nFormating rst file and converting icons... \n");
// format rst
$rst = '';
foreach($icons as $class => $icon) {
/**
* removing unwanted path and removing last slash
* /core/img/actions/caret -> actions/caret
*/
$path = implode('/', array_slice(explode('/', $icon), 3, 2));
$inPath = $sourceDirectory . $icon . '.svg';
if (file_exists($inPath)) {
$isWhite = substr($class, -strlen('white')) === 'white';
if ($isWhite) {
$path .= '-white'; //adding white suffix
}
$outPath = $destinationDirectory . 'img/' . $path . '.png';
// filling the rst file
$rst .= ".. figure:: img/$path.*\n";
if ($isWhite) {
$rst .= " :class: white-icon\n";
}
$rst .= " :height: 32\n";
$rst .= " :width: 32\n\n";
$rst .= " $class\n\n";
// create directory
$dir = implode('/', array_slice(explode('/', $destinationDirectory . 'img/' . $path), 0, -1));
if (!file_exists($dir)) {
print(" - creating dir $dir \n");
mkdir($dir, 0777, true);
}
// ! can't use svg in rst
// copy original icon
// if (!@copy($sourceDirectory . $icon . '.svg', $destinationDirectory . 'img/' . $path . '.svg')) {
// print(' - error while copying ' . $sourceDirectory . $icon . '.svg' . "\n");
// }
// converting
if ($isWhite) {
exec("svgexport $sourceDirectory$icon.svg $outPath 64: '
circle:not([fill='none']),
rect:not([fill=\"none\"]),
path:not([fill=\"none\"]) {
fill: white;
}
circle[stroke],
rect[stroke],
path[stroke] {
stroke: white;
}
'");
} else {
exec("svgexport $sourceDirectory$icon.svg $outPath 64:");
}
} else {
print(" - error while converting $inPath\n");
}
}
print("\nWriting rst file... \n");
// write file
$file = fopen($destinationDirectory . 'icons.txt', 'w');
fwrite($file, $rst);
fclose($file);
print(" - done! \n");
// path = path.split('/')
// localpath = '/'.join(path[3:5])
// result += ".. figure:: img/" + localpath + ".*\n :height: 32\n :width: 32\n\n " + icon[1:] + "\n\n"
// os.system('inkscape -z img/' + localpath + '.svg -e img/' + localpath + '.png')

View File

@ -26,10 +26,11 @@ https://github.com/nextcloud/server/blob/master/core/css/variables.scss
.. _cssicons:
SCSS icon mixins
================
.. deprecated:: 25
Some SCSS mixins and functions are employed to add and manage SVG icons.
These functions need to be used to add the icons via background-image. They create a list of every icon used in Nextcloud and create an associated list of variables.

View File

@ -10,18 +10,23 @@ Icons
List of available icons
=======================
White icons only have a grey background on this documentation page for readability purposes.
.. deprecated:: 25
.. include:: icons.txt
The icons available in the core/img/ folder of the server are deprecated. You can use them at own risk.
Due to a change of the way the list is produced now on the server it can no longer be automatically turned into documentation.
.. _svgcolorapi:
Please use `Material design icons`_ instead.
.. _svgcolorapi:
Svg color api
=============
.. deprecated:: 25
The svg API is not supported anymore due to performance reasons.
Please use `Material design icons`_ instead.
Material design icons
=====================

File diff suppressed because it is too large Load Diff