#7 [frontend] modularize design files
Merged 7 years ago by praiskup. Opened 7 years ago by praiskup.

file modified
+81 -1
@@ -5,6 +5,31 @@

  %global __python2 %{__python}

  %endif

  

+ # https://fedoraproject.org/wiki/Packaging:Guidelines#Packaging_of_Additional_RPM_Macros

+ %global macrosdir       %(d=%{_rpmconfigdir}/macros.d; [ -d $d ] || d=%{_sysconfdir}/rpm; echo $d)

+ 

+ 

+ %global design_files_list %_datadir/copr/copr-design-filelist

+ %global design_generator  %_datadir/copr/coprs_frontend/generate_colorscheme

+ %global static_files      %_datadir/copr/coprs_frontend/coprs/static

+ 

+ %global design_files                            \

+ %static_files/header_background.png             \

+ %static_files/favicon.ico                       \

+ %static_files/copr_logo.png                     \

+ %static_files/css/style-overwrite.css

+ 

+ %global devel_files \

+ %design_generator

+ 

+ %define exclude_files() %{lua:

+    macro = "%" .. rpm.expand("%1") .. "_files"

+    x = rpm.expand(macro)

+    for line in string.gmatch(x, "([^\\n]+)") do

+        print("%exclude " .. line .. "\\n")

+    end

+ }

+ 

  Name:       copr-frontend

  Version:    1.103

  Release:    1%{?dist}
@@ -61,6 +86,7 @@

  Requires:   python-marshmallow >= 2.0.0

  Requires:   python2-modulemd

  Requires:   python-pygments

+ Requires:   %{name}-design = %{version}

  

  # for tests:

  Requires:   pytest
@@ -189,6 +215,26 @@

  This package include documentation for COPR code. Mostly useful for developers

  only.

  

+ 

+ %package design

+ Summary: Template files for %{name}

+ Requires: %{name} = %{version}

+ 

+ %description design

+ Template files for %{name} (basically colors, logo, etc.).  This package is

+ designed to be replaced - build your replacement package against %{name}-devel

+ to produce compatible {name}-design package, then use man dnf.conf(5) 'priority'

+ option to prioritize your package against the default package we provide.

+ 

+ 

+ %package devel

+ Summary: Development files to build against %{name}

+ 

+ %description devel

+ Files which allow a build against %{name}, currently it's useful to build

+ custom %{name}-design package.

+ 

+ 

  %prep

  %setup -q

  
@@ -199,6 +245,7 @@

  COPR_CONFIG=../../documentation/copr-documentation.conf make %{?_smp_mflags} python

  popd

  

+ 

  %install

  install -d %{buildroot}%{_sysconfdir}/copr

  install -d %{buildroot}%{_datadir}/copr/coprs_frontend
@@ -232,9 +279,13 @@

  cp -a conf/logstash.conf %{buildroot}%{_sysconfdir}/logstash.d/copr_frontend.conf

  touch %{buildroot}%{_var}/log/copr-frontend/frontend.log

  

- 

  ln -fs /usr/share/copr/coprs_frontend/manage.py %{buildroot}/%{_bindir}/copr-frontend

  

+ mkdir -p %buildroot/$(dirname %design_files)

+ cat <<EOF > %buildroot%design_files_list

+ %design_files

+ EOF

+ 

  %check

  %if %{with check} && "%{_arch}" == "x86_64"

      pushd coprs_frontend
@@ -246,23 +297,36 @@

      popd

  %endif

  

+ mkdir -p %buildroot%macrosdir

+ cat <<EOF >%buildroot%macrosdir/macros.coprfrontend

+ %%copr_frontend_version %version

+ %%copr_frontend_design_filelist %design_files_list

+ %%copr_frontend_design_generator %design_generator

+ %%copr_frontend_static_files %static_files

+ EOF

+ 

+ 

  %pre

  getent group copr-fe >/dev/null || groupadd -r copr-fe

  getent passwd copr-fe >/dev/null || \

  useradd -r -g copr-fe -G copr-fe -d %{_datadir}/copr/coprs_frontend -s /bin/bash -c "COPR frontend user" copr-fe

  /usr/bin/passwd -l copr-fe >/dev/null

  

+ 

  %post

  service httpd condrestart

  service logstash condrestart

  %systemd_post copr-fedmsg-listener.service

  

+ 

  %preun

  %systemd_preun copr-fedmsg-listener.service

  

+ 

  %postun

  %systemd_postun_with_restart copr-fedmsg-listener.service

  

+ 

  %files

  %license LICENSE

  %doc coprs.conf.example
@@ -296,11 +360,27 @@

  %config(noreplace)  %{_sysconfdir}/copr/copr_unit_test.conf

  

  %config(noreplace) %attr(0755, root, root) %{_sysconfdir}/cron.hourly/copr-frontend

+ %exclude_files design

+ %exclude_files devel

+ 

+ 

+ %files design

+ %license LICENSE

+ %design_files

+ 

+ 

+ %files devel

+ %license LICENSE

+ %design_files_list

+ %devel_files

+ %macrosdir/*

+ 

  

  %files doc

  %license LICENSE

  %doc documentation/python-doc

  

+ 

  %changelog

  * Wed Sep 21 2016 clime <clime@redhat.com> 1.103-1

  - add migration to enable mageia chroots

@@ -6,10 +6,6 @@

    background-color: #eee;

  }

  

- h3 a {

-   color: #3d69a8!important;

- }

- 

  footer dt h3 {

    margin-top: 0px;

  }

@@ -0,0 +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

@@ -25,6 +25,7 @@

  

    <script src="{{ url_for('static', filename='copr.js') }}"></script>

    <link rel=stylesheet type=text/css href="{{ url_for('static', filename='copr.css') }}">

+   <link rel=stylesheet type=text/css href="{{ url_for('static', filename='css/style-overwrite.css') }}">

  </head>

  

  <body>

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

+ #! /bin/sh -x

+ 

+ opt_static_files=coprs_frontend/coprs/static

+ opt_base_color='#214d8b'

+ # opt_base_color='#900000' #  Red Hat Internal Copr

+ 

+ # We don't have to be too much careful when arg-parsing ..

+ while test $# -gt 0

+ do

+     case $1 in

+         --*)

+             opt=${1##--}

+             opt=${opt//-/_}

+             echo $opt

+             shift

+             eval opt_$opt=\$1

+             shift

+             ;;

+         *)

+             shift

+             continue

+             ;;

+     esac

+ done

+ 

+ mkdir -p "$opt_static_files/css"

+ 

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

+ @base: $opt_base_color;

+ a {

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

+ }

+ a:hover, a:focus {

+     color: @base;

+ }

+ .nav-tabs > li.active > a, .nav-tabs > li.active > a:hover, .nav-tabs > li.active {

+     color: @base;

+ }

+ h3 a {

+     color: @base!important;

+ }

+ EOF

+ 

+ lighten_base ()

+ {

+     lessc - <<EOF | grep unused-color | sed 's|.*unused-color: \(#.*\);.*|\1|'

+ @background_light: lighten($opt_base_color, 10%);

+ .unused-background-hack { unused-color: @background_light; };

+ EOF

+ }

+ 

+ convert -size 1x81 \

+     gradient:"$(lighten_base)"-"$opt_base_color" \

+     -define png:exclude-chunks=date,time \

+     $opt_static_files/header_background.png