-
-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#144: added multipart structure browser in the RFC Compliance page
- Loading branch information
Showing
13 changed files
with
331 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export class Email { | ||
constructor(readonly usePlainText: boolean, | ||
readonly useHTMLText: boolean, | ||
readonly useEmbeddedContent: boolean, | ||
readonly useCalendarEvent: boolean, | ||
readonly useAttachments: boolean, | ||
readonly useEmailForward: boolean, | ||
) { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import {Email} from "./Email"; | ||
|
||
export abstract class MessageStrategy { | ||
|
||
abstract compatibleWithEmail(email: Email): boolean; | ||
|
||
abstract determineMessageStructure(email: Email): string; | ||
|
||
protected static emailContainsMixedContent(email: Email): boolean { | ||
return email.useAttachments || email.useEmailForward; | ||
} | ||
|
||
protected static emailContainsRelatedContent(email: Email): boolean { | ||
return email.useEmbeddedContent; | ||
} | ||
|
||
protected static emailContainsAlternativeContent(email: Email): boolean { | ||
return (email.usePlainText ? 1 : 0) + | ||
(email.useHTMLText ? 1 : 0) + | ||
(email.useCalendarEvent ? 1 : 0) > 1; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/webapp/src/app/components/rfc/MessageStrategyAlternative.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import {MessageStrategy} from "./MessageStrategy"; | ||
import {Email} from "./Email"; | ||
|
||
export class MessageStrategyAlternative extends MessageStrategy { | ||
compatibleWithEmail(email: Email): boolean { | ||
return !MessageStrategy.emailContainsMixedContent(email) && | ||
!MessageStrategy.emailContainsRelatedContent(email) && | ||
MessageStrategy.emailContainsAlternativeContent(email); | ||
} | ||
|
||
public determineMessageStructure(email: Email): string { | ||
return "<ul>" + | ||
" <li class=\"indent\">alternative (root)" + | ||
" <ul>" + | ||
(email.usePlainText ? "<li class=\"indent\">Plain text</li>" : "") + | ||
(email.useHTMLText ? "<li class=\"indent\">HTML text</li>" : "") + | ||
(email.useCalendarEvent ? "<li class=\"indent\">iCalendar text</li>" : "") + | ||
" </ul>" + | ||
" </li>" + | ||
"</ul>"; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/webapp/src/app/components/rfc/MessageStrategyMixed.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import {Email} from "./Email"; | ||
import {MessageStrategy} from "./MessageStrategy"; | ||
|
||
export class MessageStrategyMixed extends MessageStrategy { | ||
compatibleWithEmail(email: Email): boolean { | ||
return MessageStrategy.emailContainsMixedContent(email) && | ||
!MessageStrategy.emailContainsRelatedContent(email) && | ||
!MessageStrategy.emailContainsAlternativeContent(email); | ||
} | ||
|
||
public determineMessageStructure(email: Email): string { | ||
return "<ul>" + | ||
" <li class=\"indent\">mixed (root)" + | ||
" <ul>" + | ||
(email.usePlainText ? "<li class=\"indent\">Plain text</li>" : "") + | ||
(email.useHTMLText ? "<li class=\"indent\">HTML text</li>" : "") + | ||
(email.useCalendarEvent ? "<li class=\"indent\">iCalendar text</li>" : "") + | ||
(email.useEmailForward ? "<li class=\"indent\">forwarded email</li>" : "") + | ||
(email.useAttachments ? "<li class=\"indent\">downloadable attachments</li>" : "") + | ||
" </ul>" + | ||
" </li>" + | ||
"</ul>"; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/webapp/src/app/components/rfc/MessageStrategyMixedAlternative.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import {Email} from "./Email"; | ||
import {MessageStrategy} from "./MessageStrategy"; | ||
|
||
export class MessageStrategyMixedAlternative extends MessageStrategy { | ||
compatibleWithEmail(email: Email): boolean { | ||
return MessageStrategy.emailContainsMixedContent(email) && | ||
!MessageStrategy.emailContainsRelatedContent(email) && | ||
MessageStrategy.emailContainsAlternativeContent(email); | ||
} | ||
|
||
public determineMessageStructure(email: Email): string { | ||
return "<ul>" + | ||
" <li class=\"indent\">mixed (root)" + | ||
" <ul>" + | ||
" <li class=\"indent\">alternative" + | ||
" <ul>" + | ||
(email.usePlainText ? "<li class=\"indent\">Plain text</li>" : "") + | ||
(email.useHTMLText ? "<li class=\"indent\">HTML text</li>" : "") + | ||
(email.useCalendarEvent ? "<li class=\"indent\">iCalendar text</li>" : "") + | ||
" </ul>" + | ||
" </li>" + | ||
(email.useEmailForward ? "<li class=\"indent\">forwarded email</li>" : "") + | ||
(email.useAttachments ? "<li class=\"indent\">downloadable attachments</li>" : "") + | ||
" </ul>" + | ||
" </li>" + | ||
"</ul>"; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/webapp/src/app/components/rfc/MessageStrategyMixedRelated.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import {Email} from "./Email"; | ||
import {MessageStrategy} from "./MessageStrategy"; | ||
|
||
export class MessageStrategyMixedRelated extends MessageStrategy { | ||
compatibleWithEmail(email: Email): boolean { | ||
return MessageStrategy.emailContainsMixedContent(email) && | ||
MessageStrategy.emailContainsRelatedContent(email) && | ||
!MessageStrategy.emailContainsAlternativeContent(email); | ||
} | ||
|
||
public determineMessageStructure(email: Email): string { | ||
return "<ul>" + | ||
" <li class=\"indent\">mixed (root)" + | ||
" <ul>" + | ||
" <li class=\"indent\">related" + | ||
" <ul>" + | ||
" <li class=\"indent\">HTML text</li>" + | ||
" <li class=\"indent\">embeddable content (ie. images)</li>" + | ||
" </ul>" + | ||
" </li>" + | ||
(email.useEmailForward ? "<li class=\"indent\">forwarded email</li>" : "") + | ||
(email.useAttachments ? "<li class=\"indent\">downloadable attachments</li>" : "") + | ||
" </ul>" + | ||
" </li>" + | ||
"</ul>"; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/webapp/src/app/components/rfc/MessageStrategyMixedRelatedAlternative.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import {Email} from "./Email"; | ||
import {MessageStrategy} from "./MessageStrategy"; | ||
|
||
export class MessageStrategyMixedRelatedAlternative extends MessageStrategy { | ||
|
||
compatibleWithEmail(email: Email): boolean { | ||
return MessageStrategy.emailContainsMixedContent(email) && | ||
MessageStrategy.emailContainsRelatedContent(email) && | ||
MessageStrategy.emailContainsAlternativeContent(email); | ||
} | ||
|
||
public determineMessageStructure(email: Email): string { | ||
return "<ul>" + | ||
" <li class=\"indent\">mixed (root)" + | ||
" <ul>" + | ||
" <li class=\"indent\">related" + | ||
" <ul>" + | ||
" <li class=\"indent\">alternative" + | ||
" <ul>" + | ||
(email.usePlainText ? "<li class=\"indent\">Plain text</li>" : "") + | ||
(email.useHTMLText ? "<li class=\"indent\">HTML text</li>" : "") + | ||
(email.useCalendarEvent ? "<li class=\"indent\">iCalendar text</li>" : "") + | ||
" </ul>" + | ||
" </li>" + | ||
" <li class=\"indent\">embeddable content (ie. images) </li>" + | ||
" </ul>" + | ||
" </li>" + | ||
(email.useEmailForward ? "<li class=\"indent\">forwarded email</li>" : "") + | ||
(email.useAttachments ? "<li class=\"indent\">downloadable attachments</li>" : "") + | ||
" </ul>" + | ||
" </li>" + | ||
"</ul>"; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/webapp/src/app/components/rfc/MessageStrategyRelated.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {Email} from "./Email"; | ||
import {MessageStrategy} from "./MessageStrategy"; | ||
|
||
export class MessageStrategyRelated extends MessageStrategy { | ||
compatibleWithEmail(email: Email): boolean { | ||
return !MessageStrategy.emailContainsMixedContent(email) && | ||
MessageStrategy.emailContainsRelatedContent(email) && | ||
!MessageStrategy.emailContainsAlternativeContent(email); | ||
} | ||
|
||
public determineMessageStructure(email: Email): string { | ||
return "<ul>" + | ||
" <li class=\"indent\">related (root)" + | ||
" <ul>" + | ||
" <li class=\"indent\">HTML text</li>" + | ||
" <li class=\"indent\">embeddable content (ie. images)</li>" + | ||
" </ul>" + | ||
" </li>" + | ||
"</ul>"; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/webapp/src/app/components/rfc/MessageStrategyRelatedAlternative.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import {Email} from "./Email"; | ||
import {MessageStrategy} from "./MessageStrategy"; | ||
|
||
export class MessageStrategyRelatedAlternative extends MessageStrategy { | ||
compatibleWithEmail(email: Email): boolean { | ||
return !MessageStrategy.emailContainsMixedContent(email) && | ||
MessageStrategy.emailContainsRelatedContent(email) && | ||
MessageStrategy.emailContainsAlternativeContent(email); | ||
} | ||
|
||
public determineMessageStructure(email: Email): string { | ||
return "<ul>" + | ||
" <li class=\"indent\">related (root)<ul>" + | ||
" <li class=\"indent\">alternative" + | ||
" <ul>" + | ||
(email.usePlainText ? "<li class=\"indent\">Plain text</li>" : "") + | ||
(email.useHTMLText ? "<li class=\"indent\">HTML text</li>" : "") + | ||
(email.useCalendarEvent ? "<li class=\"indent\">iCalendar text</li>" : "") + | ||
" </ul>" + | ||
" </li>" + | ||
" <li class=\"indent\">embeddable content (ie. images)</li>" + | ||
" </ul>" + | ||
"</li>"; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/webapp/src/app/components/rfc/MessageStrategySimple.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {MessageStrategy} from "./MessageStrategy"; | ||
import {Email} from "./Email"; | ||
|
||
export class MessageStrategySimple extends MessageStrategy { | ||
|
||
compatibleWithEmail(email: Email): boolean { | ||
return !MessageStrategy.emailContainsMixedContent(email) && | ||
!MessageStrategy.emailContainsRelatedContent(email) && | ||
!MessageStrategy.emailContainsAlternativeContent(email); | ||
} | ||
|
||
public determineMessageStructure(email: Email): string { | ||
return "<ul>" + | ||
(email.usePlainText ? "<li class=\"indent\">Plain text (root)</li>" : "") + | ||
(email.useHTMLText ? "<li class=\"indent\">HTML text (root)</li>" : "") + | ||
(email.useCalendarEvent ? "<li class=\"indent\">iCalendar text (root)</li>" : "") + | ||
" </ul>"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,59 @@ | ||
import {Component} from '@angular/core'; | ||
import {Component, Input} from '@angular/core'; | ||
import {MessageStrategy} from "./MessageStrategy"; | ||
import {MessageStrategyAlternative} from "./MessageStrategyAlternative"; | ||
import {MessageStrategyMixed} from "./MessageStrategyMixed"; | ||
import {MessageStrategyRelated} from "./MessageStrategyRelated"; | ||
import {MessageStrategyMixedRelatedAlternative} from "./MessageStrategyMixedRelatedAlternative"; | ||
import {MessageStrategyRelatedAlternative} from "./MessageStrategyRelatedAlternative"; | ||
import {MessageStrategyMixedAlternative} from "./MessageStrategyMixedAlternative"; | ||
import {MessageStrategyMixedRelated} from "./MessageStrategyMixedRelated"; | ||
import {MessageStrategySimple} from "./MessageStrategySimple"; | ||
import {Email} from "./Email"; | ||
|
||
@Component({ | ||
template: require('./rfc.html') | ||
}) | ||
|
||
export class RfcCompliant { | ||
@Input() usePlainText: boolean; | ||
@Input() useHTMLText: boolean; | ||
@Input() useEmbeddedContent: boolean; | ||
@Input() useCalendarEvent: boolean; | ||
@Input() useAttachments: boolean; | ||
@Input() useEmailForward: boolean; | ||
|
||
messageStructure: string; | ||
|
||
private static readonly STRATEGIES: Array<MessageStrategy> = [ | ||
new MessageStrategySimple(), | ||
new MessageStrategyAlternative(), | ||
new MessageStrategyRelated(), | ||
new MessageStrategyMixed(), | ||
new MessageStrategyMixedRelated(), | ||
new MessageStrategyMixedAlternative(), | ||
new MessageStrategyRelatedAlternative(), | ||
new MessageStrategyMixedRelatedAlternative() | ||
]; | ||
|
||
updateMessageStructure(): void { | ||
if (!this.useHTMLText) { | ||
this.useEmbeddedContent = false; | ||
} | ||
|
||
this.messageStructure = RfcCompliant.determineFormalStructure(new Email( | ||
this.usePlainText, | ||
this.useHTMLText, | ||
this.useEmbeddedContent, | ||
this.useCalendarEvent, | ||
this.useAttachments, | ||
this.useEmailForward)); | ||
} | ||
|
||
private static determineFormalStructure(email: Email): string { | ||
for (const s of RfcCompliant.STRATEGIES) { | ||
if (s.compatibleWithEmail(email)) { | ||
return s.determineMessageStructure(email); | ||
} | ||
} | ||
throw new Error("email config not recognized properly"); | ||
} | ||
} |