Browse Source

fix #125 - added schema.org structural data for crawlers

Rafał Pitoń 8 years ago
parent
commit
bb493d4bc7

+ 1 - 2
misago/categories/views/permsadmin.py

@@ -201,8 +201,7 @@ class RoleCategoriesACL(RoleAdmin, generic.ModelFormView):
 
 
             acl_version.invalidate()
             acl_version.invalidate()
 
 
-            message = _("Category permissions for role "
-                        "%(name)s have been changed.")
+            message = _("Category permissions for role %(name)s have been changed.")
             messages.success(request, message % {'name': target.name})
             messages.success(request, message % {'name': target.name})
             if 'stay' in request.POST:
             if 'stay' in request.POST:
                 return redirect(request.path)
                 return redirect(request.path)

+ 1 - 0
misago/templates/misago/base.html

@@ -24,6 +24,7 @@
     <link rel="apple-touch-icon" sizes="180x180" href="{% static 'apple-touch-icon-180.png' %}">
     <link rel="apple-touch-icon" sizes="180x180" href="{% static 'apple-touch-icon-180.png' %}">
     <link rel="shortcut icon" href="{% static 'favicon.ico' %}">
     <link rel="shortcut icon" href="{% static 'favicon.ico' %}">
     <link rel="icon" sizes="16x16 32x32" href="{% static 'favicon.ico' %}">
     <link rel="icon" sizes="16x16 32x32" href="{% static 'favicon.ico' %}">
+    <script type="application/ld+json">{"@context":"http://schema.org","@type":"WebSite","url":"{{ SITE_ADDRESS }}"}</script>
   </head>
   </head>
   <body>
   <body>
 
 

+ 1 - 1
misago/templates/misago/navbar.html

@@ -52,7 +52,7 @@
     <div id="user-menu-mount"></div>
     <div id="user-menu-mount"></div>
   </div><!-- /full navbar -->
   </div><!-- /full navbar -->
 
 
-  <ul class="nav navbar-nav navbar-compact-nav hidden-md hidden-lg">
+  <ul class="nav navbar-nav navbar-compact-nav hidden-md hidden-lg" itemscope itemtype="http://schema.org/SiteNavigationElement">
     {% if misago_settings.forum_branding_display %}
     {% if misago_settings.forum_branding_display %}
       <li>
       <li>
         <a href="{% url 'misago:index' %}">
         <a href="{% url 'misago:index' %}">

+ 6 - 3
misago/templates/misago/thread/breadcrumbs.html

@@ -1,9 +1,12 @@
 <div class="page-breadcrumbs">
 <div class="page-breadcrumbs">
   <div class="container">
   <div class="container">
-    <ol class="breadcrumb">
+    <ol class="breadcrumb" itemscope itemtype="http://schema.org/BreadcrumbList">
       {% for node in breadcrumbs %}
       {% for node in breadcrumbs %}
-        <li>
-          <a href="{{ node.get_absolute_url }}">{{ node.name }}</a>
+        <li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
+          <a href="{{ node.get_absolute_url }}" itemscope itemtype="http://schema.org/Thing" itemprop="item">
+            <span itemprop="name">{{ node.name }}</span>
+          </a>
+          <meta itemprop="position" content="{{ forloop.counter }}" />
         </li>
         </li>
       {% endfor %}
       {% endfor %}
     </ol>
     </ol>

+ 12 - 8
misago/templates/misago/thread/paginator.html

@@ -1,5 +1,5 @@
 {% load i18n %}
 {% load i18n %}
-<nav class="misago-pagination">
+<nav class="misago-pagination" role="nav" itemscope itemtype="http://schema.org/SiteNavigationElement">
   {% if paginator.pages > 1 %}
   {% if paginator.pages > 1 %}
   <ul class="pagination">
   <ul class="pagination">
     {% if paginator.first %}
     {% if paginator.first %}
@@ -10,20 +10,24 @@
       </li>
       </li>
       {% if paginator.previous > 1 %}
       {% if paginator.previous > 1 %}
         <li>
         <li>
-          <a href="{% url url_name slug=thread.slug pk=thread.pk page=paginator.previous %}" title="{% trans 'Go to previous page' %}">
+          <a href="{% url url_name slug=thread.slug pk=thread.pk page=paginator.previous %}" rel="prev" title="{% trans 'Go to previous page' %}">
             <span class="material-icon">chevron_left</span>
             <span class="material-icon">chevron_left</span>
           </a>
           </a>
         </li>
         </li>
