1
0
mirror of https://github.com/projekteuler/projekteuler.git synced 2025-12-10 08:46:41 +01:00

Switch to Bootstrap 4

This commit is contained in:
Philipp Fischbeck 2019-12-23 17:49:54 +01:00
parent f28cade211
commit f08254ffef
26 changed files with 207 additions and 120 deletions

10
Gemfile
View File

@ -37,18 +37,16 @@ gem 'web-console', '~> 4.0.1', group: :development
# Use Codacy for coverage # Use Codacy for coverage
gem 'codacy-coverage', :require => false gem 'codacy-coverage', :require => false
gem 'bootstrap-sass', '~> 3.4.1' gem 'bootstrap', '~> 4.4.1'
gem 'autoprefixer-rails', '~> 9.6.1' gem "bootstrap_form", "~> 4.0"
gem 'font-awesome-sass', '~> 5.12.0'
gem 'bh', '~> 1.3.6'
# Use Diffy for showing translation diffs # Use Diffy for showing translation diffs
gem 'diffy' gem 'diffy'
gem 'diff-lcs' 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-bootstrap4', '~> 0.2.2'
gem 'will_paginate-bootstrap', '~> 1.0.2'
gem 'devise', '~> 4.7.1' gem 'devise', '~> 4.7.1'
gem 'omniauth' gem 'omniauth'

View File

@ -56,18 +56,19 @@ GEM
minitest (~> 5.1) minitest (~> 5.1)
tzinfo (~> 1.1) tzinfo (~> 1.1)
zeitwerk (~> 2.2) zeitwerk (~> 2.2)
autoprefixer-rails (9.6.5) autoprefixer-rails (9.7.3)
execjs execjs
bcrypt (3.1.13) bcrypt (3.1.13)
bh (1.3.6)
actionpack
activesupport
bindex (0.8.1) bindex (0.8.1)
bootsnap (1.4.5) bootsnap (1.4.5)
msgpack (~> 1.0) msgpack (~> 1.0)
bootstrap-sass (3.4.1) bootstrap (4.4.1)
autoprefixer-rails (>= 5.2.1) autoprefixer-rails (>= 9.1.0)
sassc (>= 2.0.0) popper_js (>= 1.14.3, < 2)
sassc-rails (>= 2.0.0)
bootstrap_form (4.3.0)
actionpack (>= 5.0)
activemodel (>= 5.0)
builder (3.2.3) builder (3.2.3)
codacy-coverage (2.1.5) codacy-coverage (2.1.5)
simplecov simplecov
@ -94,6 +95,8 @@ GEM
faraday (0.17.0) faraday (0.17.0)
multipart-post (>= 1.2, < 3) multipart-post (>= 1.2, < 3)
ffi (1.11.2) ffi (1.11.2)
font-awesome-sass (5.12.0)
sassc (>= 1.11)
globalid (0.4.2) globalid (0.4.2)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
hashie (3.6.0) hashie (3.6.0)
@ -143,6 +146,7 @@ GEM
oauth2 (~> 1.1) oauth2 (~> 1.1)
omniauth (~> 1.9) omniauth (~> 1.9)
orm_adapter (0.5.0) orm_adapter (0.5.0)
popper_js (1.14.5)
rack (2.0.8) rack (2.0.8)
rack-test (1.1.0) rack-test (1.1.0)
rack (>= 1.0, < 3) rack (>= 1.0, < 3)
@ -227,25 +231,24 @@ GEM
websocket-driver (0.7.1) websocket-driver (0.7.1)
websocket-extensions (>= 0.1.0) websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.4) websocket-extensions (0.1.4)
will-paginate-i18n (0.1.15)
will_paginate (3.1.8) will_paginate (3.1.8)
will_paginate-bootstrap (1.0.2) will_paginate-bootstrap4 (0.2.2)
will_paginate (>= 3.0.3) will_paginate (~> 3.0, >= 3.0.0)
zeitwerk (2.2.1) zeitwerk (2.2.1)
PLATFORMS PLATFORMS
ruby ruby
DEPENDENCIES DEPENDENCIES
autoprefixer-rails (~> 9.6.1)
bh (~> 1.3.6)
bootsnap bootsnap
bootstrap-sass (~> 3.4.1) bootstrap (~> 4.4.1)
bootstrap_form (~> 4.0)
codacy-coverage codacy-coverage
coffee-rails (~> 5.0.0) coffee-rails (~> 5.0.0)
devise (~> 4.7.1) devise (~> 4.7.1)
diff-lcs diff-lcs
diffy diffy
font-awesome-sass (~> 5.12.0)
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)
@ -261,9 +264,8 @@ DEPENDENCIES
tzinfo-data tzinfo-data
uglifier (~> 4.1.20) uglifier (~> 4.1.20)
web-console (~> 4.0.1) web-console (~> 4.0.1)
will-paginate-i18n (~> 0.1.15)
will_paginate (~> 3.1.8) will_paginate (~> 3.1.8)
will_paginate-bootstrap (~> 1.0.2) will_paginate-bootstrap4 (~> 0.2.2)
BUNDLED WITH BUNDLED WITH
2.0.2 2.0.2

