Mattias Bodlund 1 year ago
parent
commit
2a30404429
12 changed files with 48 additions and 19 deletions
  1. +1
    -1
      app/assets/images/ico-arrow-updown.svg
  2. +8
    -1
      app/assets/stylesheets/application.css
  3. +5
    -0
      app/controllers/admin/admin_controller.rb
  4. +3
    -0
      app/controllers/admin/nodes_controller.rb
  5. +10
    -0
      app/controllers/direct_uploads_controller.rb
  6. +1
    -1
      app/helpers/languages_helper.rb
  7. +7
    -4
      app/models/node.rb
  8. +2
    -1
      app/views/admin/nodes/_form.html.erb
  9. +2
    -2
      app/views/material/_text_field_i18n.html.erb
  10. +5
    -5
      app/views/material/_text_field_i18n_simple.html.erb
  11. +2
    -2
      config/application.rb
  12. +2
    -2
      config/locales/en.yml

+ 1
- 1
app/assets/images/ico-arrow-updown.svg View File

@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 124 103"><path d="M118.45,59.92c-2.38-1.17-5.06-1.33-7.56-.47-2.5.86-4.52,2.65-5.68,5.03l-1.3,2.66-5.13-15c-2.06-6.01-6.32-10.86-12.01-13.66-5.69-2.79-12.12-3.19-18.11-1.13l-21.22,7.31c-.99.34-2.05.27-2.98-.19-.94-.46-1.64-1.26-1.98-2.25l-4.38-12.81,1.19.58c4.9,2.41,10.84.36,13.24-4.56,2.4-4.92.36-10.89-4.55-13.3L25.33,1.01c-4.9-2.41-10.84-.36-13.24,4.56L1.01,28.32c-1.16,2.39-1.33,5.08-.47,7.59.86,2.51,2.64,4.54,5.02,5.7,4.9,2.41,10.84.36,13.24-4.56l.58-1.19,4.38,12.81c2.06,6.01,6.32,10.86,12.01,13.66,5.69,2.79,12.12,3.2,18.11,1.13l21.22-7.31c2.04-.7,4.27.39,4.96,2.44l5.13,15-2.65-1.3c-2.38-1.17-5.06-1.33-7.56-.47-2.5.86-4.52,2.65-5.68,5.04-1.16,2.38-1.33,5.08-.47,7.59.86,2.51,2.64,4.54,5.01,5.7l24.12,11.84c1.4.68,2.87,1.01,4.33,1.01,3.67,0,7.19-2.05,8.91-5.57l11.79-24.22c2.4-4.92.36-10.89-4.54-13.3Z" style="fill:#fff;"/><path d="M104.89,94.33c-.7,1.43-2.42,2.03-3.85,1.33l-24.12-11.84c-1.43-.7-2.02-2.43-1.32-3.86.7-1.43,2.42-2.03,3.85-1.33l17.88,8.78-10.63-31.1c-1.96-5.73-8.18-8.79-13.89-6.82l-21.22,7.31c-8.71,3-18.2-1.66-21.19-10.41l-9.88-28.92-8.03,16.49c-.7,1.43-2.42,2.03-3.85,1.33-1.43-.7-2.02-2.43-1.32-3.86l11.08-22.75c.7-1.43,2.42-2.03,3.85-1.33l22.66,11.12c1.43.7,2.02,2.43,1.32,3.86-.7,1.43-2.42,2.03-3.85,1.33l-16.42-8.06,9.88,28.92c1.96,5.73,8.18,8.79,13.89,6.82l21.22-7.31c8.71-3,18.2,1.66,21.19,10.41l10.63,31.1,8.74-17.95c.7-1.43,2.42-2.03,3.85-1.33,1.43.7,2.02,2.43,1.32,3.86l-11.79,24.22Z" style="fill:#000;"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 82 97"><path d="M18.09,1.59c.78-.78,2.05-.78,2.83,0l16.5,16.5c.78.78.78,2.05,0,2.83-.78.78-2.05.78-2.83,0l-13.09-13.09v29.67c0,5.52,4.48,10,10,10h19.5c7.73,0,14,6.27,14,14v27.67l12.09-12.09c.78-.78,2.05-.78,2.83,0,.78.78.78,2.05,0,2.83l-15.5,15.5c-.78.78-2.05.78-2.83,0l-15.5-15.5c-.78-.78-.78-2.05,0-2.83.78-.78,2.05-.78,2.83,0l12.09,12.09v-27.67c0-5.52-4.48-10-10-10h-19.5c-7.73,0-14-6.27-14-14V7.83l-13.09,13.09c-.78.78-2.05.78-2.83,0-.78-.78-.78-2.05,0-2.83L18.09,1.59Z" style="fill:#000;"/></svg>

