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

Entries that truly cannot be rendered on the web #558

Open
SoniEx2 opened this issue Feb 23, 2024 · 2 comments
Open

Entries that truly cannot be rendered on the web #558

SoniEx2 opened this issue Feb 23, 2024 · 2 comments
Labels
enhancement New feature or request large This is going to take a lot longer than most things

Comments

@SoniEx2
Copy link

SoniEx2 commented Feb 23, 2024

Expected Behavior

We would like to have entries that do not get rendered on the web, for use as bonus/exclusive entries for atom feed subscribers.

Current Behavior

Some themes/templates currently use regular entries with special metadata to produce external links in a category's sidebar. This mechanism doesn't seem entirely suitable for bonus/exclusive entries, as we don't want them to be linkable.

Possible Solution

(hmm...)

Steps to Reproduce (for bugs)

N/A

Context

While we don't need them to be truly unbrowsable (after all, they'd show up in the atom feed, you could just view it in the atom feed), our goal is to encourage creatures to use the atom feed. For all we care, someone could even make an URI to the exclusive entry - so long as it points to the atom feed. They can link the feed, they can link the entry in the feed, but they shouldn't be able to link the entry on the web.

@fluffy-critter fluffy-critter added enhancement New feature or request large This is going to take a lot longer than most things labels Feb 23, 2024
@fluffy-critter
Copy link
Collaborator

Publ doesn't really differentiate templates based on whether they're "web" or not, since it's all just HTTP in the end anyway.

I think the path forward for a feature like this would be to have a header like Allowed-Templates and/or Blocked-Templates or the like, so for example if you only wanted an item to appear in your Atom feed you'd say:

Allowed-Templates: feed

or if you just didn't want it to appear in, say, your web-based index but did want it in other things (e.g. a permalink page) you'd do:

Blocked-Templates: index

Perhaps it could be given a rule parser similar to Auth, e.g.

Templates: entry !index

In any case, in order to implement this feature, changes would need to be made in a bunch of places, and there might need to be a decent amount of rearchitecting. For example,

  • view and search need to know what template it's now presenting for (and this information needs to come through Template.render
  • entry needs something like Entry.show_for_template which would consult the allowlist/blocklist
  • rendering.render_entry and rendering.render_category similarly need to provide the template name to the underlying render function, and render_entry needs to also raise an appropriate error if the template in question isn't allowed for the entry

Basically this would be an enormously complex change and while your use case is valid it's not something I care enough to support. I'm willing to accept a reasonably-well-considered pull request but I am not going to be doing this work myself.

@fluffy-critter
Copy link
Collaborator

Oh also Entry.link should be aware of templates as well and refuse to generate a link to a template type that it doesn't support. That gets super complicated, though, like what should the output be if one isn't supported? That also complicates the templates that rely on it.

All that said, you can already sort of do this with the existing template system. Give an entry a type of feed-only and then restrict your web-based HTML view queries to all have entry_type_not='feed-only' and you're, like, 80% of the way there. In the Atom feed you could also do something like:

{% if entry.type != 'feed-only' %}
<link rel="alternate" type="text/html" href="{{entry.link}}" />
{% endif %}

It does require more maintenance on the side of your templates, though, and it's up to you to decide how to handle someone attempting to load the entry page directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request large This is going to take a lot longer than most things
Projects
None yet
Development

No branches or pull requests

2 participants