Skip to content

Commit afe370e

Browse files
authored
Merge pull request #646 from topcoder-platform/mfe-issues-9
MFE-issues-12: support target url for embedded Vanilla, MFE-issesu-11: hide guest block
2 parents 2abc79b + 4a1e168 commit afe370e

File tree

3 files changed

+51
-20
lines changed

3 files changed

+51
-20
lines changed

config/vanilla/config.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@
7171
$Configuration['Garden']['ForceInputFormatter'] = false;
7272
$Configuration['Garden']['Version'] = 'Undefined';
7373
$Configuration['Garden']['CanProcessImages'] = true;
74-
$Configuration['Garden']['Theme'] = 'topcoder';
74+
// Default Topcoder Theme
75+
//$Configuration['Garden']['Theme'] = 'topcoder';
76+
// MFE Topcoder Theme
77+
$Configuration['Garden']['Theme'] = 'mfe-topcoder';
7578
$Configuration['Garden']['MobileTheme'] = 'topcoder';
7679
$Configuration['Garden']['Profile']['EditPhotos'] = false;
7780
$Configuration['Garden']['SystemUserID'] = '1';

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/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)