tags.html 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. {% extends "base.html" %}
  2. {% block head %}
  3. {{ super() }}
  4. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
  5. <script>
  6. (function ($) {
  7. // custom css expression for a case-insensitive contains()
  8. jQuery.expr[':'].Contains = function(a,i,m){
  9. return (a.textContent || a.innerText || "").toUpperCase().indexOf(m[3].toUpperCase())>=0;
  10. };
  11. function listFilter() {
  12. $('.filterinput')
  13. .change( function () {
  14. var filter = $(this).val();
  15. if(filter) {
  16. // this finds all links in a list that contain the input,
  17. // and hide the ones not containing the input while showing the ones that do
  18. $('.list-of-tags').find("a:not(:Contains(" + filter + "))").parent().hide();
  19. $('.list-of-tags').find("a:Contains(" + filter + ")").parent().show();
  20. } else {
  21. $('.list-of-tags').find("li").show();
  22. }
  23. return false;
  24. })
  25. .keyup( function () {
  26. // fire the above change event after every letter
  27. $(this).change();
  28. });
  29. }
  30. //ondomready
  31. $(function () {
  32. listFilter($());
  33. });
  34. }(jQuery));
  35. </script>
  36. {% endblock head %}
  37. {% block title %}
  38. All Tags - {{ super() }}
  39. {% endblock title %}
  40. {% block content %}
  41. <div class="row-fluid">
  42. <header class="page_header span10 offset2">
  43. <h1><a href="/tags.html">All Tags</a></h1>
  44. </header>
  45. </div>
  46. <div class="row-fluid">
  47. <div class="span8 offset2">
  48. <form class="form-search">
  49. <input type="text" class="input-medium search-query filterinput" placeholder="Find a tag">
  50. </form>
  51. <ul class="list-of-tags">
  52. {% for tag, articles in tags %}
  53. <li>
  54. {% set num = articles|count %}
  55. <a href="/tags.html#{{ tag|replace(' ', '-')|e }}-ref">{{ tag }}<span>{{ num }}</span></a>
  56. </li>
  57. {% endfor %}
  58. </ul>
  59. </div>
  60. </div>
  61. <div class="row-fluid">
  62. <div class="span8 offset2">
  63. {% for tag, articles in tags %}
  64. <h2 id="{{ tag|replace(' ', '-')|e }}-ref" class="tag-title">{{ tag }}</h2>
  65. <ul>
  66. {% for article in articles %}
  67. <li><a href="{{ article.url }}">{{ article.title }}</a></li>
  68. {% endfor %}
  69. </ul>
  70. {% endfor %}
  71. </div>
  72. </div>
  73. {% endblock content %}