How to remove ellipsis set by the browser by default? - html

I've been given a task of displaying files hosted on a webserver(jekyll) via a webpage using iframe. Iframe lists all the files. Though the view is not as pretty as an embedded Google Drive link.
However, there are 2 major issues with this:
The filenames are being truncated - "abc..." and on the browser I see ellipses and I'm not able to reverse this.
All the pdf files are getting downloaded as opposed to opening in a new tab which would have been possible via embedding a Gdrive link (the idea is to move files to a static folder on the web server instead of Gdrive)
I have read most articles. Even if the second issue is not solvable, I am interested in learning how to solve the first issue.
I'm able to inject my own CSS like this:
<script>
$( document ).ready(function() {
$('iframe').each(function(){
console.log("here");
function injectCSS(){
$iframe.contents().find('head').append(
$('<link/>', { rel: 'stylesheet', href: '{{ site.col_url}}/static/xyz/xyz.css', type: 'text/css' })
);
}
var $iframe = $(this);
$iframe.on('load', injectCSS);
injectCSS();
});
});
</script>
I would like to see the complete file names being listed on my webpage. I am not allowed to use a scripting language since the whole system is built in Markdown format

Set the below option on your vhost file, if you are using Apache
IndexOptions NameWidth=*
Ref: https://www.networkworld.com/article/2311687/showing-long-file-names-in-apache-directory-listings.html

Use can use the directory plugin https://github.com/sillylogger/jekyll-directory to display the files in your static folder. This gives full filenames and its better than using iframes. By default your chrome browser renders pdf and jpg images in a new tab as opposed to downloading them. Just take care of bad urls. To get the last modified date, use the gem file https://github.com/gjtorikian/jekyll-last-modified-at
Your code looks like this:
{% directory path: <provide a path to your static folder> %}
<a href="<static_path>/{{ file.name }}" datetime="{{ file.date |
date_to_xmlschema }}">{{ file.name }}</a>
{% enddirectory %}
Additionally, to get the last modified date:
Last Modified on {{ page.last_modified_at|date_to_string}}

Related

Next.js build and export for template engine

I would like to export my Next.js project for the use with a Template Engine. (In my case "twig") I replaced all the texts in my HTML with the {{ ... }} twig markdown.
When I run next build && next export the HTML is generated as intended. The problem now is, that when I render e.g. the "index.html" with the twig renderer the texts are replaced again bei the markdown {{ ... }} from the .../index.js code. (Since this calls createElement and replaces all creates the tags for faster loading)
Now my question is: is it possible to disable the generating of the .js file for every page sothat I can change the .html file without it being overwritten?
P.S. The build is running as a SSG (Static Site Generator) eventhough I am not using getInitalProps, getStaticProps, getStaticPaths or getServerSideProps which I find strange. And I have no configuration in the next.config.js file.
Thank you so much in advance!

HTML Conditional href

I have a folder containing a large number of pdf files. They are named with a code of 3 digits (XXX.pdf). In that same folder, I have a index.html file, which as its name suggests, is an index for navigating in the folder and opening a specific pdf.
As an example, when I search a specific pdf file but I don't know what's the name of the pdf. I only know its title or authors.
Without that index, I have no solution to find it.
With the index, the pdf are classified according to authors or titles so I can search within the index and click on the link to open the file. The index contain this line for each pdf file:
<STRONG>TITLE001</STRONG><br /> Author001
So, this is the first configuration. I can give the entire folder to a colleague and he can open the index to search for a file as soon as he doesn't change the folder organization because the href link is relative.
Now, I have a second configuration in which I uploaded that folder on a server on a private network. I changed the index.html with the following line:
<STRONG>TITLE001</STRONG><br />Author001
In that way if someone search a specific pdf file, he can download the index and when he click on the like in that index, it will download the correct pdf from the server.
BUT, I would like to have both configuration working:
If my colleague uses a lot that folder, he will maybe prefer to download the entire folder and the index will not work because its not a relative address anymore.
If my colleague uses it occasionally, he will just download the index and it will work.
Is there any solution to merge both solution and to have a conditional href attribute ?
Allowing to use both configurations. Something like:
if "001.pdf" doesn't exist
<STRONG>TITLE001</STRONG><br />Author001
else
<STRONG>TITLE001</STRONG><br />Author001
Can someone help me with that ?
Thanks a lot !
Doubt you will find a way to do that in HTML, how about something with Js ? Do you use JQuery or something ?
Something like that could do it then :
$.ajax({
type: 'HEAD',
url: 'http://personal_cloud/001.pdf',
success: function() {
// here when then file does exist
},
error: function() {
// here when then file does not exist
}
});

How do I change the layout extensions in Jekyll to .liquid?

