mirror of
https://github.com/projekteuler/projekteuler.git
synced 2025-12-10 00:36:42 +01:00
Show translation diff for admins
This commit is contained in:
parent
763a7700ed
commit
da0e80e9e0
4
Gemfile
4
Gemfile
@ -42,6 +42,10 @@ gem 'autoprefixer-rails', '~> 9.6.1'
|
|||||||
|
|
||||||
gem 'bh', '~> 1.3.6'
|
gem 'bh', '~> 1.3.6'
|
||||||
|
|
||||||
|
# Use Diffy for showing translation diffs
|
||||||
|
gem 'diffy'
|
||||||
|
gem 'diff-lcs'
|
||||||
|
|
||||||
gem 'will_paginate', '~> 3.1.8'
|
gem 'will_paginate', '~> 3.1.8'
|
||||||
gem 'will-paginate-i18n', '~> 0.1.15'
|
gem 'will-paginate-i18n', '~> 0.1.15'
|
||||||
gem 'will_paginate-bootstrap', '~> 1.0.2'
|
gem 'will_paginate-bootstrap', '~> 1.0.2'
|
||||||
|
|||||||
@ -86,6 +86,8 @@ GEM
|
|||||||
railties (>= 4.1.0)
|
railties (>= 4.1.0)
|
||||||
responders
|
responders
|
||||||
warden (~> 1.2.3)
|
warden (~> 1.2.3)
|
||||||
|
diff-lcs (1.3)
|
||||||
|
diffy (3.3.0)
|
||||||
docile (1.3.2)
|
docile (1.3.2)
|
||||||
erubi (1.8.0)
|
erubi (1.8.0)
|
||||||
execjs (2.7.0)
|
execjs (2.7.0)
|
||||||
@ -252,6 +254,8 @@ DEPENDENCIES
|
|||||||
codacy-coverage
|
codacy-coverage
|
||||||
coffee-rails (~> 5.0.0)
|
coffee-rails (~> 5.0.0)
|
||||||
devise (~> 4.7.1)
|
devise (~> 4.7.1)
|
||||||
|
diff-lcs
|
||||||
|
diffy
|
||||||
jbuilder (~> 2.9.1)
|
jbuilder (~> 2.9.1)
|
||||||
jquery-rails (~> 4.3.5)
|
jquery-rails (~> 4.3.5)
|
||||||
mysql2 (~> 0.5.2)
|
mysql2 (~> 0.5.2)
|
||||||
|
|||||||
@ -3,7 +3,8 @@ window.MathJax = {
|
|||||||
tex2jax: {
|
tex2jax: {
|
||||||
inlineMath: [ ["$","$"], ["\\(","\\)"] ],
|
inlineMath: [ ["$","$"], ["\\(","\\)"] ],
|
||||||
displayMath: [ ["$$","$$"], ["\\[","\\]"] ],
|
displayMath: [ ["$$","$$"], ["\\[","\\]"] ],
|
||||||
processEscapes: true
|
processEscapes: true,
|
||||||
|
ignoreClass: "mathjax_ignore|diff"
|
||||||
},
|
},
|
||||||
"HTML-CSS": { availableFonts: ["TeX"] }
|
"HTML-CSS": { availableFonts: ["TeX"] }
|
||||||
};
|
};
|
||||||
@ -55,6 +55,33 @@ body {
|
|||||||
margin: 20px -30px 0;
|
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 */
|
/* Custom css for fixing styles within problem content */
|
||||||
|
|
||||||
.problem-content {
|
.problem-content {
|
||||||
|
|||||||
@ -7,11 +7,6 @@
|
|||||||
<h1><%= @translation.title %> <small><%= t 'problems.show.problem_subtitle', id: @translation.problem_id %></small></h1>
|
<h1><%= @translation.title %> <small><%= t 'problems.show.problem_subtitle', id: @translation.problem_id %></small></h1>
|
||||||
</div>
|
</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? %>
|
<% if @translation.pending? %>
|
||||||
<%= link_to admin_translation_decline_path(@translation), method: :post, class: 'btn btn-default btn-sm pull-right' do %>
|
<%= link_to admin_translation_decline_path(@translation), method: :post, class: 'btn btn-default btn-sm pull-right' do %>
|
||||||
<%= icon :remove %> <%= t '.decline_translation' %>
|
<%= icon :remove %> <%= t '.decline_translation' %>
|
||||||
@ -26,6 +21,21 @@
|
|||||||
<%= sanitize @translation.content, scrubber: TranslationContentScrubber.new %>
|
<%= sanitize @translation.content, scrubber: TranslationContentScrubber.new %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% 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">
|
<div class="text-center">
|
||||||
<%= link_to t('problems.show.view_original_problem'), @translation.problem.original_url, target: '_blank' %>
|
<%= link_to t('problems.show.view_original_problem'), @translation.problem.original_url, target: '_blank' %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -15,18 +15,17 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
<%= nav class: 'navbar-right' do %>
|
<%= nav class: 'navbar-right' do %>
|
||||||
<% if user_signed_in? %>
|
<% if user_signed_in? %>
|
||||||
<span class="navbar-text">Eingeloggt als <b>
|
<span class="navbar-text"><%= t 'application.logged_in_as_html', name: current_user.name %>
|
||||||
<%= current_user.name %>
|
|
||||||
<% if current_user.admin? %>
|
<% if current_user.admin? %>
|
||||||
<%= icon :star %>
|
<b><%= icon :star %></b>
|
||||||
<% end %>
|
<% end %>
|
||||||
</b></span>
|
</span>
|
||||||
<%= link_to(t('application.sign_out'), destroy_user_session_path, method: :delete) %>
|
<%= link_to(t('application.sign_out'), destroy_user_session_path, method: :delete) %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<% if Rails.env.development? %>
|
<% 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 %>
|
<% 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 %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<% if authors.empty? %>
|
<% if authors.empty? %>
|
||||||
Diese Übersetung wurde anonym erstellt.
|
Diese Übersetzung wurde anonym erstellt.
|
||||||
<% else %>
|
<% else %>
|
||||||
Diese Übersetzung wurde von
|
Diese Übersetzung wurde von
|
||||||
<% if local_assigns[:has_anonymous_author] %>
|
<% if local_assigns[:has_anonymous_author] %>
|
||||||
|
|||||||
@ -21,6 +21,7 @@ de:
|
|||||||
visit_current_translation: "Aktuelle Übersetzung anschauen"
|
visit_current_translation: "Aktuelle Übersetzung anschauen"
|
||||||
already_translated: "Dieses Problem wurde bereits übersetzt."
|
already_translated: "Dieses Problem wurde bereits übersetzt."
|
||||||
is_new_translation: "Dieses Problem hat bisher keine Übersetzung."
|
is_new_translation: "Dieses Problem hat bisher keine Übersetzung."
|
||||||
|
changed_title_html: "Neuer Titel: <code>%{new}</code> statt <code>%{old}</code>"
|
||||||
accept:
|
accept:
|
||||||
success_message: "Übersetzung wurde erfolgreich akzeptiert!"
|
success_message: "Übersetzung wurde erfolgreich akzeptiert!"
|
||||||
decline:
|
decline:
|
||||||
|
|||||||
@ -6,8 +6,9 @@ de:
|
|||||||
updated_at: Aktualisiert
|
updated_at: Aktualisiert
|
||||||
application:
|
application:
|
||||||
site_title: "Projekt Euler"
|
site_title: "Projekt Euler"
|
||||||
sign_in: 'Einloggen'
|
sign_in_with_github: 'Mit GitHub anmelden'
|
||||||
sign_out: 'Ausloggen'
|
logged_in_as_html: "Angemeldet als <b>%{name}</b>"
|
||||||
|
sign_out: 'Abmelden'
|
||||||
info: "Info"
|
info: "Info"
|
||||||
privacy: "Datenschutz"
|
privacy: "Datenschutz"
|
||||||
legal: "Impressum"
|
legal: "Impressum"
|
||||||
|
|||||||
29
db/seeds.rb
29
db/seeds.rb
@ -10,13 +10,27 @@ Translation.delete_all
|
|||||||
Problem.delete_all
|
Problem.delete_all
|
||||||
User.delete_all
|
User.delete_all
|
||||||
|
|
||||||
|
admin = User.create!(
|
||||||
|
provider: :developer,
|
||||||
|
uid: "admin",
|
||||||
|
name: "admin",
|
||||||
|
role: :admin
|
||||||
|
)
|
||||||
|
|
||||||
for i in 1..20 do
|
translator = User.create!(
|
||||||
|
provider: :developer,
|
||||||
|
uid: "translator",
|
||||||
|
name: "translator",
|
||||||
|
role: :user
|
||||||
|
)
|
||||||
|
|
||||||
|
for i in 1..60 do
|
||||||
Problem.create!(id: i)
|
Problem.create!(id: i)
|
||||||
end
|
end
|
||||||
|
|
||||||
for i in 1..10 do
|
for i in 1..10 do
|
||||||
translation = Translation.create!(
|
translation = Translation.create!(
|
||||||
|
author: translator,
|
||||||
problem: Problem.find(i),
|
problem: Problem.find(i),
|
||||||
title: "Problem Nummer #{i}",
|
title: "Problem Nummer #{i}",
|
||||||
content: %Q(<p>Das hier ist der Inhalt von <b>Problem #{i}</b>.
|
content: %Q(<p>Das hier ist der Inhalt von <b>Problem #{i}</b>.
|
||||||
@ -30,19 +44,6 @@ for i in 1..10 do
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
User.create!(
|
|
||||||
provider: :developer,
|
|
||||||
uid: "admin",
|
|
||||||
name: "admin",
|
|
||||||
role: 1
|
|
||||||
)
|
|
||||||
|
|
||||||
User.create!(
|
|
||||||
provider: :developer,
|
|
||||||
uid: "translator",
|
|
||||||
name: "translator"
|
|
||||||
)
|
|
||||||
|
|
||||||
p "Created #{Problem.count} problems"
|
p "Created #{Problem.count} problems"
|
||||||
p "Created #{Translation.count} translations"
|
p "Created #{Translation.count} translations"
|
||||||
p "Created #{User.count} users"
|
p "Created #{User.count} users"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user