From 5fd8c2fff00140ddb4352d4bab586a673c0a7920 Mon Sep 17 00:00:00 2001 From: mimu Date: Sat, 5 Oct 2013 16:16:51 +0900 Subject: [PATCH 1/4] Fixed critical build error when translated versions of article has same slug. Ref #1107 --- pelican/generators.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pelican/generators.py b/pelican/generators.py index d695c7c8..d703c6cb 100644 --- a/pelican/generators.py +++ b/pelican/generators.py @@ -353,8 +353,8 @@ class ArticlesGenerator(Generator): def generate_drafts(self, write): """Generate drafts pages.""" - for article in self.drafts: - write(os.path.join('drafts', '%s.html' % article.slug), + for article in chain(self.translations, self.drafts): + write(os.path.join('drafts', article.save_as), self.get_template(article.template), self.context, article=article, category=article.category, all_articles=self.articles) From 91ec0f93c74161273eb52d3d49b56de79eb118ed Mon Sep 17 00:00:00 2001 From: mimu Date: Sat, 12 Oct 2013 10:47:00 +0900 Subject: [PATCH 2/4] Fixed create draft article with translations #Ref 1107 --- pelican/generators.py | 6 +- .../basic/drafts/second-article-fr.html | 70 +++++++++++ .../draft-article-with-translation-ja.html | 99 +++++++++++++++ .../draft-article-with-translation.html | 100 +++++++++++++++ .../output/custom/drafts/oh-yeah-fr.html | 114 ++++++++++++++++++ .../custom/drafts/second-article-fr.html | 114 ++++++++++++++++++ .../draft_article_with_translation-ja.rst | 8 ++ .../draft_article_with_translation.rst | 8 ++ 8 files changed, 518 insertions(+), 1 deletion(-) create mode 100644 pelican/tests/output/basic/drafts/second-article-fr.html create mode 100644 pelican/tests/output/custom/drafts/draft-article-with-translation-ja.html create mode 100644 pelican/tests/output/custom/drafts/draft-article-with-translation.html create mode 100644 pelican/tests/output/custom/drafts/oh-yeah-fr.html create mode 100644 pelican/tests/output/custom/drafts/second-article-fr.html create mode 100644 samples/content/draft_article_with_translation-ja.rst create mode 100644 samples/content/draft_article_with_translation.rst diff --git a/pelican/generators.py b/pelican/generators.py index d703c6cb..1015122d 100644 --- a/pelican/generators.py +++ b/pelican/generators.py @@ -354,7 +354,11 @@ class ArticlesGenerator(Generator): def generate_drafts(self, write): """Generate drafts pages.""" for article in chain(self.translations, self.drafts): - write(os.path.join('drafts', article.save_as), + filename = article.save_as + if article.lang != self.settings["DEFAULT_LANG"]: + filename + "."+article.lang + + write(os.path.join('drafts', filename), self.get_template(article.template), self.context, article=article, category=article.category, all_articles=self.articles) diff --git a/pelican/tests/output/basic/drafts/second-article-fr.html b/pelican/tests/output/basic/drafts/second-article-fr.html new file mode 100644 index 00000000..050d49b3 --- /dev/null +++ b/pelican/tests/output/basic/drafts/second-article-fr.html @@ -0,0 +1,70 @@ + + + + + Deuxième article + + + + + + + + +
+ +
+
+ +
+ + + + + \ No newline at end of file diff --git a/pelican/tests/output/custom/drafts/draft-article-with-translation-ja.html b/pelican/tests/output/custom/drafts/draft-article-with-translation-ja.html new file mode 100644 index 00000000..f2f6737d --- /dev/null +++ b/pelican/tests/output/custom/drafts/draft-article-with-translation-ja.html @@ -0,0 +1,99 @@ + + + + + 他言語の下書きテスト + + + + + + + + + +Fork me on GitHub + + +
+ +
+
+
+

blogroll

+ +
+ +
+ + + + + + \ No newline at end of file diff --git a/pelican/tests/output/custom/drafts/draft-article-with-translation.html b/pelican/tests/output/custom/drafts/draft-article-with-translation.html new file mode 100644 index 00000000..2f5fb9b9 --- /dev/null +++ b/pelican/tests/output/custom/drafts/draft-article-with-translation.html @@ -0,0 +1,100 @@ + + + + + A draft article with translation + + + + + + + + + +Fork me on GitHub + + +
+ +
+
+
+

blogroll

+ +
+ +
+ + + + + + \ No newline at end of file diff --git a/pelican/tests/output/custom/drafts/oh-yeah-fr.html b/pelican/tests/output/custom/drafts/oh-yeah-fr.html new file mode 100644 index 00000000..1bad0d85 --- /dev/null +++ b/pelican/tests/output/custom/drafts/oh-yeah-fr.html @@ -0,0 +1,114 @@ + + + + + Trop bien ! + + + + + + + + + +Fork me on GitHub + + +
+
+
+

+ Trop bien !

+
+ +
+

Et voila du contenu en français

+ +
+
+

Comments !

+
+ +
+ +
+
+
+
+

blogroll

+ +
+ +
+ + + + + + \ No newline at end of file diff --git a/pelican/tests/output/custom/drafts/second-article-fr.html b/pelican/tests/output/custom/drafts/second-article-fr.html new file mode 100644 index 00000000..21467c59 --- /dev/null +++ b/pelican/tests/output/custom/drafts/second-article-fr.html @@ -0,0 +1,114 @@ + + + + + Deuxième article + + + + + + + + + +Fork me on GitHub + + +
+
+
+

+ Deuxième article

+
+ +
+

Ceci est un article, en français.

+ +
+
+

