Convert .html.erb templates to .html.slim

This commit is contained in:
Sebastian Serth
2018-10-08 00:12:56 +02:00
parent 1bed13d941
commit 41bd5bac10
14 changed files with 206 additions and 258 deletions

View File

@ -1,37 +0,0 @@
<%= form_for(@comment) do |f| %>
<% if @comment.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@comment.errors.count, "error") %> prohibited this comment from being saved:</h2>
<ul>
<% @comment.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :user_id %><br>
<%= f.text_field :user_id %>
</div>
<div class="field">
<%= f.label :file_id %><br>
<%= f.text_field :file_id %>
</div>
<div class="field">
<%= f.label :row %><br>
<%= f.number_field :row %>
</div>
<div class="field">
<%= f.label :column %><br>
<%= f.number_field :column %>
</div>
<div class="field">
<%= f.label :text %><br>
<%= f.text_field :text %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>

View File

@ -0,0 +1,33 @@
= form_for(@comment) do |f|
- if @comment.errors.any?
#error_explanation
h2
= pluralize(@comment.errors.count, "error")
| prohibited this comment from being saved:
ul
- @comment.errors.full_messages.each do |message|
li= message
.field
= f.label :user_id
br/
= f.text_field :user_id
.field
= f.label :file_id
br/
= f.text_field :file_id
.field
= f.label :row
br/
= f.number_field :row
.field
= f.label :column
br/
= f.number_field :column
.field
= f.label :text
br/
= f.text_field :text
.actions
= f.submit

View File

@ -1,6 +0,0 @@
<h1>Editing comment</h1>
<%= render 'form' %>
<%= link_to 'Show', @comment %> |
<%= link_to 'Back', comments_path %>

View File

@ -0,0 +1,7 @@
h1 Editing comment
= render 'form'
= link_to 'Show', @comment
| |
= link_to 'Back', comments_path

View File

@ -1,33 +0,0 @@
<h1>Listing comments</h1>
<table>
<thead>
<tr>
<th>User</th>
<th>File</th>
<th>Row</th>
<th>Column</th>
<th>Text</th>
<th colspan="3"></th>
</tr>
</thead>
<tbody>
<% @comments.each do |comment| %>
<tr>
<td><%= comment.user %></td>
<td><%= comment.file %></td>
<td><%= comment.row %></td>
<td><%= comment.column %></td>
<td><%= comment.text %></td>
<td><%= link_to 'Show', comment %></td>
<td><%= link_to 'Edit', edit_comment_path(comment) %></td>
<td><%= link_to 'Destroy', comment, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>
<br>
<%= link_to 'New Comment', new_comment_path %>

View File

@ -0,0 +1,24 @@
h1 Listing comments
table
thead
tr
th User
th File
th Row
th Column
th Text
th colspan="3"
tbody
- @comments.each do |comment|
tr
td= comment.user
td= comment.file
td= comment.row
td= comment.column
td= comment.text
td= link_to 'Show', comment
td= link_to 'Edit', edit_comment_path(comment)
td= link_to 'Destroy', comment, method: :delete, data: confirm: 'Are you sure?'
br/
= link_to 'New Comment', new_comment_path

View File

@ -1,5 +0,0 @@
<h1>New comment</h1>
<%= render 'form' %>
<%= link_to 'Back', comments_path %>

View File

@ -0,0 +1,5 @@
h1 New comment
= render 'form'
= link_to 'Back', comments_path

View File

@ -1,29 +0,0 @@
<p id="notice"><%= notice %></p>
<p>
<strong>User:</strong>
<%= @comment.user %>
</p>
<p>
<strong>File:</strong>
<%= @comment.file %>
</p>
<p>
<strong>Row:</strong>
<%= @comment.row %>
</p>
<p>
<strong>Column:</strong>
<%= @comment.column %>
</p>
<p>
<strong>Text:</strong>
<%= @comment.text %>
</p>
<%= link_to 'Edit', edit_comment_path(@comment) %> |
<%= link_to 'Back', comments_path %>

View File

@ -0,0 +1,25 @@
p#notice= notice
p
strong User:
= @comment.user
p
strong File:
= @comment.file
p
strong Row:
= @comment.row
p
strong Column:
= @comment.column
p
strong Text:
= @comment.text
= link_to 'Edit', edit_comment_path(@comment)
| |
= link_to 'Back', comments_path

View File