View File

@ -10,9 +10,10 @@
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives. // about supported directives.
// //
//= require jquery
//= require jquery_ujs
//= require turbolinks //= require turbolinks
//= require jquery3
//= require rails-ujs
//= require popper
//= require bootstrap-sprockets //= require bootstrap-sprockets
//= require codemirror/codemirror //= require codemirror/codemirror
//= require codemirror/addon/display/placeholder //= require codemirror/addon/display/placeholder

View File

@ -18,6 +18,6 @@ App.init = ->
$(document).on "turbolinks:load", -> $(document).on "turbolinks:load", ->
App.init() App.init()
$(document).on "click", '#translationNav a[href="#preview"]', -> $(document).on "click", '#translationTab a[href="#preview"]', ->
$('#preview .problem-content').html(cm.getValue()) $('#preview .problem-content').html(cm.getValue())
MathJax.Hub.Queue(["Typeset",MathJax.Hub]); MathJax.Hub.Queue(["Typeset",MathJax.Hub]);

View File

@ -15,11 +15,13 @@
*= require_tree . *= require_tree .
*/ */
@import "bootstrap-sprockets";
@import "bootstrap"; @import "bootstrap";
@import "rails_bootstrap_forms";
@import "font-awesome-sprockets";
@import "font-awesome";
.turbolinks-progress-bar { .turbolinks-progress-bar {
background-color: $brand-primary; background-color: $primary;
} }
/* Sticky footer styles /* Sticky footer styles
-------------------------------------------------- */ -------------------------------------------------- */
@ -37,21 +39,33 @@ body {
width: 100%; width: 100%;
/* Set the fixed height of the footer here */ /* Set the fixed height of the footer here */
height: 40px; height: 40px;
background-color: $navbar-default-bg; background-color: $light;
} }
.container .text-muted { .container .text-muted {
margin: 10px 0; margin: 10px 0;
} }
.problem-buttons {
position: relative;
display: block;
}
.problem-buttons .problem-buttons-inner {
position: absolute;
right: 0;
top: 0;
z-index: 10;
}
/* Style for links to previous and next problem */ /* Style for links to previous and next problem */
.problem-prev { .problem-prev {
@extend .pull-left; float: left;
margin: 20px -30px 0; margin: 20px -30px 0;
} }
.problem-next { .problem-next {
@extend .pull-right; float: right;
margin: 20px -30px 0; margin: 20px -30px 0;
} }

View File

@ -27,4 +27,12 @@ module ApplicationHelper
page_title + ' - ' + base_title page_title + ' - ' + base_title
end end
end end
def nav_link_to(body, url)
nav_options = { class: current_page?(url) ? 'nav-item active': 'nav-item' }
content_tag(:li, nav_options) do
link_to body, url, class: 'nav-link'
end
end
end end

View File

@ -1,6 +1,8 @@
<% provide(:title, 'Copyright') %> <% provide(:title, 'Copyright') %>
<div class="page-header"><h1>Copyright</h1></div> <div class="pb-2 mt-4 mb-2 border-bottom">
<h1>Copyright</h1>
</div>
<div class="bs-callout bs-callout-info">Dieser Artikel dient gleichzeitig der Übersetzung der <a href="https://projecteuler.net/copyright">"Copyright Information" auf projecteuler.net</a> sowie der tatsächlich geltenden Copyright-Informationen für diese Seite.</div> <div class="bs-callout bs-callout-info">Dieser Artikel dient gleichzeitig der Übersetzung der <a href="https://projecteuler.net/copyright">"Copyright Information" auf projecteuler.net</a> sowie der tatsächlich geltenden Copyright-Informationen für diese Seite.</div>
<h2>Kann ich die Probleme woanders benutzen?</h2> <h2>Kann ich die Probleme woanders benutzen?</h2>
<p>Ja! Es ist nicht nur erlaubt, sondern beherzt, das Material zu teilen und frei zu benutzen - für nichtkommerzielle Zwecke. Aber bitte lesen Sie weiter...<br /> <p>Ja! Es ist nicht nur erlaubt, sondern beherzt, das Material zu teilen und frei zu benutzen - für nichtkommerzielle Zwecke. Aber bitte lesen Sie weiter...<br />

