Skip to content

Commit

Permalink
GH-278 Dynamic application name
Browse files Browse the repository at this point in the history
  • Loading branch information
Zemke committed May 22, 2021
1 parent 7fdd2df commit f6b5e20
Show file tree
Hide file tree
Showing 13 changed files with 76 additions and 36 deletions.
3 changes: 3 additions & 0 deletions cwt-angular/src/main/webapp/app/_modules/shared.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {CommonModule} from "@angular/common";
import {StandingsOrderPipe} from "../_util/standings-order.pipe";
import {ReplayLinkPipe} from "../_util/replay-link.pipe";
import {EmailNote} from "../_util/email-note.pipe";
import {NameComponent} from "../_util/name.component";

@NgModule({
imports: [
Expand All @@ -32,6 +33,7 @@ import {EmailNote} from "../_util/email-note.pipe";
StandingsOrderPipe,
ReplayLinkPipe,
EmailNote,
NameComponent,
],
exports: [
MarkdownComponent,
Expand All @@ -43,6 +45,7 @@ import {EmailNote} from "../_util/email-note.pipe";
StandingsOrderPipe,
ReplayLinkPipe,
EmailNote,
NameComponent,
],
providers: [],
bootstrap: [],
Expand Down
8 changes: 6 additions & 2 deletions cwt-angular/src/main/webapp/app/_util/email-note.pipe.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import {Pipe, PipeTransform} from '@angular/core';
import {Pipe, PipeTransform, Inject} from '@angular/core';
import {APP_CONFIG, AppConfig} from "../app.config";

@Pipe({
name: 'cwtEmailNote'
})
export class EmailNote implements PipeTransform {

constructor(@Inject(APP_CONFIG) private appConfig: AppConfig) {
}

transform(_: null): string {
return `
We use this as a source of identification. You can reset your password with it if you happen to forget it, for
instance.<br>
In spite of that and if at all, we might send you an email once a year to inform you about the upcoming
edition of CWT.<br>
edition of ${this.appConfig.nameShort}.<br>
In case you forget your password you can get a new one sent to your email address. So you wouldn’t need to contact the support.
`
}
Expand Down
22 changes: 22 additions & 0 deletions cwt-angular/src/main/webapp/app/_util/name.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {Component, Input, Inject} from '@angular/core';
import {APP_CONFIG, AppConfig} from "../app.config";

@Component({
selector: 'cwt-name',
template: '<span class="text-nowrap">{{result}}</span>'
})
export class NameComponent {

@Input()
private short: boolean = false;

/**
* The name or short name.
*/
public result: string;

constructor(@Inject(APP_CONFIG) private appConfig: AppConfig) {
this.result = this.short === true ? this.appConfig.nameShort : this.appConfig.nameLong;
}
}

4 changes: 4 additions & 0 deletions cwt-angular/src/main/webapp/app/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export interface AppConfig {
liveStreamProducer: string;
liveStreamSubscriber: string;
twitchBotEndpoint: string;
nameShort: string;
nameLong: string;
}

export const appConfig: AppConfig = {
Expand All @@ -16,6 +18,8 @@ export const appConfig: AppConfig = {
liveStreamProducer: process.env.liveStreamProducer,
liveStreamSubscriber: process.env.liveStreamSubscriber,
twitchBotEndpoint: process.env.twitchBotEndpoint,
nameShort: process.env.nameShort,
nameLong: process.env.nameLong,
};

export const APP_CONFIG = new InjectionToken<AppConfig>('app.config');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ <h1>Applicants</h1>
{{applications.length}}
applicant{{applications.length === 1 ? '' : 's'}}
for the upcoming edition of
<span class="cwt-label"></span>.
<cwt-name></cwt-name>
</p>

<p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<h1>Apply</h1>

<p class="lead mb-4">
Apply for playing in the next edition of <span class="cwt-label"></span>.
Apply for playing in the next edition of <cwt-name></cwt-name>.
</p>

<cwt-markdown [raw]="rules" *ngIf="rules"></cwt-markdown>
Expand Down
2 changes: 1 addition & 1 deletion cwt-angular/src/main/webapp/app/home/home.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<cwt-apply-banner [userId]="authenticatedUser?.id" *ngIf="authenticatedUser && tournament" class="float-right"></cwt-apply-banner>

<h1 class="mb-1">
Crespo’s Worms Tournament
<cwt-name></cwt-name>
</h1>

<div class="position-relative">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</div>

<div class="alert alert-success" *ngIf="channelCreated">
Your channel has been successfully registered on CWT.
Your channel has been successfully registered on {{nameShort}}.
</div>

<div class="row justify-content-center" *ngIf="!userAlreadyHasChannel && !channelCreated">
Expand All @@ -23,28 +23,28 @@ <h1>
</p>
<div class="alert alert-info">
<p>
Register your channel to benefit from CWT and Twitch interoperation:
Register your channel to benefit from {{nameShort}} and Twitch interoperation:
</p>
<p>
When you go live a very visible banner will appear on the top
of the page advertising your live stream to the CWT visitors.
of the page advertising your live stream to the {{nameShort}} visitors.
</p>
<p>
Your live stream broadcasts will be linked to the respective game on the CWT site.<br>
Allowing for easy finding of broadcasts and later watching in the context of CWT.
Your live stream broadcasts will be linked to the respective game on the {{nameShort}} site.<br>
Allowing for easy finding of broadcasts and later watching in the context of {{nameShort}}.
</p>
<p>
You can schedule live streams on games participants of the tournament have scheduled
and thereby attract people early on.
</p>
<p>
These features will only trigger when you include “CWT” in the title of your live stream.<br>
Therefore your Twitch channel will not publish information on CWT if you also perform other
duties with your Twitch channel other than streaming CWT games.
These features will only trigger when you include “{{nameShort}}” in the title of your live stream.<br>
Therefore your Twitch channel will not publish information on {{nameShort}} if you also perform other
duties with your Twitch channel other than streaming {{nameShort}} games.
</p>
<p>
These features are all automated and work best when you include the players’ names as they
are on the CWT site in the title of your live stream.
are on the {{nameShort}} site in the title of your live stream.
</p>
</div>
<form class="mt-4" #channelForm=ngForm (ngSubmit)="submit()">
Expand All @@ -59,7 +59,7 @@ <h1>
<label for="title">Channel name</label>
<input type="text" id="title" required class="form-control" [(ngModel)]="channel.title" name="title" minlength="3" #channelTitle=ngModel>
<small class="form-text text-muted">
The name of your channel how it will appear throughout the CWT website.
The name of your channel how it will appear throughout the {{nameShort}} website.
</small>
<div class="text-danger" *ngIf="channelTitle.errors && channelTitle.dirty">
<div [hidden]="!channelTitle.errors.minlength">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ export class ChannelCreateComponent implements OnInit {
channelCreated: boolean = false;
authUser: JwtUser;
loading: boolean = true;
nameShort: string;

constructor(private requestService: RequestService, private authService: AuthService,
@Inject(APP_CONFIG) private appConfig: AppConfig) {
this.nameShort = this.appConfig.nameShort;
}

async ngOnInit() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,39 +1,47 @@
import {Component, Input} from "@angular/core";
import {Component, Input, Inject} from "@angular/core";
import {APP_CONFIG, AppConfig} from "../app.config";

@Component({
selector: 'cwt-channel-creation-statement',
template: `
<p *ngIf="includeRegisterSentence">
Register your channel to benefit from CWT and Twitch interoperation:
Register your channel to benefit from {{nameShort}} and Twitch interoperation:
</p>
<p>
When you go live a very visible banner will appear on the top
of the page advertising your live stream to the CWT visitors.
of the page advertising your live stream to the {{nameShort}} visitors.
</p>
<p>
Your live stream broadcasts will be linked to the respective game on the CWT site.<br>
Allowing for easy finding of broadcasts and later watching in the context of CWT.
Your live stream broadcasts will be linked to the respective game on the {{nameShort}} site.<br>
Allowing for easy finding of broadcasts and later watching in the context of {{nameShort}}.
</p>
<p>
You can schedule live streams on games participants of the tournament have scheduled
and thereby attract people early on.
</p>
<p>
There is a dedicated CWT Twitch chat bot which makes “beep boop” and has some nice commands
There is a dedicated {{nameShort}} Twitch chat bot which makes “beep boop” and has some nice commands
to enrich the live streaming experience for your viewers.
</p>
<p>
These features will only trigger when you include “CWT” in the title of your live stream.<br>
Therefore your Twitch channel will not publish information on CWT if you also perform other
duties with your Twitch channel other than streaming CWT games.
These features will only trigger when you include “{{nameShort}}” in the title of your live stream.<br>
Therefore your Twitch channel will not publish information on {{nameShort}} if you also perform other
duties with your Twitch channel other than streaming {{nameShort}} games.
</p>
<p>
These features are all automated and work best when you include the players’ names as they
are on the CWT site in the title of your live stream.
are on the {{nameShort}} site in the title of your live stream.
</p>
`
})
export class ChannelCreationStatementComponent {

@Input() includeRegisterSentence: boolean = true;

nameShort: string;

constructor(@Inject(APP_CONFIG) private appConfig: AppConfig) {
this.nameShort = this.appConfig.nameShort;
console.log(this.appConfig);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ <h2 class="mt-md-0">Twitch</h2>
<div class="alert alert-success">
<i class="fa fa-check"></i>&nbsp;
<strong>{{userChannel.displayName}}</strong>
is registered on CWT.
is registered on {{nameShort}}.
</div>
<div class="my-3 card bg-secondary">
<div class="card-body">
Expand All @@ -109,12 +109,12 @@ <h2 class="mt-md-0">Twitch</h2>
<button (click)="revokeBot()" class="btn btn-danger"
*ngIf="botInvited === true" [disabled]="togglingBotInvite">
<i class="fa fa-robot"></i>
Revoke CWT Bot
Revoke {{nameShort}} Bot
</button>
<button (click)="inviteBot()" class="btn btn-success"
*ngIf="botInvited === false" [disabled]="togglingBotInvite">
<i class="fa fa-robot"></i>
Invite CWT Bot
Invite {{nameShort}} Bot
</button>
<div class="alert alert-success my-3">
<div class="form-check">
Expand All @@ -125,15 +125,15 @@ <h2 class="mt-md-0">Twitch</h2>
Allow the bot to join by itself
</label>
<small class="form-text text-muted">
Everytime you start live streaming with “CWT” in the title of your live stream,
Everytime you start live streaming with “{{nameShort}}” in the title of your live stream,
the bot will join the chat and leave once the stream ends. Maximum comfort.
</small>
</div>
</div>
</ng-container>
<small class="form-text text-muted">
Let the CWT Bot join your channel, it will provide a few commands
to enrich the experience and also mirror the CWT chat.<br>
Let the {{nameShort}} Bot join your channel, it will provide a few commands
to enrich the experience and also mirror the {{nameShort}} chat.<br>
Enter <code>!cwtcommands</code> once it has joined the Twitch chat.<br>
You can revoke access at any time.
</small>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class UserPanelComponent implements OnInit {
botInvited: boolean = null;
botRequestFailed: boolean = false;
togglingBotAutoJoin: boolean = false;
nameShort: string;

private authUser: JwtUser;
// @ts-ignore
Expand All @@ -38,6 +39,7 @@ export class UserPanelComponent implements OnInit {
private toastr: Toastr,
private binaryService: BinaryService,
@Inject(APP_CONFIG) private appConfig: AppConfig) {
this.nameShort = this.appConfig.nameShort;
}

async ngOnInit() {
Expand Down
5 changes: 0 additions & 5 deletions cwt-angular/src/main/webapp/scss/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -463,11 +463,6 @@ body {
color: #fff !important;
}

.cwt-label:before {
content: 'Crespo’s Worms Tournament';
white-space: nowrap;
}

.btn-group-justified {
display: table;
width: 100%;
Expand Down

0 comments on commit f6b5e20

Please sign in to comment.