Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Feature/mobility #6

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ded7082
Change Gemfile and gemspec to use Mobility instead of Globalize
gloubier May 8, 2018
d2b8b0d
Fix migrations
gloubier May 8, 2018
8fcf4e5
Fix routes
gloubier May 8, 2018
3636a47
Change before_filter => before_action
gloubier May 8, 2018
4e6e0a2
Update models to use mobility + modern syntax
gloubier May 8, 2018
97dd843
Use Mobility.locale instead of Globalize.locale
gloubier May 8, 2018
e7c8a40
Fix action icons
gloubier May 8, 2018
05f7475
Fix Hound syntax comments
gloubier May 9, 2018
01bd144
Clean up Gemfile
bricesanchez May 9, 2018
2f819f8
Update refinerycms-testing dependency version to 4.0.0
bricesanchez May 9, 2018
bae7bce
Update bin/rails to fix rails console start
bricesanchez May 9, 2018
8dd9b65
Merge pull request #1 from refinerycms-contrib/feature/mobility
gloubier May 9, 2018
4caf0e9
Add active state to slideshows and slides
gloubier May 9, 2018
b1b4599
Change active state to draft to follow conventions
gloubier May 9, 2018
c48e2b1
Add live? method to easily check if is published
gloubier May 9, 2018
107cddf
Remove finder methods
gloubier May 9, 2018
42edd2c
Delete script/rails
bricesanchez May 10, 2018
4eb2a83
Now require refinerycms-images
bricesanchez May 10, 2018
7feb3fa
Remove height, width and js_config fields
bricesanchez May 10, 2018
1829e4d
QA
bricesanchez May 10, 2018
9e7879a
Update README
bricesanchez May 10, 2018
9d188d3
Merge pull request #2 from refinerycms-contrib/feature/mobility
gloubier May 10, 2018
20bc9a0
Remove unecessary stuff
gloubier May 17, 2018
242ec70
Add order field to slides relation
gloubier Dec 11, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@ source "https://rubygems.org"

gemspec

git "https://github.com/refinery/refinerycms", branch: "master" do
# TODO: use master branch before merging this PR
# git "https://github.com/refinery/refinerycms", branch: "master" do
git "https://github.com/refinery/refinerycms", branch: "feature/mobility" do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.


Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning.

gem "refinerycms"

group :test do
gem "refinerycms-testing"
end
end

# TODO: remove refinerycms-i18n and mobility from this Gemfile before merging this PR

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [85/80]

gem 'refinerycms-i18n', git: "https://github.com/refinery/refinerycms-i18n", branch: 'feature/mobility'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
Metrics/LineLength: Line is too long. [103/80]


# Database Configuration
unless ENV["TRAVIS"]
gem "activerecord-jdbcsqlite3-adapter", :platform => :jruby
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ class ImageSlidesController < ::Refinery::AdminController
:sortable => true,
:include => [:translations]

before_filter :find_image_slideshow
before_filter :find_image_slides, only: :index
before_filter :find_image_slide, :except => [:index, :new]
before_action :find_image_slideshow
before_action :find_image_slides, only: :index
before_action :find_image_slide, :except => [:index, :new]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/HashSyntax: Use the new Ruby 1.9 hash syntax.
Style/SymbolArray: Use %i or %I for an array of symbols.


def create
if Refinery::ImageSlideshows::ImageSlide.any?
Expand Down
11 changes: 6 additions & 5 deletions app/models/refinery/image_slideshows/image_slide.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ module ImageSlideshows
class ImageSlide < Refinery::Core::BaseModel
self.table_name = 'refinery_image_slides'

extend Mobility
translates :title, :caption, :link_url, :body

acts_as_indexed :fields => [:title]
acts_as_indexed fields: [:title]

validates :title, :presence => true
validates :image_id, :presence => true
validates :title, presence: true
validates :image_id, presence: true

belongs_to :image_slideshow
belongs_to :image, :class_name => '::Refinery::Image'
belongs_to :image, class_name: '::Refinery::Image'

delegate :height, :width, :to => :image_slideshow
delegate :height, :width, to: :image_slideshow
end
end
end
4 changes: 2 additions & 2 deletions app/models/refinery/image_slideshows/image_slideshow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ class ImageSlideshow < Refinery::Core::BaseModel

acts_as_indexed :fields => [:title]

validates :title, :presence => true, :uniqueness => true
validates :title, presence: true, uniqueness: true

has_many :image_slides, :dependent => :destroy
has_many :image_slides, dependent: :destroy
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
:include_object_name => true %>

<%= render '/refinery/admin/locale_picker',
:current_locale => Globalize.locale %>
:current_locale => Mobility.locale %>

