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

Refactor legacy gallery code into node revision body #4074

Closed
jywarren opened this issue Nov 29, 2018 · 3 comments · Fixed by #11371
Closed

Refactor legacy gallery code into node revision body #4074

jywarren opened this issue Nov 29, 2018 · 3 comments · Fixed by #11371
Labels
deprecation help wanted requires help by anyone willing to contribute refactorization Ruby

Comments

@jywarren
Copy link
Member

We have a very old leftover feature which shows a collection of images in a "gallery" at the top of a note:

<%= render :partial => "notes/gallery" %>

Full code for the display is here; https://github.com/publiclab/plots2/blob/5c0d96274bd0be15feba69d8f30093082402ace5/app/views/notes/_gallery.html.erb

It's so simple, we could just insert the images at the top of the node body (actually the node revision body) and have it be part of the content.

We'd use this code to display each image, just like in our gallery:

  <a target="_blank" href="<%= image.image.path(:original) %>"><img rel="tooltip" data-title="<%= image.description %>" style="margin-bottom:4px;" class="img-rounded" src="<%= image.image.path(:thumb) %>" /></a>
  1. collect all nodes with image galleries, so,
  2. in a migration -- insert the above code (but with proper substitutions not in IRB style) once per image at the top of the node revision.body
  3. we'd delete this model: https://github.com/publiclab/plots2/blob/5c0d96274bd0be15feba69d8f30093082402ace5/app/models/drupal_content_field_image_gallery.rb
  4. drop the corresponding database table in the same migration as in step 2
  5. remove the "gallery" code from node.rb

This is not a super complex change, but has a lot of moving parts. We'd love help with it, and are happy to support! Thanks!

Relates to #956 as well!

@jywarren jywarren added help wanted requires help by anyone willing to contribute Ruby gci-candidate refactorization labels Nov 29, 2018
@stale stale bot added the stale label Oct 7, 2020
@publiclab publiclab deleted a comment from stale bot Oct 8, 2020
@stale stale bot removed the stale label Oct 8, 2020
@jywarren jywarren added this to the Deprecating Old Features milestone Feb 17, 2021
@TildaDares
Copy link
Member

@jywarren If I understand this correctly, I have to generate a migration that loops through each image in a node that has a gallery and then prepend this code to revision.body. Something like this?

Revision.all.each do |rev|
  rev.node.gallery.each do |image|
    rev.body = #insert code + rev.body
  end
end

2. insert the above code (but with proper substitutions not in IRB style)

What format would the code in?

@jywarren
Copy link
Member Author

jywarren commented Aug 2, 2021

Just plain html, actually because it's just stored in the database, rather than executed in ruby!

@jywarren
Copy link
Member Author

jywarren commented Aug 2, 2021

And yeah that looks great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecation help wanted requires help by anyone willing to contribute refactorization Ruby
Projects
None yet
3 participants