Passed
Push — master ( 33ca92...23b088 )
by Ahmad
10:28
created

ThemesController   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 24
rs 10
c 1
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A index() 0 18 1
1
# frozen_string_literal: true
2
3
# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
4
#
5
# Copyright (c) 2018 BigBlueButton Inc. and by respective authors (see below).
6
#
7
# This program is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU Lesser General Public License as published by the Free Software
9
# Foundation; either version 3.0 of the License, or (at your option) any later
10
# version.
11
#
12
# BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14
# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
15
#
16
# You should have received a copy of the GNU Lesser General Public License along
17
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
18
19
class ThemesController < ApplicationController
20
  skip_before_action :block_unknown_hosts, :redirect_to_https, :maintenance_mode?, :migration_error?, :user_locale,
21
    :check_admin_password, :check_user_role
22
23
  # GET /primary
24
  def index
25
    color = @settings.get_value("Primary Color") || Rails.configuration.primary_color_default
26
    lighten_color = @settings.get_value("Primary Color Lighten") || Rails.configuration.primary_color_lighten_default
27
    darken_color = @settings.get_value("Primary Color Darken") || Rails.configuration.primary_color_darken_default
28
29
    file_name = Rails.root.join('lib', 'assets', '_primary_themes.scss')
30
    @file_contents = File.read(file_name)
31
32
    # Include the variables and covert scss file to css
33
    @compiled = SassC::Engine.new("$primary-color:#{color};" \
34
                                 "$primary-color-lighten:#{lighten_color};" \
35
                                 "$primary-color-darken:#{darken_color};" +
36
                                 @file_contents, syntax: :scss).render
37
38
    respond_to do |format|
39
      format.css { render body: @compiled }
40
    end
41
  end
42
end
43