I've updated http://tetalab.org/ with RefineryCMS 1.0.8, and now, our stylesheets and javascripts are outputted as safe html, breaking anything on the site.
Exemple of code outputting safe html:
<%= javascript_include_tag 'modernizr-min' %>
Code found in html source:
<script src="/javascripts/modernizr-min.js" type="text/javascript"></script>
Could someone provide some tips about this issue?
This is likely because you're using refinerycms-theming plugin.
This plugin does bad things and is not recommended
I think if you removed that the problem would go away :)
Related
I came into work today to find that my project is throwing a syntax error for some reason, and I can't find a single thing about this error.
When using the stylesheet_link_tag or javascript_include_tag helpers, I receive SyntaxError: [stdin]:1:1: missing ///.
Some things I have noted are:
If the links dont lead to a valid file, it compiles just fine.
Even if the files are empty the error is still thrown so the syntax error is definitely in the erb, even though I havent changed my application.html.erb since adding the link for the fonts.
EDIT:
After rewriting the layout in haml, the error persists, so I suspect it is not in the erb but in the ruby functions for linking, although I don't know what could have changed.
I just noticed the "ExecJs::RuntimeError", which is interesting because I commented out the javascript link so i could deal with one at a time.
Any help is appreciated. I feel like I'm missing somethinng very simple here, but i cant find it for the life of me.
If you want to see any of my code let me know, I wasnt sure what would be relevant other than this error page:
EDIT 2:
Here's my "appllication.html.erb":
<!DOCTYPE html>
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<title>{Site Name}</title>
<%= csrf_meta_tags %>
<link href="https://fonts.googleapis.com/css?family=Lato:400,300|Raleway|Tangerine:700" rel="stylesheet">
<%= stylesheet_link_tag "application.css", media: "all", "data-turbolinks-track": "reload" %>
<%#<%= javascript_include_tag "application", 'data-turbolinks-track': 'reload' %>
</head>
<body>
<%= yield %>
</body>
</html>
This error was caused by a compilation error somewhere in the rails asset pipeline. This specific instance was caused by a rogue TypeScript file in app/assets/javascripts after I had removed typescript-rails from my Gemfile.
Thanks to #dstarh I was able to find the error.
I'll leave this here since I couldn't find any information on this error anywhere. Hopefully it can help someone else.
According to the bootstrap docs
adding the following to your <head> makes your site responsive
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="assets/css/bootstrap-responsive.css" rel="stylesheet">
In rails and the asset pipeline you declare your css file in application.css so the last line above is not required.
Im using the bootstrap-sass gem and the above line is achieved this line of code in the application.css file
#include "bootstrap-responsive";
It works!
But unfortunately this makes every view responsive.
I have a number of views such as my backbone app that I dont want to be responsive.
I thought about declaring the <meta viewport...> tag into a layout file that is only used for the those parts of my site that require responsive behavior.
This doesn't seem to work and despite some views not declaring this meta tag via their layout, they still become responsive.
Since I cant granularly control which css files get loaded in the asset pipeline I'm a bit stumped how to turn off and on this responsive behavior.
How do i achieve this?
Check out This link for some good info. It can be overwhelming, know, you don't have to do ALL of that... The key is: if you remove require tree (which will not add all files in directory) you need to manually add them in config/environments/production.rb with:
config.assets.precompile += %w( application-all.css application-print.css application-ie.css )
Then you can use stylesheet_link_tags with no issues...
To make it more flexible I add this to my application head:
<%= yield :head if content_for?(:head) %>
and then all my views use:
<% content_for(:head) do %>
<%= stylesheet_link_tag "#{params[:controller]}.#{params[:action]}" %>
<%= javascript_include_tag "#{params[:controller]}.#{params[:action]}" %>
<% end %>
I've set up application.html.erb to link to a stylesheet using the following code
<%= stylesheet_link_tag 'stylesheets/style', :media => 'screen' %>
However when I load the localhost in the browser window it prints this code
<link href="/assets/stylesheets/style.css" media="screen" rel="stylesheet" type="text/css" />
when I view the file directly I'm shown this error
Routing Error
No route matches [GET] "/assets/stylesheets/style.css"
I've read on some other questions that rails by default looks in public/stylesheets so I'm not sure why it's looking in assets?
I also tried to move the css file to the assets directory just to see if it would work however, it still doesn't work and gives the same routing error.
Been stuck on this for a couple of days and it's really doing my head in so appreciate any help you can give me.
Thanks in advance
Rails 3 comes with a new assets management which is actually one of the biggest pluses.
A guide on how it works is here
So if you have the application.css file in your assets/stylesheets you can simply drop the style.css in your assets/stylesheets directory renaming it in style.css.scss
In your view just leave:
<%= stylesheet_link_tag "application", media: 'screen' %>
Through sprockets the Rails app will load it.
Instead of the page making another request for the CSS, I would like to have the Rails view render the CSS file in the page, so it's only 1 request.
Is this possible?
Altough the typical way to include CSS is using stylesheet_link_tag (in particular so it gets cached by the client), it is possible to put it directly in your <HEAD> in Rails 3.1:
<HEAD>
....
<STYLE type="text/css">
<%= YouAppName::Application.assets["your_stylesheet.css"].to_s.html_safe %>
</STYLE>
</HEAD>
I adapted this from this post.
<%= stylesheet_link_tag :all %> assuming your CSS file is in your public/stylesheets folder (which is the conventional place to store stylesheets). Of course, instead of :all, you can specify a specific file.
in your page's block.
I usually do this in my application.html.erb (which is a layout in your app/views/layouts) folder. But you can do this in any view file with a block.
Good luck!
Just wrap your CSS in
<style></style>
within your view.
I'm attempting to create a facebook app and went through the book http://pragprog.com/titles/mmfacer/developing-facebook-platform-applications-with-rails. Everything works fine on my development machine when I have my canvas render method set as fbml. But, for various reasons I want to build an app with an iframe. When I set my app to use an iframe I am unable to connect to my development machine. I went through a lot of different articles about creating an iframe app, but none seem to work. That includes
http://wiki.developers.facebook.com/index.php/Cross_Domain_Communication_Channel
http://wiki.developers.facebook.com/index.php/XFBML
and any other site found googling any combination of facebook, iframe, rails and others.
I have the xd_receiver.htm file in my public directory and my layout looks like
<!doctype html public “-//w3c//dtd xhtml 1.0 strict//en” “http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” xmlns:fb=”http://www.facebook.com/2008/fbml”>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<title><%= controller.controller_name %>: <%= controller.action_name %></title>
<%= stylesheet_link_tag "jquery-ui-1.7.1.custom.css", "styles" %>
<%= javascript_include_tag "jquery-1.3.2.min.js", "application" %>
</head>
<body>
<%= yield %>
<script src="http://static.ak.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>
<script type="text/javascript">
FB_RequireFeatures(["XFBML"], function(){
FB.Facebook.init("my api key", "xd_receiver.htm"); });
</script>
</body>
</html>
My question is, what am I missing that is preventing facebook from connecting to my rails development machine when I set the canvas render method to iframe? Since my development log does not show any attempts of a connection, I'm guessing that it has something to do with the cross domain stuff, but I can't find a good answer about it anywhere.
If you place that file under /public, its important to note that the ERB contained within the template will not get parsed as you expected. I'm not too familiar with the plugin you are trying to use but have used the Facebooker gem (http://facebooker.rubyforge.org/) which provides a tidy way to interact with the Facebook REST API.
I strongly suggest using Facebooker from the beginning.
It'll save you a lot of time.
/xd_receiver
there are facebooker methods for this sort of thing check this out
http://blog.yangtheman.com/2009/08/23/how-to-integrate-facebook-connect-with-a-rails-app/