By default, Jekyll uses *.html, however, the program I use (Sublime Text 3) has an a package that adds Liquid syntax support but it will only auto detect and do the code suggestions if the file has the extension *.liquid. The other problem is, Jekyll is looking for default.html as well as the other layouts. How do I make Jekyll look for *.liquid files instead like default.liquid?
In the bottom right hand corner of sublime it will have the name of the filetype being used, for example 'HTML'. If you click this you can change it to liquid.
What worked for me is to rename files to *.liquid.html and then
update the front-matter to use the new name, e.g.,
Including abc.liquid.html in default.liquid.html
=== default.liquid.html ===
---
---
{% include file.liquid.html %}
Using layout default.liquid.html in a Blog Post
---
layout: default.liquid
title: "My post title"
date: 2021-01-24 19:00
---

Trouble rendering MathJax with Jekyll on github pages [duplicate]

I built a random sentence generator -- when you click an HTML button, a random sentence is generated beneath it. The generation is powered by a simple script and jQuery.
It works fine on my local machine: When I open index.html in a browser, everything goes smoothly.
But once I upload to GiHub and visit the GitHub pages URL, the generator stops working. Clicking the button does nothing.
Here's the script (it's all contained within the index.html file):
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
and
<script> function sentenceLoad() {
//declare arrays
var nouns = ['Mulder, Scully, and'];
var names = ['Assistant Director Skinner', 'the Cigarette Smoking Man', 'Alex Krycek'];
var actions = ['are running from alien bounty hunters', 'are tracking a shapeshifter', 'are hunting a mutant serial killer'];
var places = ['in the woods of New Jersey', 'in a government bunker', 'in Olympic National Forest'];
//shuffle through contents of each array, picking one entry per array
var randNoun = nouns[Math.floor(Math.random() * nouns.length)];
var randName = names[Math.floor(Math.random() * names.length)];
var randAction = actions[Math.floor(Math.random() * actions.length)];
var randPlace = places[Math.floor(Math.random() * places.length)];
//place the random entry into the appropriate place in the HTML
jQuery("h5").html("");
jQuery("h5").append(randNoun + " ");
jQuery("h5").append(randName + " ");
jQuery("h5").append(randAction + " ");
jQuery("h5").append(randPlace);
}
What would cause this to work locally, but not work on Github Pages?
If you open up your Developer Tools pane (in Chrome, right-click on the page and choose Inspect), you'll see this error in the Network console:
Mixed Content: The page at 'https://bobbyfestgenerator.github.io/' was loaded over HTTPS, but requested an insecure script 'http://code.jquery.com/jquery-1.10.1.min.js'. This request has been blocked; the content must be served over HTTPS.
You need to load your script over HTTPS instead of HTTP.
The reason this works locally is because you're using the file:// scheme on your local machine (or http:// if you have a local development server). The browser doesn't have a problem loading an external script over HTTP in this case.
However, Github Pages is hosting your file over HTTPS (a secure connection) for you. For security reasons, the browser won't load a script over HTTP if the page is hosted on HTTPS.
Just change the code in your <head> tag to load the script over HTTPS:
<script src="https://code.jquery.com/jquery-1.10.1.min.js"></script>
Today I saw a similar problem, but not because of HTTP/HTTPS: when I published to GitHub pages, all of the CR/LF characters were removed in the source HTML. Perhaps not a big deal for HTML with closing tags, but when the entire source page is on one line, including JavaScript, well - any embedded comments in JavaScript caused all code afterwards (until the JavaScript closing tag) to be unexpectedly also commented out.
In this case some more code is treated like a comment:
code...
// a comment
some more code...
Here's an example. Before, as viewed in editor:
After push to GitHub, CR/LF apparently removed by GH-Pages actions:
Note how all the remaining JavaScript ends up disabled after the comment::
The (somewhat undesired) solution would be to remove the comment or better: use /* and */ comment wrappers instead of // at the beginning of the line.
edit: the root cause seems to be the layout: compress; see https://github.com/jekyll/jekyll/issues/8660

Generating a pdf-file out of a twig template

I want to generate a pdf (an invoice as letter) out of a twig template. The template uses a css and contains a header with a logo (png-image) and a footer, which should appear at the bottom of the document.
I tried it with the KnpSnappyBundle, but this doesn't work (css only works inline, images are not rendered..., etc.). Are there any other tools to generate a pdf?
With Java I used jasper-reports (really cool), isn't there anything similar for php?
I have used KnpSnappyBundle to generate pdf before, and it worked with external css files, thought there's is some diffrence bettween regular tempaltes:
When linking asset you have to provide absolute path:
<link type="text/css" rel="stylesheet" href="{{ asset('css/css.css', null, true) }}" />
I didn't needed images files, but I think it should work the same, also you need to use "renderView" method instead of "render".
$pdf = $this->renderView('**:**:tempalte.html.twig', array());
After that you just simple use:
$file = $this->container->get('knp_snappy.pdf')->getOutputFromHtml(pdf);
The answer is: The server startet via
php app/console server:run
is single-threaded, so there is no chance, to get a response, when requesting an image or css-file...