mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Use the header background color for a site in the digest email.
This commit is contained in:
parent
f06f8abedd
commit
ede8f22971
@ -39,6 +39,7 @@ class UserNotifications < ActionMailer::Base
|
|||||||
|
|
||||||
@site_name = SiteSetting.title
|
@site_name = SiteSetting.title
|
||||||
|
|
||||||
|
@header_color = ColorScheme.hex_for_name('header_background')
|
||||||
@last_seen_at = I18n.l(@user.last_seen_at || @user.created_at, format: :short)
|
@last_seen_at = I18n.l(@user.last_seen_at || @user.created_at, format: :short)
|
||||||
|
|
||||||
# A list of topics to show the user
|
# A list of topics to show the user
|
||||||
|
@ -60,6 +60,10 @@ class ColorScheme < ActiveRecord::Base
|
|||||||
new_color_scheme
|
new_color_scheme
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.hex_for_name(name)
|
||||||
|
# Can't use `where` here because base doesn't allow it
|
||||||
|
(enabled || base).colors.find {|c| c.name == name }.try(:hex)
|
||||||
|
end
|
||||||
|
|
||||||
def colors=(arr)
|
def colors=(arr)
|
||||||
@colors_by_name = nil
|
@colors_by_name = nil
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<table style="border: 1px solid #ddd;" cellspacing="0" cellpadding="0">
|
<table style="border: 1px solid #ddd;" cellspacing="0" cellpadding="0">
|
||||||
<tr>
|
<tr>
|
||||||
<td style="padding: 10px 10px; background-color: #eee;">
|
<td style="padding: 10px 10px; background-color: #<%= @header_color %>;">
|
||||||
<a href="<%= Discourse.base_url %>">
|
<a href="<%= Discourse.base_url %>">
|
||||||
<img src="<%= logo_url %>" style="max-height: 35px; min-height: 35px; height: 35px;" class='site-logo'></a>
|
<img src="<%= logo_url %>" style="max-height: 35px; min-height: 35px; height: 35px;" class='site-logo'></a>
|
||||||
</td>
|
</td>
|
||||||
|
@ -40,6 +40,16 @@ describe ColorScheme do
|
|||||||
second.hex.should == base_colors[:second_one]
|
second.hex.should == base_colors[:second_one]
|
||||||
third.hex.should == 'F00D33'
|
third.hex.should == 'F00D33'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "hex_for_name without anything enabled" do
|
||||||
|
it "returns nil for a missing attribute" do
|
||||||
|
described_class.hex_for_name('undefined').should be_nil
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns the base color for an attribute" do
|
||||||
|
described_class.hex_for_name('second_one').should == base_colors[:second_one]
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "destroy" do
|
describe "destroy" do
|
||||||
@ -59,8 +69,10 @@ describe ColorScheme do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "returns the enabled color scheme" do
|
it "returns the enabled color scheme" do
|
||||||
|
described_class.hex_for_name('$primary_background_color').should be_nil
|
||||||
c = described_class.create(valid_params.merge(enabled: true))
|
c = described_class.create(valid_params.merge(enabled: true))
|
||||||
described_class.enabled.id.should == c.id
|
described_class.enabled.id.should == c.id
|
||||||
|
described_class.hex_for_name('$primary_background_color').should == "FFBB00"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user