1
0
mirror of https://github.com/projekteuler/projekteuler.git synced 2026-01-26 18:18:51 +01:00

Show translation diff for admins

This commit is contained in:
2019-10-26 15:06:34 +02:00
parent 763a7700ed
commit da0e80e9e0
10 changed files with 77 additions and 29 deletions

View File

@@ -3,7 +3,8 @@ window.MathJax = {
tex2jax: {
inlineMath: [ ["$","$"], ["\\(","\\)"] ],
displayMath: [ ["$$","$$"], ["\\[","\\]"] ],
processEscapes: true
processEscapes: true,
ignoreClass: "mathjax_ignore|diff"
},
"HTML-CSS": { availableFonts: ["TeX"] }
};

View File

@@ -55,6 +55,33 @@ body {
margin: 20px -30px 0;
}
/* Style for translation diffs */
.diff {
overflow:auto;
margin-bottom: 20px;
ul{background:#fff;overflow:auto;font-size:13px;list-style:none;margin:0;padding:0;display:table;width:100%;}
del, ins{display:block;text-decoration:none;}
li {
padding:0;
display:table-row;
margin: 0;
height:1em;
ins {
background:#dfd;
color:#080;
strong{font-weight:normal;background:#9f9;}
}
del {
background:#fee;
color:#b00;
strong{font-weight:normal;background:#fcc;}
}
/* try 'whitespace:pre;' if you don't want lines to wrap */
del, ins, span {white-space:pre-wrap;font-family:courier;}
}
}
/* Custom css for fixing styles within problem content */
.problem-content {

View File

@@ -7,11 +7,6 @@
<h1><%= @translation.title %> <small><%= t 'problems.show.problem_subtitle', id: @translation.problem_id %></small></h1>
</div>
<% if @translation.problem.is_translated? %>
<div class="alert alert-warning" role="alert"><%= t('.already_translated') %> <%= link_to t('.visit_current_translation'), @translation.problem, target: '_blank', class: 'alert-link' %></div>
<% else %>
<div class="alert alert-info" role="alert"><%= t('.is_new_translation') %></div>
<% end %>
<% if @translation.pending? %>
<%= link_to admin_translation_decline_path(@translation), method: :post, class: 'btn btn-default btn-sm pull-right' do %>
<%= icon :remove %> <%= t '.decline_translation' %>
@@ -26,6 +21,21 @@
<%= sanitize @translation.content, scrubber: TranslationContentScrubber.new %>
</div>
<% end %>
<% if @translation.problem.is_translated? %>
<% if @translation.title != @translation.problem.title %>
<h3><%= t 'activerecord.attributes.translation.title' %></h3>
<p><%= t '.changed_title_html', old: @translation.problem.title, new: @translation.title %></p>
<% end %>
<h3><%= t 'activerecord.attributes.translation.content' %></h3>
<%= raw Diffy::Diff.new(@translation.problem.content, @translation.content, allow_empty_diff: false).to_s(:html) %>
<div class="alert alert-warning" role="alert"><%= t('.already_translated') %> <%= link_to t('.visit_current_translation'), @translation.problem, target: '_blank', class: 'alert-link' %></div>
<% else %>
<h2><%= t 'activerecord.attributes.translation.content' %></h2>
<%= raw Diffy::Diff.new(@translation.content, @translation.content, allow_empty_diff: false).to_s(:html) %>
<div class="alert alert-info" role="alert"><%= t('.is_new_translation') %></div>
<% end %>
<div class="text-center">
<%= link_to t('problems.show.view_original_problem'), @translation.problem.original_url, target: '_blank' %>
</div>

View File

@@ -15,18 +15,17 @@
<% end %>
<%= nav class: 'navbar-right' do %>
<% if user_signed_in? %>
<span class="navbar-text">Eingeloggt als <b>
<%= current_user.name %>
<span class="navbar-text"><%= t 'application.logged_in_as_html', name: current_user.name %>
<% if current_user.admin? %>
<%= icon :star %>
<b><%= icon :star %></b>
<% end %>
</b></span>
</span>
<%= link_to(t('application.sign_out'), destroy_user_session_path, method: :delete) %>
<% else %>
<% if Rails.env.development? %>
<%= link_to(t('application.sign_in'), user_developer_omniauth_authorize_path) %>
<%= link_to(t('application.sign_in_with_github'), user_developer_omniauth_authorize_path) %>
<% else %>
<%= link_to(t('application.sign_in'), user_github_omniauth_authorize_path) %>
<%= link_to(t('application.sign_in_with_github'), user_github_omniauth_authorize_path) %>
<% end %>
<% end %>
<% end %>

View File

@@ -1,5 +1,5 @@
<% if authors.empty? %>
Diese Übersetung wurde anonym erstellt.
Diese Übersetzung wurde anonym erstellt.
<% else %>
Diese Übersetzung wurde von
<% if local_assigns[:has_anonymous_author] %>