I have the following theme configuration ...
mytheme.info.yml
name: MyTheme
type: theme
description: Theme based on Emulsify.
base theme: stable
core: 8.x
# Libraries (These are loaded on every page. Use https://www.drupal.org/developing/api/8/assets#twig whenever possible.)
libraries:
- mytheme/global
mytheme.libraries.yml
global:
version: VERSION
css:
theme:
dist/style.css: {}
That stylesheet is not being attached to my pages. I tried adding the same stylesheet onto the Bartik theme in the same way and it worked fine. Any thoughts on what I'm missing or how to track this down?
Thanks!
EDIT:
I'm getting "Notice: Array to string conversion ... " I believe on this line that gets generated in the file "sites\default\files\php\twig\5c785ff00bd6e__html.twig_0yYIGbLfvl1AKm7qslTBE8W-Z\Fay9SGEvR_arQ_YULxnlOBW1yidhbxKLSR3KrUE5-bc.php":
echo $this->env->getExtension('Twig_Extension_Sandbox')->ensureToStringAllowed($this->env->getExtension('Drupal\Core\Template\TwigExtension')->escapeFilter($this->env, ($context["page_top"] ?? null), "html", null, true));
My _html.twig file:
<!DOCTYPE html>
<html{{ html_attributes }}>
<head>
<head-placeholder token="{{ placeholder_token|raw }}">
<title>{{ head_title|safe_join(' | ') }}</title>
<css-placeholder token="{{ placeholder_token|raw }}">
<js-placeholder token="{{ placeholder_token|raw }}">
</head>
<body{{ attributes }}>
<a href="#main-content" class="visually-hidden focusable">
{{ 'Skip to main content'|t }}
</a>
{{ page_top }}
{{ page }}
{{ page_bottom }}
<js-bottom-placeholder token="{{ placeholder_token|raw }}">
</body>
</html>
I had started my theme on another, clean install of Drupal 8 and then moved it over to my working installation. I didn't even think about the fact that I already had a module in that install that had the same name as my theme. Rename the theme, problem fixed.
Leaving this here as a warning to others - do not use the same name for a theme and a module. Should probably be obvious, but maybe you end up here anyway like I did.
Related
I've got a site with two languages (it will get more in time) and a little dropdown menu to switch languages. It works as desired/expected in the development server. Urls look like this when visiting the site:
localhost:8000/en/home
localhost:8000/pl/home
The django project gets deployed on a server (Apache w/ mod-wsgi) at a subdirectory location, lets say:
mysite.com/django
Everything works as expected, even the admin site, etc, underneath that subdirectory, however, my little menu to change languages doesn't work anymore. When I change the language, the page reloads, but on the same language that it was on when I tried to change it. I can go back and forth between the languages by manually changing the url in the browser and all the pages work as expected with the translations; it's just the dropdown button that doesn't work anymore.
mysite.com/django/en/home
mysite.com/django/pl/home
At first, I thought it was my button (pretty standard off a tutorial):
<form action="{% url 'set_language' %}" method="post" class="form-inline">{% csrf_token %}
<div class="form-group mx-sm-3 mb-0">
<input type="hidden" name="text" value="{{ redirect_to }}" class="form-control form-control-sm">
<select name="language" id="langselect" onchange="this.form.submit()">
{% get_available_languages as LANGUAGES %}
{% get_language_info_list for LANGUAGES as languages %}
{% for language in languages %}
<option value="{{ language.code }}" {% if language.code == LANGUAGE_CODE %} selected {% endif %}>
{{ language.name_local }} ({{ language.code }})
</option>
{% endfor %}
</select>
</div>
</form>
but actually if I change the Apache config to deploy the site at server root mysite.com (just to try to isolate the problem) the dropdown button, translations, and everything else work as expected. I think this means that somewhere the i18n is generating a bogus link, i.e. it's not implementing the '/django' subdirectory prefix the right way.
I feel like this should be an easy fix —a setting to toggle somewhere— but I'm stumped after spending most of the day googling and reading documentation. I'm happy to share snippets of settings, etc, but honestly, I'm not sure what's relevant.
Could someone please point me in the right direction with a keyword or a suggestion how to solve this?
Edit 1:
I tried to add the prefix to value in the <input> tag. So it read value="/django{{ redirect_to }}" but that didn't work either.
Edit 2 & 4:
Using my switcher button with the network inspector open reveals that the setlang function is calling the wrong url.
mysite.com/django/django/i18n/setlang
I still don't know how to fix it, but I'm fairly certain that's the problem.
If I change the apache config to deploy at mysite.com the redirect is via mysite.com/i18n/setlang, so it seems like I need to somehow control how the django subdirectory prefix is interpreted. But HOW?!?!?
Edit 3:
The switcher successfully changes the cookie, despite not reloading to the proper language.
So after much frustration, I have a working solution.
I had to first create a custom filter that would cut the language code from the url. Since the existing code successfully updated the language preference cookie, and since navigating to any path without a language code automatically / successfully appends the language path, I could redirect with my switcher to a path without the language code and the site will successfully render according to the user's browser preferences or cookie. Cutting out the language code from the url seemed to be the most reasonable way for now.
Add a set up infrastructure for custom template tags according to the documentaiton here. I added a templatetags directory to my app, and inside an __init__.py file and a <myapp>_extras.py file
In my case, I needed to cut the second element from the full url path, so my filter function in <myapp>_extras.py. The file looks like this:
from django import template
register = template.Library()
#register.filter
def custom_redir_lang(url_fullpath):
ls_urls = url_fullpath.split('/')
del ls_urls[1]
return '/'.join(ls_urls)
Then I change the value of the input tag in my template from "{{ redirect_to }}" to "{{ request.get_full_path|custom_redir_lang }}"
Now the site redirects properly underneath the subdirectory prefix.
In my flask app, I have 2 instances of CKEditor on 2 different files.
<div>
{{ ckeditor.create(name="message_body") }}
{{ ckeditor.load(pkg_type="standard") }}
{{ ckeditor.config(name="message_body", width=1000, height=500) }}
</div>
and
<div>
{{ ckeditor.create(name="newsletter_body") }}
{{ ckeditor.load(pkg_type="standard") }}
{{ ckeditor.config(name="newsletter_body", width=1000, height=500) }}
</div>
Each of those <div> are in a {% block main %}
I'm getting the data from from 2 different file with these lines:
request.form.get("message_body")
and
request.form.get("newsletter_body")
All seems fine, I get the data but in my browser I get this errors:
[CKEDITOR] Error code: editor-element-conflict.
Object { editorName: "message_body" }
The related docs read this:
Description: There is already an editor’s instance attached to the provided element and attaching another one to it is not allowed.
Additional data:
editorName: The name of the already attached editor.
But I don't understand why. Can any one help me get rid of these errors?
Many thanks
I just release 0.4.5 to fix this, please upgrade:
pip install -U flask-ckeditor
The reason behind this error is:
When you add a "ckeditor" class to a textarea element, CKEditor will try to initialize a CKEditor editor box on top of it. At the same time, if you initialize a CKEditor editor box manually with CKEDITOR.replace(...) (which is what the ckeditor.config() does), the error happens: you can't initialize two CKEditor editor box on one textarea element.
I'm creating a webapp where I can present a documentation. In my documentations I often have some code snippets so I used prism (https://prismjs.com/) to format the text I enter in a textfield on the admin page.
The Problem is that whenever I enter code in the textfield it makes spaces on the first line like that:
import { Pipe, PipeTransform } from '#angular/core';
import { UserService } from '../user.service';
My code looks likt this:
Template:
<pre><code class="language-{{ subdoc.language }}">
{{ subdoc.code }}
</code></pre>
Remove the spaces/tab characters before {{ subdoc.code }}
You must be exhausted in coding. Most of the time we think the complicated coding is where something's wrong but in your case it's the HTML.
you sure know how <pre> tag works. Now understand the difference between this
<pre><code class="language-{{ subdoc.language }}">
{{ subdoc.code }}
</code></pre>
and this
<pre><code class="language-{{ subdoc.language }}">
{{ subdoc.code }}
</code></pre>
Happy coding ;)
I created index.md for my GitHub pages site
with the following in index.md
---
title: This is my title
layout: default
---
## Welcome to GitHub Pages My Index.md
etc
I am just editing the index.md directly in the GitHub editor. I have not installed Jekyll locally.
What do I change so that the generated source does not have my repository name in the title ?
Looking at the source I have
I have tried changing the theme.
I also tried experimented with adding a header.html to the _includes folder
This caused me to start receiving emails with subject containing "Page build failed"
Since then I have removed all the folders. I no longer get the "Page build failed" email, but I am unsure of how to proceed.
GitHub Pages silently sets default layouts using jekyll-default-layout, as described in Publishing with GitHub Pages, now as easy as 1, 2, 3.
To avoid this, you can create your own _layouts/default.html, which should look something like this:
<!doctype>
<html>
<head>
<title></title>
</head>
<body>
{{ content }}
</body>
</html>
And then apply the layout to your files:
---
layout: default
---
...
If you want to include the page title in the title tag, you can do something like this instead of the _layouts/default.html above:
<!doctype>
<html>
<head>
<title>{{ page.title }}</title>
</head>
<body>
{{ content }}
</body>
</html>
Which will use the title in your YAML front matter:
---
layout: default
title: Title
---
...
For more information, take a look at the Jekyll documentation:
https://jekyllrb.com/docs/home/
The site title can be set in _config.yml
However it seems that the _layout\default.html is also required to make the setting work.
The help to set up the default.html is here
under the title "Customizing your Jekyll theme's HTML layout"
HOW IT WORKS ?
Post content will mention name of layout file which will be in _layout folder. So for following post corresponding layout will be in _layouts/default.html
---
title: This is a post with default layout
layout: default
---
Some text for post
Typically default.html layout consumes files head.html and header.html inside _includes folder.
ACTION
Now you have to look at markdown of your page or post and identify its parent layout (inside _layouts) and from there drill-down into _includes. This will allow you to trace lines those are getting generated into output html. Also you can have your own _includes and _layouts for custom html output.
I am trying to get Protovis working in my Django site. Here is my sample code:
<html>
<head>
<script type="text/javascript" src="protovis-r3.2.js"></script>
</head>
<body>
<script type="text/javascript+protovis">
new pv.Panel().width(150).height(150).anchor("center")
.add(pv.Label)
.text("Hello, world!")
.root.render();
</script>
{{ object.name }}
</body>
</html>
When I open this file directly in firefox, a Protovis 'Hello World' image is displayed toguether with the string "{{ object.name }}".
But when accessing the .html file template from my Django server, I only see the {{ object.name }} (the object's name printed out).
I haven't found similar issues so far, catering to Protovis use in Django.
If anyone has gotten it working or know what I am doing wrong, please let me know.
Thanks,
You've asked for the javascript file using src="protovis-r3.2.js"
When you look at the html file directly, your browser will look in the same directory as the .html file for a file called protovis-r3.2.js.
However, when you ask Django to serve this same page, it doesn't follow the same protocol. See this article for more information.
To get it to work:
Move the protovis-r.32.js file to a new directory: /path/to/my/django_site/static (where /path/to/my/django_site is the absolute path to the django app)
Configure urls.py with the line:
(r'^static/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': '/path/to/my/django_site/static'}),
Change the src attribute of the script tag in your html code to:
src="/static/protovis-r3.2.js"