-      {% endif %}
-    {% endif %}
-    {% if paginator.last %}
-      {% if paginator.next < paginator.last %}
+      {% else %}
         <li>
         <li>
-          <a href="{% url url_name slug=thread.slug pk=thread.pk page=paginator.next %}" title="{% trans 'Go to next page' %}">
-            <span class="material-icon">chevron_right</span>
+          <a href="{% url url_name slug=thread.slug pk=thread.pk %}" rel="prev" title="{% trans 'Go to previous page' %}">
+            <span class="material-icon">chevron_left</span>
           </a>
           </a>
         </li>
         </li>
       {% endif %}
       {% endif %}
+    {% endif %}
+    {% if paginator.last %}
+      <li>
+        <a href="{% url url_name slug=thread.slug pk=thread.pk page=paginator.next %}" rel="next" title="{% trans 'Go to next page' %}">
+          <span class="material-icon">chevron_right</span>
+        </a>
+      </li>
       <li>
       <li>
         <a href="{% url url_name slug=thread.slug pk=thread.pk page=paginator.last %}" title="{% trans 'Go to last page' %}">
         <a href="{% url url_name slug=thread.slug pk=thread.pk page=paginator.last %}" title="{% trans 'Go to last page' %}">
           <span class="material-icon">last_page</span>
           <span class="material-icon">last_page</span>

+ 2 - 2
misago/templates/misago/thread/posts/post/body.html

@@ -1,12 +1,12 @@
 {% load i18n %}
 {% load i18n %}
 {% if post.is_valid %}
 {% if post.is_valid %}
-  <div class="panel-body">
+  <div class="panel-body" itemprop="articleBody">
     <article class="misago-markup">
     <article class="misago-markup">
       {{ post.content|safe }}
       {{ post.content|safe }}
     </article>
     </article>
   </div>
   </div>
 {% else %}
 {% else %}
-  <div class="panel-body panel-body-invalid">
+  <div class="panel-body panel-body-invalid" itemprop="articleBody">
     <p class="lead">{% trans "This post's contents cannot be displayed." %}</p>
     <p class="lead">{% trans "This post's contents cannot be displayed." %}</p>
     <p class="text-muted">{% trans "This error is caused by invalid post content manipulation." %}</p>
     <p class="text-muted">{% trans "This error is caused by invalid post content manipulation." %}</p>
   </div>
   </div>

+ 7 - 5
misago/templates/misago/thread/posts/post/header.html

@@ -2,10 +2,10 @@
 <div class="panel-heading post-heading">
 <div class="panel-heading post-heading">
   {% if post.poster %}
   {% if post.poster %}
     <a class="item-title" href="{{ post.poster.get_absolute_url }}">
     <a class="item-title" href="{{ post.poster.get_absolute_url }}">
-      {{ post.poster.username }}
+      <span itemprop="author">{{ post.poster.username }}</span>
     </a>
     </a>
   {% else %}
   {% else %}
-    <strong class="item-title">{{ post.poster_name }}</strong>
+    <strong class="item-title" itemprop="author">{{ post.poster_name }}</strong>
   {% endif %}
   {% endif %}
 
 
   {% if post.poster %}
   {% if post.poster %}
@@ -27,9 +27,11 @@
   {% endif %}
   {% endif %}
 
 
   <a href="{{ post.get_absolute_url }}" class="posted-on">
   <a href="{{ post.get_absolute_url }}" class="posted-on">
-    {% blocktrans trimmed with posted_on=post.posted_on|date:'DATETIME_FORMAT' %}
-      posted on {{ posted_on }}
-    {% endblocktrans %}
+    <time itemprop="datePublished" datetime="{{ post.posted_on|date:'c' }}">
+      {% blocktrans trimmed with posted_on=post.posted_on|date:'DATETIME_FORMAT' %}
+        posted on {{ posted_on }}
+      {% endblocktrans %}
+    </time>
   </a>
   </a>
 
 
   {% if not post.is_read %}
   {% if not post.is_read %}

+ 1 - 1
misago/templates/misago/thread/posts/post/index.html

@@ -1,5 +1,5 @@
 {% load misago_avatars %}
 {% load misago_avatars %}
-<li id="post-{{ post.pk }}" class="post {% if post.is_hidden and not post.acl.can_see_hidden %}post-hidden{% endif %} {% if not post.is_read %}post-new{% endif %}">
+<li id="post-{{ post.pk }}" class="post {% if post.is_hidden and not post.acl.can_see_hidden %}post-hidden{% endif %} {% if not post.is_read %}post-new{% endif %}" itemscope itemtype="http://schema.org/DiscussionForumPosting">
   <div class="post-border">
   <div class="post-border">
     <div class="post-avatar">
     <div class="post-avatar">
       {% if post.poster %}
       {% if post.poster %}

