tags.html 2.5 KB

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