Explorar el Código

Change comments script code to use polymorphism

Update #63
Talha Mansoor hace 11 años
padre
commit
5c1ecc9658

+ 2 - 2
templates/article.html

@@ -110,6 +110,6 @@
 
 {% block script %}
     {{ super() }}
-    {% include 'disqus_script_count.html' %}
-    {% include 'disqus_comments_uncollapse.html' %}
+    {% from 'comments.html' import comments_script with context %}
+    {{ comments_script(article) }}
 {% endblock script %}

+ 7 - 0
templates/comments.html

@@ -29,3 +29,10 @@
 </section>
     {% endif %}
 {% endmacro %}
+
+{% macro comments_script(article) %}
+    {% if DISQUS_SITENAME and SITEURL and article.status != 'draft' %}
+        {% include 'disqus_script_count.html' %}
+        {% include 'disqus_comments_uncollapse.html' %}
+    {% endif %}
+{% endmacro %}

+ 0 - 2
templates/disqus_comments_uncollapse.html

@@ -1,4 +1,3 @@
-{% if DISQUS_SITENAME and SITEURL and article.status != 'draft' %}
 <script  language="javascript" type="text/javascript">
 function uncollapse() {
     if (window.location.hash.match(/^#comment-\d+$/)) {
@@ -13,4 +12,3 @@ function uncollapse() {
             window.location.reload(true);
     }
 </script>
-{% endif %}

+ 0 - 2
templates/disqus_script_count.html

@@ -1,4 +1,3 @@
-{% if DISQUS_SITENAME and SITEURL and article.status != 'draft' %}
 <script type="text/javascript">
     var disqus_shortname = '{{ DISQUS_SITENAME }}';
 
@@ -9,4 +8,3 @@
         (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
     }());
     </script>
-{% endif %}