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: Add support for Mobility #149

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
7 changes: 6 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@ source "http://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: "feature/mobility" do
gem 'refinerycms'

group :development, :test do
gem 'refinerycms-testing'
end
end

# TODO: remove refinerycms-i18n and mobility from this Gemfile before merging this PR
gem 'refinerycms-i18n', git: "https://github.com/refinery/refinerycms-i18n", branch: 'feature/mobility'
gem 'mobility', git: "https://github.com/shioyama/mobility", branch: 'master'

gem 'refinerycms-wymeditor', ['~> 2.0', '>= 2.0.0']

group :development do
Expand Down
3 changes: 1 addition & 2 deletions app/models/refinery/image_page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ class ImagePage < Refinery::Core::BaseModel
belongs_to :image
belongs_to :page, polymorphic: true, touch: true

extend Mobility
translates :caption

attribute :caption
end
end
2 changes: 1 addition & 1 deletion db/migrate/20101014230041_create_page_images.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class CreatePageImages < ActiveRecord::Migration[4.2]
def change
create_table Refinery::ImagePage.table_name, :id => false do |t|
create_table Refinery::ImagePage.table_name do |t|
t.integer :image_id
t.integer :page_id
t.integer :position
Expand Down
25 changes: 10 additions & 15 deletions db/migrate/20110511215016_translate_page_image_captions.rb
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
class TranslatePageImageCaptions < ActiveRecord::Migration[4.2]
def up
add_column Refinery::ImagePage.table_name, :id, :primary_key

Choose a reason for hiding this comment

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

Removing this causes an Unknown primary key for table refinery_image_pages in model Refinery::ImagePage. error.

Copy link
Member Author

Choose a reason for hiding this comment

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

def change
create_table :refinery_image_page_translations do |t|

Refinery::ImagePage.reset_column_information
unless defined?(Refinery::ImagePage::Translation) && Refinery::ImagePage::Translation.table_exists?
Refinery::ImagePage.create_translation_table!({
:caption => :text
}, {
:migrate_data => true
})
end
end
# Translated attribute(s)
t.text :caption

def down
Refinery::ImagePage.reset_column_information
t.string :locale, null: false
t.integer :refinery_image_page_id, null: false

Refinery::ImagePage.drop_translation_table! :migrate_data => true
t.timestamps null: false
end

remove_column Refinery::ImagePage.table_name, :id
add_index :refinery_image_page_translations, :locale, name: :index_refinery_image_page_translations_on_locale
add_index :refinery_image_page_translations, [:refinery_image_page_id, :locale], name: :index_114aab0bbdedc79d0ec4f4b, unique: true
end
end
3 changes: 1 addition & 2 deletions lib/refinery/page_images.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require 'refinerycms-core'
require 'globalize'
require 'refinerycms-pages'

module Refinery
autoload :PageImagesGenerator, 'generators/refinery/page_images_generator'
Expand Down
1 change: 0 additions & 1 deletion refinerycms-page-images.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Gem::Specification.new do |s|

s.add_dependency 'refinerycms-pages', ['~> 4.0', '>= 4.0.0']
s.add_dependency 'decorators', '~> 2.0'
s.add_dependency 'globalize', '~> 5.1.0'

s.cert_chain = [File.expand_path("../certs/parndt.pem", __FILE__)]
if $0 =~ /gem\z/ && ARGV.include?("build") && ARGV.include?(__FILE__)
Expand Down