How to remove unwanted indent from HAML's pre tag - haml

I have problem with <pre>, here is my code, and the screenshot is attached below. How to remove the indents?
%pre.code
:escaped
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head></head>
<body>
<form>
<input type="text" name="empID" />
<input type="submit"/>
</form>
</body>
</html>

You need to use the #preserve helper to convert the newlines in the pre to newline entities, like so:
%pre.code
= preserve do
:escaped
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head></head>
<body>
<form>
<input type="text" name="empID" />
<input type="submit"/>
</form>
</body>
</html>
In the future, you'll be able to nest filters, so you can do :preserve:escaped.

When representing "pre" like text from a variable inside a div or other tag, use
.text.plain= preserve(#mail.body.to_s)
along with CSS "white-space: pre-wrap;". Use the one-line version, because the two-line will still indent the first line.
/ BAD: Will leave the first line incorrectly indented!
.text.plain
= preserve(#mail.body.to_s)

Related

arabic text get reversed in <pre> tag in ASP.NET Core MVC app

I am having real problem with Arabic text in <pre> tag
For example if I put this code in a page view
<pre>
<html>
<head>
<title>First HTML Page</title>
</head>
<body>
<h1><span>اول صفحة ويب</span></h1>
<p>هذه أول فقرة ننشؤها في أول صفحة</p>
</body>
</html>
</pre>
I get this display in browser
Here you can see that the arabic text is reversed
This happens just in ASP.NET Core MVC. In other frameworks, the text is displayed correctly.
I've tried to change the dir and the lang attributes but it does not help.
I copied your code snippet and reproduced the issue in my side, I noticed that the content in the page is wrong but in F12 is right, so I'm afraid the browser deal with specific language content automatically for the elements in <pre> tag... So I tried to change the direction manually with the style. How do you think about it?
<div>
<div>
<div style="direction:ltr;unicode-bidi: bidi-override;color:red">اول صفحة ويب</div>
<span>اول صفحة ويب</span>
<p>هذه أول فقرة ننشؤها في أول صفحة</p>
</div>
<pre >
<html>
<head>
<title>First HTML Page</title>
</head>
<body>
<h1><span style="direction:rtl;unicode-bidi: bidi-override;">اول صفحة ويب</span></h1>
<h1><span>اول صفحة ويب</span></h1>
<p>هذه أول فقرة ننشؤها في أول صفحة</p>
</body>
</html>
</pre>
</div>

Include view parameters in h:link

I have a problem when adding view parameters to a <h:link includeViewParams="true" /> - they are not added to the rendered link. I am using Mojarra 2.3.9.
Template /WEB-INF/templates/main.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head>
<!-- Some headers -->
</h:head>
<h:body>
<f:view>
<ui:insert name="metaContent" />
<div class="container-fluid" id="mainContent">
<ui:insert name="mainContent" />
</div>
</f:view>
</h:body>
</html>
Template being used on page test.xhtml
<!DOCTYPE html>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:o="http://omnifaces.org/ui"
template="/WEB-INF/templates/main.xhtml">
<ui:define name="metaContent">
<f:metadata>
<f:viewParam name="id" value="#{myBean.obj}" required="true">
<f:validator validatorId="myIdVvalidator" />
<f:converter converterId="myConverter" />
</f:viewParam>
</f:metadata>
</ui:define>
<ui:define name="mainContent">
<!-- Simply reference current page -->
<h:link outcome="test.xhtml" includeViewParams="true">
My link
</h:link>
</ui:define>
</ui:composition>
Update
If I remove the attribute value of f:viewParam as well as the f:converterand f:validator child elements, the link is rendered as expected. Why can this cause a problem? The Bean myBean is #RequestScoped

Opening web page on default Web browser and hiding URL parameters

I have an application that needs to open an external URL on the default Web Browser but I don't want to show the parameters on the URL so I think I need to make a POST instead of a GET, but how?
I'm using the following code to open an external default browser
Friend Sub WebOpen(ByVal WebAddress As String)
Dim sInfo As New ProcessStartInfo(WebAddress)
Process.Start(sInfo)
End Sub
But this expose all the parameters on the URL bar since make a GET not a POST.
Solution:
Make a temporary HTML file and open it using the previous code (WebOpen(ByVal WebAddress As String))
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -->
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<!-- <head>
</head> -->
<body>
<form name="Login" method="post" action="http://www.yourWebPage.com/" target="_self">
<input id="accountLoginField" class="textInput" name="account" value="accountX" size="24"
maxlength="32" type="hidden"/>
<input id="userLoginField" class="textInput" name="user" value="userX" size="24"
maxlength="32" type="hidden"/>
<input class="textInput" name="password" value="PassX" size="24" maxlength="32" type="hidden"/>
<input name="submit" value="Start Session" type="submit" id="btn" style="color: transparent;
background-color: transparent; border-color: transparent; cursor: default;"/>
<script type="text/javascript">
<!--
var counter = 0;
var maxCount = 50;
function pushSubmit() {
if (counter++ < maxCount) {
document.getElementById('btn').click();
}
}
//start the process
window.setTimeout(pushSubmit(), 30);
</script>
</form>
</body>
</html>
Hopefully you were able to find your answer using an older post from here: How to open IE with post info in C#?
Please mark this as an answer if this helped you solved your issue.
You could use a string encryptor in vb.net (you'll have to find that yourself) and then do this:
Process.Start(Decrypt("encryptedstringhere"))
That will 'hide' the parameters from anyone trying to decompile your code.
OR
Once you have compiled your executable, find a vb.net obfuscation program (just google it) and obfuscate your exe. This will make it unreadable to nayone who attempts to decompile it or find what string is in your parameters....
Hope this helped!
Rodit

Rails 3 Page Titles

I would like to have static Titles in my code for different pages.
How would i go about this, it keeps using the app name in the title.
I have tried
1)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Site under construction</title>
</head>
<body>
<p id="notice"><%= notice %></p>
<p>
<b>Title:</b>
<%= #page.title %>
</p>
<%= link_to 'Edit', edit_page_path(#page) %> |
<%= link_to 'Back', pages_path %>
</body>
</html>
That did not work
I have tried rails page titles
not working is there something i am missing here.
I assume that is the contents of your view. The default rails project creates a layout that has the application name in the title element. Therefore, you are likely to have something not dissimilar to the following being sent to the browser:
<!DOCTYPE html>
<html>
<head>
<title>Sample application</title>
</head>
<body>
<div>
<!DOCTYPE html PUBLIC "…" SYSTEM "…">
<html>
<head>
<meta …/>
<title>Site Under Construction</title>
</head>
<body>
…
</body>
</html>
</div>
</body>
</html>
The file you need to edit should be app/views/layouts/application.html.erb

Need help with post request portion of reCAPTCHA api

I hardly know anything about POST request or api's , so the more explicity you can make things, the better.
I'm going through the description of adding a reCAPTCHA to my site but I'm stuck on the verification portion. Here's the part I'm stuck on: http://code.google.com/apis/recaptcha/docs/verify.html
I don't know how to do a POST request. If someone could explain this portion to me that would help greatly.
Here's the code I have on my site so far, copied directly from http://code.google.com/apis/recaptcha/docs/display.html#Standard:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<body>
<!-- ... your HTML content ... --> <form action="" method="post"> <!-- ... your form code here ... --> <script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=public key"> </script> <noscript> <iframe src="http://www.google.com/recaptcha/api/noscript?k=public key" height="300" width="500" frameborder="0"></iframe><br> <textarea name="recaptcha_challenge_field" rows="3" cols="40"> </textarea> <input type="hidden" name="recaptcha_response_field" value="manual_challenge"> </noscript> <!-- ... more of your form code here ... --> </form> <!-- ... more of your HTML content ... -->
</body>
</html>
either use te recaptcha PHP/Perl/Asp/.. plugin or use the recaptcha ajax library which handles everything with javascript so you dont need server side scripts.