Pelican not rendering rst title and subtitle from imported rst file - restructuredtext

I want to import an rst file to my Pelican index page like here:
Pelican: include file's contents on main page
*****
Title
*****
subtitle
########
subsubtitle
***********
Here is some content in the document.
**ReStructuredText** (rst): plain text markup
.. image:: images/22204100065.png
:alt: exhale
:width: 512px
only from subsubtitle gets the page rendered as html.
The source of the index.html looks like this
<div class="bg-white dark:bg-zinc-800 p-4 md:p-6 mb-4 rounded-lg"><div class="section" id="subsubtitle"> <h2>subsubtitle</h2>
Here is some content in the document. ReStructuredText (rst): plain text markup
The start of the index.html template looks like this:
{% extends "base.html" %}
{% block content %}
{% block content_title %}
<div class="bg-white dark:bg-zinc-800 p-4 md:p-6 mb-4 rounded-lg">{{ INTRO }}</div>
{% if not category and not tag %}
<div class="my-12 md:my-24 text-zinc-800 dark:text-zinc-300">
{% if SOCIAL or FEED_ALL_ATOM or FEED_ALL_RSS %}
The part of my settings file looks like this (from the answer of above link):
from pelican.settings import DEFAULT_CONFIG
from pelican.readers import RstReader
config = DEFAULT_CONFIG.copy()
INTRO, _ = RstReader(config).read("content/incls/sample.rst")
I expect the Title be rendered in h1 and the Subtitle in h2.
I am using the Papyrus theme. Update: I also tried with notmyidea but have the same problem.
I tried to ask the question in a comment of the above link but I am not allowed.

Related

How can I set an interpolated value, as a style property in Angular?

Before creating this question, I've read all the question existing, and none of the answers has fixed my issue.
Well, I'm fetching a data from API, {{ album.image["3"]["#text"] }} - is the link to the .png file which I would like to set as background-image of the . Here is the example of my code:
<div class="album-grid">
<div *ngFor="let album of albums">
<div class="album"> <--! I want here to set a backgroundImage for each album-->
<h4>{{ album.name }},</h4>
<h5>by {{ album.artist.name }}</h5>
<p>{{ album.image["3"]["#text"] }}</p> <--! this is the link to .png file I'm getting from server -->
</div>
</div>
</div>
here is the solutions I've tried, but none of them helped me:
[style.backgroundImage]="album.image['3']['#text']"
[style]="backgroundImage: {{album.image['3']['#text']}"
[ngStyle]="{ 'backgroundImage': album.image['3']['#text'] }"
Link to my repo -> https://github.com/paslavskyi9roman/Spotilar
On a picture, you can see a grid of albums, with the album name, artist name, and link to album cover file which need to be a background image
click here
You are missing the url() part.
Try the following (as seen in your repository)
<div class="album" [ngStyle]="{ 'backgroundImage': 'url('+ album.image['3']['#text'] + ')'}">
<h4>{{ album.name }},</h4>
</div>
<h5>by {{ album.artist.name }}</h5>
</div>

blogdown `title` won't display on rendered `_index.html`

