-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin.rb
77 lines (60 loc) · 2.67 KB
/
plugin.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# name: discourse-mail-daily-summary
# about: Send a daily summary email.
# version: 0.12
# authors: Thomas Kalka
# url: https://www.github.com/thoka/discourse-mail-daily-summary
# meta_topic_id: 306214
# this is a fork of Joe Buhlig's discourse-mlm-daily-summary with additional features
# https://www.github.com/joebuhlig/discourse-mlm-daily-summary
enabled_site_setting :mail_daily_summary_enabled
DiscoursePluginRegistry.serialized_current_user_fields << "user_mlm_daily_summary_enabled"
require_relative "lib/discourse_mail_daily_summary/engine"
after_initialize do
require_relative "lib/discourse_mail_daily_summary/user_notifications_extension"
require_relative "app/jobs/regular/user_daily_summary_email"
require_relative "app/jobs/scheduled/enqueue_mail_daily_summary"
require_relative "app/helpers/mail_daily_summary_helper"
require_relative "lib/discourse_mail_daily_summary/email_controller_helper"
# TODO change name? this name is historical
User.register_custom_field_type("user_mlm_daily_summary_enabled", :boolean)
register_editable_user_custom_field :user_mlm_daily_summary_enabled
reloadable_patch do |plugin|
UserNotifications.prepend MailDailySummary::UserNotificationsExtension
UserNotifications.helper MailDailySummaryHelper
end
register_email_unsubscriber(
MailDailySummary::UNSUBSCRIBE,
EmailControllerHelper::MailDailySummaryUnsubscriber,
)
Email::Styles.register_plugin_style do |fragment|
@fragment = fragment
def style(selector, style = nil, dm = nil)
@fragment
.css(selector)
.each do |element|
element[:style] = style if style
element[:dm] = dm if dm
end
end
# .header style="padding:10px 10px;background-color:#ffffff"
# .daily-summary-header a "color:#006699;font-size:22px;text-decoration:none;"
style(".daily-summary-topic-list", dm: "header")
style(
".daily-summary",
"line-height:1.4;text-align:left;line-height:1.4;text-align:left;font-size:14px;font-family:Helvetica,Arial,sans-serif",
"text-color",
)
style(
".daily-summary-topic-header",
"-moz-hyphens:auto;-webkit-hyphens:auto;border-collapse:collapse!important;color:#0a0a0a;hyphens:auto;line-height:1.3;margin:0;padding:0;vertical-align:top;word-wrap:normal",
"text-color",
)
style(".daily-summary-topic-header h3", "padding: 20px 20px 10px; margin: 0", "text-color")
style(
".daily-summary-topic-content",
"border-left: 20px solid #eee; border-right: 20px solid #eee; border-bottom: 10px solid #eee; padding: 10px 10px;background: #fff",
"text-color",
)
style(".daily-summary-topic-content p", "font-size: 15px")
end
end