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

page: tag page changes to common presentational elements #155

Open
Bloke opened this issue Dec 11, 2019 · 11 comments
Open

page: tag page changes to common presentational elements #155

Bloke opened this issue Dec 11, 2019 · 11 comments
Assignees

Comments

@Bloke
Copy link
Member

Bloke commented Dec 11, 2019

Absolute URL of front-end page

(e.g.) https://docs.textpattern.com/tags/images

The question/problem

We now have the notion of 'global' attributes that all tags can take. Instead of repeating the definition of these ad nauseum in each tag page, can we use includes?

Option A

Write a whole bunch of includes for each set of things we use often, e.g. a doc that has the heading, intro text, plus class, wraptag, break, escape in it. And a doc that has heading, intro text, plus class, wraptag, break, escape, breakby, label, labeltag. And so on.

Option B (better)

Write a bunch of individual includes, one for each attribute such as escape, break, label, labeltag, breakby, wraptag, class. Then, on each tag page under the 'Common attributes' heading, call them into the doc one by one on a tag-by-tag basis.

Option C (better still?)

Write a single common presentational attributes header include file with the header text, introductory paragraph and then a bunch of conditionals in it, one for each attribute. When you call in the include, you pass in the attributes you want to display and the include only displays the ones you give it in the parameter list.

e.g. if using:

{% include common_atts.html class breakby wraptag %}

the include only displays those three under the heading and intro text.

I'm not sure how capable includes and parameters are in Liquid/Jekyll. I've not seen any examples yet where you can pass in valueless attributes so we might have to do something stupid like:

{% include common_atts.html class="1" breakby="1" wraptag="1" %}

and then check to see if each common attribute is equal to 1 in order to display it or not. But the general idea is that we write a single template with a bunch of conditionals and then just render bits of it based on the way that file is included and the params we give it.

Worth pursuing?

Checklist

