alexandrevicenzi / Flex

The minimalist Pelican theme.
https://flex.alxd.me
MIT License
608 stars 331 forks source link

Promote all links in the "social" box with rel="me" attribute #285

Open schtobia opened 3 years ago

schtobia commented 3 years ago

This part here

https://github.com/alexandrevicenzi/Flex/blob/a2b7d6de370779679875eb199279d3deea08f30f/templates/base.html#L222-L228

could be extended to promote the rel="me" attribute for all social links. This is according to the corresponding microformat and would be helpful for a Web Sign In.

What do you think?

alexandrevicenzi commented 3 years ago

Not all links will be "me", one can add any links there, not sure about that. Some social networks would work. Might be better to just change name equals something to name in some range.

schtobia commented 3 years ago

what about expanding the SOCIAL variable in pelicanconf.py to a triplet? That way we can conditionally assign each link its own relation:

      <ul class="social">
        {% for name, link, rel in SOCIAL %}
          <li>
            <a{% if name == 'mastodon' %} rel="me"{% elif rel %} rel="{{ rel }}"{% endif %} class="sc-{{ name }}" href="{{ link }}" target="_blank">
              <i class="{% if name in ['envelope', 'rss'] %}fas{% else %}fab{% endif %} fa-{{ name }}"></i>
            </a>
          </li>
        {% endfor %}
      </ul>
alexandrevicenzi commented 3 years ago

It would work, but breaks compatibility with older settings, which could be a no go, unless there's an easy way to have an if old style do this else do that.

schtobia commented 3 years ago

Yes, there is a way:

      <ul class="social">
        {% for tuple in SOCIAL %}
        {% set name = tuple.0 %}
        {% set link = tuple.1 %}
        {% set rel = tuple.2 if tuple.2 else None %}
          <li>
            <a{% if name == 'mastodon' %} rel="me"{% elif rel %} rel="{{ rel }}"{% endif %} class="sc-{{ name }}" href="{{ link }}" target="_blank">
              <i class="{% if name in ['envelope', 'rss'] %}fas{% else %}fab{% endif %} fa-{{ name }}"></i>
            </a>
          </li>
        {% endfor %}
      </ul>

(see my repo.)

alexandrevicenzi commented 2 years ago

Ok, perhaps it's time for 3.0 release, where we break some compatibility, and document properly how to migrate. Pelican itself has changed a lot since the origin of this theme.

I won't be against breaking changes, as long as we document everything properly, otherwise, people will open issues, which can be a problem.

alexandrevicenzi commented 1 year ago

So, SOCIAL is a Pelican config, and if changed, will not be compatible with Pelican.

schtobia commented 1 year ago

That's why I 've suggested a non breaking solution. For everyone on Mastodon this is really important, as Mastodon uses this part to verify the identity.

I personally don't use pelican anymore (the PR is 18 months old), so for me it's not that important.

lioman commented 1 year ago

I think this can be closed as rel=me is supported for mastodon and some other sites. or it should be changed to something different like adding a setting to enable it in theme:

pelicanconf.py

SOCIAL = (
    ("a", "https://a.example/user"),
    ("b", "https://b.example/username"),
    ("c", "https://c.example/mysite"),
)

RELME= ["a", "b"]

sidebar.html


{% if SOCIAL %}
    {% set solid = ['at', 'envelope', 'mailbox', 'rss'] %}
    <ul class="social">
      {% for name, link in SOCIAL %}
      <li>
        <a class="sc-{{ name }}"
          {% if RELME %} {% if name in RELME %}rel="me"{% endif %} {% endif %}
           href="{{ link }}"
           target="_blank"
           aria-label="{{ name }}">
          <i class="{% if name in solid %}fa-solid{% else %}fa-brands{% endif %} fa-{{ name }}"></i>

        </a>
      </li>
      {% endfor %}
    </ul>
    {% endif %}