I have a large collection of heterogenous content that has properties (or the lack thereof) that I wish to display in a manner similar to any other subpage (think: custom collections, tag pages).
As a concrete example, one use case is to collect and paginate blog posts which do not have tags.
Actual behaviour
I've tried a number of different routes to get a collection defined by a subset of resources. While I can't remember them all, I'll highlight a few.
By clearing the partial path of any page using the template local paginate, I got to a situation where when trying to render my page navigation, it couldn't find the paging "methods":
undefined local variable or method `prev_page' ...
This predates middleman-blog 4, is highly manual, and doesn't work.
I also tried creating a subset of articles that were untagged and feeding them as a local into a template located at <blog_root>/tags/untagged.html.erb, but while the local was set, the Extension's determination of what the current articles were (i.e. all articles) overrode my local setting, and so I could see the first page_size untagged articles, for the num_pages determined by the blog as a whole.
In my case, what I finally got to work was monkey-patching the tags method as follows:
<... truncate>
class BlogData
alias_method :old_tags, :tags
def tags
tags = old_tags
articles.each do |article|
next unless article.tags.count.zero?
tags['untagged'] ||= []
tags['untagged'] << article
end
tags
end
end
<...>
But there are a lot of additional subsets of data that I'd like to mess around with (short posts, posts with no explicit title, posts with no category data) that I'd also like to generate views for.
A workaround I considered is to have an explicit "untagged" tag, but that screws with my display logic and would require going back and retroactively curating a large amount of content. Further, it doesn't address the general case, where for instance I might desire a category 'short' determined by the subset of all blog posts under 140 characters. (This is actually something I plan to do.)
My feature suggestion, since it seems to be a theme for a lot of the requests/bugs I've noticed in the past three hours of reading issues, is to allow the generation of arbitrary collections of blog resources via either string or proc, contrasted with the current method of string only.
ℹ️ This issue is stale because it has been open for more than 90 days with no activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.
~Feature request
Expected behaviour
I have a large collection of heterogenous content that has properties (or the lack thereof) that I wish to display in a manner similar to any other subpage (think: custom collections, tag pages).
As a concrete example, one use case is to collect and paginate blog posts which do not have tags.
Actual behaviour
I've tried a number of different routes to get a collection defined by a subset of resources. While I can't remember them all, I'll highlight a few.
https://github.com/middleman/middleman-blog/issues/233#issuecomment-68546154 Attempting this method ended up very hackish (duplication of parameters between the blog definition and the subsequent block). Notably, though, I couldn't even get this to compile - when
middleman build
got to my proxy, it would gripe about me trying to provide a localpaginate
variable (see: https://github.com/middleman/middleman/blob/master/middleman-core/lib/middleman-core/template_renderer.rb#L137).By clearing the partial path of any page using the template local
paginate
, I got to a situation where when trying to render my page navigation, it couldn't find the paging "methods":undefined local variable or method `prev_page'
...I saw this as well: https://github.com/middleman/middleman-blog/issues/177#issuecomment-39612192
This predates middleman-blog 4, is highly manual, and doesn't work.
I also tried creating a subset of articles that were untagged and feeding them as a local into a template located at
<blog_root>/tags/untagged.html.erb
, but while the local was set, the Extension's determination of what the current articles were (i.e. all articles) overrode my local setting, and so I could see the firstpage_size
untagged articles, for thenum_pages
determined by the blog as a whole.In my case, what I finally got to work was monkey-patching the
tags
method as follows:But there are a lot of additional subsets of data that I'd like to mess around with (short posts, posts with no explicit title, posts with no category data) that I'd also like to generate views for.
A workaround I considered is to have an explicit "untagged" tag, but that screws with my display logic and would require going back and retroactively curating a large amount of content. Further, it doesn't address the general case, where for instance I might desire a category 'short' determined by the subset of all blog posts under 140 characters. (This is actually something I plan to do.)
My feature suggestion, since it seems to be a theme for a lot of the requests/bugs I've noticed in the past three hours of reading issues, is to allow the generation of arbitrary collections of blog resources via either string or proc, contrasted with the current method of string only.
Additional information