<commit_before><% require "application_helper" %>
<% require "users_helper" %>

<div class="panel panel-default">
	<div class="panel-heading" style="font-size:24px;">
		<strong>Forum</strong>
	</div>
	<div class="panel-body">
		<div>
			<ol class="breadcrumb" style="background-color: white; margin: 0">
				<li><span class="icon-home"></span> <a href="/subjects/">Home</a></li>
				<li class="active"><%= @subject.title %></li>
			</ol>
		</div>
		<hr style="margin: 3px 0 3px;">
		<div style="override: hidden;">
			<div style="float: right;">
				<!-- Following (only if user logged in) -->
				<% if @current_user %>
					<% if @subject.following_users.exists?(@current_user.id) %>
						<%= link_to "Stop following this subject", "/subjects/#{@subject.id}/stop_following", method: :delete, class: "btn btn-default btn-gray" %>
					<% else %>
						<%= link_to "Follow this subject", "/subjects/#{@subject.id}/start_following", method: :put, data: {confirm: "You will receive a mail for every message posted in this subject."}, class: "btn btn-default btn-gray" %>
					<% end %>
				<% end %>
				<!-- Remove subject (only if admin) -->
				<% if @current_user && @current_user.admin %>
					<%= link_to "Remove this subject", "/subjects/#{@subject.id}/delete", method: :delete, data: {confirm: "This subject and its messages will be permanently deleted."}, class: "btn btn-default btn-danger" %>
				<% end %>
			</div>
			<h3>
				<% if @subject.pinned? %>
					<%= "<span title=\"Pinned\" class = \"icon-pinned-big\"></span>".html_safe %>
				<% end %>
				<%= @subject.title %>
			</h3>
			Started by <%= UsersHelper.display_name(@subject.forum_messages.first.user) %>, <span style="color: #888888">the <%= ApplicationHelper.datetime_to_s(@subject.forum_messages.first.created_at) %></span>.
			<% if @current_user && @current_user.admin %>
				<%= link_to "(Toggle pinned)", "/subjects/#{@subject.id}/toggle_pinned", method: :patch %>
			<% end %>
		</div>

		<!-- All messages -->
		<% @messages.each do |m| %>
			<div class="message-display">
				<div class="header">
					<span class="time"><%= ApplicationHelper.datetime_to_s(m.created_at) %></span>
					<span class="tools" style="float: right;">
						<% if m.user_id == session[:user_id] || (session[:user_id] && User.find(session[:user_id]).admin) %>
							<a href="/subjects/edit/<%= m.id %>"><span class="edit-message" title="Edit message"></span></a>
						<% end %>
						<span class="code-text-swapper" title="Show/hide code"></span>
					</span>
				</div>
				<div class="body">
					<div class="information"><%= UsersHelper.display_name(m.user) %></div>
					<div class="message bb-code"><%= h m.text %></div>
					<% if m.created_at != m.updated_at %>
						<div class="last-edition">Last edited the <%= ApplicationHelper.datetime_to_s(m.updated_at) %>.</div>
					<% end %>
				</div>
			</div>
		<% end %>

		<!-- New message -->
		<% if session[:user_id] %>
			<div class="message-display" id="dynamical-preview" style="visibility: hidden; position: absolute;">
				<div class="header">
					<span class="time"></span>
					<span class="tools" style="float: right;">
						<span class="edit-message" title="Editing an unexisting message ? Really..."></span>
						<span class="code-text-swapper" title="Do you really need this to view the code you just typed ?"></span>
					</span>
				</div>
				<div class="body">
					<div class="information"><%= UsersHelper.display_name(User.find(session[:user_id])) %></div>
					<div id="math_buffer" style="visibility: hidden; position: absolute;"></div>
					<div class="message"></div>
				</div>
			</div>
			<%= form_for :forum_message, url: "/subjects/#{@subject.id}" do |f| %>

				<div class="form-group">
					<%= ApplicationHelper.f_label "New Message" %>
					<%= f.text_area :text, placeholder: "Text", class: "form-control", style: "height: 150px;" %>
				</div>

				<center><%= f.submit :class => "btn btn-primary", :id => "forum_message_submit" %></center>
			<% end %>
		<% end %>

		<!-- Pagination -->
		<center><%= will_paginate @messages %></center>
	</div>
</div>

<!-- Preview script -->
<script type="text/javascript">
PreviewBuffer.set_buffers($('#dynamical-preview .message'), 'math_buffer');
$('#forum_message_text').on("input", handle_message_changes);
</script>

<!-- View code script -->
<script type="text/javascript">
// Assign each button its own id...
$(register_code_text_swappers);
</script>
<commit_msg>Update the subject following message to feature slack instead of emails<commit_after><% require "application_helper" %>
<% require "users_helper" %>

