...
 
Commits (9)
......@@ -17,10 +17,10 @@ import { FeaturesService } from './services/features.service';
import { ThemeService } from './common/services/theme.service';
import { BannedService } from './modules/report/banned/banned.service';
import { DiagnosticsService } from './services/diagnostics.service';
import { SiteService } from './services/site.service';
import { PRO_DOMAIN_ROUTES, proRoutes } from './modules/pro/pro.module';
import { SiteService } from './common/services/site.service';
import { Subscription } from 'rxjs';
import { RouterHistoryService } from './common/services/router-history.service';
import { PRO_DOMAIN_ROUTES } from './modules/pro/pro.module';
@Component({
moduleId: module.id,
......@@ -72,32 +72,8 @@ export class Minds {
this.diagnostics.setUser(this.minds.user);
this.diagnostics.listen(); // Listen for user changes
if (this.site.isProDomain) {
if (!this.site.isProDomain) {
this.notificationService.getNotifications();
this.router$ = this.router.events.subscribe(
(navigationEvent: NavigationEnd) => {
try {
if (navigationEvent instanceof NavigationEnd) {
if (!navigationEvent.urlAfterRedirects) {
return;
}
let url = navigationEvent.url
.substring(1, navigationEvent.url.length)
.split('/')[0]
.split(';')[0]
.split('?')[0];
if (!this.searchRoutes(url, proRoutes)) {
window.open(window.Minds.site_url + url, '_blank');
}
}
} catch (e) {
console.error('Minds: router hook(SearchBar)', e);
}
}
);
}
this.session.isLoggedIn(async is => {
......@@ -146,16 +122,6 @@ export class Minds {
this.themeService.setUp();
}
private searchRoutes(url: string, routes: Array<string>): boolean {
for (let route of routes) {
if (route.includes(url)) {
return true;
}
}
return false;
}
ngOnDestroy() {
this.loginReferrer.unlisten();
this.scrollToTop.unlisten();
......
import { Cookie } from '../../services/cookie';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { environment } from '../../../environments/environment';
import { Location } from '@angular/common';
import { SiteService } from '../services/site.service';
/**
* API Class
*/
export class MindsHttpClient {
base: string = '/';
origin: string = '';
cookie: Cookie = new Cookie();
static _(http: HttpClient) {
return new MindsHttpClient(http);
static _(http: HttpClient, location: Location, site: SiteService) {
return new MindsHttpClient(http, location, site);
}
constructor(public http: HttpClient) {}
constructor(
public http: HttpClient,
public location: Location,
protected site: SiteService
) {
if (this.site.isProDomain) {
this.base = window.Minds.site_url;
this.origin = document.location.host;
}
}
/**
* Return a GET request
......@@ -61,21 +73,35 @@ export class MindsHttpClient {
.join('&');
}
x;
/**
* Build the options
*/
private buildOptions(options: Object) {
const XSRF_TOKEN = this.cookie.get('XSRF-TOKEN') || '';
const headers = new HttpHeaders({
const headers = {
'X-XSRF-TOKEN': XSRF_TOKEN,
'X-VERSION': environment.version,
});
};
if (this.origin) {
const PRO_XSRF_JWT = this.cookie.get('PRO-XSRF-JWT') || '';
headers['X-MINDS-ORIGIN'] = this.origin;
headers['X-PRO-XSRF-JWT'] = PRO_XSRF_JWT;
}
return Object.assign(options, {
headers: headers,
const builtOptions = {
headers: new HttpHeaders(headers),
cache: true,
});
};
if (this.origin) {
builtOptions['withCredentials'] = true;
}
return Object.assign(options, builtOptions);
}
}
......
......@@ -8,7 +8,7 @@ import {
} from '@angular/core';
import { Client } from '../../../services/api/client';
import { Storage } from '../../../services/storage';
import { SiteService } from '../../../services/site.service';
import { SiteService } from '../../services/site.service';
@Component({
selector: 'm-cookies-notice',
......
import { Injectable } from '@angular/core';
import { NavigationEnd, Router } from '@angular/router';
import { Subscription } from 'rxjs';
import { proRoutes } from '../../modules/pro/pro.routes';
@Injectable()
export class SiteService {
get pro() {
return window.Minds.pro;
}
get isProDomain(): boolean {
return Boolean(this.pro);
}
get title(): string {
return this.isProDomain ? this.pro.title || '' : 'Minds';
}
get oneLineHeadline(): string {
return this.isProDomain ? this.pro.one_line_headline || '' : '';
}
private router$: Subscription;
constructor(private router: Router) {
if (this.isProDomain) {
this.listen();
}
}
private listen() {
this.router$ = this.router.events.subscribe(
(navigationEvent: NavigationEnd) => {
try {
if (navigationEvent instanceof NavigationEnd) {
if (!navigationEvent.urlAfterRedirects) {
return;
}
let url = navigationEvent.url
.substring(1, navigationEvent.url.length)
.split('/')[0]
.split(';')[0]
.split('?')[0];
if (!this.searchRoutes(url, proRoutes)) {
window.open(window.Minds.site_url + url, '_blank');
}
}
} catch (e) {
console.error('Minds: router hook(SearchBar)', e);
}
}
);
}
private searchRoutes(url: string, routes: Array<string>): boolean {
for (let route of routes) {
if (route.includes(url)) {
return true;
}
}
return false;
}
}
......@@ -13,7 +13,7 @@ import { MindsChannelResponse } from '../../interfaces/responses';
import { ChannelComponent } from '../channels/channel.component';
import { ProChannelComponent } from '../pro/channel/channel.component';
import { Session } from '../../services/session';
import { SiteService } from '../../services/site.service';
import { SiteService } from '../../common/services/site.service';
import { FeaturesService } from '../../services/features.service';
@Component({
......@@ -112,7 +112,7 @@ export class ChannelContainerComponent implements OnInit, OnDestroy {
}
get isAdmin() {
return this.site.isAdmin;
return this.session.isAdmin();
}
get proEnabled() {
......
import { Component, EventEmitter, Input, NgZone, Output } from '@angular/core';
import { Component, EventEmitter, NgZone, Output } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { Client } from '../../../services/api';
import { Session } from '../../../services/session';
import { MindsUser } from '../../../interfaces/entities';
@Component({
moduleId: module.id,
......
......@@ -21,6 +21,7 @@ import { RouterHistoryService } from '../../../common/services/router-history.se
})
export class RegisterForm {
@Input() referrer: string;
@Input() parentId: string = '';
@Output() done: EventEmitter<any> = new EventEmitter();
......@@ -31,7 +32,6 @@ export class RegisterForm {
captcha: string;
takenUsername: boolean = false;
usernameValidationTimeout: any;
@Input() parentId: string = '';
showFbForm: boolean = false;
......
......@@ -22,7 +22,7 @@ import { AnalyticsService } from '../../../services/analytics';
import { MindsVideoComponent } from '../components/video/video.component';
import isMobileOrTablet from '../../../helpers/is-mobile-or-tablet';
import { ActivityService } from '../../../common/services/activity.service';
import { SiteService } from '../../../services/site.service';
import { SiteService } from '../../../common/services/site.service';
export type MediaModalParams = {
redirectUrl?: string;
......
......@@ -17,7 +17,7 @@ import { NotificationsComponent } from './notifications.component';
import { NotificationService } from './notification.service';
import { NotificationsToasterComponent } from './toaster.component';
import { SiteService } from '../../services/site.service';
import { SiteService } from '../../common/services/site.service';
@NgModule({
imports: [
......
......@@ -5,7 +5,7 @@ import { socketMock } from '../../../tests/socket-mock.spec';
import { fakeAsync, tick } from '@angular/core/testing';
import { mindsTitleMock } from '../../mocks/services/ux/minds-title.service.mock.spec';
import { MockService } from '../../utils/mock';
import { SiteService } from '../../services/site.service';
import { SiteService } from '../../common/services/site.service';
import { EventEmitter } from '@angular/core';
export let siteServiceMock = new (function() {
......
......@@ -4,7 +4,7 @@ import { SocketsService } from '../../services/sockets';
import { Session } from '../../services/session';
import { MindsTitle } from '../../services/ux/title';
import { Subscription, timer } from 'rxjs';
import { SiteService } from '../../services/site.service';
import { SiteService } from '../../common/services/site.service';
export class NotificationService {
socketSubscriptions: any = {
......
......@@ -22,7 +22,7 @@ import { SignupModalService } from '../../modals/signup/service';
import { OverlayModalService } from '../../../services/ux/overlay-modal';
import { OverlayModalComponent } from '../../../common/components/overlay-modal/overlay-modal.component';
import { SessionsStorageService } from '../../../services/session-storage.service';
import { SiteService } from '../../../services/site.service';
import { SiteService } from '../../../common/services/site.service';
@Component({
providers: [ProChannelService, OverlayModalService],
......
......@@ -9,7 +9,7 @@ import { Session } from '../../../services/session';
import { ActivatedRoute, Router } from '@angular/router';
import { WireCreatorComponent } from '../../wire/creator/creator.component';
import { SessionsStorageService } from '../../../services/session-storage.service';
import { SiteService } from '../../../services/site.service';
import { SiteService } from '../../../common/services/site.service';
import { BehaviorSubject, Subscription } from 'rxjs';
import { AnalyticsService } from '../../../services/analytics';
......
......@@ -2,7 +2,7 @@ import { Component } from '@angular/core';
import { ProChannelService } from '../channel.service';
import { Session } from '../../../../services/session';
import { AuthService } from '../../../../services/auth.service';
import { SiteService } from '../../../../services/site.service';
import { SiteService } from '../../../../common/services/site.service';
import {
getSocialProfileMeta,
socialProfileMeta,
......
......@@ -17,6 +17,14 @@ export class ProChannelLoginComponent {
redirectTo: string;
get settings() {
return this.service.currentChannel.pro_settings;
}
get referrer() {
return this.service.currentChannel.username;
}
constructor(
public session: Session,
public service: ProChannelService,
......@@ -39,14 +47,6 @@ export class ProChannelLoginComponent {
this.redirectTo = this.storage.get('redirect');
}
get settings() {
return this.service.currentChannel.pro_settings;
}
get referrer() {
return this.service.currentChannel.username;
}
registered() {
if (this.redirectTo) {
this.storage.destroy('redirect');
......
......@@ -10,7 +10,7 @@ import {
} from '@angular/core';
import { Router } from '@angular/router';
import { Session } from '../../../../services/session';
import { SiteService } from '../../../../services/site.service';
import { SiteService } from '../../../../common/services/site.service';
import { ProChannelService } from '../channel.service';
import { ProUnsubscribeModalComponent } from '../unsubscribe-modal/modal.component';
import { MindsUser } from '../../../../interfaces/entities';
......
......@@ -14,7 +14,7 @@ import { OverlayModalService } from '../../../../../services/ux/overlay-modal';
import { Router } from '@angular/router';
import { ProChannelService } from '../../channel.service';
import isMobile from '../../../../../helpers/is-mobile';
import { SiteService } from '../../../../../services/site.service';
import { SiteService } from '../../../../../common/services/site.service';
@Component({
selector: 'm-pro--channel-tile',
......
......@@ -23,17 +23,17 @@ import { ProUnsubscribeModalComponent } from './channel/unsubscribe-modal/modal.
import { ProCategoriesComponent } from './channel/categories/categories.component';
import { BlogView } from '../blogs/view/view';
import { MediaModalComponent } from '../media/modal/modal.component';
import { AuthModule } from '../auth/auth.module';
import { ProHamburgerMenu } from './channel/hamburger-menu/hamburger-menu.component';
import { SubscribeButtonComponent } from './channel/subscribe-button/subscribe-button.component';
import { SearchBoxComponent } from './channel/search-box/search-box.component';
import { ForgotPasswordComponent } from '../auth/forgot-password/forgot-password.component';
import { NewsfeedSingleComponent } from '../newsfeed/single/single.component';
import { MediaViewComponent } from '../media/view/view.component';
import { MediaEditComponent } from '../media/edit/edit.component';
import { BlogViewInfinite } from '../blogs/view/infinite';
import { BlogEdit } from '../blogs/edit/edit';
import { CanDeactivateGuardService } from '../../services/can-deactivate-guard';
import { ForgotPasswordComponent } from '../auth/forgot-password/forgot-password.component';
import { AuthModule } from '../auth/auth.module';
import { ProHamburgerMenu } from './channel/hamburger-menu/hamburger-menu.component';
import { SubscribeButtonComponent } from './channel/subscribe-button/subscribe-button.component';
import { SearchBoxComponent } from './channel/search-box/search-box.component';
const routes: Routes = [
{
......@@ -127,20 +127,6 @@ export const PRO_DOMAIN_ROUTES = [
},
];
export const proRoutes = [
'/feed',
'/images',
'/videos',
'/articles',
'/groups',
'/login',
'/forgot_password',
'/newsfeed',
'/media',
'/blog',
'/all',
];
@NgModule({
imports: [
NgCommonModule,
......
// used for route matching in SiteService
export const proRoutes = [
'/feed',
'/images',
'/videos',
'/articles',
'/groups',
'/login',
'/forgot_password',
'/newsfeed',
'/media',
'/blog',
'/all',
];
......@@ -10,7 +10,7 @@ import { Session } from '../../../services/session';
import { ActivatedRoute, Router } from '@angular/router';
import { MindsTitle } from '../../../services/ux/title';
import { Subscription } from 'rxjs';
import { SiteService } from '../../../services/site.service';
import { SiteService } from '../../../common/services/site.service';
@Component({
selector: 'm-pro--settings',
......@@ -50,7 +50,7 @@ export class ProSettingsComponent implements OnInit, OnDestroy {
ngOnInit() {
this.param$ = this.route.params.subscribe(params => {
if (this.site.isAdmin) {
if (this.session.isAdmin()) {
this.user = params['user'] || null;
}
......@@ -139,6 +139,6 @@ export class ProSettingsComponent implements OnInit, OnDestroy {
}
get isAdmin() {
return this.site.isAdmin;
return this.session.isAdmin();
}
}
import { Inject, Injectable } from '@angular/core';
import { NavigationEnd, Router } from '@angular/router';
import { Client } from './api/client';
import { SiteService } from './site.service';
import { SiteService } from '../common/services/site.service';
@Injectable()
export class AnalyticsService {
......
......@@ -2,7 +2,7 @@ import { Cookie } from '../cookie';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { environment } from '../../../environments/environment';
import { Location } from '@angular/common';
import { SiteService } from '../site.service';
import { SiteService } from '../../common/services/site.service';
/**
* API Class
......
import { Cookie } from '../cookie';
import { HttpClient } from '@angular/common/http';
import { SiteService } from '../site.service';
import { SiteService } from '../../common/services/site.service';
/**
* API Class
......
......@@ -43,7 +43,7 @@ import { FeedsService } from '../common/services/feeds.service';
import { ThemeService } from '../common/services/theme.service';
import { GlobalScrollService } from './ux/global-scroll.service';
import { AuthService } from './auth.service';
import { SiteService } from './site.service';
import { SiteService } from '../common/services/site.service';
import { SessionsStorageService } from './session-storage.service';
import { DiagnosticsService } from './diagnostics.service';
......
import { Injectable } from '@angular/core';
@Injectable()
export class SiteService {
get pro() {
return window.Minds.pro;
}
get isProDomain(): boolean {
return Boolean(this.pro);
}
get title(): string {
return this.isProDomain ? this.pro.title || '' : 'Minds';
}
get oneLineHeadline(): string {
return this.isProDomain ? this.pro.one_line_headline || '' : '';
}
get isAdmin(): boolean {
return window.Minds.Admin;
}
}
import { Title } from '@angular/platform-browser';
import { SiteService } from '../site.service';
import { SiteService } from '../../common/services/site.service';
export class MindsTitle {
private counter: number;
......@@ -13,7 +13,7 @@ export class MindsTitle {
constructor(public title: Title, protected site: SiteService) {
if (this.site.isProDomain) {
this.default_title = this.site.oneLineHeadline + ' | ' + this.site.title;
this.default_title = this.site.title + ' - ' + this.site.oneLineHeadline;
}
}
......