prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Only render the last index page
  The render_indexes plugin only renders the last index page.
  
  To reproduce, set the 'use_in_feed' parameter to True in more than one directory of posts.
  
  I provide the patch in a pull request (it's a little identation modification)
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `nikola/plugins/task_indexes.py`
  Content:
  ```
  1 # Copyright (c) 2012 Roberto Alsina y otros.
  2 
  3 # Permission is hereby granted, free of charge, to any
  4 # person obtaining a copy of this software and associated
  5 # documentation files (the "Software"), to deal in the
  6 # Software without restriction, including without limitation
  7 # the rights to use, copy, modify, merge, publish,
  8 # distribute, sublicense, and/or sell copies of the
  9 # Software, and to permit persons to whom the Software is
  10 # furnished to do so, subject to the following conditions:
  11 #
  12 # The above copyright notice and this permission notice
  13 # shall be included in all copies or substantial portions of
  14 # the Software.
  15 #
  16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
  17 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  18 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  19 # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
  20 # OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  21 # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  22 # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  23 # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  24 
  25 from __future__ import unicode_literals
  26 import glob
  27 import os
  28 
  29 from nikola.plugin_categories import Task
  30 from nikola.utils import config_changed
  31 
  32 
  33 class Indexes(Task):
  34     """Render the blog indexes."""
  35 
  36     name = "render_indexes"
  37 
  38     def gen_tasks(self):
  39         self.site.scan_posts()
  40 
  41         kw = {
  42             "translations": self.site.config['TRANSLATIONS'],
  43             "index_display_post_count":
  44             self.site.config['INDEX_DISPLAY_POST_COUNT'],
  45             "messages": self.site.MESSAGES,
  46             "index_teasers": self.site.config['INDEX_TEASERS'],
  47             "output_folder": self.site.config['OUTPUT_FOLDER'],
  48             "filters": self.site.config['FILTERS'],
  49             "hide_untranslated_posts": self.site.config['HIDE_UNTRANSLATED_POSTS'],
  50             "indexes_title": self.site.config['INDEXES_TITLE'],
  51             "indexes_pages": self.site.config['INDEXES_PAGES'],
  52             "blog_title": self.site.config["BLOG_TITLE"],
  53         }
  54 
  55         template_name = "index.tmpl"
  56         posts = [x for x in self.site.timeline if x.use_in_feeds]
  57         if not posts:
  58             yield {'basename': 'render_indexes', 'actions': []}
  59         for lang in kw["translations"]:
  60             # Split in smaller lists
  61             lists = []
  62             if kw["hide_untranslated_posts"]:
  63                 filtered_posts = [x for x in posts if x.is_translation_available(lang)]
  64             else:
  65                 filtered_posts = posts
  66             while filtered_posts:
  67                 lists.append(filtered_posts[:kw["index_display_post_count"]])
  68                 filtered_posts = filtered_posts[kw["index_display_post_count"]:]
  69             num_pages = len(lists)
  70             for i, post_list in enumerate(lists):
  71                 context = {}
  72                 indexes_title = kw['indexes_title'] or kw['blog_title']
  73                 if not i:
  74                     context["title"] = indexes_title
  75                 else:
  76                     if kw["indexes_pages"]:
  77                         indexes_pages = kw["indexes_pages"] % i
  78                     else:
  79                         indexes_pages = " (" + \
  80                             kw["messages"][lang]["old posts page %d"] % i + ")"
  81                     context["title"] = indexes_title + indexes_pages
  82                 context["prevlink"] = None
  83                 context["nextlink"] = None
  84                 context['index_teasers'] = kw['index_teasers']
  85                 if i > 1:
  86                     context["prevlink"] = "index-{0}.html".format(i - 1)
  87                 if i == 1:
  88                     context["prevlink"] = self.site.config["INDEX_FILE"]
  89                 if i < num_pages - 1:
  90                     context["nextlink"] = "index-{0}.html".format(i + 1)
  91                 context["permalink"] = self.site.link("index", i, lang)
  92                 output_name = os.path.join(
  93                     kw['output_folder'], self.site.path("index", i,
  94                                                         lang))
  95                 task = self.site.generic_post_list_renderer(
  96                     lang,
  97                     post_list,
  98                     output_name,
  99                     template_name,
  100                     kw['filters'],
  101                     context,
  102                 )
  103                 task_cfg = {1: task['uptodate'][0].config, 2: kw}
  104                 task['uptodate'] = [config_changed(task_cfg)]
  105                 task['basename'] = 'render_indexes'
  106                 yield task
  107 
  108         if not self.site.config["STORY_INDEX"]:
  109             return
  110         kw = {
  111             "translations": self.site.config['TRANSLATIONS'],
  112             "post_pages": self.site.config["post_pages"],
  113             "output_folder": self.site.config['OUTPUT_FOLDER'],
  114             "filters": self.site.config['FILTERS'],
  115         }
  116         template_name = "list.tmpl"
  117         for lang in kw["translations"]:
  118             for wildcard, dest, _, is_post in kw["post_pages"]:
  119                 if is_post:
  120                     continue
  121                 context = {}
  122                 # vim/pyflakes thinks it's unused
  123                 # src_dir = os.path.dirname(wildcard)
  124                 files = glob.glob(wildcard)
  125                 post_list = [self.site.global_data[os.path.splitext(p)[0]] for
  126                              p in files]
  127                 output_name = os.path.join(kw["output_folder"],
  128                                            self.site.path("post_path",
  129                                                           wildcard,
  130                                                           lang)).encode('utf8')
  131                 context["items"] = [(post.title(lang), post.permalink(lang))
  132                                     for post in post_list]
  133                 task = self.site.generic_post_list_renderer(lang, post_list,
  134                                                             output_name,
  135                                                             template_name,
  136                                                             kw['filters'],
  137                                                             context)
  138             task_cfg = {1: task['uptodate'][0].config, 2: kw}
  139             task['uptodate'] = [config_changed(task_cfg)]
  140             task['basename'] = self.name
  141             yield task
  142
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/nikola/plugins/task_indexes.py b/nikola/plugins/task_indexes.py
  --- a/nikola/plugins/task_indexes.py
  +++ b/nikola/plugins/task_indexes.py
  @@ -135,7 +135,7 @@
                                                               template_name,
                                                               kw['filters'],
                                                               context)
  -            task_cfg = {1: task['uptodate'][0].config, 2: kw}
  -            task['uptodate'] = [config_changed(task_cfg)]
  -            task['basename'] = self.name
  -            yield task
  +                task_cfg = {1: task['uptodate'][0].config, 2: kw}
  +                task['uptodate'] = [config_changed(task_cfg)]
  +                task['basename'] = self.name
  +                yield task
  
verification_info: {"golden_diff": "diff --git a/nikola/plugins/task_indexes.py b/nikola/plugins/task_indexes.py\n--- a/nikola/plugins/task_indexes.py\n+++ b/nikola/plugins/task_indexes.py\n@@ -135,7 +135,7 @@\n                                                             template_name,\n                                                             kw['filters'],\n                                                             context)\n-            task_cfg = {1: task['uptodate'][0].config, 2: kw}\n-            task['uptodate'] = [config_changed(task_cfg)]\n-            task['basename'] = self.name\n-            yield task\n+                task_cfg = {1: task['uptodate'][0].config, 2: kw}\n+                task['uptodate'] = [config_changed(task_cfg)]\n+                task['basename'] = self.name\n+                yield task\n", "issue": "Only render the last index page\nThe render_indexes plugin only renders the last index page.\n\nTo reproduce, set the 'use_in_feed' parameter to True in more than one directory of posts.\n\nI provide the patch in a pull request (it's a little identation modification)\n\n", "before_files": [{"content": "# Copyright (c) 2012 Roberto Alsina y otros.\n\n# Permission is hereby granted, free of charge, to any\n# person obtaining a copy of this software and associated\n# documentation files (the \"Software\"), to deal in the\n# Software without restriction, including without limitation\n# the rights to use, copy, modify, merge, publish,\n# distribute, sublicense, and/or sell copies of the\n# Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n#\n# The above copyright notice and this permission notice\n# shall be included in all copies or substantial portions of\n# the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY\n# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE\n# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR\n# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS\n# OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR\n# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nfrom __future__ import unicode_literals\nimport glob\nimport os\n\nfrom nikola.plugin_categories import Task\nfrom nikola.utils import config_changed\n\n\nclass Indexes(Task):\n    \"\"\"Render the blog indexes.\"\"\"\n\n    name = \"render_indexes\"\n\n    def gen_tasks(self):\n        self.site.scan_posts()\n\n        kw = {\n            \"translations\": self.site.config['TRANSLATIONS'],\n            \"index_display_post_count\":\n            self.site.config['INDEX_DISPLAY_POST_COUNT'],\n            \"messages\": self.site.MESSAGES,\n            \"index_teasers\": self.site.config['INDEX_TEASERS'],\n            \"output_folder\": self.site.config['OUTPUT_FOLDER'],\n            \"filters\": self.site.config['FILTERS'],\n            \"hide_untranslated_posts\": self.site.config['HIDE_UNTRANSLATED_POSTS'],\n            \"indexes_title\": self.site.config['INDEXES_TITLE'],\n            \"indexes_pages\": self.site.config['INDEXES_PAGES'],\n            \"blog_title\": self.site.config[\"BLOG_TITLE\"],\n        }\n\n        template_name = \"index.tmpl\"\n        posts = [x for x in self.site.timeline if x.use_in_feeds]\n        if not posts:\n            yield {'basename': 'render_indexes', 'actions': []}\n        for lang in kw[\"translations\"]:\n            # Split in smaller lists\n            lists = []\n            if kw[\"hide_untranslated_posts\"]:\n                filtered_posts = [x for x in posts if x.is_translation_available(lang)]\n            else:\n                filtered_posts = posts\n            while filtered_posts:\n                lists.append(filtered_posts[:kw[\"index_display_post_count\"]])\n                filtered_posts = filtered_posts[kw[\"index_display_post_count\"]:]\n            num_pages = len(lists)\n            for i, post_list in enumerate(lists):\n                context = {}\n                indexes_title = kw['indexes_title'] or kw['blog_title']\n                if not i:\n                    context[\"title\"] = indexes_title\n                else:\n                    if kw[\"indexes_pages\"]:\n                        indexes_pages = kw[\"indexes_pages\"] % i\n                    else:\n                        indexes_pages = \" (\" + \\\n                            kw[\"messages\"][lang][\"old posts page %d\"] % i + \")\"\n                    context[\"title\"] = indexes_title + indexes_pages\n                context[\"prevlink\"] = None\n                context[\"nextlink\"] = None\n                context['index_teasers'] = kw['index_teasers']\n                if i > 1:\n                    context[\"prevlink\"] = \"index-{0}.html\".format(i - 1)\n                if i == 1:\n                    context[\"prevlink\"] = self.site.config[\"INDEX_FILE\"]\n                if i < num_pages - 1:\n                    context[\"nextlink\"] = \"index-{0}.html\".format(i + 1)\n                context[\"permalink\"] = self.site.link(\"index\", i, lang)\n                output_name = os.path.join(\n                    kw['output_folder'], self.site.path(\"index\", i,\n                                                        lang))\n                task = self.site.generic_post_list_renderer(\n                    lang,\n                    post_list,\n                    output_name,\n                    template_name,\n                    kw['filters'],\n                    context,\n                )\n                task_cfg = {1: task['uptodate'][0].config, 2: kw}\n                task['uptodate'] = [config_changed(task_cfg)]\n                task['basename'] = 'render_indexes'\n                yield task\n\n        if not self.site.config[\"STORY_INDEX\"]:\n            return\n        kw = {\n            \"translations\": self.site.config['TRANSLATIONS'],\n            \"post_pages\": self.site.config[\"post_pages\"],\n            \"output_folder\": self.site.config['OUTPUT_FOLDER'],\n            \"filters\": self.site.config['FILTERS'],\n        }\n        template_name = \"list.tmpl\"\n        for lang in kw[\"translations\"]:\n            for wildcard, dest, _, is_post in kw[\"post_pages\"]:\n                if is_post:\n                    continue\n                context = {}\n                # vim/pyflakes thinks it's unused\n                # src_dir = os.path.dirname(wildcard)\n                files = glob.glob(wildcard)\n                post_list = [self.site.global_data[os.path.splitext(p)[0]] for\n                             p in files]\n                output_name = os.path.join(kw[\"output_folder\"],\n                                           self.site.path(\"post_path\",\n                                                          wildcard,\n                                                          lang)).encode('utf8')\n                context[\"items\"] = [(post.title(lang), post.permalink(lang))\n                                    for post in post_list]\n                task = self.site.generic_post_list_renderer(lang, post_list,\n                                                            output_name,\n                                                            template_name,\n                                                            kw['filters'],\n                                                            context)\n            task_cfg = {1: task['uptodate'][0].config, 2: kw}\n            task['uptodate'] = [config_changed(task_cfg)]\n            task['basename'] = self.name\n            yield task\n", "path": "nikola/plugins/task_indexes.py"}], "after_files": [{"content": "# Copyright (c) 2012 Roberto Alsina y otros.\n\n# Permission is hereby granted, free of charge, to any\n# person obtaining a copy of this software and associated\n# documentation files (the \"Software\"), to deal in the\n# Software without restriction, including without limitation\n# the rights to use, copy, modify, merge, publish,\n# distribute, sublicense, and/or sell copies of the\n# Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n#\n# The above copyright notice and this permission notice\n# shall be included in all copies or substantial portions of\n# the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY\n# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE\n# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR\n# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS\n# OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR\n# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nfrom __future__ import unicode_literals\nimport glob\nimport os\n\nfrom nikola.plugin_categories import Task\nfrom nikola.utils import config_changed\n\n\nclass Indexes(Task):\n    \"\"\"Render the blog indexes.\"\"\"\n\n    name = \"render_indexes\"\n\n    def gen_tasks(self):\n        self.site.scan_posts()\n\n        kw = {\n            \"translations\": self.site.config['TRANSLATIONS'],\n            \"index_display_post_count\":\n            self.site.config['INDEX_DISPLAY_POST_COUNT'],\n            \"messages\": self.site.MESSAGES,\n            \"index_teasers\": self.site.config['INDEX_TEASERS'],\n            \"output_folder\": self.site.config['OUTPUT_FOLDER'],\n            \"filters\": self.site.config['FILTERS'],\n            \"hide_untranslated_posts\": self.site.config['HIDE_UNTRANSLATED_POSTS'],\n            \"indexes_title\": self.site.config['INDEXES_TITLE'],\n            \"indexes_pages\": self.site.config['INDEXES_PAGES'],\n            \"blog_title\": self.site.config[\"BLOG_TITLE\"],\n        }\n\n        template_name = \"index.tmpl\"\n        posts = [x for x in self.site.timeline if x.use_in_feeds]\n        if not posts:\n            yield {'basename': 'render_indexes', 'actions': []}\n        for lang in kw[\"translations\"]:\n            # Split in smaller lists\n            lists = []\n            if kw[\"hide_untranslated_posts\"]:\n                filtered_posts = [x for x in posts if x.is_translation_available(lang)]\n            else:\n                filtered_posts = posts\n            while filtered_posts:\n                lists.append(filtered_posts[:kw[\"index_display_post_count\"]])\n                filtered_posts = filtered_posts[kw[\"index_display_post_count\"]:]\n            num_pages = len(lists)\n            for i, post_list in enumerate(lists):\n                context = {}\n                indexes_title = kw['indexes_title'] or kw['blog_title']\n                if not i:\n                    context[\"title\"] = indexes_title\n                else:\n                    if kw[\"indexes_pages\"]:\n                        indexes_pages = kw[\"indexes_pages\"] % i\n                    else:\n                        indexes_pages = \" (\" + \\\n                            kw[\"messages\"][lang][\"old posts page %d\"] % i + \")\"\n                    context[\"title\"] = indexes_title + indexes_pages\n                context[\"prevlink\"] = None\n                context[\"nextlink\"] = None\n                context['index_teasers'] = kw['index_teasers']\n                if i > 1:\n                    context[\"prevlink\"] = \"index-{0}.html\".format(i - 1)\n                if i == 1:\n                    context[\"prevlink\"] = self.site.config[\"INDEX_FILE\"]\n                if i < num_pages - 1:\n                    context[\"nextlink\"] = \"index-{0}.html\".format(i + 1)\n                context[\"permalink\"] = self.site.link(\"index\", i, lang)\n                output_name = os.path.join(\n                    kw['output_folder'], self.site.path(\"index\", i,\n                                                        lang))\n                task = self.site.generic_post_list_renderer(\n                    lang,\n                    post_list,\n                    output_name,\n                    template_name,\n                    kw['filters'],\n                    context,\n                )\n                task_cfg = {1: task['uptodate'][0].config, 2: kw}\n                task['uptodate'] = [config_changed(task_cfg)]\n                task['basename'] = 'render_indexes'\n                yield task\n\n        if not self.site.config[\"STORY_INDEX\"]:\n            return\n        kw = {\n            \"translations\": self.site.config['TRANSLATIONS'],\n            \"post_pages\": self.site.config[\"post_pages\"],\n            \"output_folder\": self.site.config['OUTPUT_FOLDER'],\n            \"filters\": self.site.config['FILTERS'],\n        }\n        template_name = \"list.tmpl\"\n        for lang in kw[\"translations\"]:\n            for wildcard, dest, _, is_post in kw[\"post_pages\"]:\n                if is_post:\n                    continue\n                context = {}\n                # vim/pyflakes thinks it's unused\n                # src_dir = os.path.dirname(wildcard)\n                files = glob.glob(wildcard)\n                post_list = [self.site.global_data[os.path.splitext(p)[0]] for\n                             p in files]\n                output_name = os.path.join(kw[\"output_folder\"],\n                                           self.site.path(\"post_path\",\n                                                          wildcard,\n                                                          lang)).encode('utf8')\n                context[\"items\"] = [(post.title(lang), post.permalink(lang))\n                                    for post in post_list]\n                task = self.site.generic_post_list_renderer(lang, post_list,\n                                                            output_name,\n                                                            template_name,\n                                                            kw['filters'],\n                                                            context)\n                task_cfg = {1: task['uptodate'][0].config, 2: kw}\n                task['uptodate'] = [config_changed(task_cfg)]\n                task['basename'] = self.name\n                yield task\n", "path": "nikola/plugins/task_indexes.py"}]}