View File

@ -1,12 +1,10 @@
<div class="jumbotron"> <div class="jumbotron">
<div class="container"> <h1 class="display-4">Willkommen auf Projekt Euler!</h1>
<h1>Willkommen auf Projekt Euler!</h1> <p>Diese Seite ist eine Übersetzung der englischen Rätsel-Webseite <a href="https://projecteuler.net/">projecteuler.net</a>.</p>
<p>Diese Seite ist eine Übersetzung der englischen Rätsel-Webseite <a href="https://projecteuler.net/">projecteuler.net</a>.</p> <p class="lead">
<p> <%= link_to about_info_path, class: 'btn btn-primary btn-lg' do %>
<%= link_to about_info_path, class: 'btn btn-primary btn-lg' do %> Mehr erfahren &raquo;
Mehr erfahren &raquo; <% end %>
<% end %>
</div>
</div> </div>
<div class="container"> <div class="container">
@ -16,7 +14,7 @@
<h2>Ansehen</h2> <h2>Ansehen</h2>
<p>Sehen Sie sich die mathematischen Probleme in deutscher Sprache an.</p> <p>Sehen Sie sich die mathematischen Probleme in deutscher Sprache an.</p>
<p> <p>
<%= link_to problems_path, class: 'btn btn-default' do %> <%= link_to problems_path, class: 'btn btn-primary' do %>
Zu den Problemen &raquo; Zu den Problemen &raquo;
<% end %> <% end %>
</p> </p>
@ -28,7 +26,7 @@
<div class="col-md-4"> <div class="col-md-4">
<h2>Verbessern</h2> <h2>Verbessern</h2>
<p>Vermissen Sie eine Funktion auf der Webseite, oder ist Ihnen ein Fehler aufgefallen? Dann helfen Sie beim Entwickeln der Webseite in Ruby on Rails!</p> <p>Vermissen Sie eine Funktion auf der Webseite, oder ist Ihnen ein Fehler aufgefallen? Dann helfen Sie beim Entwickeln der Webseite in Ruby on Rails!</p>
<p><a class="btn btn-default" href="https://github.com/projekteuler/projekteuler" target="_blank" role="button">Projekt Euler auf GitHub &raquo;</a></p> <p><a class="btn btn-primary" href="https://github.com/projekteuler/projekteuler" target="_blank">Projekt Euler auf GitHub &raquo;</a></p>
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,8 +1,8 @@
<% provide(:title, 'Über Project Euler') %> <% provide(:title, 'Über Project Euler') %>
<div class="pb-2 mt-4 mb-2 border-bottom">
<div class="page-header"> <h1>Über Project Euler</h1>
<h1>Über Project Euler</h1>
</div> </div>
<h2>Was ist Project Euler?</h2> <h2>Was ist Project Euler?</h2>
<%= image_tag 'euler_main.jpg', alt: 'Leonhard Euler (1707-1783)', width: '150px', style: 'border:1px solid black;margin:10px;float:right' %> <%= image_tag 'euler_main.jpg', alt: 'Leonhard Euler (1707-1783)', width: '150px', style: 'border:1px solid black;margin:10px;float:right' %>
<p>Project Euler ist eine Serie von herausfordernden mathematischen bzw. Programmier-Problemen, die mehr als nur mathematische Einblicke zum Lösen erfordern. Obwohl die Mathematik Ihnen helfen wird, auf elegante und effiziente Lösungswege zu kommen, ist der Gebrauch von Computer- und Programmierkenntnissen nötig, um den Großteil der Probleme zu lösen.<br /><br />Die Motivation für das Starten und die Instandhaltung von Project Euler ist die, dem Forschergeist eine Plattform bereitzustellen, die sich mit unbekannten Gebieten befasst, und neue Konzepte in einem spaßigen und freizeitlichen Kontext zu erlernen.</p> <p>Project Euler ist eine Serie von herausfordernden mathematischen bzw. Programmier-Problemen, die mehr als nur mathematische Einblicke zum Lösen erfordern. Obwohl die Mathematik Ihnen helfen wird, auf elegante und effiziente Lösungswege zu kommen, ist der Gebrauch von Computer- und Programmierkenntnissen nötig, um den Großteil der Probleme zu lösen.<br /><br />Die Motivation für das Starten und die Instandhaltung von Project Euler ist die, dem Forschergeist eine Plattform bereitzustellen, die sich mit unbekannten Gebieten befasst, und neue Konzepte in einem spaßigen und freizeitlichen Kontext zu erlernen.</p>
@ -18,4 +18,4 @@
</p> </p>
<p>Aber wenn die Probleme nach einer Herausforderung klingen, dann können Sie sich die <%= link_to 'Probleme', problems_path %> ansehen, bevor Sie sich registrieren. <p>Aber wenn die Probleme nach einer Herausforderung klingen, dann können Sie sich die <%= link_to 'Probleme', problems_path %> ansehen, bevor Sie sich registrieren.
</p> </p>
<blockquote><p>&quot;Project Euler existiert zum Begeistern, Herausfordern und Entwickeln der Fähigkeiten und des Genusses von jedem mit einem Interesse für die faszinierende Welt der Mathematik.&quot;</p></blockquote> <blockquote class="blockquote"><p>&quot;Project Euler existiert zum Begeistern, Herausfordern und Entwickeln der Fähigkeiten und des Genusses von jedem mit einem Interesse für die faszinierende Welt der Mathematik.&quot;</p></blockquote>

