My language switcher does not work only from the blog page - lektor

I've written my language switcher as below.
It works from / or from /blog/<blog-post> but it does not work from the /blog page even if /en/blog is available.
Japanese | English
Is it bug or should I fix something?
Below is my web site language switcher is available on top-right of the page.
Working (top level page): http://www.socoka.com/
Not working (Blog page): http://www.socoka.com/blog/

In Lektor versions < 2 there are some limitations with regards to the alts. This is working correctly in Lektor 2 which is currently in development only. But you can install it from the git master if you already want to use it.

It can be reproduced by adding the following patch to quickstart project (project name: alt_test)
Tested environment is below.
lektor version:
bc61976a0c7aca3374a40d55f633a83e0686c247
python version: 2.7.10
diff --git a/alt_test.lektorproject b/alt_test.lektorproject
index d53bfea..e3da734 100644
--- a/alt_test.lektorproject
+++ b/alt_test.lektorproject
## -1,2 +1,12 ##
[project]
name = alt_test
+
+[alternatives.jp]
+name = Japanese
+primary = yes
+locale = ja_JP
+
+[alternatives.en]
+name = English
+url_prefix = /en/
+locale = en_US
diff --git a/templates/layout.html b/templates/layout.html
index ed7a449..1a61a9c 100644
--- a/templates/layout.html
+++ b/templates/layout.html
## -17,6 +17,7 ##
<li{% if this.is_child_of(href) %} class="active"{% endif
%}>{{ title }}</li>
{% endfor %}
+ Japanese | English
</ul>
</nav>
</header>

Related

Iterating through a sequence of mappings with different inputs with pandoc

I am trying to use one template to handle varying input files. I want to iterate through a specific sequence of mappings where the keys and the values in the sequence of mappings can change. I have a solution but it feels like a hack and it only works for the latest version of pandoc. Here is an example of the functionality I would like:
input1.md:
---
title: "Input 1"
links:
- Pear: "https://pear.com/"
- Banana: "https://banana.com/"
- Grape: "https://grape.com/"
- Strawberry: "https://strawberry.com/"
---
This is the body.
desired-output1.md:
Input 1
- Pear : https://pear.com/
- Banana : https://banana.com/
- Grape : https://grape.com/
- Strawberry : https://strawberry.com/
This is the body.
input2.md:
---
title: "Input 2"
links:
- Kiwi: "https://kiwi.com/"
- Lemon: "https://lemon.com/"
---
This is the body.
desired-output2.md:
Input 2
- Kiwi : https://kiwi.com/
- Lemon : https://lemon.com/
This is the body.
Here is the pandoc template I am using right now which works however it feels hacky and does not work with recent but older versions of pandoc:
template.md:
$title$
$for(links)$
$for(it/pairs)$
- $it.key$ : $it.value$
$endfor$
$endfor$
$body$
Here is the command I am using to compile the document:
pandoc -f markdown -t markdown --template=template.md input1.md
My question is: Is there a more straightforward, less of a hack way to achieve this functionality with one template file? Is there a way to ensure this works with older versions of pandoc? Thanks.
This fixed it for me in pandoc 2.7.3
In the YAML header -
---
title: "Frank Hermosillo"
image: "frank.jpg"
links:
- site: Apple
url: "https://apples.com/"
- site: Pear
url: "https://pears.com/"
- site: Orange
url: "https://oranges.com/"
There are two tabs before 'url:' and one before '- site':
And in the template:
<ul class="list-inline">
$for(links)$
<li class="list-inline-item">
<a href=$links.url$>
<button type="button" class="btn btn-outline-dark">
To $links.site$
</button>
</a>
</li>
$endfor$
</ul>

Pass site collections from page to layout jekyll

