From 282584e035af7888685a5df44b813e759dc49cf9 Mon Sep 17 00:00:00 2001 From: Matěj Grabovský Date: Thu, 26 Mar 2015 21:39:01 +0100 Subject: A bit more consistent formatting in catalog template --- stylesheets/fonts/OpenSans-Light-webfont.eot? | Bin 19084 -> 0 bytes templates/themes/catalog/catalog.html | 117 +++++++++++++------------- 2 files changed, 59 insertions(+), 58 deletions(-) delete mode 100644 stylesheets/fonts/OpenSans-Light-webfont.eot? diff --git a/stylesheets/fonts/OpenSans-Light-webfont.eot? b/stylesheets/fonts/OpenSans-Light-webfont.eot? deleted file mode 100644 index 12430030..00000000 Binary files a/stylesheets/fonts/OpenSans-Light-webfont.eot? and /dev/null differ diff --git a/templates/themes/catalog/catalog.html b/templates/themes/catalog/catalog.html index 45239c5b..6cc75a7d 100644 --- a/templates/themes/catalog/catalog.html +++ b/templates/themes/catalog/catalog.html @@ -18,74 +18,75 @@
{{ settings.subtitle }}
- - - {% trans 'Sort by' %}: - - - {% trans 'Image size' %}: - -
- + + {% trans 'Sort by' %}: + + + {% trans 'Image size' %}: + + +
+
    + {% for post in recent_posts %} +
  • -
    - - {% if post.youtube %} - - -
    - R: {{ post.reply_count }} / I: {{ post.image_count }} - {% if post.subject %} -

    - - {{ post.subject|e }} - -

    - {% else %} -
    - {% endif %} +
    + + {% if post.youtube %} + + +
    + R: {{ post.reply_count }} / I: {{ post.image_count }} + {% if post.subject %} +

    + + {{ post.subject|e }} + +

    + {% else %} +
    + {% endif %} + + {{ post.body }} +
    +
    +
  • + {% endfor %} +
+
- {{ post.body }} -
- - - {% endfor %} - - -
- + {% endfilter %} -- cgit v1.3 From 20ce6999d2a069919754978a4a6aa32e939b523d Mon Sep 17 00:00:00 2001 From: Matěj Grabovský Date: Thu, 26 Mar 2015 21:43:26 +0100 Subject: Wrap controls on the catalog page in a div --- templates/themes/catalog/catalog.html | 40 ++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/templates/themes/catalog/catalog.html b/templates/themes/catalog/catalog.html index 6cc75a7d..12b3cd98 100644 --- a/templates/themes/catalog/catalog.html +++ b/templates/themes/catalog/catalog.html @@ -18,27 +18,29 @@
{{ settings.subtitle }}
- +
+
    +
  • {% trans 'Bump order' %}
  • +
  • {% trans 'Creation date' %}
  • +
  • {% trans 'Reply count' %}
  • +
  • {% trans 'Random' %}
  • +
