Re: QET-Element to SVG

Just for the record:

diff --git a/toSVG.sh b/toSVG.sh
index 98101ca..976a899 100755
--- a/toSVG.sh
+++ b/toSVG.sh
@@ -3,9 +3,9 @@
# scales QET - Element-files in the directory from where it was called and
# all sub-dirs by the factor given here:
 
-Skalierung="1.0"
-SkalierProg="/home/ich/Projekte/c_c++/QET_ElementScaler/QET_ElementScaler"
-
+Skalierung="5.0"
+#SkalierProg="/home/ich/Projekte/c_c++/QET_ElementScaler/QET_ElementScaler"
+SkalierProg="/home/laurent/Qet_scripts/qelectrotech-elements/QET_ElementScaler"
# to be able to process blanks in file names - remember original state:
OFS=$IFS
# set new:
@@ -16,7 +16,7 @@ for i in  `find . -name "*.elmt"` ; do
   echo "processing $i"
   # With the construct in curly brackets the file extension
   # is changed accordingly
-  "$SkalierProg" --toSVG -o "$i" > "${i%.elmt}.svg"
+  "$SkalierProg" --toSVG -o -F "$Skalierung" "$i" > "${i%.elmt}.svg"
   done
 
# blanks in filenames - back to original:
rsync -e ssh -av -W --delete-after --no-owner --no-g --chmod=g+w --progress  --exclude=''.*/ /home/laurent/Qet_scripts/qelectrotech-elements/qelectrotech-elements/  server:download.qelectrotech.org/qet/elements/
rsync -e ssh -av -W --delete-after --no-owner --no-g --chmod=g+w --progress --exclude='.*/'  /home/laurent/Qet_scripts/qelectrotech-element-contrib/qelectrotech-element-contrib/elements/   server:download.qelectrotech.org/qet/elements_contrib/

@plc-user: https://github.com/plc-user/QET_ElementScaler/pull/2

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

Re: QET-Element to SVG

Given a directory structure with QET elements and the SVG images derived from them.
Here is a script that goes through this directory structure and links all subdirectories and SVG files.
The links of the SVG files point to the corresponding QET element.

#!/bin/bash

# to be able to process blanks in file names - remember original state:
OFS=$IFS
# set new:
IFS="
"

BaseDir="elemente"

for d in `find $BaseDir -type d | sort`; do
  echo "processing directory $d"
  # html-Header:
  echo "<html><body>" > $d/index.html
  # Unterverzeichnisse auflisten:
  for sd in `find $d -maxdepth 1 -type d | sort`; do
    if [[ "$d" == "$sd" ]] ; then
      continue
    fi
    echo "sub-dir: $sd"
    echo "<a href=\"`basename $sd`/index.html\">`basename $sd`</a><br>" >> $d/index.html
  done
  # SVG-Dateien auflisten:
  for f in  `find $d -maxdepth 1 -name "*.svg" | sort` ; do
    echo "file: `basename $f`"
    svgdatei=`basename $f`
    elmtdatei="${svgdatei%.svg}.elmt"
    echo "<a href=\"$elmtdatei\">${svgdatei%.svg}<br> <img src=\"$svgdatei\" /></a><br>" >> $d/index.html
  done
  # html-Footer:
  echo "</body></html>" >> $d/index.html
  echo ""
done

# blanks in filenames - back to original:
IFS=$OFS
# DONE!

@Laurent:
In the context of writing the script, I noticed, that a scaling-factor of 5.0 will be in many cases too much!
But I will implement your idea of including the scaling-factor to the script on github!

Re: QET-Element to SVG

@plc-user:

good work, thanks plc-user. nomicons/wink
Preview on remote, example:
https://download.qelectrotech.org/qet/e … index.html

ps: I changed scale factor to 2.0 instead of 5.0.

Post's attachments

Attachment icon PHP5online -svg_converter.zip 34.48 kb, 28 downloads since 2023-12-26 

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

Re: QET-Element to SVG

Benchmark scripts on my Debian workstation
8340 elements dans 1110 categories (soit 9450 fichiers)