<%= f.hidden_field :image_slideshow_id, :value => @image_slideshow.id %>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
<%
# setup params for various action links
edit_url = refinery.edit_image_slideshows_admin_image_slideshow_image_slide_path(@image_slideshow, image_slide)
delete_url = refinery.image_slideshows_admin_image_slideshow_image_slide_path(@image_slideshow, image_slide)
delete_options = {
class: "cancel confirm-delete",
data: {confirm: t('message', scope: 'refinery.admin.delete', title: image_slide.title)}
}
%>
<li class='clearfix record <%= cycle("on", "on-hover") %>' id="<%= dom_id(image_slide) -%>" style="background-color: #EAEAEA; margin-bottom: 10px;">
<%= image_fu image_slide.image, '128x128', :style => 'padding: 1em 1em 0 1em;' %>
<span class="preview">
<% image_slide.translations.each do |translation| %>
<% if translation.title.present? %>
<%= link_to refinery_icon_tag("flags/#{translation.locale}.png", :size => '16x11'),
refinery.edit_image_slideshows_admin_image_slideshow_image_slide_path(@image_slideshow, image_slide, :switch_locale => translation.locale),
:class => 'locale' %>
<%= link_to refinery.edit_image_slideshows_admin_image_slideshow_image_slide_path(@image_slideshow, image_slide, :switch_locale => translation.locale),
class: 'locale', title: translation.locale.upcase do %>

<div class="<%=translation.locale %> locale_marker">
<%= locale_text_icon(translation.locale.upcase) %>
</div>
<% end %>
<% end %>
<% end %>
</span>

<span class='actions'>
<%= link_to refinery_icon_tag("application_edit.png"), refinery.edit_image_slideshows_admin_image_slideshow_image_slide_path(@image_slideshow, image_slide),
:title => t('.edit') %>
<%= link_to refinery_icon_tag("delete.png"), refinery.image_slideshows_admin_image_slideshow_image_slide_path(@image_slideshow, image_slide),
:class => "cancel confirm-delete",
:title => t('.delete'),
:confirm => t('message', :scope => 'refinery.admin.delete', :title => image_slide.title),
:method => :delete %>
<%= action_icon(:edit, edit_url , t('edit', scope: 'refinery.image_slideshows.admin.image_slides.image_slide' ) ) %>
<%= action_icon(:delete, delete_url, t('delete', scope: 'refinery.image_slideshows.admin.image_slides.image_slide' ), delete_options ) %>
</span>
</li>
</li>
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
<%
# setup params for various action links
manage_url = refinery.image_slideshows_admin_image_slideshow_image_slides_path(image_slideshow)
edit_url = refinery.edit_image_slideshows_admin_image_slideshow_path(image_slideshow)
delete_url = refinery.image_slideshows_admin_image_slideshow_path(image_slideshow)
delete_options = {
class: "cancel confirm-delete",
data: {confirm: t('message', scope: 'refinery.admin.delete', title: image_slideshow.title)}
}
%>
<li class='clearfix record <%= cycle("on", "on-hover") %>' id="<%= dom_id(image_slideshow) -%>">
<span class='title'>
<%= link_to refinery.image_slideshows_admin_image_slideshow_image_slides_path(image_slideshow) do %>
<%= image_slideshow.title %>
<% end %>
</span>
<span class='actions'>
<%= link_to refinery_icon_tag("img.png"), refinery.image_slideshows_admin_image_slideshow_image_slides_path(image_slideshow),
:title => t('.manage_image_slides') %>
<%= link_to refinery_icon_tag("application_edit.png"), refinery.edit_image_slideshows_admin_image_slideshow_path(image_slideshow),
:title => t('.edit') %>
<%= link_to refinery_icon_tag("delete.png"), refinery.image_slideshows_admin_image_slideshow_path(image_slideshow),
:class => "cancel confirm-delete",
:title => t('.delete'),
:confirm => t('message', :scope => 'refinery.admin.delete', :title => image_slideshow.title),
:method => :delete %>
<%= action_icon(:switch_view_list, manage_url, t('.manage_image_slides') ) %>
<%= action_icon(:edit, edit_url , t('.edit') ) %>
<%= action_icon(:delete, delete_url, t('.delete'), delete_options ) %>
</span>
</li>
</li>
4 changes: 2 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Refinery::Core::Engine.routes.append do
Refinery::Core::Engine.routes.draw do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.


# Admin routes
namespace :image_slideshows, :path => '' do
Expand All @@ -16,4 +16,4 @@
end
end

end
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/TrailingBlankLines: Final newline missing.

2 changes: 1 addition & 1 deletion db/migrate/1_create_image_slideshows_image_slideshows.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateImageSlideshowsImageSlideshows < ActiveRecord::Migration
class CreateImageSlideshowsImageSlideshows < ActiveRecord::Migration[5.1]

def up
create_table :refinery_image_slideshows do |t|
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/2_create_image_slides_image_slides.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateImageSlidesImageSlides < ActiveRecord::Migration
class CreateImageSlidesImageSlides < ActiveRecord::Migration[5.1]