+ 8
- 1
app/assets/stylesheets/application.css View File

@ -222,6 +222,7 @@ main {
border: 2px solid var(--clr-black);
color: var(--clr-white);
font-size: var(--fs-lg);
font-family: var(--ff-ikea);
font-weight: 700;
line-height: 1;
border-radius: 400px;
@ -399,6 +400,7 @@ ul.card__stack {
svg {
width: 80%;
max-width: 82px;
}
& > *:nth-child(1) {
@ -524,7 +526,7 @@ ul.card__stack {
.link {
display: grid;
grid-template-columns: 1fr 1fr;
grid-template-rows: auto;
grid-template-rows: 2fr 1fr;
gap: 32px;
margin-bottom: 40px;
@ -556,4 +558,9 @@ ul.card__stack {
grid-row: 2;
}
}
@media (min-width: 815px) {
header {
margin: 4rem 4rem 2rem 4rem;
}
}

+ 5
- 0
app/controllers/admin/admin_controller.rb View File

@ -18,6 +18,11 @@ private
end
def set_locale_to_default
I18n.locale = I18n.default_locale
end
def form_locale
(params['form_locale'] || I18n.locale).to_sym
end


+ 3
- 0
app/controllers/admin/nodes_controller.rb View File

@ -1,6 +1,9 @@
class Admin::NodesController < Admin::AdminController
before_action :set_node, only: %i[ edit update destroy children sort toggle ]
before_action :set_locale_to_default, only: %i[ create ]
helper_method :current_node_id, :open_node_ids
# GET /nodes


+ 10
- 0
app/controllers/direct_uploads_controller.rb View File

@ -0,0 +1,10 @@
class DirectUploadsController < ActiveStorage::DirectUploadsController
skip_forgery_protection
before_action :authenticate!
def authenticate!
head :unauthorized unless User.enabled.admin_role.find_by(id: session[:user_id]).present?
end
end

+ 1
- 1
app/helpers/languages_helper.rb View File

@ -1,7 +1,7 @@
module LanguagesHelper
def languages_for_select
t('languages').map {|k,v| ["#{t(k, scope: 'flags')} #{v}", k]}
t('languages').map {|k,v| ["#{v} #{t(k, scope: 'flags')} ", k]}.sort
end
end

+ 7
- 4
app/models/node.rb View File

@ -10,16 +10,19 @@ class Node < ApplicationRecord
extend Mobility
translates :slug, locale_accessors: I18n.available_locales
translates :tags, locale_accessors: I18n.available_locales
translates :slug,
:tags,
locale_accessors: I18n.available_locales,
fallbacks: {zh: :en, hr: :en, cs: :en, da: :en, nl: :en, fi: :en, fr: :en, de: :en, hu: :en, it: :en, ja: :en, ko: :en, nb: :en, pl: :en, pt: :en, ro: :en, sr: :en, sk: :en, sl: :en, es: :en, sv: :en, uk: :en}
translates :title,
:url,
:href,
:page_title,
:page_description,
fallbacks: :en,
locale_accessors: I18n.available_locales
locale_accessors: I18n.available_locales,
fallbacks: {zh: :en, hr: :en, cs: :en, da: :en, nl: :en, fi: :en, fr: :en, de: :en, hu: :en, it: :en, ja: :en, ko: :en, nb: :en, pl: :en, pt: :en, ro: :en, sr: :en, sk: :en, sl: :en, es: :en, sv: :en, uk: :en}
NODE_TEMPLATES = %w"tmpl_article tmpl_index tmpl_list"


+ 2
- 1
app/views/admin/nodes/_form.html.erb View File

@ -110,7 +110,8 @@
<%= form.text_field i18n_attr,
class: 'material__input',
disabled: form.object.root? %>
disabled: form.object.root?,
placeholder: form.object.public_send(:slug, locale: I18n.default_locale) %>
<% end %>
<%- form.object.errors.full_messages_for(i18n_attr).uniq.each do |msg| -%>


+ 2
- 2
app/views/material/_text_field_i18n.html.erb View File

@ -8,11 +8,11 @@
<%- i18n_attr = "#{attr}_#{locale}" -%>
<%= f.label i18n_attr, class: "input-box i18n__input i18n__input-#{locale}" do %>
<%= f.text_field i18n_attr,
<%= f.text_field i18n_attr,
class: 'material__input',
disabled: local_assigns[:disabled],
data: local_assigns[:data],
placeholder: local_assigns[:placeholder] %>
placeholder: local_assigns[:placeholder].blank? ? f.object.public_send(attr, locale: I18n.default_locale) : local_assigns[:placeholder] %>
<% end %>
<%- f.object.errors.full_messages_for(i18n_attr).uniq.each do |msg| -%>


+ 5
- 5
app/views/material/_text_field_i18n_simple.html.erb View File

@ -1,11 +1,11 @@
<%- I18n.available_locales.each do |locale| %>
<%- i18n_attr = "#{attr}_#{locale}" -%>
<div class="i18n__input i18n__input-<%= locale %>">
<%= f.text_field i18n_attr,
class: "material__input",
disabled: local_assigns[:disabled],
data: local_assigns[:data],
placeholder: local_assigns[:placeholder] %>
<%= f.text_field i18n_attr,
class: "material__input",
disabled: local_assigns[:disabled],
data: local_assigns[:data],
placeholder: local_assigns[:placeholder].blank? ? f.object.public_send(attr, locale: I18n.default_locale) : local_assigns[:placeholder] %>
<%- f.object.errors.full_messages_for(i18n_attr).uniq.each do |msg| -%>
<%= content_tag :p, msg, role: 'alert' %>


+ 2
- 2
config/application.rb View File

@ -31,8 +31,8 @@ module Week2024
config.time_zone = "Copenhagen"
config.i18n.default_locale = :en
config.i18n.available_locales = [:en, :zh, :hr, :cs, :da, :nl, :fi, :fr, :fr, :de, :hu, :it, :ja, :ko, :nb, :pl, :pt, :ro, :sr, :sk, :sl, :es, :sv, :uk]
config.i18n.fallbacks = [:en]
config.i18n.available_locales = [:en, :zh, :hr, :cs, :da, :nl, :fi, :fr, :de, :hu, :it, :ja, :ko, :nb, :pl, :pt, :ro, :sr, :sk, :sl, :es, :sv, :uk]
config.i18n.fallbacks = true
config.active_storage.routes_prefix = 'storage' #change /rails/active_storage to /storage


+ 2
- 2
config/locales/en.yml View File

@ -89,10 +89,10 @@ en:
learn_more: Learn more
spot_another_link: Spot another link
challange_a_friend: Challange a friend
challange_a_friend: Challenge a friend
drag_to_reveal: Drag to reveal
shuffel_cards: Shuffel cards
shuffle_cards: Shuffle cards
ui:
'yes': Yes


Loading…
Cancel
Save