<div class="panel panel-default">
	<div class="panel-heading" style="font-size:24px;">
		<strong>Forum</strong>
	</div>
	<div class="panel-body">
		<div>
			<ol class="breadcrumb" style="background-color: white; margin: 0">
				<li><span class="icon-home"></span> <a href="/subjects/">Home</a></li>
				<li class="active"><%= @subject.title %></li>
			</ol>
		</div>
		<hr style="margin: 3px 0 3px;">
		<div style="override: hidden;">
			<div style="float: right;">
				<!-- Following (only if user logged in) -->
				<% if @current_user %>
					<% if @subject.following_users.exists?(@current_user.id) %>
						<%= link_to "Stop following this subject", "/subjects/#{@subject.id}/stop_following", method: :delete, class: "btn btn-default btn-gray" %>
					<% else %>
						<%= link_to "Follow this subject", "/subjects/#{@subject.id}/start_following", method: :put, data: {confirm: "You will receive a private slack message for every message posted in this subject."}, class: "btn btn-default btn-gray" %>
					<% end %>
				<% end %>
				<!-- Remove subject (only if admin) -->
				<% if @current_user && @current_user.admin %>
					<%= link_to "Remove this subject", "/subjects/#{@subject.id}/delete", method: :delete, data: {confirm: "This subject and its messages will be permanently deleted."}, class: "btn btn-default btn-danger" %>
				<% end %>
			</div>
			<h3>
				<% if @subject.pinned? %>
					<%= "<span title=\"Pinned\" class = \"icon-pinned-big\"></span>".html_safe %>
				<% end %>
				<%= @subject.title %>
			</h3>
			Started by <%= UsersHelper.display_name(@subject.forum_messages.first.user) %>, <span style="color: #888888">the <%= ApplicationHelper.datetime_to_s(@subject.forum_messages.first.created_at) %></span>.
			<% if @current_user && @current_user.admin %>
				<%= link_to "(Toggle pinned)", "/subjects/#{@subject.id}/toggle_pinned", method: :patch %>
			<% end %>
		</div>

		<!-- All messages -->
		<% @messages.each do |m| %>
			<div class="message-display">
				<div class="header">
					<span class="time"><%= ApplicationHelper.datetime_to_s(m.created_at) %></span>
					<span class="tools" style="float: right;">
						<% if m.user_id == session[:user_id] || (session[:user_id] && User.find(session[:user_id]).admin) %>
							<a href="/subjects/edit/<%= m.id %>"><span class="edit-message" title="Edit message"></span></a>
						<% end %>
						<span class="code-text-swapper" title="Show/hide code"></span>
					</span>
				</div>
				<div class="body">
					<div class="information"><%= UsersHelper.display_name(m.user) %></div>
					<div class="message bb-code"><%= h m.text %></div>
					<% if m.created_at != m.updated_at %>
						<div class="last-edition">Last edited the <%= ApplicationHelper.datetime_to_s(m.updated_at) %>.</div>
					<% end %>
				</div>
			</div>
		<% end %>

		<!-- New message -->
		<% if session[:user_id] %>
			<div class="message-display" id="dynamical-preview" style="visibility: hidden; position: absolute;">
				<div class="header">
					<span class="time"></span>
					<span class="tools" style="float: right;">
						<span class="edit-message" title="Editing an unexisting message ? Really..."></span>
						<span class="code-text-swapper" title="Do you really need this to view the code you just typed ?"></span>
					</span>
				</div>
				<div class="body">
					<div class="information"><%= UsersHelper.display_name(User.find(session[:user_id])) %></div>
					<div id="math_buffer" style="visibility: hidden; position: absolute;"></div>
					<div class="message"></div>
				</div>
			</div>
			<%= form_for :forum_message, url: "/subjects/#{@subject.id}" do |f| %>

				<div class="form-group">
					<%= ApplicationHelper.f_label "New Message" %>
					<%= f.text_area :text, placeholder: "Text", class: "form-control", style: "height: 150px;" %>
				</div>

				<center><%= f.submit :class => "btn btn-primary", :id => "forum_message_submit" %></center>
			<% end %>
		<% end %>

		<!-- Pagination -->
		<center><%= will_paginate @messages %></center>
	</div>
</div>

<!-- Preview script -->
<script type="text/javascript">
PreviewBuffer.set_buffers($('#dynamical-preview .message'), 'math_buffer');
$('#forum_message_text').on("input", handle_message_changes);
</script>

<!-- View code script -->
<script type="text/javascript">
// Assign each button its own id...
$(register_code_text_swappers);
</script>

{'fraction_non_alphanumeric': 0.21064326185979335, 'fraction_numerical': 0.0037773580713254084, 'mean_word_length': 3.7705352411234765, 'pattern_counts': {'":': 0, '<': 267, '<?xml version=': 0, '>': 271, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5809125', 'n_tokens_mistral': 3605, 'n_tokens_neox': 2896, 'n_words': 682}