article.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. {% extends 'base.html' %}
  2. {% block title %}
  3. {{ article.title|striptags|e }} {%if article.subtitle %} - {{ article.subtitle|striptags|e }} {% endif %} · {{ super() }}
  4. {% endblock title %}
  5. {% block head_description %}
  6. {% if article.summary %}
  7. {{ article.summary|striptags|e }}
  8. {% endif %}
  9. {% endblock head_description %}
  10. {% block meta_tags_in_head %}
  11. {{ super() }}
  12. {% if article.tags or article.category or article.keywords %}
  13. <meta name="keywords" content="{{ [article.tags|join(', '), article.category, article.keywords]|join(', ') }}" />
  14. {% endif %}
  15. {% from '_includes/smo_metadata.html' import smo_metadata with context %}
  16. {{ smo_metadata(article) }}
  17. {% endblock meta_tags_in_head %}
  18. {% block style %}
  19. {% if DRAFT %}
  20. <style>
  21. .article-content p {
  22. padding-left: 50px;
  23. position: relative;
  24. }
  25. .article-content p:before {
  26. display: block;
  27. position: absolute;
  28. left: 5px;
  29. }
  30. </style>
  31. {% endif %}
  32. {% endblock %}
  33. {% block content %}
  34. <article>
  35. <div class="row-fluid">
  36. <header class="page-header span10 offset2">
  37. <h1><a href="{{ SITEURL }}/{{ article.url }}"> {{ article.title }} {%if article.subtitle %} <small> {{ article.subtitle }} </small> {% endif %} </a></h1>
  38. </header>
  39. </div>
  40. <div class="row-fluid">
  41. {% if article.toc %}
  42. <div class="span2 table-of-content">
  43. <nav>
  44. <h4>Contents</h4>
  45. {{ article.toc }}
  46. </nav>
  47. </div>
  48. <div class="span8 article-content">
  49. {% else %}
  50. <div class="span8 offset2 article-content">
  51. {% endif %}
  52. {% import '_includes/translations.html' as translations with context %}
  53. {{ translations.translations_for(article) }}
  54. {{ article.content }}
  55. {% from '_includes/share_links.html' import share_links with context %}
  56. {{ share_links(article) }}
  57. {% from '_includes/comments.html' import comments with context %}
  58. {{ comments(article) }}
  59. <hr/>
  60. {% include '_includes/related_posts.html' with context %}
  61. {% if article.prev_article or article.next_article %}
  62. <aside>
  63. <nav>
  64. <ul class="articles-timeline">
  65. {% if article.prev_article %}
  66. {% set ptitle = article.prev_article.title|striptags|e %}
  67. {% set pv_title = article.prev_article.title|striptags %}
  68. {%if article.prev_article.subtitle %}
  69. {% set pv_title = pv_title + ' ' + '<small>' + article.prev_article.subtitle|striptags + '</small>' %}
  70. {% set ptitle = ptitle + ' - ' + article.prev_article.subtitle|e %}
  71. {% endif %}
  72. <li class="previous-article">« <a href="{{ SITEURL }}/{{ article.prev_article.url }}" title="Previous: {{ ptitle }}">{{ pv_title }}</a></li>
  73. {% endif %}
  74. {% if article.next_article %}
  75. {% set ntitle = article.next_article.title|striptags|e %}
  76. {% set nv_title = article.next_article.title|striptags %}
  77. {%if article.next_article.subtitle %}
  78. {% set nv_title = nv_title + ' ' + '<small>' + article.next_article.subtitle|striptags + '</small>' %}
  79. {% set ntitle = ntitle + ' - ' + article.next_article.subtitle|e %}
  80. {% endif %}
  81. <li class="next-article"><a href="{{ SITEURL }}/{{ article.next_article.url }}" title="Next: {{ ntitle }}">{{ nv_title }}</a> »</li>
  82. {% endif %}
  83. </ul>
  84. </nav>
  85. </aside>
  86. {% endif %}
  87. </div>
  88. <style id="numbers"></style>
  89. <section>
  90. <div class="span2" style="float:right;font-size:0.9em;">
  91. {% include '_includes/last_updated.html' %}
  92. {% include '_includes/multi_parts.html' %}
  93. </div>
  94. </section>
  95. </div>
  96. </article>
  97. {% endblock content %}
  98. {% block script %}
  99. {{ super() }}
  100. {% from '_includes/comments.html' import comments_script with context %}
  101. {{ comments_script(article) }}
  102. {% if DRAFT %}
  103. <script>
  104. $(document).ready(function() {
  105. var maxNum = 0; //how many lines should be prepared (Takin in considersation, there would be more wrappers)
  106. $(".article-content").each(function() {//create counter for each .NumeredTextBlock wrapper
  107. var line = 1; //start with number 1
  108. $("p", this).each(function() {//look for paragraph elements inside wrapper
  109. $(this).addClass("line" + line);//add class with line number
  110. line++;
  111. if (maxNum < line) maxNum = line;//set the maximum number of lines used in HTML DOM for wrapper
  112. });
  113. });
  114. var prepStyle = "";//prepare css style with line numbering
  115. while (maxNum--) {//prepare as many styles as the max number in document
  116. prepStyle += ".line" + maxNum + ":before{content:'" + maxNum + "'}";
  117. }
  118. $("#numbers").html(prepStyle);//add prepared styles to the HTML DOM
  119. console.log("resulting generated <style id='numbers'>"+prepStyle+"</style>")
  120. });
  121. </script>
  122. {% endif %}
  123. {% endblock script %}