+ 8 - 6
misago/templates/misago/threadslist/base.html

@@ -27,7 +27,7 @@
 
 
     {% block list-container %}
     {% block list-container %}
       {% if subcategories %}
       {% if subcategories %}
-        <section class="toolbar">
+        <section class="toolbar" itemscope itemtype="http://schema.org/SiteNavigationElement">
           <ul class="list-inline subcategories-list">
           <ul class="list-inline subcategories-list">
             {% for subcategory in subcategories %}
             {% for subcategory in subcategories %}
               <li>
               <li>
@@ -43,7 +43,9 @@
       <section>
       <section>
         <div class="threads-list ui-ready">
         <div class="threads-list ui-ready">
           {% block threads-list %}
           {% block threads-list %}
-            <ul class="list-group">
+            <ul class="list-group" itemscope itemtype="http://schema.org/ItemList">
+              <meta itemprop="numberOfItems" content="{{ paginator.count }}">
+              <meta itemprop="itemListOrder" content="http://schema.org/ItemListOrderDescending">
               {% for thread in threads %}
               {% for thread in threads %}
                 {% block thread %}
                 {% block thread %}
                   {% include "misago/threadslist/thread.html" %}
                   {% include "misago/threadslist/thread.html" %}
@@ -74,11 +76,11 @@
 
 
         <noscript>
         <noscript>
           {% if paginator.pages > 1 %}
           {% if paginator.pages > 1 %}
-            <nav>
+            <nav role="navigation" itemscope itemtype="http://schema.org/SiteNavigationElement">
               <ul class="pager">
               <ul class="pager">
                 {% if paginator.previous > 1 %}
                 {% if paginator.previous > 1 %}
                   <li class="previous">
                   <li class="previous">
-                    <a href="{{ REQUEST_PATH }}?page={{ paginator.previous }}">
+                    <a href="{{ REQUEST_PATH }}?page={{ paginator.previous }}" rel="prev" title="{% trans 'Previous page' %}">
                       <span aria-hidden="true" class="material-icon">
                       <span aria-hidden="true" class="material-icon">
                         arrow_back
                         arrow_back
                       </span>
                       </span>
@@ -86,7 +88,7 @@
                   </li>
                   </li>
                 {% elif paginator.first %}
                 {% elif paginator.first %}
                   <li class="previous">
                   <li class="previous">
-                    <a href="{{ REQUEST_PATH }}">
+                    <a href="{{ REQUEST_PATH }}" rel="prev" title="{% trans 'Previous page' %}">
                       <span aria-hidden="true" class="material-icon">
                       <span aria-hidden="true" class="material-icon">
                         arrow_back
                         arrow_back
                       </span>
                       </span>
@@ -95,7 +97,7 @@
                 {% endif %}
                 {% endif %}
                 {% if paginator.next %}
                 {% if paginator.next %}
                   <li class="next">
                   <li class="next">
-                    <a href="{{ REQUEST_PATH }}?page={{ paginator.next }}">
+                    <a href="{{ REQUEST_PATH }}?page={{ paginator.next }}" rel="next" title="{% trans 'Next page' %}">
                       <span aria-hidden="true" class="material-icon">
                       <span aria-hidden="true" class="material-icon">
                         arrow_forward
                         arrow_forward
                       </span>
                       </span>

+ 4 - 3
misago/templates/misago/threadslist/thread.html

@@ -1,5 +1,5 @@
 {% load i18n misago_capture %}
 {% load i18n misago_capture %}
-<li class="list-group-item thread-{{ thread.is_read|yesno:'read,new' }}">
+<li class="list-group-item thread-{{ thread.is_read|yesno:'read,new' }}" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
   <div class="thread-icon">
   <div class="thread-icon">
     {% if thread.is_read %}
     {% if thread.is_read %}
     <a href="{{ thread.get_last_post_url }}" class="read-status item-read" title="{% trans "This thread has no new posts." %}">
     <a href="{{ thread.get_last_post_url }}" class="read-status item-read" title="{% trans "This thread has no new posts." %}">
@@ -58,8 +58,8 @@
     </div>
     </div>
   </div>
   </div>
   <div class="thread-main">
   <div class="thread-main">
