-
-
Notifications
You must be signed in to change notification settings - Fork 30
[harmony] Bug 1983391: Add a donation banner to the home page #156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
b08f5b4
c2e833d
f70d3a9
1caad2f
b828764
bba189b
67d1a76
1d1942c
02edf73
3a4c243
8d08751
a33d385
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # This Source Code Form is subject to the terms of the Mozilla Public | ||
| # License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| # file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
| # | ||
| # This Source Code Form is "Incompatible With Secondary Licenses", as | ||
| # defined by the Mozilla Public License, v. 2.0. | ||
|
|
||
| package Bugzilla::Config::Donation; | ||
|
|
||
| use 5.10.1; | ||
| use strict; | ||
| use warnings; | ||
|
|
||
| use Bugzilla::Config::Common; | ||
|
|
||
| our $sortkey = 175; | ||
|
|
||
| use constant get_param_list => ( | ||
| { | ||
| name => 'donation_banner_visibility', | ||
| type => 's', | ||
| choices => ['admins_only', 'end_users', 'disabled'], | ||
| default => 'admins_only', | ||
| checker => \&check_multi, | ||
| }, | ||
| ); | ||
|
|
||
| 1; | ||
|
|
||
| __END__ | ||
|
|
||
| =head1 NAME | ||
|
|
||
| Bugzilla::Config::Donation - Donation banner settings | ||
|
|
||
| =cut |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| # This Source Code Form is subject to the terms of the Mozilla Public | ||
| # License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| # file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
| # | ||
| # This Source Code Form is "Incompatible With Secondary Licenses", as | ||
| # defined by the Mozilla Public License, v. 2.0. | ||
|
|
||
| package Bugzilla::Donation; | ||
|
|
||
| use 5.10.1; | ||
| use strict; | ||
| use warnings; | ||
|
|
||
| use Bugzilla::Constants; | ||
| use Bugzilla::Token qw(issue_hash_token); | ||
|
|
||
| use DateTime; | ||
|
|
||
| use constant BANNER_URL => 'https://bugzilla.org/donate'; | ||
| use constant BANNER_MESSAGES => ( | ||
| 'Help us make Bugzilla better more often.', | ||
| 'A small donation helps keep Bugzilla moving forward.', | ||
| 'Support the people who keep Bugzilla running.', | ||
| 'Even a little funding helps Bugzilla improve more quickly.', | ||
| 'If Bugzilla helps your team, consider helping Bugzilla too.', | ||
| ); | ||
|
|
||
| sub get_banner { | ||
| my $user = Bugzilla->user; | ||
| return undef if !$user->id; | ||
|
|
||
| my $visibility = Bugzilla->params->{'donation_banner_visibility'} || 'admins_only'; | ||
| return undef if $visibility eq 'disabled'; | ||
| return undef if $visibility eq 'admins_only' && !$user->in_group('admin'); | ||
|
|
||
| my $settings = $user->settings; | ||
| my $pref = $settings->{'donate_banner_pref'}->{'value'}; | ||
| my $last_version = $settings->{'donate_banner_last_version'}->{'value'} || '0.0'; | ||
| my $next_date = $settings->{'donate_banner_reminder_date'}->{'value'} || '1970-01-01'; | ||
| my $current_version = BUGZILLA_VERSION; | ||
|
|
||
| my $show; | ||
| my $show_thanks = 0; | ||
| if ($pref eq 'next_upgrade') { | ||
| $show = ($last_version ne $current_version); | ||
| $show_thanks = $show | ||
| && $user->in_group('admin') | ||
| && $last_version ne '0' | ||
| && $last_version ne '0.0'; | ||
| } | ||
| elsif ($pref eq 'specific_date') { | ||
| my $today = DateTime->now(time_zone => Bugzilla->local_timezone)->ymd; | ||
| $show = ($next_date le $today); | ||
| } | ||
| else { | ||
| $show = 0; | ||
| } | ||
|
|
||
| return undef if !$show; | ||
|
|
||
| my @messages = BANNER_MESSAGES; | ||
| my $message = $messages[int(rand(@messages))]; | ||
|
|
||
| my $data = { | ||
| url => BANNER_URL, | ||
| message => $message, | ||
| show_thanks => $show_thanks, | ||
| visibility => $visibility, | ||
| settings_link => 'editparams.cgi?section=donation#donation_banner_visibility_desc', | ||
| token => issue_hash_token(['donation_banner']), | ||
| }; | ||
|
|
||
| if ($visibility eq 'admins_only') { | ||
| $data->{'visibility_note'} | ||
| = 'This message is only shown to logged-in users with admin privs.'; | ||
| } | ||
| elsif ($user->in_group('admin')) { | ||
| $data->{'visibility_note'} | ||
| = 'This message is visible to all logged-in users.'; | ||
| } | ||
|
|
||
| return $data; | ||
| } | ||
|
|
||
| sub set_banner_preference { | ||
| my ($action) = @_; | ||
| my $user = Bugzilla->user; | ||
| my $settings = $user->settings; | ||
|
|
||
| my $pref_setting = $settings->{'donate_banner_pref'}; | ||
| my $date_setting = $settings->{'donate_banner_reminder_date'}; | ||
| my $version_setting = $settings->{'donate_banner_last_version'}; | ||
| my $current_version = BUGZILLA_VERSION; | ||
|
|
||
| if ($action eq 'next_upgrade') { | ||
| $pref_setting->set('next_upgrade'); | ||
| $version_setting->set($current_version); | ||
| return 'index.cgi'; | ||
| } | ||
| if ($action eq 'week' || $action eq 'month') { | ||
| my $days = $action eq 'week' ? 7 : 30; | ||
| my $dt = DateTime->now(time_zone => Bugzilla->local_timezone); | ||
| $dt->add(days => $days); | ||
| $pref_setting->set('specific_date'); | ||
| $date_setting->set($dt->ymd); | ||
| $version_setting->set($current_version); | ||
| return 'index.cgi'; | ||
| } | ||
| if ($action eq 'never') { | ||
| $pref_setting->set('never'); | ||
| $version_setting->set($current_version); | ||
| return 'index.cgi'; | ||
| } | ||
| if ($action eq 'date') { | ||
| return 'userprefs.cgi?tab=donate'; | ||
| } | ||
|
|
||
| return 'index.cgi'; | ||
| } | ||
|
|
||
| 1; | ||
|
|
||
| __END__ | ||
| =head1 NAME | ||
| Bugzilla::Donation - Donation banner helpers | ||
| =cut |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1050,6 +1050,148 @@ input[type="radio"]:checked { | |
| color: var(--secondary-label-color); | ||
| } | ||
|
|
||
| .donation_banner { | ||
| border-color: rgba(var(--accent-color-green-1), 0.75); | ||
| color: var(--primary-text-color); | ||
| background: var(--primary-region-background-color); | ||
| box-shadow: var(--primary-region-box-shadow); | ||
| font-weight: normal; | ||
| } | ||
|
|
||
| .donation_banner_layout { | ||
| display: flex; | ||
| align-items: center; | ||
| gap: 1rem; | ||
| } | ||
|
|
||
| .donation_banner_image { | ||
| width: 110px; | ||
| height: 110px; | ||
| flex: 0 0 auto; | ||
| object-fit: contain; | ||
| object-position: center; | ||
| border: 1px dashed rgba(var(--accent-color-green-1), 0.7); | ||
| border-radius: 10px; | ||
| background: rgba(var(--accent-color-green-1), 0.08); | ||
| } | ||
|
|
||
| .donation_banner_content { | ||
| flex: 1 1 auto; | ||
| padding-top: 0.35rem; | ||
| } | ||
|
|
||
| .donation_banner_thanks { | ||
| margin: 0 0 0.5rem; | ||
| color: var(--primary-text-color); | ||
| font-weight: bold; | ||
| } | ||
|
|
||
| .donation_banner_message { | ||
| margin: 0 0 0.6rem; | ||
| color: var(--primary-text-color); | ||
| font-size: 1.08rem; | ||
| line-height: 1.45; | ||
| } | ||
|
|
||
| .donation_banner_cta_row { | ||
| margin: 0 0 0.75rem; | ||
| } | ||
|
|
||
| .donation_banner_cta { | ||
| display: inline-block; | ||
| padding: 0.55rem 1rem; | ||
| border: 1px solid rgb(var(--accent-color-green-1)); | ||
| border-radius: 5px; | ||
| background: rgb(var(--accent-color-green-1)); | ||
|
Comment on lines
+1103
to
+1105
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In dark mode, the contrast ratio is too low. We have two options:
I, personally, find option 1 more aesthitically more pleasing.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added a follow-up using your version 1 suggestion. |
||
| color: #fff !important; | ||
| text-decoration: none; | ||
| font-weight: bold; | ||
| font-size: 1rem; | ||
| } | ||
|
|
||
| .donation_banner_cta:hover { | ||
| border-color: rgb(var(--accent-color-green-1)); | ||
| background: rgba(var(--accent-color-green-1), 0.9); | ||
| text-decoration: none; | ||
| } | ||
|
|
||
| .donation_banner_form { | ||
| display: flex; | ||
| align-items: center; | ||
| flex-wrap: wrap; | ||
| gap: 0.5rem; | ||
| } | ||
|
|
||
| .donation_banner_label { | ||
| font-weight: bold; | ||
| } | ||
|
|
||
| .donation_banner_select { | ||
| min-width: 240px; | ||
| } | ||
|
|
||
| .donation_banner_submit { | ||
| padding: 0.35rem 0.8rem; | ||
| } | ||
|
|
||
| .donation_banner_submit:hover { | ||
| border-color: var(--hovered-secondary-button-border-color); | ||
| color: var(--hovered-secondary-button-foreground-color); | ||
| background: var(--hovered-secondary-button-background-color); | ||
| } | ||
|
|
||
| .donation_banner_form_subtle { | ||
| font-size: 0.9rem; | ||
| opacity: 0.9; | ||
| } | ||
|
|
||
| .donation_banner_form_subtle .donation_banner_label { | ||
| font-weight: normal; | ||
| color: var(--secondary-label-color); | ||
| } | ||
|
|
||
| .donation_banner_form_subtle .donation_banner_select { | ||
| min-width: 230px; | ||
| padding: 0.25rem 0.4rem; | ||
| font-size: 0.9rem; | ||
| } | ||
|
|
||
| .donation_banner_form_subtle .donation_banner_submit { | ||
| padding: 0.25rem 0.65rem; | ||
| font-size: 0.88rem; | ||
| } | ||
|
|
||
| @media (max-width: 720px) { | ||
| .donation_banner_layout { | ||
| align-items: flex-start; | ||
| } | ||
|
|
||
| .donation_banner_image { | ||
| width: 84px; | ||
| height: 84px; | ||
| } | ||
|
|
||
| .donation_banner_select { | ||
| min-width: 100%; | ||
| } | ||
| } | ||
|
|
||
| @media screen and (prefers-color-scheme: dark) { | ||
| .donation_banner { | ||
| border-color: rgb(var(--accent-color-lightgreen-1)); | ||
| background: rgba(var(--accent-color-lightgreen-1), 0.12); | ||
| } | ||
|
|
||
| .donation_banner_image { | ||
| border-color: rgba(var(--accent-color-lightgreen-1), 0.55); | ||
| background: rgba(var(--accent-color-lightgreen-1), 0.12); | ||
| } | ||
|
|
||
| .donation_banner_form_subtle { | ||
| opacity: 1; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Global header | ||
| */ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't look related to the banner addition to me?