GabLeRoux / webextensions-history-browser

🕘 Browse your firefox history like a boss.
https://addons.mozilla.org/en-US/firefox/addon/webextensions-history-browser/
MIT License
20 stars 1 forks source link

Query search development #6

Open JulioJu opened 6 years ago

JulioJu commented 6 years ago

Hi

Thanks for your work. What is your plan for the future development ?

I believe a good feature who was in Norwell was the query search, especially the « - » operator. Example: « history -google ». It's a very good feature, not implemented in the built-in Firefox history.

Do you think implement this soon ?

GabLeRoux commented 6 years ago

For future development, I plan to do what I listed in ReadMe's todo.

For improved search, I wonder if there's some query language that could be easily included to do exactly this. I did a quick search in npm registry, but I'm not sure what keyword I should use. I'm not sure yet how I could implement - search yet.

I could quickly include datatables multi-filter which adds search fields to all columns.

My personal use case when I started the plugin was to have a date range picker to quickly see history based on a date range (ex: 1 week). I created the following feature/date-range-picker branch which I will update with master shortly.

JulioJu commented 6 years ago

Yes, I've seen your ReadME, but I only ask if you plan to continue the dev and when ? When do you think to implement Query search ?

I've read the Norvell source code. If I know the Trumpai code, he uses Regex. To answer to your question posted 8 month ago at https://addons.mozilla.org/en-US/firefox/addon/norwell/reviews/, to see source code simply download the extension and unzip it. As Trumpai says, this code is already Open Source. If you want reuse portions of his code, you must ask him to place it under MIT licence.

There is no dependencies in the Trumpai plugin. It's cool, because I think it's lightweight. Maybe it's not necessary to search in npm registry

If I understand the Norwell plugin, it pushes only the results who matches the regex.

For the date, if I understand the Norwell plugin, he uses the javascript Date Object. Each raw is associated to a Date. It displays only raw with Date => minDate && Date <= maxDate.

Maybe (it's not sure) in one month I'll could try to help you. But I'm not really sure to have any time. There is not emergency, actually we have Firefox ESR for legacy plugins ;-), or Waterfox (but I don't know if it is very secure).

JulioJu commented 6 years ago

For query search I think something like

    const result = [];
    const regexAdd = "/^.+history.+$/" // Or "/^.+history google.+$/"  if in the search string there is /^".+"$/ or /^'.+'$/
    const regexMinus = "/^+google.+$/" // (deduce from search terms « history -google ».  null if there  isn't $/^-\S$/  in the search string. 
    const dateMin =  new Date('2016-12-17T03:24:00'); // retrieve from UI
    const dateMax =  new Date('2017-12-17T03:24:00'); // retrieve from UI
    allHistory.forEach(function(item){
        const date = retrieveDate(item);
        if (date >= dateMin && date <= dateMax && isMatch(regexAdd) && ! isMatch(regexMinus)){
            result.push[item];
        }
    })

I don't know if it's possible to do something like that, or exactly like that. But there is the idea in this algorithm ;-).

Obviously, it could be cool to could have an infinite number of regex… i.e. in the search bar have several « -term1 », « -term2 », « "term 3" », « "term 4" »…

JulioJu commented 6 years ago

I try to write a pull request ;-)

GabLeRoux commented 6 years ago

I like the idea. Maybe we could have a enable regex search checkbox so one could search using a regex string directly.

I also plan to add some unit tests to the project just to make additions keep working on the long term. Project is already set to run them automatically in travis.

JulioJu commented 6 years ago

I've had not a much time this afternoon. The next week, I will not have lot of time too, but probably some hour the next week-end.

I believe we must customize https://datatables.net/plug-ins/filtering/row-based/range_dates#Example . (see example at https://github.com/DataTables/DataTables/blob/master/examples/plug-ins/range_filtering.html).

Could wait until the next week-end?

GabLeRoux commented 6 years ago

Sure, we can have a look next weekend. I did find the same links and examples as you. I also found vedmack/yadcf (Yet Another DataTables Column Filter) which has a few filters. It does support daterange, see server side source example.

Its date range filter uses jquery-ui and it feels old, but it could be a first working step for the date range.

Thanks for investigating this, have an awesome week.

If we go the acdf way, implementation should look something like that:

yadcf.init(oTable, [{
    column_number: 3, // date column numer, not sure if its the right one
    filter_type: "range_date",
    date_format: "mm/dd/yyyy",
    filter_delay: 500
}])
vedmack commented 6 years ago

yadcf also support bootstrap datetimepicker with moment, read more in the docs - datepicker_type and here is the link to a relevant showcase page. In addition, I hope to finish the integration of another bootstrap plugin soon https://github.com/vedmack/yadcf/issues/435