View File

@ -1,6 +1,8 @@
<% provide(:title, 'Impressum') %> <% provide(:title, 'Impressum') %>
<div class="page-header"><h1>Impressum</h1></div> <div class="pb-2 mt-4 mb-2 border-bottom">
<h1>Impressum</h1>
</div>
<p>Angaben gemäß § 5 TMG:<br/><br/></p> <p>Angaben gemäß § 5 TMG:<br/><br/></p>
<p>Philipp Fischbeck<br /> <p>Philipp Fischbeck<br />
Großbeerenstraße 48<br /> Großbeerenstraße 48<br />

View File

@ -1,6 +1,8 @@
<% provide(:title, 'Datenschutz') %> <% provide(:title, 'Datenschutz') %>
<div class="page-header"><h1>Datenschutz</h1></div> <div class="pb-2 mt-4 mb-2 border-bottom">
<h1>Datenschutz</h1>
</div>
<p>Diese Datenschutz-Information gilt für die Datenverarbeitung durch:<br /></p> <p>Diese Datenschutz-Information gilt für die Datenverarbeitung durch:<br /></p>
<p>Philipp Fischbeck<br /> <p>Philipp Fischbeck<br />

View File

@ -1,6 +1,6 @@
<%= provide(:title, 'Über römische Zahlen') %> <%= provide(:title, 'Über römische Zahlen') %>
<div class="page-header"> <div class="pb-2 mt-4 mb-2 border-bottom">
<h1>Über... römische Zahlen</h1> <h1>Über... römische Zahlen</h1>
</div> </div>
<h3>Wie liest und schreibt man römische Zahlen?</h3> <h3>Wie liest und schreibt man römische Zahlen?</h3>

View File

@ -1,6 +1,8 @@
<% provide(:title, t('.administration')) %> <% provide(:title, t('.administration')) %>
<h1><%= t('.administration') %></h1> <div class="pb-2 mt-4 mb-2 border-bottom">
<%= link_to t('.view_translations'), admin_translations_path, class: 'btn btn-default' %> <h1><%= t('.administration') %></h1>
</div>
<%= link_to t('.view_translations'), admin_translations_path, class: 'btn btn-primary' %>
<h1><%= t('.update_problem_count') %></h1> <h1><%= t('.update_problem_count') %></h1>
<%= form_tag '/admin/update_problem_count', method: :post, class: 'form-inline' do %> <%= form_tag '/admin/update_problem_count', method: :post, class: 'form-inline' do %>

View File

