Skip to content

Commit

Permalink
update to rails 6.1 (#1333)
Browse files Browse the repository at this point in the history
* update to rails 6.1

---------

Co-authored-by: Tyranja <tyranja@cassiopeia.uberspace.de>
  • Loading branch information
tyranja and Tyranja authored Nov 4, 2023
1 parent 08ef073 commit d20cd4a
Show file tree
Hide file tree
Showing 30 changed files with 355 additions and 187 deletions.
4 changes: 1 addition & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source 'https://rubygems.org'
ruby '3.1.1'
gem 'rails', '6.0.3.6'
gem 'rails', '6.1.7.6'

# Needed for Javascript Runtime
# gem 'therubyracer'
Expand All @@ -22,9 +22,7 @@ gem 'deadweight', require: 'deadweight/hijack/rails'
gem 'kaminari'
gem 'mime-types'

# gem 'acts-as-taggable-on', '~> 6.0'
gem 'acts-as-taggable-on', '~> 9.0', '>= 9.0.1'
gem 'auto_html', '~>1.6.4'
gem 'devise', '~> 4.7'
gem 'invisible_captcha'
gem 'jquery-rails', '~> 4.4.0'
Expand Down
137 changes: 67 additions & 70 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -38,38 +38,40 @@ GIT
GEM
remote: https://rubygems.org/
specs:
actioncable (6.0.3.6)
actionpack (= 6.0.3.6)
actioncable (6.1.7.6)
actionpack (= 6.1.7.6)
activesupport (= 6.1.7.6)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.0.3.6)
actionpack (= 6.0.3.6)
activejob (= 6.0.3.6)
activerecord (= 6.0.3.6)
activestorage (= 6.0.3.6)
activesupport (= 6.0.3.6)
actionmailbox (6.1.7.6)
actionpack (= 6.1.7.6)
activejob (= 6.1.7.6)
activerecord (= 6.1.7.6)
activestorage (= 6.1.7.6)
activesupport (= 6.1.7.6)
mail (>= 2.7.1)
actionmailer (6.0.3.6)
actionpack (= 6.0.3.6)
actionview (= 6.0.3.6)
activejob (= 6.0.3.6)
actionmailer (6.1.7.6)
actionpack (= 6.1.7.6)
actionview (= 6.1.7.6)
activejob (= 6.1.7.6)
activesupport (= 6.1.7.6)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (6.0.3.6)
actionview (= 6.0.3.6)
activesupport (= 6.0.3.6)
rack (~> 2.0, >= 2.0.8)
actionpack (6.1.7.6)
actionview (= 6.1.7.6)
activesupport (= 6.1.7.6)
rack (~> 2.0, >= 2.0.9)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.0.3.6)
actionpack (= 6.0.3.6)
activerecord (= 6.0.3.6)
activestorage (= 6.0.3.6)
activesupport (= 6.0.3.6)
actiontext (6.1.7.6)
actionpack (= 6.1.7.6)
activerecord (= 6.1.7.6)
activestorage (= 6.1.7.6)
activesupport (= 6.1.7.6)
nokogiri (>= 1.8.5)
actionview (6.0.3.6)
activesupport (= 6.0.3.6)
actionview (6.1.7.6)
activesupport (= 6.1.7.6)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
Expand All @@ -79,34 +81,33 @@ GEM
activemodel (>= 4.1, < 7.1)
case_transform (>= 0.2)
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
activejob (6.0.3.6)
activesupport (= 6.0.3.6)
activejob (6.1.7.6)
activesupport (= 6.1.7.6)
globalid (>= 0.3.6)
activemodel (6.0.3.6)
activesupport (= 6.0.3.6)
activerecord (6.0.3.6)
activemodel (= 6.0.3.6)
activesupport (= 6.0.3.6)
activestorage (6.0.3.6)
actionpack (= 6.0.3.6)
activejob (= 6.0.3.6)
activerecord (= 6.0.3.6)
marcel (~> 1.0.0)
activesupport (6.0.3.6)
activemodel (6.1.7.6)
activesupport (= 6.1.7.6)
activerecord (6.1.7.6)
activemodel (= 6.1.7.6)
activesupport (= 6.1.7.6)
activestorage (6.1.7.6)
actionpack (= 6.1.7.6)
activejob (= 6.1.7.6)
activerecord (= 6.1.7.6)
activesupport (= 6.1.7.6)
marcel (~> 1.0)
mini_mime (>= 1.1.0)
activesupport (6.1.7.6)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 2.2, >= 2.2.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
acts-as-taggable-on (9.0.1)
activerecord (>= 6.0, < 7.1)
addressable (2.8.1)
public_suffix (>= 2.0.2, < 6.0)
ansi (1.5.0)
ast (2.4.2)
auto_html (1.6.4)
redcarpet (~> 3.1)
rinku (~> 1.5.0)
autoprefixer-rails (10.4.13.0)
execjs (~> 2)
aws-eventstream (1.2.0)
Expand Down Expand Up @@ -340,7 +341,7 @@ GEM
timeout
net-smtp (0.3.3)
net-protocol
nio4r (2.5.8)
nio4r (2.5.9)
nokogiri (1.14.2-arm64-darwin)
racc (~> 1.4)
nokogiri (1.14.2-x86_64-linux)
Expand Down Expand Up @@ -392,20 +393,20 @@ GEM
rack-test (2.1.0)
rack (>= 1.3)
rack-timeout (0.6.3)
rails (6.0.3.6)
actioncable (= 6.0.3.6)
actionmailbox (= 6.0.3.6)
actionmailer (= 6.0.3.6)
actionpack (= 6.0.3.6)
actiontext (= 6.0.3.6)
actionview (= 6.0.3.6)
activejob (= 6.0.3.6)
activemodel (= 6.0.3.6)
activerecord (= 6.0.3.6)
activestorage (= 6.0.3.6)
activesupport (= 6.0.3.6)
bundler (>= 1.3.0)
railties (= 6.0.3.6)
rails (6.1.7.6)
actioncable (= 6.1.7.6)
actionmailbox (= 6.1.7.6)
actionmailer (= 6.1.7.6)
actionpack (= 6.1.7.6)
actiontext (= 6.1.7.6)
actionview (= 6.1.7.6)
activejob (= 6.1.7.6)
activemodel (= 6.1.7.6)
activerecord (= 6.1.7.6)
activestorage (= 6.1.7.6)
activesupport (= 6.1.7.6)
bundler (>= 1.15.0)
railties (= 6.1.7.6)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
Expand All @@ -416,12 +417,12 @@ GEM
nokogiri (>= 1.6)
rails-html-sanitizer (1.5.0)
loofah (~> 2.19, >= 2.19.1)
railties (6.0.3.6)
actionpack (= 6.0.3.6)
activesupport (= 6.0.3.6)
railties (6.1.7.6)
actionpack (= 6.1.7.6)
activesupport (= 6.1.7.6)
method_source
rake (>= 0.8.7)
thor (>= 0.20.3, < 2.0)
rake (>= 12.2)
thor (~> 1.0)
rainbow (3.1.1)
raindrops (0.20.1)
rake (13.0.6)
Expand All @@ -431,15 +432,13 @@ GEM
rdoc (6.3.2)
record_tag_helper (1.0.1)
actionview (>= 5)
redcarpet (3.6.0)
regexp_parser (2.7.0)
request_store (1.5.1)
rack (>= 1.4)
responders (3.1.0)
actionpack (>= 5.2)
railties (>= 5.2)
rexml (3.2.5)
rinku (1.5.1)
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
Expand Down Expand Up @@ -504,11 +503,10 @@ GEM
sprockets (>= 3.0.0)
stackprof (0.2.24)
thor (1.2.1)
thread_safe (0.3.6)
tilt (2.1.0)
timeout (0.3.2)
tzinfo (1.2.11)
thread_safe (~> 0.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
unaccent (0.4.0)
Expand All @@ -535,7 +533,6 @@ PLATFORMS
DEPENDENCIES
active_model_serializers
acts-as-taggable-on (~> 9.0, >= 9.0.1)
auto_html (~> 1.6.4)
aws-sdk-s3
better_errors
bootsnap (~> 1.4.2)
Expand Down Expand Up @@ -581,7 +578,7 @@ DEPENDENCIES
psych (< 4.0)
rack-piwik (~> 0.3.0)
rack-timeout
rails (= 6.0.3.6)
rails (= 6.1.7.6)
rails-controller-testing
record_tag_helper (~> 1.0)
rexml (~> 3.2.4)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/medialinks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def index
end

def new
@medialink = Medialink.new(url: 'http://')
@medialink = Medialink.new(url: 'https://')
end

def edit; end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/medialinks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def index
end

def new
@medialink = Medialink.new(url: 'http://')
@medialink = Medialink.new(url: 'https://')
end

def edit; end
Expand Down
4 changes: 4 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,8 @@ def bootstrap_class_for(flash_type)
end
end

def url_with_protocol(url)
(url.start_with?("http://") || url.start_with?("https://")) ? url : 'https://' + url
end

end
19 changes: 10 additions & 9 deletions app/models/medialink.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# frozen_string_literal: true

class Medialink < ApplicationRecord
include AutoHtml

belongs_to :profile

validates :title, :url, presence: true

auto_html_for :url do
html_escape
image
youtube width: 400, height: 250
vimeo width: 400, height: 250
simple_format
link target: '_blank', rel: 'nofollow'
def youtube_thumbnail_url
youtube_id = find_youtube_id
return unless youtube_id

"https://img.youtube.com/vi/" + youtube_id + "/mqdefault.jpg"
end

def find_youtube_id
id = url.match(/((?<=v=)|(?<=youtu.be\/)).+/)
id ? id[0].split(/(\?|&)/).first : nil
end
end
10 changes: 1 addition & 9 deletions app/models/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,6 @@ def should_generate_new_friendly_id?
slug.blank? || firstname_changed? || lastname_changed?
end

def website_with_protocol(profile_website)
if profile_website =~ %r{^https?://}
profile_website
else
'http://' + profile_website
end
end

def website_in_language_scope(lang, number = '')
send(('website_' + number + lang.to_s).to_sym)
end
Expand All @@ -146,7 +138,7 @@ def twitter_name_formatted
end

def twitter_link_formatted
'http://twitter.com/' + twitter.gsub(%r{^@|https:|http:|:|//|www.|twitter.com/}, '')
'https://twitter.com/' + twitter.gsub(%r{^@|https:|http:|:|//|www.|twitter.com/}, '')
end

def country_name
Expand Down
22 changes: 1 addition & 21 deletions app/views/admin/medialinks/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,6 @@
<p id="medialinks__list--sort-message"></p>

<ul id="medialinks__list" data-update-url="<%= sort_admin_profile_medialinks_url%>" class="<%= t(:language_short, scope: 'medialinks')%>">
<% @medialinks.each do |medialink| %>
<%= content_tag_for(:li, medialink, nil, {'title' => t(:tooltip, scope: 'medialinks')}) do %>
<% if medialink.url =~ /youtube|vimeo/i %>
<b><%= medialink.title %></b>
<%= medialink.url_html if medialink.url != 'http://' %>
<% else %>
<%= link_to medialink.title, medialink.url %>
<% end %>
<%= simple_format(medialink.description) %>
<span class="color-grey">
<%= t(:select_language, scope: 'medialinks') + t("#{medialink.language}", scope: 'iso_639_1').capitalize if medialink.language.present? %>
</span>
<hr>

<%= link_to '<i class="fa fa-pencil"></i>'.html_safe+ t(:edit_link, scope: 'medialinks'),
edit_admin_profile_medialink_path(@profile, medialink) %>
<%= link_to '<i class="fa fa-minus-circle"></i>'.html_safe+ t(:delete_link, scope: 'medialinks'),
admin_profile_medialink_path(@profile, medialink),
method: :delete, data: { confirm: 'Are you sure?'}, title: t(:delete, scope: "medialinks") %>
<% end %>
<% end %>
<%= render partial: 'medialinks/medialink', collection: @medialinks %>
</ul>
</div>
23 changes: 23 additions & 0 deletions app/views/medialinks/_medialink.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<%= content_tag_for(:li, medialink, nil, {'title' => t(:tooltip, scope: 'medialinks')}) do %>
<b style="text-decoration: underline">
<%= link_to medialink.title, url_with_protocol(medialink.url) %>
</b><br>
<% if medialink.url =~ /youtube|youtu.be/i and medialink.youtube_thumbnail_url%>
<img src=<%= medialink.youtube_thumbnail_url %> alt="Video Thumbnail">
<% end %>
<p>
<%= simple_format(medialink.description, class: '') %>
</p>
<span class="color-grey">
<%= t(:select_language, scope: 'medialinks') + t("#{medialink.language}", scope: 'iso_639_1').capitalize if medialink.language.present? %>
</span>
<hr>

<%= link_to "<i class='fa fa-pencil'></i>".html_safe + t(:edit_link, scope: 'medialinks'),
edit_profile_medialink_path(@profile, medialink) %>
<%= link_to "<i class='fa fa-minus-circle'></i>".html_safe + t(:delete_link, scope: 'medialinks'),
profile_medialink_path(@profile, medialink),
method: :delete,
data: { confirm: "Are you sure?"},
title: t(:delete, scope: "medialinks") %>
<% end %>
Loading

0 comments on commit d20cd4a

Please sign in to comment.