I created an _index.Rmd file in my blogdown /*/content/ directory and the body of the _index.Rmd file looks like this:
---
title: "Home"
date: "2016-05-05T21:48:51-07:00"
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
Welcome to the home page of this blogdown site.
I would expect to see a "Home" title heading but nothing appears. I presume this is an intentional design choice. I can understand why, but in my case I want the title that I specify in the YAML to showup on the rendered _index.html file. How do I achieve this goal?
This is because the index (main) page has special treatment with this theme. How you can change this is go to themes/(yourtheme)/layouts/index.html. It would look something like:
{{ partial "header.html" . }}
<main class="content">
<div class="list">
{{ range (.Paginate ((where .Data.Pages "Type" "post").GroupByDate "2006")).PageGroups }}
<h2 class="list-title">{{ .Key }}</h2>
{{ range .Pages }}
{{ partial "list-item.html" . }}
{{ end }}
{{ end }}
</div>
{{ partial "pagination.html" . }}
</main>
{{ partial "footer.html" . }}
Now you can edit this file to add the desired title in many ways, for example if you want the same style as a post title would have you could add between the <main class="content"> and <div class="list>:
<h1 class="article-title">Home</h1>
If you want to source the title from the .Rmd file, you would do:
<h1 class="article-title">{{ .Title }}</h1>
Now after rebuilding the site the title will appear on the homepage.

flask-bootswatch: css is not loading in "/" paths

While working on a project which I build using Flask and a Bootswatch theme which is a books website, letting users to register, log in and then search for books and when a users selects one of results it gives information about that book,but I found out that information page which I implemented wasn't loading the styling of page, contrary to all other pages which are working fine.
My application.py for information page is:
#app.route("/book/<isbn>")
def book(isbn):
# getting the book from database
book = db.execute("SELECT * FROM books WHERE isbn=:isbn", {"isbn": isbn}).fetchone()
if book is None:
return render_template("failure.html", error="Please enter some query", code = "403!")
db.commit()
# giving details to webpage
return render_template("book.html", book = book)
as you can see I am using ISBN (International Standard Book Number), as a path for different books because each book has unique ISBN, thus I assume it is great for making links to different individual book page.
and book.html looks something like this:
<!-- further exptending the layout page -->
{% extends "layout.html" %}
<!-- further extending the title -->
{% block title %}
Books: Book Page
{% endblock %}
<!-- further extending the body -->
{% block body %}
<h3 align="center"> {{book.title}} by {{book.author}}</h3>
<div>
<li>
Title: {{book.title}}
</li>
<li>
Author: {{book.author}}
</li>
<li>
ISBN: {{book.isbn}}
</li>
<li>
Year: {{book.year}}
</li>
</div>
{% endblock %}
Please figure out where I am going wrong.
Problem is in first line here in application.py it should be
#app.route("/<isbn>")
because /book/<isbn> loads css from /book/static/bootstrap.min.css.

Drupal 8 - reach node/content needed variables in view

New user of D8 : my problem is to access to fields in a view or even in general with Drupal 8.
As we could do with ACF in Wordpress.
a {{ kint() }} crash my chrome but works with Firefox to explore the content var.
Unfortunately I do not managed to find and use fields' variables in my view.
I create a new view, which actually display the last three articles. These are well displayed in ugly list but I want to extract fields to put them in a custom html integration.
I create and use a new template for the view :
x node--view--liste-des-actualites--page-2.html.twig
In a custom parent :
x node--page-accueil.html.twig
But when I try to kint() content in my node--view--liste-des-actualites--page-2.html.twig, I have the custom field of the page (Page accueil) and can't find the article's one.
I managed to do it in my custom page but not in this view.
{%
set classes = [
'node',
'node--type-' ~ node.bundle|clean_class,
node.isPromoted() ? 'node--promoted',
node.isSticky() ? 'node--sticky',
not node.isPublished() ? 'node--unpublished',
view_mode ? 'node--view-mode-' ~ view_mode|clean_class,
'clearfix',
]
%}
{{ attach_library('classy/node') }}
<article{{ attributes.addClass(classes) }}>
<div{{ content_attributes.addClass('node__content', 'clearfix') }}>
{{ content }}
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
<a href="{{ LINK_VAR }}" class="bloc-type">
<div class="categ categ_projet">{{ CATEGORY_VAR }}</div>
<div class="img"> <img src="{{ IMAGESRC_VAR }}" alt=""> </div>
<span class="wrapper">
<p class="date">{{ DATE_VAR }}</p>
<h3>{{ TITLE_VAR }}</h3>
</span>
</a>
</div>
</div>
</article>
EDIT
I managed to guess some fields but this is definitely not a good way to find variables..
{{ node.label }} + {{ content.field_tags }} (But I do not want a rendered one, I just want the text/value)
if you use kint(); to debug large arrays can crash your browser.
I would suggest to use the devel module https://www.drupal.org/project/devel. With devel you can debug your arrays inside of the Drupal8 UI for each content type, block or view.
In my case i use the UI of devel (additional tab on each content). in the module settings, you can chose how devel debugs, the error handling and the output.
As the OP commented it is possible to use a preprocess to display the array on your site:
function <themename>_preprocess_page(&$variables) {
dpm($variables);
}

for in twig templates of drupal is behaving strangely

I am trying to show only upcoming events from a list of events. Below is how I have tried to display.
<div class="row">
{% for item in items %}
{% if item.content['#node'].field_event_type.getValue()|first.value == 'upcoming' %}
<div class="col">{{item.content}}</div>
{% endif %}
{% endfor %}
</div>
But the output rendering is, the second event is displaying after the row div like below. I don't understand how this is happening as the for loop is inside the row div
<div class="row">
<div class="col"> content </div>
</div><div class="col"> content </div>
Expected output
<div class="row">
<div class="col"> content </div>
<div class="col"> content </div>
</div>
Twig does lots of things:
loading (open your Twig content)
parsing (create a parse tree from your Twig content)
compiling (browse that tree to create a php file)
caching (store the php file somewhere to avoid recompile it next time)
executing (execute the generated php file)
When a {% for %} is detected during parsing, Twig calls the token parser recursively until it finds {% endfor %} and builds a token tree. In your case, it would look like:
root
|
--- string
|
--- for
| |
| --- if
| |
| --- string
|
--- string
Then, Twig compiler crosses over that tree recursively and generates the corresponding php code. In that way, the following Twig loop:
{% for i in 1..5 %}
Value = {{ i }}
{% endfor %}
Compiles to this in PHP:
// line 1
$context['_parent'] = $context;
$context['_seq'] = twig_ensure_traversable(range(1, 5));
foreach ($context['_seq'] as $context["_key"] => $context["i"]) {
// line 2
echo "Value = ";
echo twig_escape_filter($this->env, $context["i"], "html", null, true);
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['_key'], $context['i'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
As you can see, a {% for %} is no more than a simple foreach and as Twig tokens are stored into a tree, it is by design not possible to display contents located below a pair of open/close tags.
The only possibility I can see is that one of the tag you're using in Twig is playing with output buffering, and one of the methods you're using in your loop breaks the ob stack (like a ob_get_clean() without any ob_start() for example, that have been open previously).
My advice is to grep your twig file name into your cache directory (eg: grep -Ri 'test.twig' cache/) in order to see that file compiled to PHP, to understand exactly what it does, and debug it.
Instead of filtering your content in twig, filter the results in your Drupal view.
In the "filter criteria" on your view, select the field_event_type field and set it "is equal to" and select/add 'upcoming' as the option.
If you filter in the view, you don't have to mess with the twig template.

Resources