@ -1,33 +0,0 @@
<%= form_for(@request_for_comment) do |f| %>
<% if @request_for_comment.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@request_for_comment.errors.count, "error") %> prohibited this request_for_comment from being saved:</h2>
<ul>
<% @request_for_comment.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :user_id %><br>
<%= f.number_field :user_id %>
</div>
<div class="field">
<%= f.label :exercise_id %><br>
<%= f.number_field :exercise_id %>
</div>
<div class="field">
<%= f.label :file_id %><br>
<%= f.number_field :file_id %>
</div>
<div class="field">
<%= f.label :user_type %><br>
<%= f.text_field :user_type %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>

View File

@ -0,0 +1,28 @@
= form_for(@request_for_comment) do |f|
- if @request_for_comment.errors.any?
#error_explanation
h2
= pluralize(@request_for_comment.errors.count, "error")
| prohibited this request_for_comment from being saved:
ul
- @request_for_comment.errors.full_messages.each do |message|
li= message
.field
= f.label :user_id
br/
= f.number_field :user_id
.field
= f.label :exercise_id
br/
= f.number_field :exercise_id
.field
= f.label :file_id
br/
= f.number_field :file_id
.field
= f.label :user_type
br/
= f.text_field :user_type
.actions
= f.submit

View File

@ -1,116 +1,87 @@
<div class="list-group"> .list-group
<h4 id ="exercise_caption" class="list-group-item-heading" data-exercise-id="<%=@request_for_comment.exercise.id%>" data-comment-exercise-url="<%=create_comment_exercise_request_for_comment_path%>" data-rfc-id = "<%= @request_for_comment.id %>" > h4#exercise_caption.list-group-item-heading data-comment-exercise-url=create_comment_exercise_request_for_comment_path data-exercise-id="#{@request_for_comment.exercise.id}" data-rfc-id="#{@request_for_comment.id}"
<% if @request_for_comment.solved? %> - if @request_for_comment.solved?
<span class="fa fa-check" aria-hidden="true"></span> span.fa.fa-check aria-hidden="true"
<% end %> = link_to(@request_for_comment.exercise.title, [:implement, @request_for_comment.exercise])
<%= link_to(@request_for_comment.exercise.title, [:implement, @request_for_comment.exercise]) %> p.list-group-item-text
</h4> - user = @request_for_comment.user
<p class="list-group-item-text"> - submission = @request_for_comment.submission
<% - testruns = Testrun.where(:submission_id => @request_for_comment.submission)
user = @request_for_comment.user = user.displayname
submission = @request_for_comment.submission | | #{@request_for_comment.created_at.localtime}
testruns = Testrun.where(:submission_id => @request_for_comment.submission) .rfc
%> .description
<%= user.displayname %> | <%= @request_for_comment.created_at.localtime %> h5
</p> = t('activerecord.attributes.exercise.description')
<div class="rfc"> .text
<div class="description"> span.fa.fa-chevron-up.collapse-button
<h5> = render_markdown(@request_for_comment.exercise.description)
<%= t('activerecord.attributes.exercise.description') %>
</h5>
<div class="text">
<span class="fa fa-chevron-up collapse-button"></span>
<%= render_markdown(@request_for_comment.exercise.description) %>
</div>
</div>
<div class="question"> .question
<h5 class="mt-4"> h5.mt-4
<%= t('activerecord.attributes.request_for_comments.question')%> = t('activerecord.attributes.request_for_comments.question')
</h5> .text
<div class="text"> - question = @request_for_comment.question
<% question = @request_for_comment.question %> = question.nil? or question.empty? ? t('request_for_comments.no_question') : question
<%= question.nil? or question.empty? ? t('request_for_comments.no_question') : question %>
</div>
</div>
<% if policy(@request_for_comment).mark_as_solved? and not @request_for_comment.solved? %> - if policy(@request_for_comment).mark_as_solved? and not @request_for_comment.solved?
<%= render('mark_as_solved') %> = render('mark_as_solved')
<% end %>
<% if testruns.size > 0 %> - if testruns.size > 0
<div class="testruns"> .testruns
<% output_runs = testruns.select { |run| run.cause == 'run' } %> - output_runs = testruns.select {|run| run.cause == 'run'}
<% if output_runs.size > 0 %> - if output_runs.size > 0
<h5 class="mt-4"><%= t('request_for_comments.runtime_output') %></h5> h5.mt-4= t('request_for_comments.runtime_output')
<div class="collapsed testrun-output text"> .collapsed.testrun-output.text
<span class="fa fa-chevron-down collapse-button"></span> span.fa.fa-chevron-down.collapse-button
<% output_runs.each do |testrun| %> - output_runs.each do |testrun|
<% - output = testrun.try(:output)
output = testrun.try(:output) - if output
if output - messages = output.scan(/{(?:(?:".+?":".+?")+?,?)+}/)
messages = output.scan(/{(?:(?:".+?":".+?")+?,?)+}/) - messages.map! {|el| JSON.parse(el)}
messages.map! {|el| JSON.parse(el)} - messages.keep_if {|message| message['cmd'] == 'write'}
messages.keep_if {|message| message['cmd'] == 'write'} - messages.map! {|message| message['data']}
messages.map! {|message| message['data']} - output = messages.join ''
output = messages.join '' pre= output or t('request_for_comments.no_output')
end
%>
<pre><%= output or t('request_for_comments.no_output') %></pre>
<% end %>
</div>
<% end %>
<% assess_runs = testruns.select { |run| run.cause == 'assess' } %> - assess_runs = testruns.select {|run| run.cause == 'assess'}
<% if assess_runs.size > 0 %> - if assess_runs.size > 0
<h5 class="mt-4"><%= t('request_for_comments.test_results') %></h5> h5.mt-4= t('request_for_comments.test_results')
<div class="testrun-assess-results"> .testrun-assess-results
<% assess_runs.each do |testrun| %> - assess_runs.each do |testrun|
<div class="testrun-container"> .testrun-container
<div class="result <%= testrun.passed ? 'passed' : 'failed' %>"></div> div class=("result #{testrun.passed ? 'passed' : 'failed'}")
<div class="collapsed testrun-output text"> .collapsed.testrun-output.text
<span class="fa fa-chevron-down collapse-button"></span> span.fa.fa-chevron-down.collapse-button
<pre><%= testrun.output or t('request_for_comments.no_output')%></pre> pre= testrun.output or t('request_for_comments.no_output')
</div>
</div>
<% end %>
</div>
<% end %>
</div>
<% end %>
<% if @current_user.admin? && user.is_a?(ExternalUser) %> - if @current_user.admin? && user.is_a?(ExternalUser)
<%= render('admin_menu') %> = render('admin_menu')
<% end %>
<hr> hr/
<div class="howto"> .howto
<h5 class="mt-4"> h5.mt-4
<%= t('request_for_comments.howto_title') %> = t('request_for_comments.howto_title')
</h5> .text
<div class="text"> = render_markdown(t('request_for_comments.howto'))
<%= render_markdown(t('request_for_comments.howto')) %>
</div>
</div>
</div>
</div>
<div class="d-none sanitizer"></div> .d-none.sanitizer
<!-- /!
do not put a carriage return in the line below. it will be present in the presentation of the source code, otherwise. | do not put a carriage return in the line below. it will be present in the presentation of the source code, otherwise.
also, all settings from the rails model needed for the editor configuration in the JavaScript are attached to the editor as data attributes here. | also, all settings from the rails model needed for the editor configuration in the JavaScript are attached to the editor as data attributes here.
--> - submission.files.each do |file|
<% submission.files.each do |file| %> = (file.path or "") + "/" + file.name + file.file_type.file_extension
<%= (file.path or "") + "/" + file.name + file.file_type.file_extension %><br> br/
&nbsp;&nbsp;<i class="fa fa-arrow-down" aria-hidden="true"></i> <%= t('request_for_comments.click_here') %> |   
<div id='commentitor' class='editor' data-read-only='true' data-file-id='<%=file.id%>' data-mode='<%=file.file_type.editor_mode%>'><%= file.content %> i.fa.fa-arrow-down aria-hidden="true"
</div> = t('request_for_comments.click_here')
<% end %> #commentitor.editor data-file-id="#{file.id}" data-mode="#{file.file_type.editor_mode}" data-read-only="true"
= file.content
<%= render('shared/modal', id: 'comment-modal', title: t('exercises.implement.comment.dialogtitle'), template: 'exercises/_comment_dialogcontent') %> = render('shared/modal', id: 'comment-modal', title: t('exercises.implement.comment.dialogtitle'), template: 'exercises/_comment_dialogcontent')
<script type="text/javascript"> javascript:
$('.modal-content').draggable({ $('.modal-content').draggable({
handle: '.modal-header' handle: '.modal-header'
@ -132,7 +103,7 @@ also, all settings from the rails model needed for the editor configuration in t
if(response.solved){ if(response.solved){
solvedButton.removeClass('btn-primary'); solvedButton.removeClass('btn-primary');
solvedButton.addClass('btn-success'); solvedButton.addClass('btn-success');
solvedButton.html('<%= t('request_for_comments.solved') %>'); solvedButton.html("#{t('request_for_comments.solved')}");
solvedButton.off('click'); solvedButton.off('click');
thankYouContainer.show(); thankYouContainer.show();
} }
@ -207,14 +178,14 @@ also, all settings from the rails model needed for the editor configuration in t
<div class="comment-date">' + comment.date + '</div> \ <div class="comment-date">' + comment.date + '</div> \
<div class="comment-updated' + (comment.updated ? '' : ' d-none') + '"> \ <div class="comment-updated' + (comment.updated ? '' : ' d-none') + '"> \
<i class="fa fa-pencil" aria-hidden="true"></i> \ <i class="fa fa-pencil" aria-hidden="true"></i> \
<%= t('request_for_comments.comment_edited') %> \ #{{ t('request_for_comments.comment_edited') }} \
</div> \ </div> \
</div> \ </div> \
<div class="comment-content">' + commentText + '</div> \ <div class="comment-content">' + commentText + '</div> \
<textarea class="comment-editor">' + commentText + '</textarea> \ <textarea class="comment-editor">' + commentText + '</textarea> \
<div class="comment-actions' + (comment.editable ? '' : ' d-none') + '"> \ <div class="comment-actions' + (comment.editable ? '' : ' d-none') + '"> \
<button class="action-edit btn btn-sm btn-warning"><%= t('shared.edit') %></button> \ <button class="action-edit btn btn-sm btn-warning">#{ t('shared.edit') }</button> \
<button class="action-delete btn btn-sm btn-danger"><%= t('shared.destroy') %></button> \ <button class="action-delete btn btn-sm btn-danger">#{ t('shared.destroy') }</button> \
</div> \ </div> \
</div>'; </div>';
}); });
@ -227,7 +198,7 @@ also, all settings from the rails model needed for the editor configuration in t
var htmlContent = generateCommentHtmlContent(comments.reverse().slice(0, maxComments)); var htmlContent = generateCommentHtmlContent(comments.reverse().slice(0, maxComments));
if (comments.length > maxComments) { if (comments.length > maxComments) {
// add a hint that there are more comments than shown here // add a hint that there are more comments than shown here
htmlContent += '<div class="popover-footer"><%= t('request_for_comments.click_for_more_comments') %></div>' htmlContent += '<div class="popover-footer">#{ t('request_for_comments.click_for_more_comments') }</div>'
.replace('${numComments}', String(comments.length - maxComments)); .replace('${numComments}', String(comments.length - maxComments));
} }
where.popover({ where.popover({
@ -398,7 +369,7 @@ also, all settings from the rails model needed for the editor configuration in t
var row = e.getDocumentPosition().row; var row = e.getDocumentPosition().row;
e.stop(); e.stop();
$('.modal-title').text('<%= t('request_for_comments.modal_title') %>'.replace('${line}', row + 1)); $('.modal-title').text("#{ t('request_for_comments.modal_title') }".replace('${line}', row + 1));
var commentModal = $('#comment-modal'); var commentModal = $('#comment-modal');
@ -416,7 +387,7 @@ also, all settings from the rails model needed for the editor configuration in t
var commentId = parent.data('comment-id'); var commentId = parent.data('comment-id');
deleteComment(commentId, editor, fileid, function () { deleteComment(commentId, editor, fileid, function () {
parent.html('<div class="comment-removed"><%= t('comments.deleted') %></div>'); parent.html('<div class="comment-removed">#{ t('comments.deleted') }</div>');
}); });
}); });
@ -434,7 +405,7 @@ also, all settings from the rails model needed for the editor configuration in t
if (currentlyEditing) { if (currentlyEditing) {
updateComment(commentId, commentEditor.val(), editor, fileid, function () { updateComment(commentId, commentEditor.val(), editor, fileid, function () {
button.text('<%= t('shared.edit') %>'); button.text("#{ t('shared.edit') }");
button.data('editing', false); button.data('editing', false);
commentContent.text(commentEditor.val()); commentContent.text(commentEditor.val());
deleteButton.show(); deleteButton.show();
@ -443,7 +414,7 @@ also, all settings from the rails model needed for the editor configuration in t
commentUpdated.removeClass('d-none'); commentUpdated.removeClass('d-none');
}); });
} else { } else {
button.text('<%= t('comments.save_update') %>'); button.text("#{ t('comments.save_update') }");
button.data('editing', true); button.data('editing', true);
deleteButton.hide(); deleteButton.hide();
commentContent.hide(); commentContent.hide();
@ -487,5 +458,3 @@ also, all settings from the rails model needed for the editor configuration in t
text: message.length > 0 ? message : $('#flash').data('message-failure') text: message.length > 0 ? message : $('#flash').data('message-failure')
}); });
} }
</script>