diff --git a/layerindex/models.py b/layerindex/models.py index 66cbe67..6042d58 100644 --- a/layerindex/models.py +++ b/layerindex/models.py @@ -467,6 +467,17 @@ class Recipe(models.Model): eu = ExtraURL(name=item.name, url=item.render_url(self)) yield eu + def adjacent_includes(self): + """Returns an iterator over any files included by this recipe that are adjacent to the recipe (usually .inc files)""" + recipepath = os.path.join(self.layerbranch.vcs_subdir, self.filepath) + if not recipepath.endswith('/'): + recipepath += '/' + IncludeFile = namedtuple('IncludeFile', 'filepath vcs_web_url') + for rfd in self.recipefiledependency_set.all(): + if rfd.path.startswith(recipepath) and not os.path.basename(rfd.path) == self.filename: + ifile = IncludeFile(filepath=rfd.layer_path(), vcs_web_url=rfd.vcs_web_url()) + yield ifile + def comparison_recipes(self): return ClassicRecipe.objects.filter(cover_layerbranch=self.layerbranch).filter(cover_pn=self.pn) @@ -560,6 +571,13 @@ class RecipeFileDependency(models.Model): class Meta: verbose_name_plural = "Recipe file dependencies" + def layer_path(self): + return os.path.relpath(self.path, self.layerbranch.vcs_subdir) + + def vcs_web_url(self): + url = self.layerbranch.file_url(self.layer_path()) + return url or '' + def __str__(self): return '%s' % self.path diff --git a/layerindex/views.py b/layerindex/views.py index 1ebef49..fb2dd51 100644 --- a/layerindex/views.py +++ b/layerindex/views.py @@ -870,6 +870,11 @@ class RecipeDetailView(DetailView): context['verappends'] = verappends context['packageconfigs'] = recipe.packageconfig_set.order_by('feature') context['staticdependencies'] = recipe.staticbuilddep_set.order_by('name') + extrafiles = [] + for dep in recipe.recipefiledependency_set.all(): + if dep.path.endswith('.inc'): + extrafiles.append(dep) + context['extrafiles'] = extrafiles return context diff --git a/templates/layerindex/comparisonrecipebase.html b/templates/layerindex/comparisonrecipebase.html index 5fba8c1..50bcd76 100644 --- a/templates/layerindex/comparisonrecipebase.html +++ b/templates/layerindex/comparisonrecipebase.html @@ -116,6 +116,13 @@ {% else %} {{ rcp.full_path }} {% endif %} + {% for include in rcp.adjacent_includes %} + {% if include.vcs_web_url %} +
{{ include.filepath }} + {% else %} +
{{ include.filepath }} + {% endif %} + {% endfor %} {% endfor %} diff --git a/templates/layerindex/recipedetail.html b/templates/layerindex/recipedetail.html index 47b5e3f..6ed5a36 100644 --- a/templates/layerindex/recipedetail.html +++ b/templates/layerindex/recipedetail.html @@ -96,6 +96,13 @@ {% else %} {{ recipe.full_path }} {% endif %} + {% for include in recipe.adjacent_includes %} + {% if include.vcs_web_url %} +
{{ include.filepath }} + {% else %} +
{{ include.filepath }} + {% endif %} + {% endfor %}