-    <a href="{{ thread.get_absolute_url }}" class="item-title thread-title">
-      {{ thread.title }}
+    <a href="{{ thread.get_absolute_url }}" class="item-title thread-title" itemprop="url">
+      <span itemprop="name">{{ thread.title }}</span>
     </a>
     </a>
     <ul class="thread-details-full list-inline">
     <ul class="thread-details-full list-inline">
       {% if not thread.is_read %}
       {% if not thread.is_read %}
@@ -213,4 +213,5 @@
     </ul>
     </ul>
   </div>
   </div>
   <div class="clearfix"></div>
   <div class="clearfix"></div>
+  <meta itemprop="position" content="{{ paginator.before|add:forloop.counter }}">
 </li>
 </li>

+ 10 - 4
misago/templates/misago/userslists/active_posters.html

@@ -34,10 +34,10 @@
       </p>
       </p>
 
 
       <div class="active-posters ui-ready">
       <div class="active-posters ui-ready">
-        <ul class="list-group">
+        <ul class="list-group" itemscope itemtype="http://schema.org/ItemList">
           {% for ranked in users %}
           {% for ranked in users %}
-            {% url USER_PROFILE_URL slug=ranked.slug pk=ranked.pk as user_url %}
-            <li class="list-group-item{% if ranked.rank.css_class %} list-group-rank-{{ ranked.rank.css_class }}{% endif %}">
+            {% url 'misago:user' slug=ranked.slug pk=ranked.pk as user_url %}
+            <li class="list-group-item{% if ranked.rank.css_class %} list-group-rank-{{ ranked.rank.css_class }}{% endif %}" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
               <div class="rank-user-avatar">
               <div class="rank-user-avatar">
                 <a href="{{ user_url }}">
                 <a href="{{ user_url }}">
                   <img src="{{ ranked|avatar:50 }}" alt="{% trans "Avatar" %}" class="avatar">
                   <img src="{{ ranked|avatar:50 }}" alt="{% trans "Avatar" %}" class="avatar">
@@ -46,7 +46,9 @@
 
 
               <div class="rank-user">
               <div class="rank-user">
                 <div class="user-name">
                 <div class="user-name">
-                  <a href="{{ user_url }}" class="item-title">{{ ranked }}</a>
+                  <a href="{{ user_url }}" class="item-title" itemprop="url">
+                    <span itemprop="name">{{ ranked }}</span>
+                  </a>
                 </div>
                 </div>
                 <div class="user-details">
                 <div class="user-details">
                   {% if ranked.rank.is_tab %}
                   {% if ranked.rank.is_tab %}
@@ -80,8 +82,12 @@
                 <strong>{{ ranked.posts }}</strong>
                 <strong>{{ ranked.posts }}</strong>
                 <small>{% trans "Total posts" %}</small>
                 <small>{% trans "Total posts" %}</small>
               </div>
               </div>
+
+              <meta itemprop="position" content="{{ forloop.counter }}" />
             </li>
             </li>
           {% endfor %}
           {% endfor %}
+          <meta itemprop="numberOfItems" content="{{ users|length }}">
+          <meta itemprop="itemListOrder" content="http://schema.org/ItemListOrderDescending">
         </ul>
         </ul>
       </div>
       </div>
     {% else %}
     {% else %}

+ 1 - 1
misago/templates/misago/userslists/base.html

@@ -14,7 +14,7 @@
     </div>
     </div>
     <div class="page-tabs">
     <div class="page-tabs">
       <div class="container">
       <div class="container">
-        <ul class="nav nav-pills">
+        <ul class="nav nav-pills" role="nav" itemscope itemtype="http://schema.org/SiteNavigationElement">
           {% for page in pages %}
           {% for page in pages %}
             <li{% if page.is_active %} class="active"{% endif %}>
             <li{% if page.is_active %} class="active"{% endif %}>
               <a href="{{ page.reversed_link }}">
               <a href="{{ page.reversed_link }}">

+ 16 - 12
misago/templates/misago/userslists/rank.html

@@ -32,22 +32,22 @@
   <div class="container">
   <div class="container">
 
 
     {% if rank.description %}
     {% if rank.description %}
-      <div class="rank-description">
+      <section class="rank-description">
         <div class="page-lead {{ rank.description|escape|linebreaks|isdescriptionshort|iftrue:"lead" }}">
         <div class="page-lead {{ rank.description|escape|linebreaks|isdescriptionshort|iftrue:"lead" }}">
           {{ rank.description|escape|urlize|linebreaks|safe }}
           {{ rank.description|escape|urlize|linebreaks|safe }}
         </div>
         </div>
