Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paging on untagged posts #358

Open
pjpoole opened this issue Dec 7, 2017 · 1 comment
Open

Paging on untagged posts #358

pjpoole opened this issue Dec 7, 2017 · 1 comment

Comments

@pjpoole
Copy link

pjpoole commented Dec 7, 2017

~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.

#233 (comment)
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 local paginate 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: #177 (comment)

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.

Additional information

  • Ruby version: 2.4.1
  • Middleman version: 4.2.1
  • Middleman Blog version: 4.0.2
  • OS version: macOS 10.13.1
@github-actions github-actions bot added the Stale label Apr 11, 2024
@markets
Copy link
Member

markets commented Apr 15, 2024

ℹ️ 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.

@github-actions github-actions bot removed the Stale label Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants