Showing file name in Jekyll with Pygments code highlight - jekyll

When highlighting a standard file at a known location I'd like to put the file name in the code block; preferably at the top. A hypothetical example would be
{% highlight apache show_filename=/etc/httpd/conf/httpd.conf %}
.... the file contents ....
{% endhighlight %}
which would then render a code block with a filename prefixed. Is there a way to accomplish this?

You can simply use the nice html5 figure tag.
"The HTML Element represents self-contained content, frequently with a caption (figcaption), and is typically referenced as a single unit. While it is related to the main flow, its position is independent of the main flow. Usually this is an image, an illustration, a diagram, a code snippet, or a schema that is referenced in the main text, but that can be moved to another page or to an appendix without affecting the main flow."
MDN > html > figure
<figure>
<figcaption>File: folderName/fileName.rb</figcaption>
{% highlight ruby %}
def print_hi(name)
puts "Hi, #{name}"
end
{% endhighlight %}
</figure>

Another, a bit nicer solution which will work with kramdown:
>Some/test/xml/file.xml
{:.filename}
{% highlight xml %}
.... the file content ....
{% endhighlight %}
And in you .css file you can make it look nice with your code snippet, for example like this:
.fileName{
padding: 0px;
margin: 0px;
background-color: #292929;
color: lightgrey;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
margin-bottom: 0px;
padding-left: 1em;
font-family: Menlo,Monaco,Consolas,"Courier New",monospace;
border-left: 0px;
}
Here you can find more info about this kramdown feature.

Related

Django: using Images in Hyperlinks

im pretty new to Django (as in no Knowledge so far) and a project requires me to include a Image inside of a hyperlink.
just including the inside of the hyperlinks created the error message
'blocktrans' doesn't allow other block tags (seen "static 'pretix_app/Instagram.png'") inside it
my code so far is
li ><img src="{% static 'pretix_app/YouTube.png' %}" alt="Youtube_icon" style="alignment: left;vertical-align:middle; width: 20px; padding-right: 5px" >
{% with 'target="blank" href="https://www.youtube.com"'|safe as a_attr %}
{% blocktrans trimmed %} <a {{ a_attr }}> Social Media-target {% endblocktrans %}
{% endwith %}</li>
This produces a working hyperlink, but does not include the image (which is required as a social media hyperlink)
The "safe as attr"-method was copied from a working template included in the source code.
Does anybody know if it is possible to include Images in Hyperlinks, and if yes, how?
Thanks in advance for any help
Hello Corinari and welcome to StackOverflow.
As the Django log says, the blocktrans (should be blocktranslate since Django 3.1 ref) may not contain other tags, which in this case is the {% static 'pretix_app/YouTube.png' %} part. We need to remove that part.
One possible way is to use the as statement. You could have the static tag outside your blocktrans block and pass through a variable, like this:
{% static 'pretix_app/YouTube.png' as yt_icon %}
{% blocktrans %}
<li>
<img src="{{ yt_icon }}" alt="Youtube_icon" style="alignment: left;vertical-align:middle; width: 20px; padding-right: 5px"/>
...
</li>
{% endblocktrans %}
This will fix your current error. There are, however several further notes I have. First is the probable typo pretix_app in the static path. The other, much more important, as Abdul says in his comment, you will reach another error with the second blocktrans block. As far as I know from what you have posted here you should not need the second blocktrans nested within the first one. You will be able to translate the whole thing as one.

Link external CSS stylesheet with Shopify product page

I usually put these below code in order to do additional styling for my product page. But I am looking for a way where I would like to link CSS style sheet in the product page and do the CSS designing in a different directory, example: "assets/custom.css".
So how do I link the below styles made under .
<style>
.checkmarks li {
list-style-type: none;
background: url("https://i.imgur.com/FqEWdiJ.png") 0px 5px no-repeat;
background-size: 20px;
padding-left: 30px;
line-height: 200%;
}
</style>
<ul class="checkmarks">
<li>First</li>
<li>Second</li>
<li>Third</li>
</ul>
If you have a file in the assets folder, you can access it using the asset_url filter in Liquid. (Reference: https://shopify.dev/docs/themes/liquid/reference/filters/url-filters#asset_url)
If you create your stylesheet as assets/custom.css you can get the URL using:
{{ 'custom.css' | asset_url }}
Since it's a stylesheet, you can add on the stylesheet_tag filter to also have Shopify automatically make it into an appropriate HTML tag for you:
{{ 'custom.css' | asset_url | stylesheet_tag }}
One further possible improvement would be to make your stylesheet a scss file rather than a standard css file. This allows you to use some fancy features that help keep longer CSS files more readable/maintainable. Additionally, Shopify will minify a scss file when it compiles everything into a final css file - which means the file size will be slightly smaller because all of the whitespace gets stripped out. If you decide to do this, the compiled (browser-friendly) version of the file is accessed as <filename>.scss.css - so custom.scss could be put in as:
{{ 'custom.scss.css' | asset_url | stylesheet_tag }}
Finally, if you want this file to only appear on your product pages, you can either:
Place this code inside your templates/product.liquid file, or
Place this code in the layout/theme.liquid file, wrapped in a simple template check to see if we are on a product page:
{% if template.name == 'product' %}
{{ 'custom.scss.css' | asset_url | stylesheet_tag }}
{% endif %}

Mysql data include text style to html

In mysql database, table named "project" contains text data below. Text style(e.g. < h1 >) is included together.
I want to show "description" data of "project" table {{project.description}} in monitor like:
But it keeps showing as it is.
What tags should I use?
I already used div, source, resource, code, pre, p...
Also, I used iframe tag but I don't know how to use...
My html code is:
<!DOCTYPE html>
{% extends "layout.html" %}
{% block body %}
<p>
{{ project.description }}
</p>
{% endblock %}
This template is extended from layout.html and I just wrote p tag example.

How can I prevent login box from including background image in modified JupyterHub?

I have deployed JupyterHub and am modifying the appearance. I have modified the login template (login.html) to display a background image. The problem is that the login box itself includes the background image.
Looks like this:
Login template code begins:
{% extends "page.html" %}
{% block login_widget %}
{% endblock %}
{% block main %}
{% block login %}
<div id="login-main" class="container">
{% if custom_html %}
{{ custom_html | safe }}
{% elif login_service %}
<div class="service-login">
<a role="button" class='btn btn-jupyter btn-lg' href='{{authenticator_login_url}}'>
Sign in with {{login_service}}
</a>
</div>
{% else %}
I insterted the following 6 lines:
<style>
body {
background-image: url("static/images/login_back.jpg");
background-color: #cccccc;
}
</style>
Original template continues (much longer than what's included here):
<form action="{{login_url}}?next={{next}}" method="post" role="form">
<div class="auth-form-header">
iamdodge
</div>
<div class='auth-form-body'>
<p id='insecure-login-warning' class='hidden'>
Warning: JupyterHub seems to be served over an unsecured HTTP connection.
We strongly recommend enabling HTTPS for JupyterHub.
</p>
Desired result:
Again, my desired result is for the login box itself to not contain the background image. Ideally it would be a solid color. As you might guess the intent is to modify the colors of the login box to match the background, but that part I can handle.
Thanks for any advice. I'm happy to edit my question for clarity as needed.
Do:
Give the form main (auth-form-body i think) area a background color, should do.
Since as can be seen on you picture the form header background-color overwrites the background image, so adding a background color to .auth-from-body is what you are missing.
Code:
.auth-form-body {
background-color: red;
}
<div class='auth-form-body'>
<p id='insecure-login-warning' class='hidden'>
Warning: JupyterHub seems to be served over an unsecured HTTP connection.
We strongly recommend enabling HTTPS for JupyterHub.
</p>
</div>

Issue with Django Template Background

I'm getting an issue with my background template picture. Each time I'm loading Django template, my background is black in the first time, then becomes good with my picture after 0.5/1 second.
I wrote in my script (Common HTML Template) :
{% load staticfiles %}
{% load static %}
{% load user_tags %}
{% load variables %}
<style>
body {
background-image:url("{% get_static_prefix %}{{ mytheme }}/images/bg.jpg");
}
</style>
The url path is good because my picture is loaded, but I have this black background before during ~ 1s
I didn't write background picture in my CSS file, but only in my common template (navbar template which is called each time).
Do you have any idea ?
It is due to high image quality, you can add the one loader till the all web content so that black screen will not be displayed. There is nothing problem with Django template in this.
http://smallenvelop.com/display-loading-icon-page-loads-completely/