Comments !

+
+ +
+ +
+
+
+
+

blogroll

+ +
+ +
+ + + + + + \ No newline at end of file diff --git a/samples/content/draft_article_with_translation-ja.rst b/samples/content/draft_article_with_translation-ja.rst new file mode 100644 index 00000000..f22bfbbe --- /dev/null +++ b/samples/content/draft_article_with_translation-ja.rst @@ -0,0 +1,8 @@ +他言語の下書きテスト +###################### + +:slug: draft-article-with-translation +:status: draft +:lang: ja + +これは下書きファイルです。/draftに生成されて、他のところには影響を与えません。 diff --git a/samples/content/draft_article_with_translation.rst b/samples/content/draft_article_with_translation.rst new file mode 100644 index 00000000..5bd83dbb --- /dev/null +++ b/samples/content/draft_article_with_translation.rst @@ -0,0 +1,8 @@ +A draft article with translation +################################ + +:slug: draft-article-with-translation +:status: draft + +This is a draft article, it should live under the /drafts/ folder and not be +listed anywhere else. From 177b8ecd0dd126e9f95dc4c430686a85781d6b40 Mon Sep 17 00:00:00 2001 From: mimu Date: Sun, 13 Oct 2013 13:49:36 +0900 Subject: [PATCH 3/4] Fixed generate filename with article's slug and lang #Ref 1107 --- pelican/generators.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pelican/generators.py b/pelican/generators.py index 1015122d..9e37d773 100644 --- a/pelican/generators.py +++ b/pelican/generators.py @@ -354,9 +354,10 @@ class ArticlesGenerator(Generator): def generate_drafts(self, write): """Generate drafts pages.""" for article in chain(self.translations, self.drafts): - filename = article.save_as + filename = article.slug if article.lang != self.settings["DEFAULT_LANG"]: - filename + "."+article.lang + filename += "-" + article.lang + filename += ".html" write(os.path.join('drafts', filename), self.get_template(article.template), self.context, From c977c84f455e05a6a8eda3b62b3382269601b0a6 Mon Sep 17 00:00:00 2001 From: mimu Date: Fri, 25 Oct 2013 14:37:12 +0900 Subject: [PATCH 4/4] Fixed output of the test --- .../custom/drafts/draft-article-with-translation-ja.html | 2 +- .../output/custom/drafts/draft-article-with-translation.html | 2 +- pelican/tests/output/custom/drafts/oh-yeah-fr.html | 4 ++-- pelican/tests/output/custom/drafts/second-article-fr.html | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pelican/tests/output/custom/drafts/draft-article-with-translation-ja.html b/pelican/tests/output/custom/drafts/draft-article-with-translation-ja.html index f2f6737d..97ad4108 100644 --- a/pelican/tests/output/custom/drafts/draft-article-with-translation-ja.html +++ b/pelican/tests/output/custom/drafts/draft-article-with-translation-ja.html @@ -91,7 +91,7 @@ (function () { var s = document.createElement('script'); s.async = true; s.type = 'text/javascript'; - s.src = 'http://' + disqus_shortname + '.disqus.com/count.js'; + s.src = '//' + disqus_shortname + '.disqus.com/count.js'; (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s); }()); diff --git a/pelican/tests/output/custom/drafts/draft-article-with-translation.html b/pelican/tests/output/custom/drafts/draft-article-with-translation.html index 2f5fb9b9..ba31bc17 100644 --- a/pelican/tests/output/custom/drafts/draft-article-with-translation.html +++ b/pelican/tests/output/custom/drafts/draft-article-with-translation.html @@ -92,7 +92,7 @@ listed anywhere else.

(function () { var s = document.createElement('script'); s.async = true; s.type = 'text/javascript'; - s.src = 'http://' + disqus_shortname + '.disqus.com/count.js'; + s.src = '//' + disqus_shortname + '.disqus.com/count.js'; (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s); }()); diff --git a/pelican/tests/output/custom/drafts/oh-yeah-fr.html b/pelican/tests/output/custom/drafts/oh-yeah-fr.html index 1bad0d85..e83e2ab7 100644 --- a/pelican/tests/output/custom/drafts/oh-yeah-fr.html +++ b/pelican/tests/output/custom/drafts/oh-yeah-fr.html @@ -60,7 +60,7 @@ Translations: var disqus_url = "../oh-yeah-fr.html"; (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; - dsq.src = 'http://blog-notmyidea.disqus.com/embed.js'; + dsq.src = '//blog-notmyidea.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })(); @@ -106,7 +106,7 @@ Translations: (function () { var s = document.createElement('script'); s.async = true; s.type = 'text/javascript'; - s.src = 'http://' + disqus_shortname + '.disqus.com/count.js'; + s.src = '//' + disqus_shortname + '.disqus.com/count.js'; (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s); }()); diff --git a/pelican/tests/output/custom/drafts/second-article-fr.html b/pelican/tests/output/custom/drafts/second-article-fr.html index 21467c59..d208e838 100644 --- a/pelican/tests/output/custom/drafts/second-article-fr.html +++ b/pelican/tests/output/custom/drafts/second-article-fr.html @@ -60,7 +60,7 @@ var disqus_url = "../second-article-fr.html"; (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; - dsq.src = 'http://blog-notmyidea.disqus.com/embed.js'; + dsq.src = '//blog-notmyidea.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })(); @@ -106,7 +106,7 @@ (function () { var s = document.createElement('script'); s.async = true; s.type = 'text/javascript'; - s.src = 'http://' + disqus_shortname + '.disqus.com/count.js'; + s.src = '//' + disqus_shortname + '.disqus.com/count.js'; (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s); }());