- {% trans 'Sort by' %}: - + {% trans 'Sort by' %}: + - {% trans 'Image size' %}: - + {% trans 'Image size' %}: + +
    -- cgit v1.3 From 32821745c632bff01feb58cd234295dceaeea2a5 Mon Sep 17 00:00:00 2001 From: Matěj Grabovský Date: Thu, 26 Mar 2015 22:32:00 +0100 Subject: Add a simple search functionality to the catalog Requires commit 20ce699 which adds a wrapper for the controls on the catalog page. --- js/catalog-search.js | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 js/catalog-search.js diff --git a/js/catalog-search.js b/js/catalog-search.js new file mode 100644 index 00000000..07e21f87 --- /dev/null +++ b/js/catalog-search.js @@ -0,0 +1,45 @@ +/* + * catalog-search.js + * https://github.com/mgrabovsky/lainchan/lainchan/blob/catalog-search/js/catalog-search.js + * + * Released under the MIT license + * Copyright (c) 2015 Matěj Grabovský + * + * Usage: + * $config['additional_javascript'][] = 'js/jquery.min.js'; + * $config['additional_javascript'][] = 'js/catalog-search.js'; + */ + +(function() { + +var catalogSearch = function() { + var $controls = $('.controls'), + $threads = $('.threads .thread'), + $searchLabel = $(''), + $searchBox = $(''); + + $controls.append($searchLabel) + .append($searchBox); + + $searchBox.change(function() { + var query = new RegExp(this.value, 'm'), + $found = searchThreads($threads, query); + $threads.hide(); + $found.show(); + }); +}; + +// Filter threads by their content, given a regex. Can be extended later to load data +// remotely and filter by multiple fields +var searchThreads = function($threads, re) { + return $threads.filter(function() { + return re.test($('.replies', this).text()); + }); +}; + +// Only load in the catalog +if (active_page == 'catalog') { + onready(catalogSearch); +} + +}()); -- cgit v1.3 From 3d2ddb8c3b3eb0f1d5c697bc9dcf7faf371f6708 Mon Sep 17 00:00:00 2001 From: Matěj Grabovský Date: Fri, 27 Mar 2015 13:38:45 +0100 Subject: Make catalog search case-insensitive & instantaneous --- js/catalog-search.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/catalog-search.js b/js/catalog-search.js index 07e21f87..b91fc1ea 100644 --- a/js/catalog-search.js +++ b/js/catalog-search.js @@ -21,9 +21,8 @@ var catalogSearch = function() { $controls.append($searchLabel) .append($searchBox); - $searchBox.change(function() { - var query = new RegExp(this.value, 'm'), - $found = searchThreads($threads, query); + $searchBox.keyup(function() { + var $found = searchThreads($threads, this.value); $threads.hide(); $found.show(); }); @@ -31,7 +30,8 @@ var catalogSearch = function() { // Filter threads by their content, given a regex. Can be extended later to load data // remotely and filter by multiple fields -var searchThreads = function($threads, re) { +var searchThreads = function($threads, query) { + var re = new RegExp(query, 'mi'); return $threads.filter(function() { return re.test($('.replies', this).text()); }); -- cgit v1.3 From 6b37abab85ad342fd18e5c09c65248634e7dd194 Mon Sep 17 00:00:00 2001 From: Matěj Grabovský Date: Fri, 27 Mar 2015 13:55:01 +0100 Subject: Allow catalog search by a URL fragment (#s=...) --- js/catalog-search.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/js/catalog-search.js b/js/catalog-search.js index b91fc1ea..3235d1dc 100644 --- a/js/catalog-search.js +++ b/js/catalog-search.js @@ -26,9 +26,14 @@ var catalogSearch = function() { $threads.hide(); $found.show(); }); + + var m = location.hash.match(/[#&]s=([^&]+)/); + if(m) { + $searchBox.val(decodeURIComponent(m[1])).keyup(); + } }; -// Filter threads by their content, given a regex. Can be extended later to load data +// Filter threads by their content, given a regex. Can be extended to load data // remotely and filter by multiple fields var searchThreads = function($threads, query) { var re = new RegExp(query, 'mi'); -- cgit v1.3 From 7b33348a16e04f68458d1d2f876fbea27e9cb14d Mon Sep 17 00:00:00 2001 From: Matěj Grabovský Date: Fri, 27 Mar 2015 13:59:41 +0100 Subject: Fix source URL in comment --- js/catalog-search.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/catalog-search.js b/js/catalog-search.js index 3235d1dc..ac7ef57a 100644 --- a/js/catalog-search.js +++ b/js/catalog-search.js @@ -1,6 +1,6 @@ /* * catalog-search.js - * https://github.com/mgrabovsky/lainchan/lainchan/blob/catalog-search/js/catalog-search.js + * https://github.com/mgrabovsky/lainchan/blob/catalog-search/js/catalog-search.js * * Released under the MIT license * Copyright (c) 2015 Matěj Grabovský -- cgit v1.3