I'm trying to pass one site collection to my page's layout, in order to be able to make my nav menu according to the sections I pass.
In my _config.yml
collections:
tt:
output: true
In my index.md page:
---
layout: mylayout
title: My Great Homepage
icon: fa-home
order: 1
sec: "{{site.tt}}"
---
In my layout:
---
layout: mylayout
---
{%- assign _sections = page.sec | flatify -%}
{%- include header.html scrolly_nav=_sections -%}
<!-- Main -->
<div id="main">
{{page.sec | flatify}} <!-- just to debug -->
</div>
Flatify is under _plugins/flatify.rb:
module Jekyll
module ExpandNestedVariableFilter
def flatify(input)
Liquid::Template.parse(input).render(#context)
end
end
end
Liquid::Template.register_filter(Jekyll::ExpandNestedVariableFilter)
In my layout, using {%- assign _sections = site.sec | flatify -%} works perfectly, but when I pass the collection from the page to the layout, it's not working.
If I do the exact same thing passing site.title instead of site.tt from the page to the layout, everything works just fine. But when I try to pass a collection, it's not working.
Thanks for your help.
Your flatify plugin is cool, but it does not reflect real life.
You cannot use liquid vars in front matter because they are not parsed.
In your page's front matter :
---
sec: "tt"
---
Then, from the page or the layout, you can just call :
{%- assign _sections = site[page.sec] -%}
{%- include header.html scrolly_nav=_sections -%}
If you want to debug, you can use inspect filter, which just outputs variable content.
{{ page.sec | inspect }} or {{ site[page.sec] | inspect }}

Jekyll error: undefined method ancestors for nil:NilClass

My post template in jekyll renders a presentation either of Google slides or of a jupyter notebook html. For this purpose, I use the markdown structure shown below:
---
layout: post
title: title
date: 2018-10-28 00:00:00 -0500
categories: category
author: author
medium: jupyter
link: [//]: # (Here I insert the presentation url)
lang: en
---
<div>
{% if page.medium == 'jupyter' %}
{% include jupyter.html link=page.link %}
{% elsif page.medium == 'gslides' %}
{% include gslides.html link=page.link %}
{% else %}
{% include nodata.html %}
{% endif %}
</div>
This generates the desired result. However, during the bundle creation, jekyll outputs this error for each post file:
Error: A Liquid tag in the excerpt of ./file.markdown couldn't be parsed.
Error: could not read file ./file.markdown: undefined method `ancestors' for nil:NilClass
I have already looked for any syntax errors along with this and other files, and all seems to be ok. Does someone has gone through a similar problem?
EDIT: I've taken the elif and the else clause of the statement, only then the problem ceases.

Removing the view source link when using Read The Docs & Sphinx with ReadTheDocs Theme

Is there any way to remove the "View page source" link from a sphinx generated read the docs theme page?
There is a similar question here and it recommends finding the breadcrumbs file, but I can't find one
In your conf.py file, try setting the variable html_show_sourcelink to False,
html_show_sourcelink = False
If it does not exist, just create it. Then, compile again the project,
$ make html
Don't be fooled by the configuration. You can see the source code.
In fact, from the HTML theming support of Sphinx, it introduced that the structure of a theme should look like this.
[theme]
inherit = base theme
stylesheet = main CSS name
pygments_style = stylename
sidebars = localtoc.html, relations.html, sourcelink.html, searchbox.html
...
here is site-packages/sphinx_rtd_theme/theme.conf
[theme]
inherit = basic
stylesheet = css/theme.css
pygments_style = default
So we know that its sidebars completely inherited from basic.
What is basic? One of the themes of the sphinx.
site-packages/sphinx/theme/ {basic, nature...}
The contents of site-packages/sphinx/themes/basic/sourcelink.html
...
{%- if show_source and has_source and sourcename %}
<div role="note" aria-label="source link">
<h3>{{ _('This Page') }}</h3>
<ul class="this-page-menu">
<li><a href="{{ pathto('_sources/' + sourcename, true)|e }}"
rel="nofollow">{{ _('Show Source') }}</a></li>
</ul>
</div>
{%- endif %}
(If you are confused with this format, please reference here: jinja))
And then, we know that show if and only if the show_source, has_source, sourcename all the True.
What is show_source, has_source, sourcename ?
If your format is HTML, then it's coming from: sphinx.builders.html StandaloneHTMLBuilder
Among them, he created a variable globalcontext, see below:
class StandaloneHTMLBuilder(Builder):
...
def prepare_writing(...):
...
self.globalcontext = {
'has_source': self.config.html_copy_source,
'show_source': self.config.html_show_sourcelink,
}
...
...
def get_doc_context(...):
...
# the name for the copied source
if self.config.html_copy_source:
sourcename = docname + source_suffix
if source_suffix != self.config.html_sourcelink_suffix:
sourcename += self.config.html_sourcelink_suffix
else:
sourcename = ''
Click the link if you want to see the full code
prepare_writing
get_doc_context
Now, I think you already get it.
has_source is html_copy_source
show_source is html_show_sourcelink
and sourcename = ... if html_copy_source else ''
So, the close way has two, both ok.
html_copy_source = False (since has_source + html_copy_source)
html_show_sourcelink = False (since show_source + htm_show_sourcelink )
(or 3. both eq False ...)
It doesn't work in my side with #lucasrodesg's answer, my Sphinx vertion is 1.8.2, I just removed 'sphinx.ext.viewcode' of extensions variable in the conf.py and worked. Just like in the following code, uncomment the last line.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.todo',
'sphinx.ext.coverage',
'sphinx.ext.mathjax',
# 'sphinx.ext.viewcode',]

Wrong Tax calculation in Magento on HHVM

I'm running Magento 1.9.1.0 at HHVM 3.14.4
I added hhvm.enable_zend_sorting = 1 to /etc/hhvm/php.ini file and /etc/hhvm/server.ini, but the tax calculation is actually wrong.
Magento Wrong Tax Calculation
34,90*0,07 = 2,429 and not 2,28 like Magento show it.
Has anyone an idea how I can solve my problem?
I had the same problem.
I fixed it by patching app/code/core/Mage/Sales/etc/config.xml:
diff --git a/app/code/core/Mage/Sales/etc/config.xml b/app/code/core/Mage/Sales/etc/config.xml
index f32ac46..852865d 100644
--- a/app/code/core/Mage/Sales/etc/config.xml
+++ b/app/code/core/Mage/Sales/etc/config.xml
## -1218,7 +1218,7 ##
</subtotal>
<shipping>
<class>sales/quote_address_total_shipping</class>
- <after>subtotal,freeshipping,tax_subtotal</after>
+ <after>subtotal,freeshipping,tax_subtotal,msrp</after>
<before>grand_total</before>
</shipping>
<grand_total>
## -1227,6 +1227,7 ##
</grand_total>
<msrp>
<class>sales/quote_address_total_msrp</class>
+ <before>grand_total</before>
</msrp>
</totals>
<nominal_totals>
You might want to wrap it up as an extension to make it upgrade-proof.
here is an example of how to overwrite core config.xml https://magento.stackexchange.com/questions/10695/how-to-override-config-xml

Resources