-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy pathprofile.html.erb
278 lines (230 loc) · 13.1 KB
/
profile.html.erb
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
<div class="col-md-3">
<% if @user.user %>
<img class="hidden-xs hidden-sm img-rounded" id="profile-photo" style="width:100%;margin-bottom:10px;" src="<%= @user.user.profile_image %>" />
<div style="text-align:center;" class="visible-sm visible-xs">
<img class="img-circle" id="profile-photo" style="width:50%;margin-bottom:20px;" src="<%= @user.user.profile_image %>" />
</div>
<% end %>
<div style="text-align: -webkit-center;">
<% if @twitter.nil? == false %>
<a href="<%= @twitter %>" >
<i class="fa fa-twitter fa-3x" aria-hidden="true"></i>
</a>
<% end %>
<% if @facebook.nil? == false %>
<a href="<%= @facebook %>" >
<i class="fa fa-facebook fa-3x" aria-hidden="true"></i>
</a>
<% end %>
<% if @github.nil? == false %>
<a href="<%= @github %>" >
<i class="fa fa-github fa-3x" aria-hidden="true"></i>
</a>
<% end %>
<% if @instagram.nil? == false %>
<a href="<%= @instagram %>" >
<i class="fa fa-instagram fa-3x" aria-hidden="true"></i>
</a>
<% end %>
</div>
<br>
<% if current_user && @profile_user %>
<% unless current_user == @profile_user %>
<hr />
<div id="follow_form" class="col-md-offset-4">
<% if current_user.following?(@profile_user) %>
<%= render 'unfollow' %>
<% else %>
<%= render 'follow' %>
<% end %>
</div>
<br />
<% end %>
<% end %>
<% if @user.user.nil? && current_user && current_user.role == "admin" %>
<a href="/admin/migrate/<%= @user.uid %>" class="btn btn-block"><i class="fa fa-bolt"></i> <%= t('users.profile.migrate_new_site') %></a>
<% end %>
<% if @user.user && current_user && current_user.role == "admin" && @user.user.role != "admin" %>
<a href="/admin/promote/admin/<%= @user.user.id %>" class="btn btn-default btn-block"><i class="fa fa-certificate"></i> <%= t('users.profile.make_admin') %></a>
<% end %>
<% if @user.user && current_user && current_user.role == "admin" && @user.role == "moderator" %>
<a href="/admin/demote/basic/<%= @user.user.id %>" class="btn btn-default btn-block"><i class="fa fa-ban"></i> <%= t('users.profile.revert_to_basic_user') %></a>
<% end %>
<% if @user.user && current_user && (current_user.role == "admin" || current_user.role == "moderator") && @user.role == "basic" %>
<a href="/admin/promote/moderator/<%= @user.user.id %>" class="btn btn-default btn-block"><i class="fa fa-certificate"></i> <%= t('users.profile.make_moderator') %></a>
<% end %>
<% if current_user && (current_user.role == "admin" || current_user.role == "moderator") && @user.status == 0 %>
<a href="/unban/<%= @user.id %>" class="btn btn-default btn-block"><i class="fa fa-thumbs-up"></i> <%= t('users.profile.unban_user') %></a>
<% elsif current_user && (current_user.role == "admin" || current_user.role == "moderator") && @user.status == 1 %>
<a data-confirm="<%= t('users.profile.confirm_ban_user') %>" href="/ban/<%= @user.id %>" class="btn btn-default btn-block"><i class="fa fa-ban"></i> <%= t('users.profile.ban_user') %></a>
<% end %>
<% if current_user && (current_user.role == "admin" || current_user.role == "moderator") && @user.status == 5 %>
<a href="/admin/unmoderate/<%= @user.id %>" class="btn btn-default btn-block"><i class="fa fa-thumbs-up"></i> <%= t('users.profile.unmoderate_user') %></a>
<% elsif current_user && (current_user.role == "admin" || current_user.role == "moderator") && @user.status == 1 %>
<a rel="tooltip" title="Prevent author from logging in, without hiding their work or profile." data-confirm="<%= t('users.profile.confirm_moderate_user') %>" href="/admin/moderate/<%= @user.id %>" class="btn btn-default btn-block"><i class="fa fa-ban"></i> <%= t('users.profile.moderate_user') %></a>
<% end %>
<% if @user.user && !@user.user.reset_key.nil? && current_user && current_user.role == "admin" %>
<a id="user-reset-key" href="/reset/key/<%= @user.user.reset_key %>" class="btn btn-default btn-block"><i class="fa fa-info-sign"></i> <%= t('users.profile.reset_user') %>: <%= @user.user.reset_key %></a>
<% end %>
<% if @user.user && @profile_user.reset_key.nil? && current_user && (current_user.role == "admin" || current_user.role == "moderator") && (@user.role == "basic" || @user.role == "moderator") %>
<a href="/admin/force/reset/<%= @profile_user.id %>" class="btn btn-default btn-block">Reset User Password</a>
<% end %>
<hr />
<p>
<a class="btn btn-default btn-sm btn-block" href="/feed/<%= @user.name %>.rss"><i class="fa fa-rss" style="color:orange;"></i> <%= t('users.profile.rss_feed_for') %> <%= @user.name %></a>
<% if current_user && current_user.uid == @user.uid %>
<a href="/profile/<%= @user.name %>/edit" class="btn btn-default btn-sm btn-block"><i class="fa fa-pencil"></i> <%= t('users.profile.edit_profile') %></a>
<% end %>
</p>
<% if @profile_user && current_user && @profile_user == current_user %>
<button id="btn-token" class="btn btn-default btn-block">My Access Token</button>
<% end %>
<% if @profile_user && current_user && @profile_user == current_user %>
<button id="link_social_media" class="btn btn-default btn-block">Link Social media</button>
<% end %>
<hr />
<% if params[:preview] %>
<hr />
<div class="row">
<div class="col-md-3 col-md-offset-1">
<h4>Followers</h4>
</div>
<div class="col-md-3 col-md-offset-2">
<h4>Following</h4>
</div>
<br />
<div class="col-md-3 col-md-offset-2">
<h5><b><%= link_to @profile_user.followers.count, followers_path(id: @profile_user.username) %></b></h5>
</div>
<div class="col-md-3 col-md-offset-2">
<h5><b><%= link_to @profile_user.following_users.count, following_path(id: @profile_user.username) %></b></h5>
</div>
</div>
<hr />
<% end %>
<div class="hidden-xs">
<% if @wikis && @wikis.length > 0 %>
<h4><%= t('users.profile.wiki_contributed_to') %></h4>
<ul class="nav bullet">
<% @wikis.each do |wiki| %>
<% unless (!@node.nil? && wiki.nid == @node.nid) %>
<li><a href="<%= wiki.path %>"><i class="fa fa-<%= wiki.icon %>"></i> <%= wiki.latest.title %></a> <small style="color:#888;"><%= t('users.profile.updated') %> <%= distance_of_time_in_words(wiki.updated_at, Time.current, { include_seconds: false, scope: 'datetime.time_ago_in_words' }) %> <%= t('users.profile.by') %> <a href="/profile/<%= wiki.latest.author.name %>"><%= wiki.latest.author.name %></a></small></li>
<% end %>
<% end %>
<% if params[:controller] == "search" %>
<li><a href="/tag/<%= params[:id] %>"><%= t('users.profile.more') %>...</a></li>
<% end %>
</ul>
<% end %>
</div>
</div>
<div class="col-md-9">
<div id="note-graph" style="height:100px;display:none;margin-bottom:16px;"></div>
<h3 style="margin-top:0;"><%= @user.name %>
<small>
<%= @user.node_count %> <%= raw t('users.profile.notes_and_edits', :url1 => "/notes/author/"+@user.name) %>
<% if current_user && current_user.role == "admin" %> | <%= @user.email %><% end %>
<% if @user.role == "moderator" %> | <i class="fa fa-certificate"></i> <%= t('users.profile.moderator') %><% end %>
<% if @user.role == "admin" %> | <i class="fa fa-certificate"></i> <%= t('users.profile.admin') %><% end %>
<% if @user.status == 0 %> | <i class="fa fa-ban" style="color:#a00;"></i> <%= t('users.profile.banned') %><% end %>
</small>
</h3>
<p><small><%= raw auto_link(RDiscount.new(@profile_user.bio || '').to_html, :sanitize => false) %></small></p>
<hr />
<div class="row" id="highlight" style=" text-align: center;">
<h3 class="col-md-4 col-xs-12 col-sm-4"><a href = "/tag/question:*/author/<%= params[:id] %>"><%= Node.questions.where(status: 1, uid: @user.id).length %> questions asked </a><br><br> <%= Answer.where(uid: @profile_user.id).count %> answers posted</h3>
<h3 class="col-md-4 col-xs-12 col-sm-4"><a href = "/tag/activity:*/author/<%= params[:id] %>"><%= @count_activities_posted %> activities posted </a><br><br> <a href = "/tag/replication:*/author/<%= params[:id] %>"><%= @count_activities_attempted %> activities attempted</a></h3>
<% if !@map_lat.nil? && !@map_lon.nil? %>
<%= render :partial => "map/userLeaflet" , locals: {haslocation: true} %>
<% elsif !current_user.nil? && current_user.id == @user.id %>
<%= render :partial => "map/userLeaflet" , locals: {haslocation: false} %>
<% end %>
</div>
<hr />
<ul class="nav nav-tabs">
<span style="float:right;"><small><%= raw t('users.profile.joined_time_ago', :time_ago => distance_of_time_in_words(@user.created_at, Time.current, { include_seconds: false, scope: 'datetime.time_ago_in_words' })) %></small></span>
<li class="active"><a href="#research" data-toggle="tab"><%= t('users.profile.research') %></a></li>
<li><a href="#coauthored" data-toggle="tab"><span class="hidden-sm hidden-xs"> <%= t('users.profile.Coauthored') %> (<%= @coauthored.size %>)</span></a></li>
<li><a href="#questions" data-toggle="tab"><i class="fa fa-comments"></i><span class="hidden-sm hidden-xs"> <%= t('users.profile.questions') %> (<%= Node.questions.where(status: 1, uid: @user.id).length %>)</span></a></li>
<li><a href="#comments" id="comments-tab" data-toggle="tab"><i class="fa fa-comment"></i><span class="hidden-sm hidden-xs"></span></a></li>
<li><a href="/profile/<%= @user.username %>/likes"><i class="fa fa-star"></i><span class="hidden-sm hidden-xs"> <%= t('users.profile.liked') %></span> (<%= @user.like_count %>)</a></li>
<li><a href="#barnstars" data-toggle="tab"><i class="fa fa-certificate"></i><span class="hidden-sm hidden-xs"> </span> (<%= @user.user.try(:barnstars).try(:length) %>)</a></li>
</ul>
<br />
<div class="tab-content">
<div class="tab-pane active" id="research">
<%= render :partial => "notes/notes" %>
</div>
<div class="tab-pane" id="coauthored">
<%= render :partial => "notes/coauthored_notes" %>
</div>
<div class="tab-pane" id="questions">
<div class="btn-group text-center">
<a href="#asked" class="btn btn-default active" data-toggle="tab">Asked</a>
<a href="#answered" class="btn btn-default" data-toggle="tab">Answered</a>
</div>
<div class="tab-content">
<div class="tab-pane active" id="asked">
<%= render :partial => "questions/questions" %>
</div>
<div class="tab-pane" id="answered">
<%= render :partial => "users/answered" %>
</div>
</div>
</div>
<div class="tab-pane" id="maps">
<p><i><%= raw t('users.profile.view_these_maps', :url1 => "//mapknitter.org/profile/"+@user.name) %></i></p>
<table class="table">
<tr>
<th style="width:200px;"><%= t('users.profile.title') %></th>
<th style="width:200px;"><%= t('users.profile.creation_date') %></th>
<th><%= t('users.profile.image') %></th>
</tr>
</table>
</div>
<div class="tab-pane" id="comments">
<h2 style="text-align:center;"><i class="fa fa-spinner fa fa-spin"></i></h2>
</div>
<div class="tab-pane" id="barnstars">
<% if @user.user %>
<% @user.user.barnstars.each do |tag| %>
<p style="color:#aaa;"><i style="color:#db4;" class="fa fa-large fa fa-star-o"></i> <i><%= raw t('users.profile.barnstar_awarded_to_by', :url1 => "/profile/"+tag.node.author.name, :author => tag.node.author.name, :url2 => "/wiki/barnstars#"+tag.name.split(':').last.split('-').each{|w| w.capitalize!}.join('+'), :barnstar => tag.name.split(':').last.split('-').each{|w| w.capitalize!}.join(' '), :url3 => "/profile/"+tag.author.username, :awarder => tag.author.username, :url4 => tag.node.path, :work => tag.node.title) %></i></p>
<hr />
<% end %>
<% end %>
</div>
</div>
<hr />
<% if current_user && (current_user.id == @user.id || current_user.role == "admin") %>
<%= render :partial => "tag/tagging", locals: { url: "/profile/tags/create/#{ @user.id }" } %>
<% end %>
<hr />
</div>
<script type="text/javascript">
$('#btn-token').click(function() {
alert("Your access token is: <%= @user.user.token %>");
});
$('#link_social_media').click(function(){
var sign = prompt("Enter Your Social Media User name like twitter:publiclab or instagram:publiclab");
$.post('/profile/tags/create/<%=@user.uid %> ',{"name": sign,"id":<%=@user.uid %>}, function(data) {
window.location='/profile/<%=@user.name %> ';
});
});
(function () {
var profile = Object.create(Profile);
profile.value.user_id = "<%= @user.uid %>"
profile.display_comments();
<% if @user && @user.user %>
var notes = <%= @user.user.weekly_note_tally.to_a.sort.to_json %>
var comments = <%= @user.user.weekly_comment_tally.to_a.sort.to_json %>
$('#note-graph').show()
<% end %>
profile.value.notes = notes;
profile.value.comments = comments;
profile.plot_graph();
profile.value.name = "<%= @user.name %>"
profile.fetch_maps();
})();
</script>
<%= stylesheet_link_tag "dashboard" %>
<%= javascript_include_tag "dashboard" %>