瀏覽代碼

Change comments script code to use polymorphism

Update #63
Talha Mansoor 11 年之前
父節點
當前提交
5c1ecc9658
共有 4 個文件被更改,包括 9 次插入6 次删除
  1. 2 2
      templates/article.html
  2. 7 0
      templates/comments.html
  3. 0 2
      templates/disqus_comments_uncollapse.html
  4. 0 2
      templates/disqus_script_count.html

+ 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 %}