From 3711035ad4e756c406faaebe2e74446f3355665e Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Mon, 12 Dec 2022 19:22:10 -0300 Subject: [PATCH] Set Initial Query from URL Query Parameter in Elfeed Web, if present - What - Before - Cannot customize the initial query, which is set to `@3-days-ago' - After - Set initial query to load entries in elfeed-web via url query parameter, i.e `?q=' - Illustration - Open `/elfeed/?q=%2bimportant%20%4030-days-ago' in web browser - This sets initial query to `+important @30-days-ago' - And loads entries tagged as "important" from >30-days-ago - Why - Simplifies customizing initial query to use for loading entries - Create browser bookmarks to your standard elfeed filters. Especially useful when accessing elfeed web via phone as a web app. Reduce unnecessary typing for accessing standard filters. --- web/elfeed.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/web/elfeed.js b/web/elfeed.js index bdab089..dc12582 100644 --- a/web/elfeed.js +++ b/web/elfeed.js @@ -19,7 +19,10 @@ function entryFill(entry) { } function SearchCtrl($scope, $http) { - $scope.query = INITIAL_QUERY; + // Populate query scope with value passed in URL query parameters, if any. + var query_via_url = new URLSearchParams(window.location.search).get("q"); + + $scope.query = query_via_url || INITIAL_QUERY; $scope.busy = false; $scope.dirty = true;