From dae2c3ed8895b5fea60fe20530b3634e9c8a1ee6 Mon Sep 17 00:00:00 2001 From: Luciano Prestes Cavalcanti Date: Tue, 19 Jan 2016 11:44:38 +0000 Subject: [PATCH] Remove broken theme --- src/noosfero-spb/software_communities/lib/ext/theme.rb | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+), 0 deletions(-) create mode 100644 src/noosfero-spb/software_communities/lib/ext/theme.rb diff --git a/src/noosfero-spb/software_communities/lib/ext/theme.rb b/src/noosfero-spb/software_communities/lib/ext/theme.rb new file mode 100644 index 0000000..994fddc --- /dev/null +++ b/src/noosfero-spb/software_communities/lib/ext/theme.rb @@ -0,0 +1,29 @@ +require_dependency 'theme' + +class Theme + + class << self + def approved_themes(owner) + Dir.glob(File.join(system_themes_dir, '*')).map do |item| + next unless File.exists? File.join(item, 'theme.yml') + id = File.basename item + config = YAML.load_file File.join(item, 'theme.yml') + + approved = config['public'] + unless approved + begin + approved = owner.kind_of?(config['owner_type'].constantize) + rescue + end + approved &&= config['owner_id'] == owner.id if config['owner_id'].present? + end + + approved = false if id == 'cube-responsive' + + [id, config] if approved + end.compact.map do |id, config| + new id, config + end + end + end +end -- libgit2 0.21.2