@ -1 +1 @@
<%= will_paginate @translations, renderer: BootstrapPagination::Rails %> <%= will_paginate @translations, renderer: WillPaginate::ActionView::BootstrapLinkRenderer %>

View File

@ -1,6 +1,8 @@
<% provide(:title, Translation.model_name.human(count: 2)) %> <% provide(:title, Translation.model_name.human(count: 2)) %>
<h1><%= Translation.model_name.human(count: 2) %></h1> <div class="pb-2 mt-4 mb-2 border-bottom">
<h1><%= Translation.model_name.human(count: 2) %></h1>
</div>
<%= render 'translation_pagination' %> <%= render 'translation_pagination' %>
<table class="table table-striped table-bordered"> <table class="table table-striped table-bordered">

View File

@ -1,6 +1,6 @@
<% provide(:title, t('problems.show.problem_subtitle', id: @translation.problem_id)) %> <% provide(:title, t('problems.show.problem_subtitle', id: @translation.problem_id)) %>
<div class="page-header"> <div class="pb-2 mt-4 mb-2">
<p class="text-muted"> <p class="text-muted">
<%= render 'shared/authors', authors: Array(@translation.author) %> <%= render 'shared/authors', authors: Array(@translation.author) %>
</p> </p>
@ -8,19 +8,23 @@
</div> </div>
<% if @translation.pending? %> <% if @translation.pending? %>
<%= link_to admin_translation_decline_path(@translation), method: :post, class: 'btn btn-default btn-sm pull-right' do %> <div class="problem-buttons">
<%= icon :remove %> <%= t '.decline_translation' %> <div class="btn-group problem-buttons-inner">
<% end %> <%= link_to admin_translation_decline_path(@translation), method: :post, class: 'btn btn-danger btn-sm' do %>
<%= link_to admin_translation_accept_path(@translation), method: :post, class: 'btn btn-default btn-sm pull-right' do %> <%= icon('fas', 'times') %> <%= t '.decline_translation' %>
<%= icon :ok %> <%= t '.accept_translation' %> <% end %>
<% end %> <%= link_to admin_translation_accept_path(@translation), method: :post, class: 'btn btn-success btn-sm' do %>
<%= icon('fas', 'check') %> <%= t '.accept_translation' %>
<% end %>
</div>
</div>
<% end %> <% end %>
<%= panel do %> <div class="card mb-3">
<div class="panel-body problem-content"> <div class="card-body problem-content">
<%= sanitize @translation.content, scrubber: TranslationContentScrubber.new %> <%= sanitize @translation.content, scrubber: TranslationContentScrubber.new %>
</div> </div>
<% end %> </div>
<% if @translation.problem.is_translated? %> <% if @translation.problem.is_translated? %>
<% if @translation.title != @translation.problem.title %> <% if @translation.title != @translation.problem.title %>

View File

@ -1,33 +1,40 @@
<%= navbar position: :static do %> <nav class="navbar navbar-expand-lg navbar-light bg-light">
<%= vertical do %> <%= link_to t('application.site_title'), root_path, class: 'navbar-brand' %>
<%= link_to t('application.site_title'), root_path %> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<% end %> <span class="navbar-toggler-icon"></span>
<%= horizontal do %> </button>
<%= nav class: 'navbar-left' do %> <div class="collapse navbar-collapse" id="navbarSupportedContent">
<%= link_to t('application.info'), about_info_path %> <ul class="navbar-nav mr-auto">
<%= link_to Problem.model_name.human(count: 2), problems_path %> <%= nav_link_to t('application.info'), about_info_path %>
<%= nav_link_to Problem.model_name.human(count: 2), problems_path %>
<% if user_signed_in? and current_user.admin? %> <% if user_signed_in? and current_user.admin? %>
<%= link_to t('admin.dashboard.index.administration'), admin_dashboard_index_path %> <%= nav_link_to t('admin.dashboard.index.administration'), admin_dashboard_index_path %>
<%= link_to admin_translations_path do %> <%= link_to admin_translations_path, class: 'nav-link' do %>
<%= t('admin.dashboard.index.translations') %> <span class="badge"><%= Translation.pending.count %></span> <%= t('admin.dashboard.index.translations') %> <span class="badge badge-secondary"><%= Translation.pending.count %></span>
<% end %> <% end %>
<% end %> <% end %>
<% end %> </ul>
<%= nav class: 'navbar-right' do %> <ul class="navbar-nav">
<% if user_signed_in? %> <% if user_signed_in? %>
<li class="nav-item">
<span class="navbar-text"><%= t 'application.logged_in_as_html', name: current_user.name %> <span class="navbar-text"><%= t 'application.logged_in_as_html', name: current_user.name %>
<% if current_user.admin? %> <% if current_user.admin? %>
<b><%= icon :star %></b> <b><%= icon('fas', 'star') %></b>
<% end %> <% end %>
</span> </span>
<%= link_to(t('application.sign_out'), destroy_user_session_path, method: :delete) %> </li>
<% else %> <li class="nav-item">
<%= link_to t('application.sign_out'), destroy_user_session_path, method: :delete, class: 'nav-link' %>
</li>
<% else %>
<li class="nav-item">
<% if Rails.env.development? %> <% if Rails.env.development? %>
<%= link_to(t('application.sign_in_with_github'), user_developer_omniauth_authorize_path) %> <%= link_to t('application.sign_in_with_github'), user_developer_omniauth_authorize_path, class: 'nav-link' %>
<% else %> <% else %>
<%= link_to(t('application.sign_in_with_github'), user_github_omniauth_authorize_path) %> <%= link_to t('application.sign_in_with_github'), user_github_omniauth_authorize_path, class: 'nav-link' %>
<% end %> <% end %>
<% end %> </li>
<% end %> <% end %>
<% end %> </ul>
<% end %> </div>
</nav>

