-
Notifications
You must be signed in to change notification settings - Fork 271
/
_SubmissionLink.cshtml
145 lines (125 loc) · 5.78 KB
/
_SubmissionLink.cshtml
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
@*This source file is subject to version 3 of the GPL license,
that is bundled with this package in the file LICENSE, and is
available online at http://www.gnu.org/licenses/gpl.txt;
you may not use this file except in compliance with the License.
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
the specific language governing rights and limitations under the License.
All portions of the code written by Whoaverse are Copyright (c) 2014 Whoaverse
All Rights Reserved.*@
@model Whoaverse.Models.Message
@using Whoaverse.Utils;
@{
string ahrefTarget = "_self";
if (User.Identity.IsAuthenticated)
{
if (Whoaverse.Utils.User.LinksInNewWindow(User.Identity.Name))
{
ahrefTarget = "_blank";
}
}
var commentCount = Model.Comments.Where(c => c.Name != "deleted").Count();
bool ratedAdult = false;
if (Model.Subverses != null)
{
if (Model.Subverses.rated_adult.HasValue)
{
ratedAdult = Model.Subverses.rated_adult.Value;
}
}
string routeActiveSubverse = (string)ViewContext.RouteData.Values["subversetoshow"];
string commentsUrl = "/v/" + Model.Subverse + "/comments/" + Model.Id;
DateTime submissionDate = Model.Date;
string postAge = Submissions.CalcSubmissionAge(submissionDate);
//type 2 = urls
if (Model.Type == 2)
{
string submissionDomain = UrlUtility.GetDomainFromUri(Model.MessageContent);
if (Model.Thumbnail != null)
{
if (routeActiveSubverse != null)
{
if (Model.Linkdescription.ToLower().Contains("nsfw") && Model.Subverse.ToLower() != routeActiveSubverse.ToLower())
{
<a class="thumbnail nsfw may-blank " href="@Model.MessageContent" rel="nofollow" target="@ahrefTarget"></a>
}
else if (ratedAdult && Model.Subverse.ToLower() != routeActiveSubverse.ToLower())
{
<a class="thumbnail nsfw may-blank " href="@Model.MessageContent" rel="nofollow" target="@ahrefTarget"></a>
}
else
{
<a class="thumbnail may-blank " href="@Model.MessageContent" target="@ahrefTarget">
<img src="~/Thumbs/@Model.Thumbnail" alt="" />
</a>
}
}
else
{
if (Model.Linkdescription.ToLower().Contains("nsfw"))
{
<a class="thumbnail nsfw may-blank " href="@Model.MessageContent" rel="nofollow" target="@ahrefTarget"></a>
}
else if (ratedAdult)
{
<a class="thumbnail nsfw may-blank " href="@Model.MessageContent" rel="nofollow" target="@ahrefTarget"></a>
}
else
{
<a class="thumbnail may-blank " href="@Model.MessageContent" target="@ahrefTarget">
<img src="~/Thumbs/@Model.Thumbnail" alt="" />
</a>
}
}
}
<div class="entry unvoted">
<p class="title">
@if (Model.FlairLabel != null && Model.FlairCss != null)
{
if (routeActiveSubverse != "" && routeActiveSubverse != "all" && routeActiveSubverse != null)
{
<span class="@Model.FlairCss" title="@Model.FlairLabel">@Model.FlairLabel</span>
}
}
<a class="title may-blank " href="@Model.MessageContent" tabindex="1" title="@Model.Linkdescription" target="@ahrefTarget">@Model.Linkdescription</a>
<span class="domain">(<a href="/domains/@submissionDomain/">@submissionDomain</a>)</span>
</p>
@if (Model.Name == "deleted")
{
<p class="tagline">
submitted <time title="@Model.Date" datetime="@Model.Date">@postAge</time> ago by
<span class="userattrs">[deleted]</span> to <a href="/v/@Model.Subverse" class="subreddit hover may-blank">@Model.Subverse</a>
</p>
}
else
{
<p class="tagline">
submitted <time title="@Model.Date" datetime="@Model.Date">@postAge</time> ago by <a href="/user/@Model.Name" class="author may-blank id-t2_8bunp">@Model.Name</a>
<span class="userattrs"></span> to <a href="/v/@Model.Subverse" class="subreddit hover may-blank">@Model.Subverse</a>
<span class="commentvotesratio">(<span class="post_upvotes">+@Model.Likes</span>|<span class="post_downvotes">−@Model.Dislikes</span>)</span>
</p>
}
<ul class="flat-list buttons">
<li class="first">
@if (commentCount > 0)
{
<a href="@commentsUrl" class="comments may-blank">@commentCount comments</a>
}
else
{
<a href="@commentsUrl" class="comments may-blank">discuss</a>
}
</li>
<li class="share">
<span class="share-button toggle" style="">
<a class="option active login-required" href="#" tabindex="100">share</a>
<a class="option " href="#">cancel</a>
</span>
</li>
</ul>
<div class="expando" style="display: none">
<span class="error">loading...</span>
</div>
</div>
}
}