#8 [frontend] allow storing chroot logo into database
Merged 8 years ago by clime. Opened 8 years ago by praiskup.

@@ -303,6 +303,7 @@

  %%copr_frontend_design_filelist %design_files_list

  %%copr_frontend_design_generator %design_generator

  %%copr_frontend_static_files %static_files

+ %%copr_frontend_chroot_logodir %%copr_frontend_static_files/chroot_logodir

  EOF

  

  

@@ -0,0 +1,1 @@

+ ../centos_logo.png 

\ No newline at end of file

@@ -0,0 +1,1 @@

+ ../fedora_logo.png 

\ No newline at end of file

@@ -0,0 +1,1 @@

+ ../cauldron_logo.png 

\ No newline at end of file

@@ -1,1 +1,1 @@

- a{color:#2b64b4}a:hover,a:focus{color:#214d8b}.nav-tabs>li.active>a,.nav-tabs>li.active>a:hover,.nav-tabs>li.active{color:#214d8b}h3 a{color:#214d8b !important} 

\ No newline at end of file

+ a{color:#2b64b4}a:hover,a:focus{color:#214d8b}.nav-tabs>li.active>a,.nav-tabs>li.active>a:hover,.nav-tabs>li.active{color:#214d8b}h3 a{color:#214d8b !important}.btn-primary{background-color:#214d8b;background-image:linear-gradient(to bottom, #2b64b4 0, #214d8b 100%);border-color:#2b64b4}.btn-primary:hover{background-color:#558bd7;border-color:#558bd7} 

\ No newline at end of file

@@ -141,13 +141,11 @@

  {% endmacro %}

  

  {% macro chroot_to_os_logo(chroot) %}

-   {% if chroot.os_release == "fedora" %}

-     <img style="height:1.8em" src="{{ url_for('static', filename='fedora_logo.png') }}" /> Fedora {{chroot.os_version}}

-   {% elif chroot.os_release == "epel" %}

-     Epel for <img style="height:1.8em" src="{{ url_for('static', filename='centos_logo.png') }}" /> CentOS {{chroot.os_version}}

-   {% elif chroot.os_release == "mageia" %}

-     <img style="height:1.8em" src="{{ url_for('static', filename='cauldron_logo.png') }}" /> Mageia {{chroot.os_version}}

- 

+   {% if chroot.logo %}

+     <img style="height:1.8em" src="{{ url_for('static', filename="chroot_logodir/"+chroot.logo) }}" />

+   {% endif %}

+   {% if chroot.os_release == 'epel' %}

+     Epel for CentOS {{ chroot.os_version }}

    {% else %}

      {{ chroot.os_release | capitalize }} {{ chroot.os_version }}

    {% endif %}

@@ -2,7 +2,7 @@

  

  import os

  import time

- import os

+ import fnmatch

  import re

  import uuid

  import subprocess
@@ -313,12 +313,26 @@

              name=chroot_rpms_dl_stat_key,

          )

  

+         logoset = set()

+         logodir = app.static_folder + "/chroot_logodir"

+         for logo in os.listdir(logodir):

+             # glob.glob() uses listdir() and fnmatch anyways

+             if fnmatch.fnmatch(logo, "*.png"):

+                 logoset.add(logo.strip(".png"))

+ 

          if chroot.name_release not in repos_info:

+             logo = None

+             if chroot.name_release in logoset:

+                 logo = chroot.name_release + ".png"

+             elif chroot.os_release in logoset:

+                 logo = chroot.os_release + ".png"

+ 

              repos_info[chroot.name_release] = {

                  "name_release": chroot.name_release,

                  "name_release_human": chroot.name_release_human,

                  "os_release": chroot.os_release,

                  "os_version": chroot.os_version,

+                 "logo": logo,

                  "arch_list": [chroot.arch],

                  "repo_file": "{}-{}.repo".format(copr.repo_id, chroot.name_release),

                  "dl_stat": repo_dl_stat[chroot.name_release],

@@ -27,8 +27,9 @@

  

  cat <<EOF | lessc -x - | tee $opt_static_files/css/style-overwrite.css

  @base: $opt_base_color;

+ @lighten: lighten(@base, 10%);

  a {

-     color: lighten(@base, 10%);

+     color: @lighten;

  }

  a:hover, a:focus {

      color: @base;
@@ -39,6 +40,17 @@

  h3 a {

      color: @base!important;

  }

+ 

+ .btn-primary {

+     background-color: @base;

+     background-image: linear-gradient(to bottom, @lighten 0px, @base 100%);

+     border-color: @lighten;

+ }

+ 

+ .btn-primary:hover {

+     background-color: lighten(@base, 25%);

+     border-color: lighten(@base, 25%);

+ }

  EOF

  

  lighten_base ()

Make the 'chroot icon' configurable per-chroot (useful for not completely free icons).

Why can't be the logo file named just according to chroot name (os.release)? That seems much more simple. We wouldn't need any db changes. So for chroot 'foo', the logo would be searched for under logos/foo.png.

Fair points, I've tried to think about it the same way, but:

  • currently the logo file-names are not according to chroot names ... it could be changed, but with respect to CentOS, we shouldn't name the file "epel_logo.png". So I was thinking about symlink, but ...
  • I didn't want to "check if file exists" in template to fallback into "chroot without logo"
  • I wanted to have a chance to set rhel-7.dev-x86_64 (and the rawhide alternative) a bit different icon than for rhel-7-x86_64, but this is minor point, truth.

Dunno, tell me what you prefer and I'll update accordingly ... the db field is optional, so I didn't pay too much attention to this change.

I think that requiring the design package to have some particular setting in db is not exactly what we want. There might be some minor drawbacks but I would, personally, prefer to go the pure "file" way, if possible.

rebased

8 years ago

Updated to "file" only way. There's os.listdir()(instead of stat()) used to minimize filesystem syscalls when rendering per page.

1 new commit added

  • [frontend] generate_colorscheme to fix buttons too
8 years ago

Pull-Request has been merged by clime

8 years ago