From bc9e9313046fe76fd0f515c7a4958023e17b6beb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Sun, 17 Mar 2013 01:24:52 +0100 Subject: [PATCH] site setting for category colors --- .../templates/modal/edit_category.js.handlebars | 4 ++-- .../discourse/views/modal/edit_category_view.js | 9 +++++++-- app/models/site_setting.rb | 2 ++ config/locales/server.en.yml | 2 ++ config/locales/server.fr.yml | 2 ++ 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/discourse/templates/modal/edit_category.js.handlebars b/app/assets/javascripts/discourse/templates/modal/edit_category.js.handlebars index 49fd5c47b87..4e4fb5e6f42 100644 --- a/app/assets/javascripts/discourse/templates/modal/edit_category.js.handlebars +++ b/app/assets/javascripts/discourse/templates/modal/edit_category.js.handlebars @@ -28,13 +28,13 @@
{{i18n category.background_color}}: #{{view Discourse.TextField valueBinding="view.category.color" placeholderKey="category.color_placeholder" maxlength="6"}} - {{view Discourse.ColorsView colorsBinding="view.predefinedColors" valueBinding="view.category.color"}} + {{view Discourse.ColorsView colorsBinding="view.backgroundColors" valueBinding="view.category.color"}}
{{i18n category.foreground_color}}: #{{view Discourse.TextField valueBinding="view.category.text_color" placeholderKey="category.color_placeholder" maxlength="6"}} - {{view Discourse.ColorsView colorsBinding="view.predefinedColors" valueBinding="view.category.text_color"}} + {{view Discourse.ColorsView colorsBinding="view.foregroundColors" valueBinding="view.category.text_color"}}
diff --git a/app/assets/javascripts/discourse/views/modal/edit_category_view.js b/app/assets/javascripts/discourse/views/modal/edit_category_view.js index d2e0935a630..422b01deecf 100644 --- a/app/assets/javascripts/discourse/views/modal/edit_category_view.js +++ b/app/assets/javascripts/discourse/views/modal/edit_category_view.js @@ -21,8 +21,13 @@ Discourse.EditCategoryView = Discourse.ModalBodyView.extend({ return "background-color: #" + (this.get('category.color')) + "; color: #" + (this.get('category.text_color')) + ";"; }).property('category.color', 'category.text_color'), - predefinedColors: ["FFFFFF", "000000", "AECFC6", "836953", "77DD77", "FFB347", "FDFD96", "536878", - "EC5800", "0096E0", "7C4848", "9AC932", "BA160C", "003366", "B19CD9", "E4717A"], + // background colors are available as a pipe-separated string + backgroundColors: (function() { + return Discourse.SiteSettings.category_colors.split("|").map(function(i) { return i.toUpperCase(); }); + }).property('Discourse.SiteSettings.category_colors'), + + // black & white only for foreground colors + foregroundColors: ['FFFFFF', '000000'], title: (function() { if (this.get('category.id')) return Em.String.i18n("category.edit_long"); diff --git a/app/models/site_setting.rb b/app/models/site_setting.rb index 08cc60afd54..6246a4a219d 100644 --- a/app/models/site_setting.rb +++ b/app/models/site_setting.rb @@ -36,6 +36,8 @@ class SiteSetting < ActiveRecord::Base client_setting(:version_checks, true) client_setting(:min_title_similar_length, 10) client_setting(:min_body_similar_length, 15) + # cf. https://github.com/discourse/discourse/pull/462#issuecomment-14991562 + client_setting(:category_colors, 'BF1E2E|F1592A|F7941D|9EB83B|3AB54A|12A89D|25AAE2|0E76BD|652D90|92278F|ED207B|8C6238|231F20|808281|B3B5B4|283890') # settings only available server side setting(:auto_track_topics_after, 300000) diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 63e51aec9cd..d1f9b160aba 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -415,6 +415,8 @@ en: min_title_similar_length: "The minimum length of a title before it will be checked for similar topics" min_body_similar_length: "The minimum length of a post's body before it will be checked for similar topics" + category_colors: "A pipe (|) separated list of hexadecimal color values allowed for categories" + notification_types: mentioned: "%{display_username} mentioned you in %{link}" liked: "%{display_username} liked your post in %{link}" diff --git a/config/locales/server.fr.yml b/config/locales/server.fr.yml index 403dfd37eca..9168a93fa0e 100644 --- a/config/locales/server.fr.yml +++ b/config/locales/server.fr.yml @@ -422,6 +422,8 @@ fr: min_title_similar_length: "La taille minimale du titre avant que l'on vérifie l'existence de discussions identiques" min_body_similar_length: "La taille minimale du message avant que l'on vérifie l'existence de discussions identiques" + category_colors: "Une liste de couleurs autorisées pour les catégories (au format hexadécimal, séparés par un |)" + notification_types: mentioned: "%{display_username} vous a mentionné dans %{link}" liked: "%{display_username} a aimé votre message dans %{link}"