Need to:

  1. Remove all links to any 'panel' pages (they will be gone).
  2. For links -- page-templates-explained.md and form-templates-explained.md -- assuming such links are still needed; change them to the following locations, respectively:
    • [page templates](/build/site-structures#page-templates)
    • [form markup](/build/site-structures#form-markup)
  3. . . .

Currenty 168 tags (pages)

  • article_custom.md
  • article_id.md
  • article_image.md
  • article_url_title.md
  • article.md
  • author_email.md
  • author.md
  • authors.md
  • body.md
  • breadcrumb.md
  • category_list.md
  • category.md
  • category1.md
  • category2.md
  • comment_anchor.md
  • comment_email_input.md
  • comment_email.md
  • comment_id.md
  • comment_message_input.md
  • comment_message.md
  • comment_name_input.md
  • comment_name.md
  • comment_permlink.md
  • comment_preview.md
  • comment_remember.md
  • comment_submit.md
  • comment_time.md
  • comment_web_input.md
  • comment_web.md
  • comments_count.md
  • comments_error.md
  • comments_form.md
  • comments_help.md
  • comments_invite.md
  • comments_preview.md
  • comments.md
  • css.md
  • custom_field.md
  • else.md
  • email.md
  • error_message.md
  • error_status.md
  • evaluate.md
  • excerpt.md
  • expires.md
  • feed_link.md
  • file_download_author.md
  • file_download_category.md
  • file_download_created.md
  • file_download_description.md
  • file_download_downloads.md
  • file_download_id.md
  • file_download_link.md
  • file_download_list.md
  • file_download_modified.md
  • file_download_name.md
  • file_download_size.md
  • file_download.md
  • header.md
  • hide.md
  • if_article_author.md
  • if_article_category.md
  • if_article_id.md
  • if_article_image.md
  • if_article_list.md
  • if_article_section.md
  • if_author.md
  • if_category.md
  • if_comments_allowed.md
  • if_comments_disallowed.md
  • if_comments_error.md
  • if_comments_preview.md
  • if_comments.md
  • if_custom_field.md
  • if_description.md
  • if_different.md
  • if_excerpt.md
  • if_expired.md
  • if_expires.md
  • if_first_article.md
  • if_first_category.md
  • if_first_file.md
  • if_first_image.md
  • if_first_link.md
  • if_first_section.md
  • if_individual_article.md
  • if_keywords.md
  • if_last_article.md
  • if_last_category.md
  • if_last_file.md
  • if_last_image.md
  • if_last_link.md
  • if_last_section.md
  • if_logged_in.md
  • if_plugin.md
  • if_search_results.md
  • if_search.md
  • if_section.md
  • if_status.md
  • if_thumbnail.md
  • if_variable.md
  • if_yield.md
  • image_author.md
  • image_date.md
  • image_display.md
  • image_index.md
  • image_info.md
  • image_list.md
  • image_url.md
  • image.md
  • images.md
  • index.md
  • item.md
  • keywords.md
  • lang.md
  • link_author.md
  • link_category.md
  • link_date.md
  • link_description.md
  • link_feed_link.md
  • link_id.md
  • link_name.md
  • link_to_home.md
  • link_to_next.md
  • link_to_prev.md
  • link_url.md
  • link.md
  • linkdesctitle.md
  • linklist.md
  • meta_author.md
  • meta_description.md
  • meta_keywords.md
  • modified.md
  • newer.md
  • next_title.md
  • older.md
  • output_form.md
  • page_title.md
  • page_url.md
  • password_protect.md
  • permlink.md
  • php.md
  • popup_comments.md
  • popup.md
  • posted.md
  • prev_title.md
  • recent_articles.md
  • recent_comments.md
  • related_articles.md
  • rsd.md
  • search_input.md
  • search_result_count.md
  • search_result_date.md
  • search_result_excerpt.md
  • search_result_title.md
  • search_result_url.md
  • search_term.md
  • section_list.md
  • section.md
  • site_name.md
  • site_slogan.md
  • site_url.md
  • text.md
  • thumbnail.md
  • title.md
  • txp_die.md
  • variable.md
  • yield.md
@Bloke
Copy link
Member Author

Bloke commented Dec 11, 2019

Another avenue for Option C might be to pass in something like this:

{% include common_atts.html atts="class, breakby, wraptag" %}

and then iterate over them in the include file:

### Common presentational attributes

These attributes, which affect presentation, are shared by many tags. Note that default values can vary among tags.

{% for att in include.atts %}
   {% if {{att}} == "class" %}
      // display class attribute info
   {% endif %}
   {% if {{att}} == "breakby" %}
      // display breakby attribute info
   {% endif %}
   ...
{% endfor %}

@wion
Copy link
Member

wion commented Dec 11, 2019

I think anytime you can eliminate overhead editing by single-sourcing... Do it. And the tag pages seem to be prime candidates for simplified editing wins wherever they can be gained. Especially as there are so damn many of them.

As for understanding the liquid options and whatnot, thus what is the best course, I'll have to defer to your and Phil's better judgement on how to proceed there. I get lost when anything is too deeply woven around conditionals, and liquid has always been a bit abstract to me.

At any rate, I'm licking my wounds and directing my attention away from tags pages now, back to the other site sections and needed materials, and the various guidelines I still need to finish.

@philwareham
Copy link
Member

Yes we should always try to utilise reusable code wherever possible to make everyones life easier. So I'm in favour of includes wherever we can.

@Bloke Bloke self-assigned this Dec 12, 2019
@Bloke
Copy link
Member Author

Bloke commented Dec 12, 2019

I'll see what I can do.

@Bloke
Copy link
Member Author

Bloke commented Dec 12, 2019

Okay, it works. I've added an '_includes/common-atts.html' file and have coded in entries so far for:

  • break
  • breakby
  • class
  • escape (global)
  • label
  • labeltag
  • style
  • wraptag

We can add more entries, plus the additional global attributes, as and when we need them.

To use it in a tag page, call the include file and pass it a list of attributes, using the attribute name and then its default value as the argument. That value will be used verbatim in the tag default text, which means we can get rid of the silly 'see exceptions' thing, as we can put the exact defaults in per tag.

So, for the section_list tag:

{% include common-atts.html break="br" breakby="unset" class="tag name or unset" escape="html" label="unset" labeltag="unset" wraptag="unset" %}

That's live for that tag now. I've added automatic links to the cross-reference pages for each one, noted if an attribute is global or not, and also (for escape) linked to the tag-escaping doc, which will move when the tag basics area is consolidated. But once all tag pages are converted to use this, we'll only need to update the link once in the include file. Woohoo!

Any amendments, improvements and help converting the tag pages over to use it welcome.

@Bloke
Copy link
Member Author

Bloke commented Dec 12, 2019

Made some more tweaks to the include file so you don't need to specify the default value if it's the most common default we use. Unfortunately, Liquid doesn't accept valueless attributes so if you want to use the default value, you have to specify ="". The defaults are:

  • break (br)
  • breakby (unset)
  • class (unset)
  • escape (html)
  • label (unset)
  • labeltag (unset)
  • style (unset)
  • wraptag (unset)

So the above mentioned include for section_list could now be:

{% include common-atts.html break="" breakby="" class="tag name or unset" escape="" label="" labeltag="" wraptag="" %}

@Bloke
Copy link
Member Author

Bloke commented Dec 13, 2019

Moved the global atts out of the common-atts.html file into their own global-atts include file.

So for the above mentioned section_list tag page, the include now becomes:

{% include common-atts.html break="" breakby="" %}

@wion
Copy link
Member

wion commented Dec 13, 2019

Any amendments, improvements and help converting the tag pages over to use it welcome.

I've moved the tag pages checklist from #153 to head post here, to help keep track. You might want to add to the 'what to change' list just above it, as needed.

@wion
Copy link
Member

wion commented Dec 16, 2019

#127

@wion
Copy link
Member

wion commented Dec 18, 2019

#118

@Bloke
Copy link
Member Author

Bloke commented Dec 21, 2019

For completeness, I've renamed the include file so it is grouped better in the file list with the global attributes include:

{% include atts-common.html %}

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

3 participants