-      </div>
+      </section>
     {% endif %}
     {% endif %}
 
 
     {% if paginator.count %}
     {% if paginator.count %}
-      <div>
-        <div class="users-cards-list ui-ready">
+      <section>
+        <div class="users-cards-list ui-ready" itemscope itemtype="http://schema.org/ItemList">
           {% for row in users|batch:3 %}
           {% for row in users|batch:3 %}
             <div class="row">
             <div class="row">
               {% for user in row %}
               {% for user in row %}
                 <div class="col-md-4">
                 <div class="col-md-4">
 
 
-                  <div class="user-card {% if rank.css_class %} user-card-{{ rank.css_class }}{% endif %}">
+                  <div class="user-card {% if rank.css_class %} user-card-{{ rank.css_class }}{% endif %}" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
                     <div class="user-card-bg-image">
                     <div class="user-card-bg-image">
                       <img src="{{ user|avatar:400 }}" alt="" class="bg-image">
                       <img src="{{ user|avatar:400 }}" alt="" class="bg-image">
 
 
@@ -61,8 +61,8 @@
                           </div>
                           </div>
 
 
                           <h4 class="user-name">
                           <h4 class="user-name">
-                            <a href="{{ user.get_absolute_url }}" class="item-title">
-                              {{ user.username }}
+                            <a href="{{ user.get_absolute_url }}" class="item-title" itemprop="url">
+                              <span itemprop="name">{{ user.username }}</span>
                             </a>
                             </a>
                           </h4>
                           </h4>
 
 
@@ -107,21 +107,25 @@
 
 
                       </div>
                       </div>
                     </div>
                     </div>
+
+                    <meta itemprop="position" content="{{ paginator.before|add:forloop.counter }}" />
                   </div>
                   </div>
 
 
                 </div>
                 </div>
               {% endfor %}
               {% endfor %}
             </div>
             </div>
           {% endfor %}
           {% endfor %}
+          <meta itemprop="numberOfItems" content="{{ paginator.count }}">
+          <meta itemprop="itemListOrder" content="http://schema.org/ItemListOrderAscending">
         </div>
         </div>
 
 
         {% if paginator.pages > 1 %}
         {% if paginator.pages > 1 %}
           <div class="pager-undercontent">
           <div class="pager-undercontent">
-            <nav>
+            <nav role="navigation" itemscope itemtype="http://schema.org/SiteNavigationElement">
               <ul class="pager">
               <ul class="pager">
                 {% if paginator.previous > 1 %}
                 {% if paginator.previous > 1 %}
                 <li class="previous">
                 <li class="previous">
-                  <a href="{% url 'misago:users-rank' slug=rank.slug page=paginator.previous %}">
+                  <a href="{% url 'misago:users-rank' slug=rank.slug page=paginator.previous %}" rel="prev" title="{% trans 'Go to previous page' %}">
                     <span aria-hidden="true" class="material-icon">
                     <span aria-hidden="true" class="material-icon">
                       arrow_back
                       arrow_back
                     </span>
                     </span>
@@ -129,7 +133,7 @@
                 </li>
                 </li>
                 {% elif paginator.first %}
                 {% elif paginator.first %}
                 <li class="previous">
                 <li class="previous">
-                  <a href="{% url 'misago:users-rank' slug=rank.slug %}">
+                  <a href="{% url 'misago:users-rank' slug=rank.slug %}" rel="prev" title="{% trans 'Go to previous page' %}">
                     <span aria-hidden="true" class="material-icon">
                     <span aria-hidden="true" class="material-icon">
                       arrow_back
                       arrow_back
                     </span>
                     </span>
@@ -138,7 +142,7 @@
                 {% endif %}
                 {% endif %}
                 {% if paginator.next %}
                 {% if paginator.next %}
                 <li class="next">
                 <li class="next">
-                  <a href="{% url 'misago:users-rank' slug=rank.slug page=paginator.next %}">
+                  <a href="{% url 'misago:users-rank' slug=rank.slug page=paginator.next %}" rel="next" title="{% trans 'Go to next page' %}">
                     <span aria-hidden="true" class="material-icon">
                     <span aria-hidden="true" class="material-icon">
                       arrow_forward
                       arrow_forward
                     </span>
                     </span>
@@ -149,7 +153,7 @@
             </nav>
             </nav>
           </div>
           </div>
         {% endif %}
         {% endif %}
-      </div>
+      </section>
     {% else %}
     {% else %}
       <p class="lead">
       <p class="lead">
         {% trans "There are no users with this rank at the moment." %}
         {% trans "There are no users with this rank at the moment." %}