View File

@ -15,11 +15,9 @@
<body> <body>
<main role="main"> <main role="main">
<%= render 'layouts/header' %> <%= render 'layouts/header' %>
<div class="container"> <div class="container mt-3 mb-3">
<%= flash_messages %> <%= flash_messages %>
<div class="row"> <%= yield %>
<%= yield %>
</div>
</div> </div>
</main> </main>

View File

@ -1 +1 @@
<%= will_paginate @problems, renderer: BootstrapPagination::Rails %> <%= will_paginate @problems, renderer: WillPaginate::ActionView::BootstrapLinkRenderer %>

View File

@ -1,9 +1,15 @@
<% provide(:title, Problem.model_name.human(count: 2)) %> <% provide(:title, Problem.model_name.human(count: 2)) %>
<div class="page-header"><h1><%= Problem.model_name.human(count: 2) %></h1></div> <div class="pb-2 mt-4 mb-2 border-bottom">
<h1><%= Problem.model_name.human(count: 2) %></h1>
</div>
<p><%= t('problems.index.translated_count', translated: Problem.translated_count, total: Problem.count) %></p> <p><%= t('problems.index.translated_count', translated: Problem.translated_count, total: Problem.count) %></p>
<%= progress_bar percentage: @translated_percentage, label: true, striped: true %> <div class="progress mb-3">
<div class="progress-bar progress-bar-striped bg-primary" role="progressbar" style="width: <%= @translated_percentage %>%" aria-valuenow="<%= @translated_percentage %>>" aria-valuemin="0" aria-valuemax="100">
<%= @translated_percentage %>%
</div>
</div>
<%= render 'problem_pagination' %> <%= render 'problem_pagination' %>
<table class="table table-striped table-bordered"> <table class="table table-striped table-bordered">
@ -23,8 +29,8 @@
<%= link_to problem.title, problem %> <%= link_to problem.title, problem %>
<% else %> <% else %>
<i><%= t 'problems.not_yet_translated' %></i> <i><%= t 'problems.not_yet_translated' %></i>
<%= link_to new_problem_translation_path(problem), class: 'btn btn-default btn-xs' do %> <%= link_to new_problem_translation_path(problem), class: 'btn btn-primary btn-sm' do %>
<%= icon :pencil %> <%= t '.suggest_translation' %> <%= icon('fas', 'edit') %> <%= t '.suggest_translation' %>
<% end %> <% end %>
<% end %> <% end %>

View File

