forked from JamBrain/JamBrain
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost.js
More file actions
119 lines (106 loc) · 3.11 KB
/
post.js
File metadata and controls
119 lines (106 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import {h, Component} from 'preact/preact';
import ContentSimple from 'com/content-simple/simple';
import UIIcon from 'com/ui/icon/icon';
import UILink from 'com/ui/link/link';
import UIButton from 'com/ui/button/button';
//import $Node from '../../shrub/js/node/node';
export default class ContentPost extends Component {
constructor( props ) {
super(props);
}
render( props ) {
let {node, user, path, extra} = props;
props = Object.assign({}, props);
// Additional properties
//props.authored = 1;
if ( node ) {
if ( node.subtype === 'news' ) {
//props.flag = "NEWS";
props.by = "NEWS";
props.flagIcon = "news";
props.flagClass = "-col-c";
}
else if ( node.subtype === 'info' ) {
//props.flag = "INFO";
props.by = "INFO";
props.flagIcon = "info";
props.flagClass = "-col-nddd";
}
else if ( node.subtype === 'guide' ) {
//props.flag = "GUIDE";
props.by = "GUIDE";
props.flagIcon = "article";
props.flagClass = "-col-nddd";
}
else if ( node.subtype === 'promo' ) {
//props.flag = "INFO";
//props.by = "INFO";
props.flagIcon = "gift";
props.flagClass = "-col-ab";
if ( props.single ) {
if ( props.user && props.user.id ) {
let Body = <div>Unknown Promo Type</div>;
// Shared promos have a single code used by many (associated with the node)
if ( node.subsubtype == 'shared' ) {
if ( node.meta['promo-code'] ) {
let PromoCode = node.meta['promo-code'].toLowerCase();
// TODO: Replace this with a library function that can detect URLs
let IsURL = false;
if ( PromoCode.indexOf("http://") === 0 )
IsURL = true;
if ( PromoCode.indexOf("https://") === 0 )
IsURL = true;
if ( PromoCode.indexOf("ftp://") === 0 )
IsURL = true;
if ( IsURL ) {
Body = (
<div>
<span>Link:</span> <strong><UILink href={node.meta['promo-code']}>{node.meta['promo-code']}</UILink></strong>
</div>
);
}
else {
Body = (
<div>
<span>Code:</span> <strong>{node.meta['promo-code']}</strong>
</div>
);
}
}
else {
Body = <div>No `promo-code` associated with shared promo node.</div>;
}
}
// Single promos have a pool of codes, and each user must request one
else if ( node.subsubtype == 'single' ) {
Body = <div>{node.subsubtype}</div>;
}
props.children = (
<div class="content-common-body -promo">
<h2>Get Promo</h2>
{Body}
</div>
);
}
else {
props.children = (
<div class="content-common-body -promo">
<h2>Get Promo</h2>
<div>Login to claim</div>
</div>
);
}
}
else {
props.children = (
<div class="content-common-body -promo">
<UIButton class="content-common-nav-button" href={node.path}><UIIcon src="gift" /><div>Continue</div></UIButton>
</div>
);
}
}
}
props.limit = 1024*24;
return <ContentSimple {...props} />;
}
}