Clean my local git repository:

cd qelectrotech-elements/
git clean -d -x -f
cd ..

Convert *.elmt to *.SVG:

time ./toSVG.sh

real    0m55,232s

Add index.html pages in all directory:

time ./toHTMLsh

real    0m47,843s

Ssh sync to remote:

time rsync -e ssh -av -W --delete-after --no-owner --no-g --chmod=g+w --progress  --exclude='.*/' /home/laurent/Qet_scripts/qelectrotech-elements/qelectrotech-elements/  server:download.qelectrotech.org/qet/elements/

real    0m30,741s

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

Re: QET-Element to SVG

Added the back button to the parent directory, to make navigation easier.


<a href="../index.html">Parent Directory </a><br>
#!/bin/bash
 
# to be able to process blanks in file names - remember original state:
OFS=$IFS
# set new:
IFS="
"

 
BaseDir="qelectrotech-elements"
 
for d in `find $BaseDir -type d | sort`; do
  echo "processing directory $d"
  # html-Header:
  echo "<html><body>" > $d/index.html
  echo "<a href="../index.html">Parent Directory </a><br>"  > $d/index.html
  # Unterverzeichnisse auflisten:
  for sd in `find $d -maxdepth 1 -type d | sort`; do
    if [[ "$d" == "$sd" ]] ; then
      continue
    fi
    echo "sub-dir: $sd"
    echo "<a href=\"`basename $sd`/index.html\">`basename $sd`</a><br>" >> $d/index.html
  done
  # SVG-Dateien auflisten:
  for f in  `find $d -maxdepth 1 -name "*.svg" | sort` ; do
    echo "file: `basename $f`"
    svgdatei=`basename $f`
    elmtdatei="${svgdatei%.svg}.elmt"
    echo "<a href=\"$elmtdatei\">${svgdatei%.svg}<br> <img src=\"$svgdatei\" /></a><br>" >> $d/index.html
  done
  # html-Footer:
  echo "</body></html>" >> $d/index.html
  echo ""
done
 
# blanks in filenames - back to original:
IFS=$OFS
# DONE!

Edit: changed to

echo "<li><a href="../index.html">Parent Directory </a></li>"  > $d/index.html

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

Re: QET-Element to SVG

Added automatic download element file when you click on *.elmt link text.

- echo "<a href=\"$elmtdatei\">${svgdatei%.svg}<br> <img src=\"$svgdatei\" /></a><br>" >> $d/index.html
+echo "<a href=\"$elmtdatei\" download>${svgdatei%.svg}<br> <img src=\"$svgdatei\" /></a><br>" >> $d/index.html

Added return to history back button:

echo '<li><a href="../index.html">Parent Directory </a></li><br><br><li><button class="spectrum-Button spectrum-Button--sizeM spectrum-Button--cta svelte-1gv5n3y cd17fc8d794774a44aa5bbe652ad93894-dom" onclick="history.back()">Back return</button></li><br>'  > $d/index.html

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

82 (edited by plc-user 2023-12-31 13:40:53)

Re: QET-Element to SVG

So macht OpenSource Spaß: Jeder gibt einen Teil seines Wissens / seiner Erfahrung dazu!

-----

This is how OpenSource is fun: Everyone contributes a part of their knowledge / experience!

Re: QET-Element to SVG

Just for record:

#!/bin/bash
 
# to be able to process blanks in file names - remember original state:
OFS=$IFS
# set new:
IFS="
"

 
BaseDir="qelectrotech-elements"
 