def up
create_table :refinery_image_slides do |t|
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/3_add_image_and_caption_to_image_slides.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddImageAndCaptionToImageSlides < ActiveRecord::Migration
class AddImageAndCaptionToImageSlides < ActiveRecord::Migration[5.1]
def change
add_column :refinery_image_slides, :image_id, :integer
add_column :refinery_image_slides, :caption, :string
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/4_add_js_config_to_image_slideshows.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddJsConfigToImageSlideshows < ActiveRecord::Migration
class AddJsConfigToImageSlideshows < ActiveRecord::Migration[5.1]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/Documentation: Missing top-level class documentation comment.
Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.

def change
add_column :refinery_image_slideshows, :js_config, :text
end
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/5_add_link_url_to_image_slides.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddLinkUrlToImageSlides < ActiveRecord::Migration
class AddLinkUrlToImageSlides < ActiveRecord::Migration[5.1]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/Documentation: Missing top-level class documentation comment.
Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.

def change
add_column :refinery_image_slides, :link_url, :string
end
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/6_add_height_and_width_to_image_slideshows.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddHeightAndWidthToImageSlideshows < ActiveRecord::Migration
class AddHeightAndWidthToImageSlideshows < ActiveRecord::Migration[5.1]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/Documentation: Missing top-level class documentation comment.
Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.

def change
add_column :refinery_image_slideshows, :height, :string
add_column :refinery_image_slideshows, :width, :string
Expand Down
29 changes: 17 additions & 12 deletions db/migrate/7_create_image_slides_translations.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
class CreateImageSlidesTranslations < ActiveRecord::Migration
def up
Refinery::ImageSlideshows::ImageSlide.create_translation_table!({
:title => :string,
:caption => :string,
:link_url => :string
}, {
:migrate_data => true
})
end
class CreateImageSlidesTranslations < ActiveRecord::Migration[5.1]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/Documentation: Missing top-level class documentation comment.
Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.

def change
create_table :refinery_image_slide_translations do |t|

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning.

# Translated attribute(s)
t.string :title
t.string :caption
t.string :link_url

t.string :locale, null: false
t.integer :refinery_image_slide_id, null: false

t.timestamps null: false
end

add_index :refinery_image_slide_translations, :locale, name: :index_8a4a2e1ce2c2f55f4778012dc82b5ec014fac0f5

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [112/80]

add_index :refinery_image_slide_translations, [:refinery_image_slide_id, :locale], name: :index_299ee7f96d4de207d5ce93e99727d66ae68c25f2, unique: true

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/SymbolArray: Use %i or %I for an array of symbols.
Metrics/LineLength: Line is too long. [154/80]


def down
Refinery::ImageSlideshows::ImageSlide.drop_translation_table! :migrate_data => true
end
end
9 changes: 3 additions & 6 deletions db/migrate/8_add_body_to_image_slides.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
class AddBodyToImageSlides < ActiveRecord::Migration
def up
Refinery::ImageSlideshows::ImageSlide.add_translation_fields! body: :text
end
def down
remove_column :refinery_image_slide_translations, :body
class AddBodyToImageSlides < ActiveRecord::Migration[5.1]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/Documentation: Missing top-level class documentation comment.
Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.

def change
add_column :refinery_image_slide_translations, :body, :text
end
end
2 changes: 1 addition & 1 deletion db/seeds.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
if defined?(Refinery::User)
Refinery::User.all.each do |user|
if user.plugins.where(:name => 'refinerycms-image_slideshows').blank?
user.plugins.create(:name => "refinerycms-image_slideshows",
user.plugins.create(:name => 'refinerycms-image_slideshows',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/HashSyntax: Use the new Ruby 1.9 hash syntax.

:position => (user.plugins.maximum(:position) || -1) +1)
end
end
Expand Down
7 changes: 3 additions & 4 deletions refinerycms-image_slideshows.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@ Gem::Specification.new do |s|
s.name = 'refinerycms-image_slideshows'
s.authors = ['Jim Pruetting', 'Brice Sanchez']
s.homepage = 'http://www.refinerycms.com'
s.version = '3.0.0'
s.version = '4.0.0'
s.description = 'Ruby on Rails Image Slideshows extension for Refinery CMS'
s.date = '2012-12-12'
s.summary = 'Image Slideshows extension for Refinery CMS'
s.require_paths = %w(lib)
s.files = Dir["{app,config,db,lib}/**/*"] + ["readme.md"]

# Runtime dependencies
s.add_dependency 'refinerycms-core', '~> 3.0.0'
s.add_dependency 'refinerycms-images', '~> 3.0.0'
s.add_dependency 'refinerycms-core', '~> 4.0.0'
s.add_dependency 'refinerycms-images', '~> 4.0.0'
s.add_dependency 'acts_as_indexed', '~> 0.8.0'
s.add_dependency 'globalize', ['>= 4.0.0', '< 5.2']

# Development dependencies (usually used for testing)
s.add_development_dependency 'refinerycms-testing', '~> 3.0.0'
Expand Down