Internal style written in rails mailer template is not working.
<html>
<head>
...
...
</head>
<body>
<style type="text/css">
...
...
</style>
</body>
</html>
How to solve this problem?
Make sure that you are putting internal style inside head tag
eg:
<head>
<style type="text/css">
...
...
</style>
</head>
Note: Only internal style (must be in head tag) supports.
Related
ReDoc displays a remote openapi.json normally:
<?xml version="1.0" encoding="UTF-8"?><html>
<head>
<title>ReDoc - openapi.json</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<style>
body {
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<redoc spec-url="https://petstore3.swagger.io/api/v3/openapi.json"/>
<script src="https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js">/**/</script>
</body>
</html>
But if I save openapi.json locally
<?xml version="1.0" encoding="UTF-8"?><html>
<head>
<title>ReDoc - openapi.json</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<style>
body {
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<redoc spec-url="file:///tmp/openapi.json"/>
<script src="https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js">/**/</script>
</body>
</html>
it shows this error:
Something went wrong...
process is not defined
Stack trace
resolve#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:8:301803
resolveExternalRef#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:8:76499
4182/resolveDocument/<#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:8:77225
4182/r</<#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:8:74930
4182/r<#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:8:74675
resolveDocument#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:8:77178
3675/t.bundle/<#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:8:33256
3675/r</<#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:8:28947
3675/r<#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:8:28692
3675/t.bundle#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:8:33035
n#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:117:579
Mu/</n/e<#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:117:1021
Mu/</n/e<#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:117:837
n#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:117:1040
Mu/</<#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:117:1261
Mu/</<#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:117:1077
Mu/<#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:117:1280
Il#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:8:488153
53/t.unstable_runWithPriority#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:8:517125
Wo#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:8:428837
Rl#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:8:487616
4448/Cl/<#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:8:487527
D#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:8:516186
53/w.port1.onmessage#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:8:514909
ReDoc Version: 2.0.0
Commit: 5fb4daa
How to display a local OpenAPI definition file with ReDoc?
The easiest way is with Redocly CLI:
npx #redocly/cli preview-docs openapi.json
Source: https://redocly.com/docs/cli/commands/preview-docs/
I'm trying to give my html an css inline style. But this style gets ignored.
This is the HTML string that I'm using for webView.loadHTMLString(htmlBelow, baseURL: Bundle.main.bundleURL)
let fontsize = 16 //This is an dynamic variable
<!DOCTYPE html>
<html lang=\"en\">
<head>
<meta charset=\"UTF-8\">
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
<meta http-equiv=\"X-UA-Compatible\"content=\"ie=edge\">
<title>Document</title>
<style>
​html {
font-size:\(fontsize)px; */THIS DOESN'T WORK/*
}
</style>
<link rel=\"stylesheet\" href=\"\style.css\">
<script src=\"jquery-3.4.1.min.js\"></script>
<script src=\"script.js\"></script>
</head>
<body>
<div class=\ "sqr-tree-level\"> \(restOfHtml) </div>
</body>
</html>
I'm trying to set the fontsize dynamically.
When I change the font-size in my css file it works, but I want to set it dynamically. That's why I wanna do it like this.
This is how my document.head.innerHTML looks like
For future reference the fix here was to put the styling in to the <body> tag instead of in the head <style> tag.
<body style=\"font-size:\(fontsize)px;\">
I have an angular 2 app that I built using the angular cli generator: https://github.com/EdmundMai/angular-2-playing
This is the generator: https://github.com/angular/angular-cli
I ran ng serve and now I have a page I can see when I visit http://localhost:4002
My dist/index.html file in the angular 2 app looks like this:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>AngularTwo</title>
<base href="/">
<script src="/ember-cli-live-reload.js" type="text/javascript"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<script src="http://carbon.ec2.crowdtap.com/component_importer.js"></script>
</head>
<body>
<angular-two-app>Loading...</angular-two-app>
<script src="vendor/es6-shim/es6-shim.js"></script><script src="vendor/reflect-metadata/Reflect.js"></script><script src="vendor/systemjs/dist/system.src.js"></script><script src="vendor/zone.js/dist/zone.js"></script>
<script>
System.import('system-config.js').then(function () {
System.import('main');
}).catch(console.error.bind(console));
</script>
</body>
<script>
window.carbon.importComponents({ components: ['ct-button', 'ct-button/ct-button-link', 'ct-dialog', 'ct-progress'] });
</script>
</html>
In my rails view, I am trying to include these JS files:
<script src="http://localhost:4200/vendor/es6-shim/es6-shim.js"></script>
<script src="http://localhost:4200/vendor/reflect-metadata/Reflect.js"></script>
<script src="http://localhost:4200/vendor/systemjs/dist/system.src.js"></script>
<script src="http://localhost:4200/vendor/zone.js/dist/zone.js"></script>
<script src="http://localhost:4200/system-config.js"></script>
<script src="http://localhost:4200/main.js"></script>
However, it's not working and complaining that main.ts:1Uncaught ReferenceError: require is not defined
Is there a proper way of doing this?
You need to change the <base href="/"> tag (line 6) in the generated
dist/index.html
to <script>document.write('<base href="' + document.location + '" />');</script>
I need to downcase all text in an HTML document that has been parsed with Nokogiri. Here my code:
agent = Mechanize.new
page = agent.get('http://www.example.com').parser.search('//*[translate(text(),"ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz") = *]').to_html
There is not error as such in the code; it executes without an error. If I go in and check a random tag in the document, however, the case is still the same as before. Is there another/better way to downcase all text in a document?
You could use traverse to downcase all text nodes:
require 'open-uri'
require 'nokogiri'
doc = Nokogiri::HTML(open("http://www.example.com/"))
doc.traverse do |node|
node.content = node.content.downcase if node.text?
end
puts doc.to_html
Output:
<!DOCTYPE html>
<html>
<head>
<title>example domain</title>
<meta charset="utf-8">
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style type="text/css">
body { ... }
</style>
</head>
<body>
<div>
<h1>example domain</h1>
<p>this domain is established to be used for illustrative examples in documents. you may use this
domain in examples without prior coordination or asking for permission.</p>
<p>more information...</p>
</div>
</body>
</html>
I have a base header layout (base-header-footer.gsp)
<!DOCTYPE html>
<html>
<head>
<title><g:layoutTitle default="${g.message(code: 'title.index.page')}"/></title>
</head>
... some common resources loading....
<body id="launch">
<g:layoutBody/>
...........................
<r:layoutResources />
</body>
</html>
And then 2 more header, one for logged-in user, and another for guest users, and both of these header layout are extending the base layout.
Guest users (anonymouys-header-footer.gsp) -
<g:applyLayout name="base-header-footer">
<!DOCTYPE html>
<html>
<head>
<g:layoutHead/>
</head>
<body>
... render guest user header
<g:layoutBody/>
</body>
</html>
Logged-in users (loggedin-header-footer.gsp) -
<g:applyLayout name="base-header-footer">
<!DOCTYPE html>
<html>
<head>
... some css
<g:layoutHead/>
</head>
<body>
... Render header for logged-in user
</body>
... load some JS file...
</html>
Now in specific pages I apply guest OR logged-in layout based on user's login state, hence I want to show the page specific title user is on, but it doesn't work.
This is how I am using those layout
OrderStatus.gsp -
<!DOCTYPE html>
<html>
<head>
<title>Order status | Some title</title>
<meta name="layout" content="logged-in-header-footer" />
<script type="text/javascript" src="${resource(dir:'js',file:'some.js')}"></script>
</head>
<body>
</body>
</html>
But I still see the title which is defined base-header-footer.gsp, not the one in OrderStatus.gsp
I have also tried using g:layoutTitle in OrderStatus.gsp but doesn't help.
Any help is highly appreciated.
Use
<meta name="layout" content="base-header-footer">
in your pages to load the layout, then add your title there,
<title>${whatever.something()}</title>
in your layout add this:
<title><g:layoutTitle/></title>
enjoy.
Try to use
<title><g:layoutTitle/></title>
in your layouts (base-header-footer and loggedin-header-footer.gsp). More info in the official documentation.