@ -1,6 +1,6 @@
<% provide(:title, t('problems.show.problem_subtitle', id: @problem.id)) %> <% provide(:title, t('problems.show.problem_subtitle', id: @problem.id)) %>
<div class="page-header"> <div class="pb-2 mt-4 mb-2">
<p class="text-muted"> <p class="text-muted">
<%= render 'shared/authors', authors: @problem.authors, has_anonymous_author: @problem.has_anonymous_author? %> <%= render 'shared/authors', authors: @problem.authors, has_anonymous_author: @problem.has_anonymous_author? %>
</p> </p>
@ -8,22 +8,24 @@
</div> </div>
<% if Problem.exists?(@problem.id-1) %> <% if Problem.exists?(@problem.id-1) %>
<%= link_to problem_path(@problem.id-1), title: t('problems.show.problem_subtitle', id: @problem.id-1), class: 'problem-prev' do %> <%= link_to problem_path(@problem.id-1), title: t('problems.show.problem_subtitle', id: @problem.id-1), class: 'problem-prev' do %>
<%= icon :menu_left %> <%= icon('fas', 'chevron-left') %>
<% end %> <% end %>
<% end %> <% end %>
<% if Problem.exists?(@problem.id+1) %> <% if Problem.exists?(@problem.id+1) %>
<%= link_to problem_path(@problem.id+1), title: t('problems.show.problem_subtitle', id: @problem.id+1), class: 'problem-next' do %> <%= link_to problem_path(@problem.id+1), title: t('problems.show.problem_subtitle', id: @problem.id+1), class: 'problem-next' do %>
<%= icon :menu_right %> <%= icon('fas', 'chevron-right') %>
<% end %> <% end %>
<% end %> <% end %>
<%= link_to new_problem_translation_path(@problem), class: 'btn btn-default btn-sm pull-right' do %> <div class="problem-buttons">
<%= icon :pencil %> <%= t '.improve_translation' %> <%= link_to new_problem_translation_path(@problem), class: 'problem-buttons-inner btn btn-primary btn-sm' do %>
<% end %> <%= icon('fas', 'edit') %> <%= t '.improve_translation' %>
<%= panel do %> <% end %>
<div class="panel-body problem-content"> </div>
<div class="card mb-3">
<div class="card-body problem-content">
<%= sanitize @problem.content, scrubber: TranslationContentScrubber.new %> <%= sanitize @problem.content, scrubber: TranslationContentScrubber.new %>
</div> </div>
<% end %> </div>
<div class="text-center"> <div class="text-center">
<%= link_to t('.view_original_problem'), @problem.original_url, target: '_blank' %> <%= link_to t('.view_original_problem'), @problem.original_url, target: '_blank' %>
</div> </div>

View File

@ -1,10 +1,10 @@
<% provide(:title, t('problems.show.problem_subtitle', id: @problem.id)) %> <% provide(:title, t('problems.show.problem_subtitle', id: @problem.id)) %>
<div class="page-header"> <div class="pb-2 mt-4 mb-2 border-bottom">
<h1><%= t 'problems.show.problem_subtitle', id: @problem.id %></h1> <h1><%= t 'problems.show.problem_subtitle', id: @problem.id %></h1>
</div> </div>
<%= t 'problems.not_yet_translated' %> <%= t 'problems.not_yet_translated' %>
<%= link_to new_problem_translation_path(@problem), class: 'btn btn-default btn-xs' do %> <%= link_to new_problem_translation_path(@problem), class: 'btn btn-default btn-xs' do %>
<%= icon :pencil %> <%= t 'problems.index.suggest_translation' %> <%= icon('fas', 'edit') %> <%= t 'problems.index.suggest_translation' %>
<% end %> <% end %>

View File

