From d73127b09e3be4b11a6e94737c2a05a8d2f826c1 Mon Sep 17 00:00:00 2001 From: afornerot Date: Tue, 29 Oct 2024 21:15:16 +0100 Subject: [PATCH] svg --- public/styles/css/style.css | 6 +- src/Controller/HomeController.php | 2 +- src/Entity/Category.php | 2 +- src/Service/sessionInit.php | 26 +++ templates/Home/home.html.twig | 272 ++++++++++++++++-------------- templates/Include/style.css.twig | 1 + 6 files changed, 180 insertions(+), 129 deletions(-) diff --git a/public/styles/css/style.css b/public/styles/css/style.css index 5465270..dfe3e7f 100644 --- a/public/styles/css/style.css +++ b/public/styles/css/style.css @@ -360,8 +360,10 @@ th.dt-center, td.dt-center { text-align: center; } } } -.grid-sizer { width: 10%; margin-bottom: 0%;float:left;} +.grid-sizer { width: 5%; margin-bottom: 0%;float:left;} .grid-item-size { width: 10%; margin-bottom: 0%;float:left;} +.grid-item-size-1 { width: 10%; margin-bottom: 0%;float:left;} +.grid-item-size-15 { width: 15%; margin-bottom: 0%;float:left;} .grid-item-size-2 { width: 20%; margin-bottom: 0%;float:left;} .grid-item-size-3 { width: 30%; margin-bottom: 0%;float:left;} .grid-item-size-4 { width: 40%; margin-bottom: 0%;float:left;} @@ -373,7 +375,7 @@ th.dt-center, td.dt-center { text-align: center; } .grid-item-full { width: 100%; margin-bottom: 0%; font-size:20px;float:left; } .grid-item-full h1 {margin: 0; border:none; padding: 20px 0px 0px 10px; } .gutter-sizer { width: 0%;float:left; } -.member{display:flex; flex-direction: column; align-items: center;} +.member{display:flex; flex-direction: column; align-items: center; background-color: var(--colorbgbodydarkdarker); border-radius:10px; padding:10px;} .member img{border-radius:100%;width:60px; height: 60px;} @media (max-width: 980px) { .grid-sizer { width: 10%; margin-bottom: 0%;} diff --git a/src/Controller/HomeController.php b/src/Controller/HomeController.php index 2ee9b98..9dc2a31 100755 --- a/src/Controller/HomeController.php +++ b/src/Controller/HomeController.php @@ -14,7 +14,7 @@ class HomeController extends AbstractController $em = $this->getDoctrine()->getManager(); $users = $em->getRepository("App:User")->findBy([],["pseudo"=>"ASC"]); - $illustrations = $em->getRepository("App:Illustration")->findAll(); + $illustrations = $em->getRepository("App:Illustration")->findBy([],["submittime"=>"DESC"]); $links = $em->getRepository("App:Link")->findBy(["user"=>null]); $webzines = $em->getRepository("App:Webzine")->findBy(["user"=>null], ['set' => 'ASC', 'order' => 'ASC']); diff --git a/src/Entity/Category.php b/src/Entity/Category.php index d4a9c68..f739745 100644 --- a/src/Entity/Category.php +++ b/src/Entity/Category.php @@ -73,7 +73,7 @@ class Category /** * @ORM\OneToMany(targetEntity="Illustration", mappedBy="category", cascade={"persist", "remove"}, orphanRemoval=true) - * @ORM\OrderBy({"id" = "DESC"}) + * @ORM\OrderBy({"submittime" = "DESC"}) */ private $illustrations; diff --git a/src/Service/sessionInit.php b/src/Service/sessionInit.php index feb95b5..66fa246 100644 --- a/src/Service/sessionInit.php +++ b/src/Service/sessionInit.php @@ -21,5 +21,31 @@ foreach($configs as $config) { $this->session->set($config->getKeyid(), strval($config->getValue())); } + + $this->session->set("colorbgbodydarkdarker",$this->adjustBrightness($this->session->get("colorbgbodydark"),-20)); } + + + public function adjustBrightness($hex, $steps) { + // Steps should be between -255 and 255. Negative = darker, positive = lighter + $steps = max(-255, min(255, $steps)); + + // Normalize into a six character long hex string + $hex = str_replace('#', '', $hex); + if (strlen($hex) == 3) { + $hex = str_repeat(substr($hex,0,1), 2).str_repeat(substr($hex,1,1), 2).str_repeat(substr($hex,2,1), 2); + } + + // Split into three parts: R, G and B + $color_parts = str_split($hex, 2); + $return = ''; + + foreach ($color_parts as $color) { + $color = hexdec($color); // Convert to decimal + $color = max(0,min(255,$color + $steps)); // Adjust color + $return .= str_pad(dechex($color), 2, '0', STR_PAD_LEFT); // Make two char hex code + } + + return "#".$return; + } } diff --git a/templates/Home/home.html.twig b/templates/Home/home.html.twig index 4b7f9e6..dce4b4e 100644 --- a/templates/Home/home.html.twig +++ b/templates/Home/home.html.twig @@ -29,47 +29,55 @@ {% block body %} +
+ -
- - -
- Membres  - Illustrations  - {% if not webzines is empty %} - Webzines  - {% endif %} - Liens  -
- -
- {% if app.user %} - - - - - {% if is_granted('ROLE_ADMIN') %} - - - - - - +
+ {% if users is not empty %} + Membres  {% endif %} - - - - {% else %} - - - - {% endif %} -
-
-
- -
+ {% if illustrations is not empty %} + Illustrations  + {% endif %} + + {% if not webzines is empty %} + Webzines  + {% endif %} + + {% if not links is empty %} + Liens  + {% endif %} +
+ +
+ {% if app.user %} + + + + + {% if is_granted('ROLE_ADMIN') %} + + + + + + + {% endif %} + + + + {% else %} + + + + {% endif %} +
+
+ +
+ +
@@ -117,9 +125,11 @@ {% endif %}
+
+
-

{{ (app.session.get("appname")) }}

+

{{ (app.session.get("appname")) }}

{% if not app.session.get("appsubname") is empty %} @@ -149,8 +159,13 @@
- Membres
- Illustrations
+ {% if not users is empty %} + Membres
+ {% endif %} + + {% if not illustrations is empty %} + Illustrations
+ {% endif %} {% if not webzines is empty %} Webzines
@@ -179,7 +194,9 @@
-
+

+ +
@@ -219,103 +236,107 @@
-
-

Membres

- - {% for user in users %} - - {% endfor %} -
+ {% if not users is empty %} +
+

Membres

+ + {% for user in users %} + + {% endfor %} +
+ {% endif %} -
-

Illustrations

+ {% if not illustrations is empty %} +
+

Illustrations

- {% for illustration in illustrations %} - {% set appthumbwidth=app.session.get("appthumbwidth") %} - {% set appthumbheight=app.session.get("appthumbheight") %} + {% for illustration in illustrations %} + {% set appthumbwidth=app.session.get("appthumbwidth") %} + {% set appthumbheight=app.session.get("appthumbheight") %} - {% if appthumbwidth==0 %} - {% set class="" %} - {% if loop.index < 40 %} - {% if loop.index == 1 %} - {% set class="grid-item-size-4" %} - {% elseif loop.index is divisible by(28) %} - {% set class="grid-item-size-4" %} - {% elseif loop.index is divisible by(7) %} - {% set class="grid-item-size-2" %} - {% elseif loop.index is divisible by(46) %} - {% set class="grid-item-size-4" %} - {% endif %} - {% elseif loop.index > 48 %} - {% if loop.index == 49 %} - {% set class="grid-item-size-4" %} - {% elseif (loop.index-49) is divisible by(28) %} - {% set class="grid-item-size-4" %} - {% elseif (loop.index-49) is divisible by(7) %} - {% set class="grid-item-size-2" %} + {% if appthumbwidth==0 %} + {% set class="" %} + {% if loop.index < 40 %} + {% if loop.index == 1 %} + {% set class="grid-item-size-4" %} + {% elseif loop.index is divisible by(28) %} + {% set class="grid-item-size-4" %} + {% elseif loop.index is divisible by(7) %} + {% set class="grid-item-size-2" %} + {% elseif loop.index is divisible by(46) %} + {% set class="grid-item-size-4" %} + {% endif %} + {% elseif loop.index > 48 %} + {% if loop.index == 49 %} + {% set class="grid-item-size-4" %} + {% elseif (loop.index-49) is divisible by(28) %} + {% set class="grid-item-size-4" %} + {% elseif (loop.index-49) is divisible by(7) %} + {% set class="grid-item-size-2" %} + {% endif %} {% endif %} + {% elseif appthumbwidth==1 %} {% set class="" %} + {% elseif appthumbwidth==2 %} {% set class="grid-item-size-2" %} {% endif %} - {% elseif appthumbwidth==1 %} {% set class="" %} - {% elseif appthumbwidth==2 %} {% set class="grid-item-size-2" %} - {% endif %} - {%if appthumbheight==0 %} - {% set class=class~" grid-item-size-square" %} - {% elseif appthumbheight==1 %} - {% set class=class~" grid-item-size-proportion" %} - {% else %} - {% set class=class~" grid-item-size-page" %} - {% endif %} + {%if appthumbheight==0 %} + {% set class=class~" grid-item-size-square" %} + {% elseif appthumbheight==1 %} + {% set class=class~" grid-item-size-proportion" %} + {% else %} + {% set class=class~" grid-item-size-page" %} + {% endif %} - {% set source="thumb_"~illustration.illustration %} - {% if appthumbheight!=0 %} - {% set source="thumbori_"~illustration.illustration %} - {% endif %} + {% set source="thumb_"~illustration.illustration %} + {% if appthumbheight!=0 %} + {% set source="thumbori_"~illustration.illustration %} + {% endif %} - -
-
-
- {% endfor %} -
+ +
+
+
+ {% endfor %} +
+ {% endif %} -
- {% if not webzines is empty %} -

Webzines

- {% endif %} + {% if not webzines is empty %} +
+

Webzines

- {% set setname="" %} - {% for webzine in webzines %} - {% if not webzine.webzinepages is empty %} - {% if setname!=webzine.set %} - {% if not webzine.set is empty %} -

{{webzine.set}}

+ {% set setname="" %} + {% for webzine in webzines %} + {% if not webzine.webzinepages is empty %} + {% if setname!=webzine.set %} + {% if not webzine.set is empty %} +

{{webzine.set}}

+ {% endif %} + {% set setname=webzine.set %} {% endif %} - {% set setname=webzine.set %} - {% endif %} - {% set page=webzine.webzinepages[0] %} - {% set source="thumbori_"~page.illustration %} - {% set class=" grid-item-size-2 grid-item-size-page" %} + {% set page=webzine.webzinepages[0] %} + {% set source="thumbori_"~page.illustration %} + {% set class=" grid-item-size-2 grid-item-size-page" %} - -
-
-
- {% endif %} - {% endfor %} -
+ +
+
+
+ {% endif %} + {% endfor %} +
+ {% endif %} -
- {% if not webzines is empty %} - + {% if not links is empty %} +
+
@@ -325,9 +346,10 @@ {{ link.name }} {% endfor %}
- {% endif %} -
+
+ {% endif %} +
diff --git a/templates/Include/style.css.twig b/templates/Include/style.css.twig index 149f5c3..29043a9 100644 --- a/templates/Include/style.css.twig +++ b/templates/Include/style.css.twig @@ -1,6 +1,7 @@ :root{ --colorbgbodylight: {{ app.session.get('colorbgbodylight')|raw }}; --colorbgbodydark: {{ app.session.get('colorbgbodydark')|raw }}; + --colorbgbodydarkdarker: {{ app.session.get('colorbgbodydarkdarker')|raw }}; --colorfttitlelight: {{ app.session.get('colorfttitlelight')|raw }}; --colorfttitledark: {{ app.session.get('colorfttitledark')|raw }}; --colorftbodylight: {{ app.session.get('colorftbodylight')|raw }};