for d in `find $BaseDir -type d | sort`; do
  echo "processing directory $d"
  # html-Header:
  echo "<html><body>" > $d/index.html
  echo '<li><a href="../index.html">&larr;  Parent Directory </a></li><br><li><button class="spectrum-Button spectrum-Button--sizeM spectrum-Button--cta svelte-1gv5n3y cd17fc8d794774a44aa5bbe652ad93894-dom" onclick="history.back()">Back return</button></li>'  >> $d/index.html
  # Unterverzeichnisse auflisten:
  for sd in `find $d -maxdepth 1 -type d | sort`; do
    if [[ "$d" == "$sd" ]] ; then
      continue
    fi
    echo "sub-dir: $sd"
    echo "<a href=\"`basename $sd`/index.html\">`basename $sd`</a><br>" >> $d/index.html
  done
  # SVG-Dateien auflisten:
  for f in  `find $d -maxdepth 1 -name "*.svg" | sort` ; do
    echo "file: `basename $f`"
    svgdatei=`basename $f`
    elmtdatei="${svgdatei%.svg}.elmt"
    echo "<a href=\"$elmtdatei\" download>${svgdatei%.svg}<br> <img src=\"$svgdatei\" /></a><br><br>" >> $d/index.html
  done
  # html-Footer:
  echo "<li><a href="../index.html">&larr;  Parent Directory </a></li><br><a href="#" class="btn btn-default">Back to top ↑</a>" >> $d/index.html
  echo "</body></html>" >> $d/index.html
  echo ""
done
 
# blanks in filenames - back to original:
IFS=$OFS
# DONE!

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

Re: QET-Element to SVG

Add a Scroll Back To Top Button.

#!/bin/bash
 
# to be able to process blanks in file names - remember original state:
OFS=$IFS
# set new:
IFS="
"

 
BaseDir="qelectrotech-elements"
 
for d in `find $BaseDir -type d | sort`; do
  echo "processing directory $d"
  # html-Header:
  echo '<!doctype html>
  <html>
<head>
<link href="/qet/to-top.css" rel='
stylesheet' type='text/css'>' > $d/index.html
  echo '<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.min.js"></script>'  >> $d/index.html
  echo '<script src="/qet/to-top.js"></script>'  >> $d/index.html
  echo '<li><a href="../index.html">&larr;  Parent Directory </a></li><br><li><button class="spectrum-Button spectrum-Button--sizeM spectrum-Button--cta svelte-1gv5n3y cd17fc8d794774a44aa5bbe652ad93894-dom" onclick="history.back()">Back return</button></li>'  >> $d/index.html
  # Unterverzeichnisse auflisten:
  for sd in `find $d -maxdepth 1 -type d | sort`; do
    if [[ "$d" == "$sd" ]] ; then
      continue
    fi
    echo "sub-dir: $sd"
    echo "<a href=\"`basename $sd`/index.html\">`basename $sd`</a><br>" >> $d/index.html
  done
  # SVG-Dateien auflisten:
  for f in  `find $d -maxdepth 1 -name "*.svg" | sort` ; do
    echo "file: `basename $f`"
    svgdatei=`basename $f`
    elmtdatei="${svgdatei%.svg}.elmt"
    echo "<a href=\"$elmtdatei\" download>${svgdatei%.svg}<br> <img src=\"$svgdatei\" /></a><br><br>" >> $d/index.html
  done
  # html-Footer:
  #echo "<li><a href="../index.html">&larr;  Parent Directory </a></li><br><a href="#" class="btn btn-default">Back to top ↑</a>" >> $d/index.html
  echo '<div id="scrollUp">
<a href="#top"><img src="/qet/to_top.png"/></a>
</div></body></html>'
>> $d/index.html
  echo ""
done
 
# blanks in filenames - back to original:
IFS=$OFS
# DONE!

If you have a website that has large pages, it may be useful to display a button to return to the top of the page.
It is a good idea to place the button at the bottom right.
The goal is that it is displayed once 200 pixels of page go down.

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

Re: QET-Element to SVG

Hello everybody!

In this post https://qelectrotech.org/forum/viewtopi … 380#p19380 I asked the forum participants to try out the elements they use most often and give feedback on whether they are OK.
After eight weeks of waiting, I am a little surprised:
There was no feedback on the elements!

That can mean two things:
No one has checked them or there is nothing wrong with them.

In German, we have a saying:
To say nothing is to agree!

So I'll just say that the elements that I automatically updated to the current version are fine! Nevertheless, I will not release the pull-request myself:
The "four-eyes principle" should still be applied in my opinion.

Best regards
  plc-user