Skip to content

Commit 248c6b6

Browse files
authored
Merge pull request #679 from topcoder-platform/develop
v1.9 - Self service app
2 parents 8734daf + a88f5ae commit 248c6b6

File tree

16 files changed

+982
-78
lines changed

16 files changed

+982
-78
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ RUN git clone --branch ${BRANCH} https://${CI_DEPLOY_TOKEN}@github.com/topcoder-
4545

4646
# Copy the forum-theme repository
4747
RUN git clone --branch ${BRANCH} https://${CI_DEPLOY_TOKEN}@github.com/topcoder-platform/forums-theme.git /vanillapp/themes/topcoder
48+
RUN git clone --branch mfe https://${CI_DEPLOY_TOKEN}@github.com/topcoder-platform/forums-theme.git /vanillapp/themes/mfe-topcoder
4849

4950
# Remove DebugPlugin from PROD env
5051
# RUN if [ "$ENV" = "prod" ]; \

config/vanilla/bootstrap.before.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,10 @@ function watchIcon($hasWatched = false, $title='') {
374374
* @return string
375375
*/
376376
function watchButton($category, $isHijackButton = true) {
377+
if(hideInMFE()){
378+
return '';
379+
}
380+
377381
$output = ' ';
378382
$userID = Gdn::session()->UserID;
379383
if(is_numeric($category)) {

config/vanilla/config.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
<?php if (!defined('APPLICATION')) exit();
22

33
$Configuration['Garden']['Installed'] = true;
4+
// Embed
5+
$Configuration['Garden']['Embed']['Allow'] = true;
6+
$Configuration['Garden']['Embed']['ForceForum'] = false;
7+
$Configuration['Garden']['Embed']['RemoteUrl'] = getenv('VANILLA_ENV') === 'prod'? 'https://platform.topcoder.com':'https://platform.topcoder-dev.com';
8+
// Trusted Domains. Specify one domain per line; use * for wildcard matches
9+
$Configuration['Garden']['TrustedDomains'] = '*.topcoder-dev.com
10+
*.topcoder.com';
411

512
$Configuration['Database']['Name'] = getenv('MYSQL_DATABASE');
613
$Configuration['Database']['Host'] = getenv('MYSQL_HOST');
@@ -68,6 +75,7 @@
6875
$Configuration['Garden']['ForceInputFormatter'] = false;
6976
$Configuration['Garden']['Version'] = 'Undefined';
7077
$Configuration['Garden']['CanProcessImages'] = true;
78+
// MFE Topcoder Theme 'mfe-topcoder'
7179
$Configuration['Garden']['Theme'] = 'topcoder';
7280
$Configuration['Garden']['MobileTheme'] = 'topcoder';
7381
$Configuration['Garden']['Profile']['EditPhotos'] = false;

vanilla/applications/dashboard/controllers/class.entrycontroller.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,16 @@ protected function checkOverride($type, $target, $transientKey = null) {
372372
throw new Exception("Unknown entry type $type.");
373373
}
374374

375-
$url = str_ireplace('{target}', rawurlencode(url($target, true)), $url);
375+
// FIX: micro-frontends-forums-app issues-12
376+
$isEmbedded = (bool) c('Garden.Embed.Allow',false);
377+
$remoteUrl = c("Garden.Embed.RemoteUrl");
378+
if($isEmbedded && is_string( $remoteUrl)) {
379+
$targetUrl = rawurlencode($remoteUrl.'/#'.url($target));
380+
} else {
381+
$targetUrl = rawurlencode(url($target, true));
382+
}
383+
384+
$url = str_ireplace('{target}', $targetUrl, $url);
376385

377386
if ($this->deliveryType() == DELIVERY_TYPE_ALL && strcasecmp($this->data('Method'), 'POST') != 0) {
378387
redirectTo(url($url, true), 302, false);
@@ -1019,7 +1028,16 @@ public function signOut($transientKey = "", $override = "0") {
10191028
$this->_setRedirect();
10201029
}
10211030

1022-
$target = url($this->target(), true);
1031+
// FIX: micro-frontends-forums-app issues-12
1032+
$isEmbedded = (bool) c('Garden.Embed.Allow',false);
1033+
$remoteUrl = c("Garden.Embed.RemoteUrl");
1034+
1035+
if($isEmbedded && is_string( $remoteUrl)) {
1036+
$target = rawurlencode($remoteUrl.'/#'.url($this->target()));
1037+
} else {
1038+
$target = url($this->target(), true);
1039+
}
1040+
10231041
if (!isTrustedDomain($target)) {
10241042
$target = Gdn::router()->getDestination('DefaultController');
10251043
}

vanilla/applications/dashboard/models/class.activitymodel.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,10 +1054,21 @@ public function email(&$activity, $options = []) {
10541054
$email->subject($subject);
10551055
$email->to($user);
10561056

1057-
$url = externalUrl(val('Route', $activity) == '' ? '/' : val('Route', $activity));
1057+
// FIX https://github.com/topcoder-platform/forums/issues/662
1058+
if($activity['Data']['EmailUrl']) {
1059+
$url = $activity['Data']['EmailUrl'];
1060+
} else {
1061+
$url = externalUrl(val('Route', $activity) == '' ? '/' : val('Route', $activity));
1062+
}
1063+
1064+
$emailTemplate = $email->getEmailTemplate();
1065+
// Set Custom Email View
1066+
if($activity['Data']['EmailTemplate']) {
1067+
$view = strval($activity['Data']['EmailTemplate']);
1068+
$emailTemplate->setView($view, 'email', 'dashboard');
1069+
}
10581070

1059-
$emailTemplate = $email->getEmailTemplate()
1060-
->setButton($url, val('ActionText', $activity, t('Check it out')))
1071+
$emailTemplate->setButton($url, val('ActionText', $activity, t('Check it out')))
10611072
->setTitle($subject);
10621073

10631074
if ($message = $this->getEmailMessage($activity)) {
@@ -1067,7 +1078,7 @@ public function email(&$activity, $options = []) {
10671078
$email->setEmailTemplate($emailTemplate);
10681079

10691080
// Fire an event for the notification.
1070-
$notification = ['ActivityID' => $activityID, 'User' => $user, 'Email' => $email, 'Route' => $activity['Route'], 'Story' => $activity['Story'], 'Headline' => $activity['Headline'], 'Activity' => $activity];
1081+
$notification = ['ActivityID' => $activityID, 'User' => $user, 'Email' => $email, 'EmailUrl'=>$url, 'Route' => $activity['Route'], 'Story' => $activity['Story'], 'Headline' => $activity['Headline'], 'Activity' => $activity];
10711082
$this->EventArguments = $notification;
10721083
$this->fireEvent('BeforeSendNotification');
10731084

@@ -1090,12 +1101,14 @@ public function email(&$activity, $options = []) {
10901101
}
10911102
}
10921103
} catch (phpmailerException $pex) {
1104+
logException($pex);
10931105
if ($pex->getCode() == PHPMailer::STOP_CRITICAL && !$email->PhpMailer->isServerError($pex)) {
10941106
$emailed = self::SENT_FAIL;
10951107
} else {
10961108
$emailed = self::SENT_ERROR;
10971109
}
10981110
} catch (Exception $ex) {
1111+
logException($ex);
10991112
switch ($ex->getCode()) {
11001113
case Gdn_Email::ERR_SKIPPED:
11011114
$emailed = self::SENT_SKIPPED;

vanilla/applications/dashboard/settings/class.hooks.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,8 @@ public function base_render_before($sender) {
254254
$sender->addJsFile('embed_local.js');
255255
}
256256
} else {
257-
$sender->setHeader('X-Frame-Options', 'SAMEORIGIN');
257+
// FIX: MFE-9 issue: add this header sporadically
258+
// $sender->setHeader('X-Frame-Options', 'SAMEORIGIN');
258259
}
259260

260261

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2+
<html xmlns="http://www.w3.org/1999/xhtml">
3+
<head>
4+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5+
<!--[if !mso]><!-->
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
7+
<!--<![endif]-->
8+
{literal}
9+
<style type="text/css">
10+
.notification {
11+
margin: 0 0;
12+
padding: 0 0;
13+
font-size: 10pt;
14+
font-weight: normal;
15+
font-style: normal;
16+
font-family: "\48\65\6C\76\65\74\69\63\61", "\41\72\69\61", sans-serif;
17+
}
18+
.notification hr {
19+
border-top: 1px dashed #8c8b8b;
20+
border-bottom: 1px dashed #fff;
21+
}
22+
23+
.notification table td {
24+
border-collapse: collapse;
25+
}
26+
27+
.notification td {
28+
margin-top: 0px;
29+
margin-right: 0px;
30+
margin-bottom: 0px;
31+
margin-left: 0px;
32+
}
33+
34+
.notification td img {
35+
display: block;
36+
}
37+
38+
.notification a {
39+
font-size: 10pt;
40+
text-decoration: underline;
41+
}
42+
43+
.notification a img {
44+
text-decoration: none;
45+
}
46+
47+
.notification h1, h2, h3, h4, h5, h6 {
48+
font-weight: normal;
49+
font-style: normal;
50+
font-family: "\48\65\6C\76\65\74\69\63\61", "\41\72\69\61", sans-serif;
51+
margin: 2px 0;
52+
padding: 4px 0;
53+
}
54+
55+
.notification h1 {
56+
font-size: 14pt;
57+
font-weight: 700;
58+
}
59+
60+
.notification h2 {
61+
font-size: 12pt;
62+
font-weight: 700;
63+
}
64+
65+
.notification h3 {
66+
font-size: 10pt;
67+
font-weight: 600;
68+
}
69+
70+
.notification h4 {
71+
font-size: 10pt;
72+
font-weight: 500;
73+
}
74+
75+
.notification h5 {
76+
font-size: 10pt;
77+
font-weight: 400;
78+
}
79+
80+
.notification h6 {
81+
font-size: 10pt;
82+
font-weight: 300;
83+
}
84+
85+
.notification blockquote {
86+
padding: 1ex 16px;
87+
margin: 1em 0;
88+
background: #f3f3f3;
89+
background: rgba(0, 0, 0, 0.05);
90+
border-left: 4px solid #eee;
91+
border-left: 4px solid rgba(0, 0, 0, 0.1);
92+
min-width: 200px;
93+
overflow-y: initial;
94+
}
95+
.notification code {
96+
padding: 5px 20px;
97+
display: block;
98+
background-color: #f7f7f7;
99+
}
100+
101+
.notification p, span {
102+
padding: 0 0;
103+
margin: 0;
104+
}
105+
.footer a {
106+
text-decoration: underline;
107+
}
108+
</style>
109+
{/literal}
110+
</head>
111+
<body style="margin: 0; padding: 0; background-color: {$email.backgroundColor} !important; color: {$email.textColor};">
112+
<center>
113+
<div class="notification" style="max-width: 600px;color: {$email.textColor};background-color: {$email.containerBackgroundColor}">
114+
<!--[if (gte mso 9)|(IE)]>
115+
<table width="600" align="center" cellpadding="0" cellspacing="0" border="0" style="color: {$email.textColor};background-color: {$email.containerBackgroundColor}">
116+
<tr>
117+
<td>
118+
<![endif]-->
119+
<table width="100%" border="0" cellpadding="5" cellspacing="0" style="margin: auto;color: {$email.textColor};background-color: {$email.containerBackgroundColor}">
120+
<tbody>
121+
<tr>
122+
<td align="left" style="padding-bottom:15px;">
123+
{if $email.image}
124+
<a href="https://www.topcoder.com/" rel=" noopener noreferrer"
125+
target="_blank">
126+
{if $email.image.link != ''}
127+
<img alt="Topcoder"
128+
border="0"
129+
src="{$email.image.source}"
130+
style="width:120px">
131+
{/if}
132+
</a>
133+
{/if}
134+
</td>
135+
<td align="right">
136+
</td>
137+
</tr>
138+
</tbody>
139+
</table>
140+
<!--[if (gte mso 9)|(IE)]>
141+
</td>
142+
</tr>
143+
</table>
144+
<![endif]-->
145+
<!--[if (gte mso 9)|(IE)]>
146+
<table width="600" align="center" cellpadding="0" cellspacing="0" border="0">
147+
<tr>
148+
<td>
149+
<![endif]-->
150+
<table class="content" width="100%" border="0" cellpadding="5" cellspacing="0" style="margin: auto;color: {$email.textColor};background-color: {$email.containerBackgroundColor}">
151+
<tbody>
152+
<tr>
153+
<td>
154+
<p class="message" style='margin: 0;Margin-bottom: 10px;padding: 0;color: {$email.textColor};text-align: left;margin-top: 10px;
155+
margin-bottom: 15px'>{$email.message}</p>
156+
{if $email.button}
157+
<div style="margin: 5px 0px;padding: 0;text-align: center">
158+
<a class="button" href="{$email.button.url}" style="font-size: 12px;
159+
border: 1px solid #137D60;min-width: 36px;background: #137D60;color: #FAFAFB;line-height: 30px;min-height: 30px;text-decoration: none;
160+
white-space: nowrap;text-align: center;font-weight: 700 !important;letter-spacing: .69px !important; text-transform: uppercase;
161+
border-radius: 20px !important; padding: 10px 20px !important;" rel=" noopener noreferrer" target="_blank">{$email.button.text}</a>
162+
</div>
163+
{/if}
164+
165+
</td>
166+
</tr>
167+
</tbody>
168+
</table>
169+
<!--[if (gte mso 9)|(IE)]>
170+
</td>
171+
</tr>
172+
</table>
173+
<![endif]-->
174+
</div>
175+
</center>
176+
</body>
177+
</html>

vanilla/applications/dashboard/views/modules/guest.php

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,40 @@
1-
<?php if (!defined('APPLICATION')) exit(); ?>
1+
<?php if (!defined('APPLICATION')) exit();
2+
3+
$isEmbedded = (bool) c('Garden.Embed.Allow',false);
4+
?>
25
<div class="Box GuestBox">
36
<h4><?php echo t('Welcome to Topcoder!'); ?></h4>
47

5-
<p><?php echo t($this->MessageCode, $this->MessageDefault); ?></p>
8+
<p><?php
9+
$message = $isEmbedded?
10+
"Looks like you are new or haven't signed in. Please use the \"Login\" link in the upper right to log into your account.": "Looks like you are new or aren't currently signed in." ;
11+
echo $message;
12+
?></p>
613

714
<p><?php $this->fireEvent('BeforeSignInButton'); ?></p>
815

916
<?php
17+
1018
$signInUrl = signInUrl($this->_Sender->SelfUrl);
1119

12-
if ($signInUrl) {
13-
echo '<div class="P">';
14-
echo anchor(t('Login'), signInUrl($this->_Sender->SelfUrl), 'Button Primary SignIn BigButton'.(signInPopup() ? ' SignInPopup' : ''), ['rel' => 'nofollow']);
15-
echo '</div>';
16-
}
20+
if(!$isEmbedded) {
21+
if ($signInUrl) {
22+
echo '<div class="P">';
23+
echo anchor(t('Login'), signInUrl($this->_Sender->SelfUrl), 'Button Primary SignIn BigButton'.(signInPopup() ? ' SignInPopup' : ''), ['rel' => 'nofollow']);
24+
echo '</div>';
25+
}
1726

18-
$Url = registerUrl($this->_Sender->SelfUrl);
19-
if (!empty($Url)) {
20-
?>
21-
<p class="SignUpBlock">
22-
<span>Don't have an account?</span>
23-
<?php
24-
echo anchor(t('SIGN UP').sprite('SpArrowRight'), $Url, 'Button SignUp', ['rel' => 'nofollow']);
25-
?>
26-
</p>
27-
<?php
27+
$Url = registerUrl($this->_Sender->SelfUrl);
28+
if (!empty($Url)) {
29+
?>
30+
<p class="SignUpBlock">
31+
<span>Don't have an account?</span>
32+
<?php
33+
echo anchor(t('SIGN UP').sprite('SpArrowRight'), $Url, 'Button SignUp', ['rel' => 'nofollow']);
34+
?>
35+
</p>
36+
<?php
37+
}
2838
}
2939

3040
?>

0 commit comments

Comments
 (0)