Skip to content

Commit

Permalink
add site.less, for defining site-specific Less rules
Browse files Browse the repository at this point in the history
Admins can (either by hand, or in a separate RPM) overwrite the
site.less symlink to point at their own custom Less rules, which will be
included with Beaker's Less sources when generating CSS.

Ideally this would just be a config option of extra filenames which are
appended to the 'css' assets bundle. Unfortunately that doesn't work
because webassets compiles each Less source file separately, which
prevents the site Less rules from overriding or cross-referencing the
Beaker ones.

In future Less might support @import globs [1] which would allow us to
@import site rules from a defined directory. But until then we have to
do this ghost symlink hackery.

[1] less/less.js#1181

Bug: 1012224
Change-Id: I86f6d6987fd66988a46ec7372bbc3a249f015b46
  • Loading branch information
danc86 authored and Gerrit Code Review committed May 7, 2014
1 parent f377349 commit 9e30ed1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions Server/assets/site.less
5 changes: 5 additions & 0 deletions Server/assets/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,8 @@ input.tt-hint {
@import "reserve-workflow.less";
@import "job-matrix.less";
@import "system.less";

// Site-specific styles. The beaker-server package creates site.less as
// a symlink to /dev/null if it doesn't exist. Admins can overwrite the symlink
// to point at their own custom LESS instead.
@import "site.less";
2 changes: 2 additions & 0 deletions Server/bkr/server/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ def list_asset_sources(source_dir):
for bundle in env:
for path in get_all_bundle_files(bundle, env):
paths.append(os.path.relpath(path, source_dir))
# site.less should be skipped because it's a symlink
paths.remove('site.less')
# font-awesome is currently not managed by webassets because webassets
# breaks on non-UTF8 input files
paths.extend([
Expand Down
5 changes: 5 additions & 0 deletions beaker.spec
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,10 @@ chown root:root %{_localstatedir}/log/%{name}/*.log >/dev/null 2>&1 || :
chmod go-w %{_localstatedir}/log/%{name}/*.log >/dev/null 2>&1 || :
# Restart rsyslog so that it notices the config which we ship
/sbin/service rsyslog condrestart >/dev/null 2>&1 || :
# Create symlink for site.less (this is ghosted so that other packages can overwrite it)
if [ ! -f %{_datadir}/bkr/server/assets/site.less ] ; then
ln -s /dev/null %{_datadir}/bkr/server/assets/site.less || :
fi
%endif

%if %{with labcontroller}
Expand Down Expand Up @@ -469,6 +473,7 @@ rm -rf %{_var}/lib/beaker/osversion_data
%attr(-,apache,root) %dir %{_datadir}/bkr
%attr(-,apache,root) %{_datadir}/bkr/beaker-server.wsgi
%attr(-,apache,root) %{_datadir}/bkr/server
%ghost %attr(0777,root,root) %{_datadir}/bkr/server/assets/site.less
%attr(0660,apache,root) %config(noreplace) %{_sysconfdir}/%{name}/server.cfg
%dir %{_localstatedir}/log/%{name}
%dir %{_localstatedir}/cache/%{name}
Expand Down

0 comments on commit 9e30ed1

Please sign in to comment.