Browse Source

record hidden content in native lang, fixes #409

added 404 test pages for this case
Ondrej Grover 9 years ago
parent
commit
03da9b5d7e

+ 4 - 0
i18n_subsites/i18n_subsites.py

@@ -248,6 +248,10 @@ def filter_contents_translations(generator):
     hiding_func = inspector.hiding_function()
     untrans_policy = inspector.untranslated_policy(default='hide')
     for (contents, other_contents) in inspector.contents_list_pairs():
+        for content in other_contents: # save any hidden native content first
+            if content.lang == current_lang: # in native lang
+                # save the native URL attr formatted in the current locale
+                _NATIVE_CONTENT_URL_DB[content.source_path] = content.url
         for content in contents[:]:        # copy for removing in loop
             if content.lang == current_lang: # in native lang
                 # save the native URL attr formatted in the current locale

+ 7 - 0
i18n_subsites/test_data/content/pages/hidden-page-cz.rst

@@ -0,0 +1,7 @@
+404 stránka
+===========
+:slug: 404
+:lang: cz
+:status: hidden
+
+Jednoduchá 404 stránka.

+ 7 - 0
i18n_subsites/test_data/content/pages/hidden-page-de.rst

@@ -0,0 +1,7 @@
+Eine 404 Seite
+==============
+:slug: 404
+:lang: de
+:status: hidden
+
+Eine einfache 404 Seite.

+ 7 - 0
i18n_subsites/test_data/content/pages/hidden-page-en.rst

@@ -0,0 +1,7 @@
+A 404 page
+==========
+:slug: 404
+:lang: en
+:status: hidden
+
+A simple 404 page.

+ 33 - 0
i18n_subsites/test_data/output/cz/pages/404.html

@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html lang="cz">
+<head>
+        <title>404 stránka</title>
+        <meta charset="utf-8" />
+        <link href="http://example.com/test/feeds_all.atom.xml" type="application/atom+xml" rel="alternate" title="Testovací stránka Full Atom Feed" />
+
+<link rel="stylesheet" href="http://example.com/test/cz/../theme/style.css" />
+</head>
+
+<body id="index" class="home">
+        <header id="banner" class="body">
+                <h1><a href="http://example.com/test/cz/">Testovací stránka <strong></strong></a></h1>
+        </header><!-- /#banner -->
+        <nav id="menu"><ul>
+        </ul></nav><!-- /#menu -->
+    <h1>404 stránka</h1>
+    Translations: 
+<a href="http://example.com/test/cz/../de/pages/404.html">de</a>
+<a href="http://example.com/test/cz/../pages/404.html">en</a>
+
+
+    <p>Jednoduchá 404 stránka.</p>
+
+
+        <footer id="contentinfo" class="body">
+                <address id="about" class="vcard body">
+                Proudly powered by <a href="http://getpelican.com/">Pelican</a>,
+                which takes great advantage of <a href="http://python.org">Python</a>.
+                </address><!-- /#about -->
+        </footer><!-- /#contentinfo -->
+</body>
+</html>

+ 33 - 0
i18n_subsites/test_data/output/de/pages/404.html

@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html lang="de">
+<head>
+        <title>Eine 404 Seite</title>
+        <meta charset="utf-8" />
+        <link href="http://example.com/test/feeds_all.atom.xml" type="application/atom+xml" rel="alternate" title="Testseite Full Atom Feed" />
+
+<link rel="stylesheet" href="http://example.com/test/de/../theme/style.css" />
+</head>
+
+<body id="index" class="home">
+        <header id="banner" class="body">
+                <h1><a href="http://example.com/test/de/">Testseite <strong></strong></a></h1>
+        </header><!-- /#banner -->
+        <nav id="menu"><ul>
+        </ul></nav><!-- /#menu -->
+    <h1>Eine 404 Seite</h1>
+    Translations: 
+<a href="http://example.com/test/de/../cz/pages/404.html">cz</a>
+<a href="http://example.com/test/de/../pages/404.html">en</a>
+
+
+    <p>Eine einfache 404 Seite.</p>
+
+
+        <footer id="contentinfo" class="body">
+                <address id="about" class="vcard body">
+                Proudly powered by <a href="http://getpelican.com/">Pelican</a>,
+                which takes great advantage of <a href="http://python.org">Python</a>.
+                </address><!-- /#about -->
+        </footer><!-- /#contentinfo -->
+</body>
+</html>

+ 34 - 0
i18n_subsites/test_data/output/pages/404.html

@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+        <title>A 404 page</title>
+        <meta charset="utf-8" />
+        <link href="http://example.com/test/feeds_all.atom.xml" type="application/atom+xml" rel="alternate" title="Testing site Full Atom Feed" />
+
+<link rel="stylesheet" href="http://example.com/test/theme/style.css" />
+</head>
+
+<body id="index" class="home">
+        <header id="banner" class="body">
+                <h1><a href="http://example.com/test/">Testing site <strong></strong></a></h1>
+        </header><!-- /#banner -->
+        <nav id="menu"><ul>
+            <li><a href="http://example.com/test/pages/untranslated-page.html">Untranslated page</a></li>
+        </ul></nav><!-- /#menu -->
+    <h1>A 404 page</h1>
+    Translations: 
+<a href="http://example.com/test/cz/pages/404.html">cz</a>
+<a href="http://example.com/test/de/pages/404.html">de</a>
+
+
+    <p>A simple 404 page.</p>
+
+
+        <footer id="contentinfo" class="body">
+                <address id="about" class="vcard body">
+                Proudly powered by <a href="http://getpelican.com/">Pelican</a>,
+                which takes great advantage of <a href="http://python.org">Python</a>.
+                </address><!-- /#about -->
+        </footer><!-- /#contentinfo -->
+</body>
+</html>