From 12843ef2a04f6c1ad2c386cb512c2baf2f185c8e Mon Sep 17 00:00:00 2001 From: Grayson Wright Date: Sat, 13 Feb 2016 22:24:51 -0800 Subject: [PATCH 1/2] Extract image field into a separate gem Feature: **When I** have a custom field type that I want to share with others, **I want to** reference an official template for a field gem **so I can** more easily package my field for sharing. Implementation: Create a template for field plugins by extracting the image field into its own gem. This is a breaking change with an easy fix - anybody who uses Image fields will need to add `gem "administrate-field-image"` to their `Gemfile`. The source for the image field gem is up at https://github.com/graysonwright/administrate-field-image. --- CHANGELOG.md | 7 +++++++ Gemfile | 1 + Gemfile.lock | 8 ++++++++ app/views/fields/image/_form.html.erb | 23 ----------------------- app/views/fields/image/_index.html.erb | 18 ------------------ app/views/fields/image/_show.html.erb | 18 ------------------ docs/customizing_dashboards.md | 1 - lib/administrate/field/image.rb | 8 -------- spec/lib/fields/image_spec.rb | 14 -------------- 9 files changed, 16 insertions(+), 82 deletions(-) delete mode 100644 app/views/fields/image/_form.html.erb delete mode 100644 app/views/fields/image/_index.html.erb delete mode 100644 app/views/fields/image/_show.html.erb delete mode 100644 lib/administrate/field/image.rb delete mode 100644 spec/lib/fields/image_spec.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 18065e6918..897ea3dfd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,13 @@ ### Upcoming Release +* [#476] [CHANGE] Extract `Administrate::Field::Image` into its own gem. + Users who have image fields in their dashboards + should add to their `Gemfile`: + ```ruby + gem "administrate-field-image" + ``` + ### 0.1.5 (April 1, 2016) * [master] [BUGFIX] Protect from CSRF attacks [CVE-2016-3098] diff --git a/Gemfile b/Gemfile index 400a47d620..3136c4e359 100644 --- a/Gemfile +++ b/Gemfile @@ -4,6 +4,7 @@ ruby "2.2.3" gemspec +gem "administrate-field-image", path: "../administrate-field-image" gem "delayed_job_active_record" gem "high_voltage" gem "markdown-rails" diff --git a/Gemfile.lock b/Gemfile.lock index 3e5c694dbc..5946522ff8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,10 @@ +PATH + remote: ../administrate-field-image + specs: + administrate-field-image (0.0.1) + administrate (~> 0.1.3) + rails (~> 4.2) + PATH remote: . specs: @@ -280,6 +287,7 @@ PLATFORMS DEPENDENCIES administrate! + administrate-field-image! ammeter appraisal awesome_print diff --git a/app/views/fields/image/_form.html.erb b/app/views/fields/image/_form.html.erb deleted file mode 100644 index 18712a711a..0000000000 --- a/app/views/fields/image/_form.html.erb +++ /dev/null @@ -1,23 +0,0 @@ -<%# -# Image Form Partial - -This partial renders an input element for image attributes. -By default, the input is a text field for the image's URL. - -## Local variables: - -- `f`: - A Rails form generator, used to help create the appropriate input fields. -- `field`: - An instance of [Administrate::Field::Image][1]. - A wrapper around the image url pulled from the database. - -[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Image -%> - -
- <%= f.label field.attribute %> -
-
- <%= f.text_field field.attribute %> -
diff --git a/app/views/fields/image/_index.html.erb b/app/views/fields/image/_index.html.erb deleted file mode 100644 index a02b714c70..0000000000 --- a/app/views/fields/image/_index.html.erb +++ /dev/null @@ -1,18 +0,0 @@ -<%# -# Image Index Partial - -This partial renders an image attribute -to be displayed on a resource's index page. - -By default, the attribute is rendered as an image tag. - -## Local variables: - -- `field`: - An instance of [Administrate::Field::Image][1]. - A wrapper around the image url pulled from the database. - -[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Image -%> - -<%= image_tag field.data %> diff --git a/app/views/fields/image/_show.html.erb b/app/views/fields/image/_show.html.erb deleted file mode 100644 index 52a7892389..0000000000 --- a/app/views/fields/image/_show.html.erb +++ /dev/null @@ -1,18 +0,0 @@ -<%# -# Image Show Partial - -This partial renders an image attribute, -to be displayed on a resource's show page. - -By default, the attribute is rendered as an image tag. - -## Local variables: - -- `field`: - An instance of [Administrate::Field::Image][1]. - A wrapper around the image url pulled from the database. - -[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Image -%> - -<%= image_tag field.data %> diff --git a/docs/customizing_dashboards.md b/docs/customizing_dashboards.md index 7f48367482..c0e9c9bd0d 100644 --- a/docs/customizing_dashboards.md +++ b/docs/customizing_dashboards.md @@ -57,7 +57,6 @@ specify, including: - `Field::Email` - `Field::HasMany` - `Field::HasOne` -- `Field::Image` - `Field::Number` - `Field::Polymorphic` - `Field::Select` diff --git a/lib/administrate/field/image.rb b/lib/administrate/field/image.rb deleted file mode 100644 index 3589634926..0000000000 --- a/lib/administrate/field/image.rb +++ /dev/null @@ -1,8 +0,0 @@ -require_relative "base" - -module Administrate - module Field - class Image < Field::Base - end - end -end diff --git a/spec/lib/fields/image_spec.rb b/spec/lib/fields/image_spec.rb deleted file mode 100644 index 52b79e39d6..0000000000 --- a/spec/lib/fields/image_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -require "administrate/field/image" - -describe Administrate::Field::Image do - describe "#to_partial_path" do - it "returns a partial based on the page being rendered" do - page = :show - field = Administrate::Field::Image.new(:image, "/a.jpg", page) - - path = field.to_partial_path - - expect(path).to eq("/fields/image/#{page}") - end - end -end From 53457a6eb98eed54a114caa52d33aa0c25afacf8 Mon Sep 17 00:00:00 2001 From: Grayson Wright Date: Wed, 20 Apr 2016 17:03:51 -0700 Subject: [PATCH 2/2] Add release notes & release v `0.2.0` Problem: This repository contains both the administrate gem and the demo application. The demo application uses the image field, which means that its Gemfile will be dependent on the new administrate-field-image gem. In turn, the administrate-field-image gem is dependent on the administrate gem in this repository. This creates a little bit of a chicken-and-egg problem for publishing both of those gems. Solution: Our release plan is as follows: - Release this branch as a new version of the administrate gem, as version `0.2.0.rc1` - Make administrate-field-image dependent on `"administrate", "0.2.0.rc1", "~> 0.2.0"` - Release administrate-field-image v `0.0.1` - Make the demo app's Gemfile dependent on `"administrate-field-image", "~> 0.0"` - Re-push this branch to Github to run CircleCI suite. All of the gems would be available on rubygems.org, so the suite should pass. - Update and release this branch as version `0.2.0` - Merge branch --- CHANGELOG.md | 2 ++ Gemfile | 2 +- Gemfile.lock | 16 ++++++---------- README.md | 2 +- gemfiles/bourbon_5.gemfile | 1 + gemfiles/sass_3_4.gemfile | 1 + lib/administrate/version.rb | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 897ea3dfd2..db516850eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ ### Upcoming Release +### 0.2.0 (April 20, 2016) + * [#476] [CHANGE] Extract `Administrate::Field::Image` into its own gem. Users who have image fields in their dashboards should add to their `Gemfile`: diff --git a/Gemfile b/Gemfile index 3136c4e359..e8098ce35a 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ ruby "2.2.3" gemspec -gem "administrate-field-image", path: "../administrate-field-image" +gem "administrate-field-image" gem "delayed_job_active_record" gem "high_voltage" gem "markdown-rails" diff --git a/Gemfile.lock b/Gemfile.lock index 5946522ff8..7c3ef9704d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,14 +1,7 @@ -PATH - remote: ../administrate-field-image - specs: - administrate-field-image (0.0.1) - administrate (~> 0.1.3) - rails (~> 4.2) - PATH remote: . specs: - administrate (0.1.5) + administrate (0.2.0) autoprefixer-rails (~> 6.0) datetime_picker_rails (~> 0.0.7) jquery-rails (~> 4.0) @@ -59,6 +52,9 @@ GEM thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) addressable (2.3.8) + administrate-field-image (0.0.2) + administrate (>= 0.2.0.rc1, < 0.3.0) + rails (~> 4.2) ammeter (1.1.3) activesupport (>= 3.0) railties (>= 3.0) @@ -159,7 +155,7 @@ GEM mime-types (2.99.1) mini_portile2 (2.0.0) minitest (5.8.4) - momentjs-rails (2.11.0) + momentjs-rails (2.11.1) railties (>= 3.1) multi_json (1.11.2) neat (1.7.4) @@ -287,7 +283,7 @@ PLATFORMS DEPENDENCIES administrate! - administrate-field-image! + administrate-field-image ammeter appraisal awesome_print diff --git a/README.md b/README.md index d6f14c7f40..5cecce9f66 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ Add Administrate to your Gemfile: ```ruby # Gemfile -gem "administrate", "~> 0.1.5" +gem "administrate", "~> 0.2.0" ``` Re-bundle, then run the installer: diff --git a/gemfiles/bourbon_5.gemfile b/gemfiles/bourbon_5.gemfile index fe28f5ac09..a957d5c40e 100644 --- a/gemfiles/bourbon_5.gemfile +++ b/gemfiles/bourbon_5.gemfile @@ -4,6 +4,7 @@ source "https://rubygems.org" ruby "2.2.3" +gem "administrate-field-image" gem "delayed_job_active_record" gem "high_voltage" gem "markdown-rails" diff --git a/gemfiles/sass_3_4.gemfile b/gemfiles/sass_3_4.gemfile index 9dad4967ff..0776fcafa4 100644 --- a/gemfiles/sass_3_4.gemfile +++ b/gemfiles/sass_3_4.gemfile @@ -4,6 +4,7 @@ source "https://rubygems.org" ruby "2.2.3" +gem "administrate-field-image" gem "delayed_job_active_record" gem "high_voltage" gem "markdown-rails" diff --git a/lib/administrate/version.rb b/lib/administrate/version.rb index 0ef54f3892..cd59f90b15 100644 --- a/lib/administrate/version.rb +++ b/lib/administrate/version.rb @@ -1,3 +1,3 @@ module Administrate - VERSION = "0.1.5".freeze + VERSION = "0.2.0".freeze end