How to index file contents - windows

I have a server at batalabs.tk where I use batch files as most of my CGI scripts, I am currently trying to make an Indexing service for a search script...
Example files:
Directory to search:
<DIR HTDOCS>
index.html
otherpage1.html
otherpage2.html
</DIR>
index.html:
<HTML>
<HEAD>
<TITLE>MyWebsite - Buy Products</TITLE>
<META NAME="Description" Content="Buy Software and products from MyWebsite">
</HEAD>
<BODY>
<DIV ALIGN="CENTER">
<H2>Software</H2>
<h4>Find the latest and greatest in software right here at the Shop Page!</h4>
<hr>
Lorum - Free Cloud Storage
<hr>
Ipsum - Free Networking Software
<hr>
</div>
Copyright MyWebsite.com, 2016
</body>
</html>
Otherpage1.html
<html>
<head>
<title>Page One - Hello World!</title>
<META Name="Description" Content="Hello World Page For Testing.">
</head>
<body>
<h1>
Hello, World!
</h1>
<div>
<pre>
this is an example page for use with testing.
Any of these words can be searched and should (optimally) show this page in the results.
</pre>
</div>
</body>
</html>
otherpage2.html:
<html>
<head>
<title>Page Two - The Revenge Of The Coder</title>
<meta Name="Tags" content="dummy; coder; file; otherpage2;;">
</head>
<body>
<pre>
Hello, This file doesn't matter. At all. It is a dummy.
</pre>
</body>
</html>
These are just example files, But i want my batch file to pick up on the
<META> tag with Description and Tags, as well as the file's name, every word in the body,
and the title... I've tried some stuff to no avail, any help?
So maybe a user could type "dummy" as their keyword, and Otherpage2.html would pop up like so:
Page Two - The Revenge Of The Coder
HTTPS://www.batalabs.tk/otherpage2.html
Hello, this file doesn't matter. At all. It is a dummy.

Related

Spring Boot HtmlConverter set dynamic value in html file

I would like to have dynamic value in my html file which gets Convertet to a PDF file. I've got no idea how to do that.
HTML
<!doctype html>
<html lang="en">
<head>
<title>SpringHow html to pdf</title>
</head>
<body>
<div>
<h2> --> DYNAMIC VALUE HERE <-- </h2>
</div>
</body>
</html>
JAVA
HtmlConverter.convertToPdf(new File("template.html"),new File("report.pdf"));

Thymeleaf can not find internationalized messages

I tried searching on Google but could not find any solution to my problem.
The link for code is
https://github.com/optimus29/ThymeleafDemo
I get the following output on running the JUnit test com.jk.th.mail.util.MailTemplateTest.java :
----------------------------------------------
* Mail contents *
----------------------------------------------
Recipients: def#mail.com
Subject: Complete registraion process
Message:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>??subject.registration.complete_en_US??</title>
</head>
<body>
<p>??grettings.user_en_US??</p>
<p>??registration.text.line1_en_US??</p>
<p>
??registration.link.text_en_US??
</p>
<p>??registration.text.line2_en_US??</p>
<div>
<p>
<span>??thanks_en_US??</span><br/>
<span>??pustakalaya.team_en_US??</span><br/>
<span>??contact.mail_en_US??</span><br/>
<span>??contact.number_en_US??</span>
</p>
</div>
</body>
</html>
----------------------------------------------
I'm not really sure what is not right in the way you wrote the configuration, but...
Since you are using the default paths anyway, you could just remove the call (in SpringMailConfig.springTemplateEngine()):
templateEngine.setMessageResolver(messageResolver());
Then you may also remove the beans messageResolver and emailMessageSource.
After you do this, the only unresolved message will be "grettings" (because it's misspelled).

Thymeleaf in spring boot

I am trying to use an HTML template as given below and set 2 values to it dynamically.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title th:text="${title}"></title>
</head>
<body>
<div class="page-content">
<h1 th:text="|Hello ${siteCode}!|"></h1>
</div>
</body>
</html>
I used the below code to set the values.
Model model = new ExtendedModelMap();
model.addAttribute("title", site.getName());
model.addAttribute("siteCode", site.getCode());
I want to get the new html file with the values added in the template variable so that I can store the file to s3. Please help.. Thanks in advance.

How to keep special characters in template variables on the commandline with pandoc?

I am trying to set a template variable with a string containing an umlaut. The body content is converted correctly, but the variable looses its special characters.
If I have a simple template var-template.md
<!DOCTYPE html>
<html>
<head>
<title>$title$</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<div>
$for(navi)$<button name="navi" value="$navi$">$navi$</button>$endfor$
</div>
<div>
$body$
</div>
</html>
and try to convert with variables set:
echo Hällo Wörld | pandoc -w html --template=var-template -V navi="Übung 1" -V title="Laß das döch"
it outputs:
<!DOCTYPE html>
<html>
<head>
<title>La� das d�ch</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<div>
<button name="navi" value="�bung 1">�bung 1</button>
</div>
<div>
<p>Hällo Wörld</p>
</div>
</html>
So the body text is converted correctly, but the variables are not.
Is this a bug or a mistake?
I am on ubuntu 12.04 with pandoc 1.9.1 ... do I have to manually update from the repository-version to a newer on?
I just tried this with the latest pandoc release, and it worked fine, so you may just need to upgrade. You should also make sure that your locale is UTF-8.

Can I put HTML into a variable?

Using the Sinatra library, I'm trying to condense two functions that display HTML code into a single function. Both these functions differ by only a small amount of HTML.
Here's an example.
def make_start_page()
<<EOS
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<p> Hello </p>
<img src="..." />
</body>
</html>
EOS
end
def make_guess_page()
<<EOS
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<p> Something different </p>
<a href="..." >1</a>
</body>
</html>
EOS
end
In the Ruby function that will call these two functions, I was wondering if it is possible to take the small portion of HTML that differs and pass it to a single, condensed version of these two functions that will display the page.
def handle()
if 1
var = "<p> Hello </p>
<img src="..." />"
elsif 2
var = "<p> Something different </p>
<a href="..." >1</a>"
make_start_guess_page(var)
end
You can interpolate variables in heredoc:
def make_start_page(var)
<<EOS
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
#{var}
</body>
</html>
EOS
end
For example.
There no reason why you could not do that. However if you want to print it, you'll probably have to use functions like String#html_safe in rails, or != in haml

Resources