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

Remove extra javascript content blocks. #1842

Merged
merged 1 commit into from
Aug 9, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## 2.1.0 [unreleased]

* Removed :before_javascript_libraries, :after_javascript_libraries, and :javascript_libraries content blocks. [#1842](https://github.com/resolve/refinerycms/pull/1842). [Rob Yurkowski](https://github.com/robyurkowski)
* Refactored wysiwyg fields into a partial. [#1796](https://github.com/resolve/refinerycms/pull/1796). [Rob Yurkowski](https://github.com/robyurkowski)
* Shortened all authentication helpers. [#1719](https://github.com/resolve/refinerycms/pull/1719). [Ryan Bigg](https://github.com/radar)
* Added canonical page id to body to allow CSS selectors to target specific pages instead of including special CSS files. [#1700](https://github.com/resolve/refinerycms/pull/1700) & [#1828](https://github.com/resolve/refinerycms/pull/1828). [Philip Arndt](https://github.com/parndt) & [Graham Wagener](https://github.com/gwagener/)
Expand Down
23 changes: 18 additions & 5 deletions core/app/views/refinery/_javascripts.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
<%= yield :before_javascript_libraries -%>
<%= yield :javascript_libraries %>
<%= yield :after_javascript_libraries %>
<% if content_for :before_javascript_libraries %>
<% Refinery.deprecate "content_for :before_javascript_libraries", :when => '2.2', :replacement => "content_for :javascripts" %>
<% content_for :javascripts, yield(:before_javascript_libraries) %>
<% end %>

<% if content_for :javascript_libraries %>
<% Refinery.deprecate "content_for :javascript_libraries", :when => '2.2', :replacement => "content_for :javascripts" %>
<% content_for :javascripts, yield(:javascript_libraries) %>
<% end %>

<% if content_for :after_javascript_libraries %>
<% Refinery.deprecate "content_for :after_javascript_libraries", :when => '2.2', :replacement => "content_for :javascripts" %>
<% content_for :javascripts, yield(:after_javascript_libraries) %>
<% end %>


<%= javascript_include_tag 'application' %>
<%= yield :javascripts -%>
<% if request.env['HTTP_USER_AGENT'] =~ /MSIE/ %>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've rearranged this, but this might be in error. My rationale was that users should be given the opportunity to insert any stylesheets before Refinery's (albeit minimal) stylesheets are loaded, but I'm concerned that this might result in errors if the user is on IE6 and loads some library with PNGs. @parndt WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

I don't know about doing this without deprecating first. You can use this functionality to warn the user:

<% if content_for? :before_javascript_libraries %>
  <% Refinery.deprecate "content_for :before_javascript_libraries", :when => '2.2', :replacement => "content_for :javascripts" %>
  <% content_for :javascripts, yield(:before_javascript_libraries) %>
<% end %>
<%= yield :javascripts %>

It complicates the view but is somewhat necessary.

Also this means you have no way to specify the order so you need to put all libraries inside application.js -- correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I guess it's somewhat necessary to deprecate. Alas.

As far as order goes, if you need to append anything, you can do it with content_for :javascripts. Anything beforehand needs to be in application.js... as it should be, in my opinion.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I agree with the application.js

If you can add the deprecation code that'd be awesome.
Should we take this opportunity to move to a helper method or PORO (Plain Old Ruby Object) or should we continue using content_for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll add those deprecation statements shortly.

content_for should suffice. Let's not overcomplicate things — if we were keeping the ability to prepend or append scripts, I might be in favour of that, but as it stands, being able to just yield a block is pretty useful.

<!--[if lt IE 7 ]>
<%= javascript_include_tag 'dd_belatedpng' %>
<script> DD_belatedPNG.fix('img, .png_bg'); //fix any <img> or .png_bg background-images </script>
<![endif]-->
<% end %>
<%= javascript_include_tag 'application' %>
<%= yield :javascripts -%>