Google didn't turn up anything on the topic and there are some questions related to Subresource integrity on Stackoverflow but my question is: how do you generate this cryptographic hash for a CDN <link> ? In my case it is the animate.css, but I guess this can be applied to any custom CSS file.
Cheers
You can use SRIHash from Mozilla
Example using animate.css from JSDelivr
<link rel="stylesheet"
href="https://cdn.jsdelivr.net/animatecss/3.5.2/animate.min.css"
integrity="sha384-OHBBOqpYHNsIqQy8hL1U+8OXf9hH6QRxi0+EODezv82DfnZoV7qoHAZDwMwEJvSw"
crossorigin="anonymous">
Or you can generate it using your console :
https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity#Tools_for_generating_SRI_hashes
Related
I have made my own stylesheet that I require to include on the Jenkins plugin.
<l:layout css="/plugin/myPlugin/css/jquery-ui.css">
<link rel="stylesheet" href="${rootURL}/plugin/myPlugin/jquery-ui.css" type="text/css" media="screen" />
Please advice me..
Thanks..
To link CSS files in Jelly files is deprecated, see jelly tags documentation:
This was originally added to allow plugins to load their stylesheets, but the use of thie
attribute is discouraged now. plugins should now do so by inserting <style> elements
and/or <script> elements in <l:header/> tag.
Please use inline css tags instead (code example).
Place your css file(s) under
/src/webapp/css
and reference them as ..
" href="${rootURL}/plugin//css/layout.css"
Using a <link> element with the $rootURL as noted above worked for me. The important thing that I noticed was to make sure to place the <link> element after <l:layout>. I had it right after the <j:jelly> tag originally and it wasn't able to render the ${rootURL}.
The <link> tag will be much cleaner than doing inline styling.
I have the following content in an HTML file placed under public/company/ with a CSS file css/style.css:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<link href="css/style.css" rel="stylesheet" type="text/css" media="all"/>
</head>
<body>
<div class="title">Name {name}</div>
</body>
</html>
I want to render this HTML file with the CSS stylesheet from an action and replace {name} without changing the physical file content and place. I can render the HTML file but the CSS file would not be found. Can anyone help me render the HTML file with the CSS file and replace the {name}?
css/style.css when called from company/file.html will try to load company/css/style.css.
Click here to see an article the way you can do that. Hope it will help!
But, I'm not sure why you are looking to render that way where Rails has all the features in place.
If your CSS file is located at /public/company/css/style.css, then your static HTML file should link it with an absolute path. Use a leading / in the resource's path indicate an absolute path.:
<link href="/company/css/style.css" rel="stylesheet" type="text/css" media="all"/>
Note that the Rails router will likely catch this request and raise an exception. Depending on the web server, you may need to enable static assets or serve directly, bypassing Rails altogether.
Changing the content of a static HTML file server-side without actually modifying it (ie. adding ERb) isn't straightforward. You could:
inject some javascript into the response to perform modifications client-side. (ugly)
load the static HTML file using Nokogiri, et. al., modify the content, and send the output to the client. (expensive)
Sounds to me like these vanilla HTML/CSS files are third party (designer? client?) and you would like to drop it in /public and have it work automatically with Rails. That would be nice, but it's not that easy. You'd be better off using Rails' built-in templating system, but that means modifying files and moving them to the expected locations.
I am loading jQuery UI as
google.load("jqueryui", "1.8.6");
from the Google CDN
And I want the theme UI Darkness to be associated with it.
Any other methods other than
<link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/ui-darkness/jquery-ui.css" />
Something like
google.load("jqueryui", "1.8.6","{theme: 'UI-Darkness'}");
So far google loader doesn't support this syntax for jqueryui, you can check the documentation here.
http://code.google.com/intl/zh-CN/apis/loader/#GoogleLoad
I think refer to the link in a tag is still the best way in your case.
in the cover page (login, register...) of my app i have this line:
<link rel="stylesheet" type="text/css" href="/css/formularios.css">
When i deploy my app, the that css rule is not loaded because, as i can
see in Firebug, it's looking for that rules in
www.tirengarfio.com/css/formularios.css instead of
www.tiregarfio.com/rs2/web/css/formularios.css.
What should i do?
Javi
You should use the view.yml config file and the include_stylesheets() helper. However, if you'd like to create the link tags by hand, use the public_path() helper to get the correct path.
how many methods for adding style sheets in a page using Asp.net MVC
Wherever you're specifying the CSS for your details page instead of a relative path e.g.
<link href="../../Content/CSS/details.css" rel="stylesheet" type="text/css" />
try using the content helper and specifying a virtual path instead
<link href="<%= Url.Content("~/Content/CSS/details.css") %>" rel="stylesheet" type="text/css" />
It seems that the site is having trouble loading getting to the CSS file based on a relative link.
Use absolute links to css instead of relative (eg /Content/site.css" instead of "../Content/site.css"). Also you may use Html.Stylesheet("~/Content/site.css") extension (in MvcContrib library) to specify a stylesheet.
Is the problem not getting the right CSS? If so, then I would check your Details.aspx file and make sure the link to the CSS is the right path. Most likely, your Details.aspx file got moved into a new subdirectory or into another directory, thus making the relative paths between the aspx file and the CSS file different.
I would check the page source from the browser and look to see what the path to the CSS file is. The way I would solve the problem would be to modify the aspx file to use a fully-qualified path to the css file. Make sure that works. Then try changing the full path to use relative path.
I had the same issue when working through an example in an MVC book, it mentioned something about the '~' character only working because the <head> tag has the runat="server" attribute on it. So, I tried adding the runat attribute to the link tag itself, as seen below, and it worked:
<link runat="server" href="~/Content/styles.css" rel="stylesheet" type="text/css" />