@ -1,17 +1,23 @@
<%= form_for [@problem, @translation], layout: :basic do |f| %> <%= bootstrap_form_for [@problem, @translation], layout: :basic do |f| %>
<%= f.text_field :title %> <%= f.text_field :title %>
<%= nav id: 'translationNav' do %> <ul class="nav nav-tabs" id="translationTab" role="tablist">
<%= link_to t('.source_code'), '#source', data: {toggle: 'tab'} %> <li class="nav-item">
<%= link_to t('.preview'), '#preview', data: {toggle: 'tab'} %> <%= link_to t('.source_code'), '#source', data: {toggle: 'tab'}, class:'nav-link active', id:'source-tab', role:'tab', 'aria-controls':'source', 'aria-selected':'true' %>
<% end %> </li>
<div class="tab-content"> <li class="nav-item">
<div class="tab-pane active" id="source"> <%= link_to t('.preview'), '#preview', data: {toggle: 'tab'}, class:'nav-link', id:'preview-tab', role:'tab', 'aria-controls':'preview', 'aria-selected':'false' %>
</li>
</ul>
<div class="tab-content" id="translationTabContent">
<div class="tab-pane show active" id="source" role="tabpanel" aria-labelledby="source-tab">
<%= f.text_area :content, placeholder: t('.translation_source_explanation') %> <%= f.text_area :content, placeholder: t('.translation_source_explanation') %>
</div> </div>
<%= panel class: 'tab-pane', id: 'preview' do %> <div class="tab-pane" id="preview" role="tabpanel" aria-labelledby="preview-tab">
<div class="panel-body problem-content"> <div class="card">
<div class="card-body problem-content">
</div>
</div> </div>
<% end %> </div>
</div> </div>
<div class="alert alert-info"> <div class="alert alert-info">
<%= t '.copyright_warning_html' %> <%= t '.copyright_warning_html' %>
@ -19,8 +25,8 @@
<%= t '.not_logged_in_warning' %> <%= t '.not_logged_in_warning' %>
<% end %> <% end %>
</div> </div>
<%= f.submit %> <%= f.primary %>
<% if user_signed_in? and current_user.admin? %> <% if user_signed_in? and current_user.admin? %>
<%= f.button t('.save_and_accept'), type: :submit, name: "accept", value: true, class: "btn-success" %> <%= f.button t('.save_and_accept'), type: :submit, name: "accept", value: true, class: "btn btn-success" %>
<% end %> <% end %>
<% end %> <% end %>

View File

@ -1,5 +1,8 @@
<%= panel heading: 'Hinweise zur Erstellung von Übersetzungen', context: :info do %> <div class="card">
<div class='panel-body'> <div class="card-header">
Hinweise zur Erstellung von Übersetzungen
</div>
<div class='card-body'>
<ul> <ul>
<li>Als Basis für jede Übersetzung dient der HTML-Quelltext von projecteuler.net. <li>Als Basis für jede Übersetzung dient der HTML-Quelltext von projecteuler.net.
Dazu gehen Sie auf die entsprechende <%= link_to "Problem-Seite", @problem.original_url, target: '_blank' %>. Dazu gehen Sie auf die entsprechende <%= link_to "Problem-Seite", @problem.original_url, target: '_blank' %>.
@ -12,4 +15,4 @@
<li>Die Sie-Form benutzen.</li> <li>Die Sie-Form benutzen.</li>
</ul> </ul>
</div> </div>
<% end %> </div>

View File

@ -7,6 +7,8 @@ class Admin::TranslationsControllerTest < ActionDispatch::IntegrationTest
login_admin login_admin
@translation = translations(:translation_one) @translation = translations(:translation_one)
@translation_alternative = translations(:translation_two_alternative) @translation_alternative = translations(:translation_two_alternative)
@translation_outdated = translations(:translation_two_outdated)
@translation_declined = translations(:translation_two_declined)
end end
test "should get index" do test "should get index" do
get admin_translations_url get admin_translations_url
@ -14,11 +16,26 @@ class Admin::TranslationsControllerTest < ActionDispatch::IntegrationTest
assert_not_nil assigns(:translations) assert_not_nil assigns(:translations)
end end
test "should show translation" do test "should show current_translation" do
get admin_translation_url(translation_id: @translation) get admin_translation_url(translation_id: @translation)
assert_response :success assert_response :success
end end
test "should show alternative_translation" do
get admin_translation_url(translation_id: @translation_alternative)
assert_response :success
end
test "should show outdated_translation" do
get admin_translation_url(translation_id: @translation_outdated)
assert_response :success
end
test "should show declined_translation" do
get admin_translation_url(translation_id: @translation_declined)
assert_response :success
end
test "should accept translation" do test "should accept translation" do
post admin_translation_accept_path(@translation_alternative) post admin_translation_accept_path(@translation_alternative)
assert_redirected_to problem_path(2) assert_redirected_to problem_path(2)

View File

@ -18,6 +18,19 @@ translation_two_alternative:
content: The changed content for the second problem content: The changed content for the second problem
status: 0 status: 0
translation_two_outdated:
problem_id: 2
title: Second title
content: The old content for the second problem
status: 2
translation_two_declined:
problem_id: 2
title: Second title
content: The content for the second problem with typo
status: 3
translation_with_html: translation_with_html:
problem_id: 4 problem_id: 4
title: Some title title: Some title