Pārlūkot izejas kodu

Adds paragraph numbering to articles

Caleb Fangmeier 5 gadi atpakaļ
vecāks
revīzija
cdaf51fe87
3 mainītis faili ar 37 papildinājumiem un 25 dzēšanām
  1. 12 0
      static/css/custom.css
  2. 22 22
      templates/article.html
  3. 3 3
      templates/base.html

+ 12 - 0
static/css/custom.css

@@ -3,3 +3,15 @@ figure img {
   margin-left: auto;
   margin-right: auto;
 }
+
+/* Next 2 rules add ability to have paragraph numbers */
+.article-content p {
+  padding-left: 50px;
+  position: relative;
+}
+
+.article-content p:before {
+  display: block;
+  position: absolute;
+  left: 5px;
+}

+ 22 - 22
templates/article.html

@@ -77,32 +77,11 @@
             </aside>
             {% endif %}
         </div>
+        <style id="numbers"></style>
         <section>
         <div class="span2" style="float:right;font-size:0.9em;">
-            {% if article.date %}
-            <h4>Published</h4>
-            {% set day = article.date.strftime('%d')|int %}
-            <time pubdate="pubdate" datetime="{{ article.date.isoformat() }}">{{ article.date.strftime('%b') }} {{ day }} {{- article.date.strftime(', %Y') }}</time>
-            {% endif %}
             {% include '_includes/last_updated.html' %}
             {% include '_includes/multi_parts.html' %}
-            {% if article.category|trim|count > 0 %}
-            <h4>Category</h4>
-            <a class="category-link" href="{{ SITEURL }}/categories.html#{{ category.slug }}-ref">{{ article.category }}</a>
-            {% endif %}
-            {% if article.tags and article.tags[0]|trim|count > 0 %}
-            <h4>Tags</h4>
-            <ul class="list-of-tags tags-in-article">
-                {% for tag in article.tags|sort %}
-                <li><a href="{{ SITEURL }}/tags.html#{{ tag.slug }}-ref">{{ tag }}
-                    {% for aTag, tagged_articles in tags if aTag == tag %}
-                    <span>{{ tagged_articles|count }}</span>
-                    {% endfor %}</a></li>
-                {% endfor %}
-            </ul>
-            {% endif %}
-            {% include '_includes/social_links.html' %}
-            {% include '_includes/mailchimp.html' %}
         </div>
         </section>
 </div>
@@ -113,4 +92,25 @@
     {{ super() }}
     {% from '_includes/comments.html' import comments_script with context %}
     {{ comments_script(article) }}
+
+<script>
+$(document).ready(function() {
+  var maxNum = 0;  //how many lines should be prepared (Takin in considersation, there would be more wrappers) 
+  $(".article-content").each(function() {//create counter for each .NumeredTextBlock wrapper
+    var line = 1;  //start with number 1
+    $("p", this).each(function() {//look for paragraph elements inside wrapper
+      $(this).addClass("line" + line);//add class with line number
+      line++;
+      if (maxNum < line) maxNum = line;//set the maximum number of lines used in HTML DOM for wrapper
+    });
+  });
+  var prepStyle = "";//prepare css style with line numbering
+  while (maxNum--) {//prepare as many styles as the max number in document
+    prepStyle += ".line" + maxNum + ":before{content:'" + maxNum + "'}";
+  }
+  $("#numbers").html(prepStyle);//add prepared styles to the HTML DOM
+  console.log("resulting generated <style id='numbers'>"+prepStyle+"</style>")
+});
+</script>
+
 {% endblock script %}

+ 3 - 3
templates/base.html

@@ -48,9 +48,9 @@
         <link rel="stylesheet" type="text/css" href="{{ SITEURL }}/theme/css/pygments.css" media="screen">
         <link href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css">
         <script src="{{ SITEURL }}/theme/tipuesearch/tipuesearch_content.js"></script>
-        <link rel="stylesheet" type="text/css" href="{{ SITEURL }}/theme/tipuesearch/tipuesearch.css" media="screen">
-        <link rel="stylesheet" type="text/css" href="{{ SITEURL }}/theme/css/elegant.css" media="screen">
-        <link rel="stylesheet" type="text/css" href="{{ SITEURL }}/theme/css/custom.css" media="screen">
+        <link rel="stylesheet" type="text/css" href="./theme/tipuesearch/tipuesearch.css" media="screen">
+        <link rel="stylesheet" type="text/css" href="./theme/css/elegant.css" media="screen">
+        <link rel="stylesheet" type="text/css" href="./theme/css/custom.css" media="screen">
 
         {% endif %}
         {% endblock head_links %}