API cursor pagination jump to specific page - pagination

I'm looking into implementing cursor pagination in a project API that I'm building. I've got it setup so that the url contains /?cursor=<the next id> (EX: /?cursor=60 starts at ID 61). I've noticed that a lot of implementations will base64_encode the cursor value. I believe this is because it allows you to add more info the cursor (other filters, etc.). Once this encoding happens, it seems like you lose the ability to jump to a certain page, like you could with offset pagination or by not encoding the cursor.
Is this true? Is there something I'm missing to enable jumping to a certain page with cursor pagination using an encoded cursor?

Related

WebExtension API: Toggle DOM replace on/off

I'm just starting to work with the WebExtension API (on Safari rather than Chrome), and I've gotten as far as having the extension show a button in the popover ui and on clicking it the content.js script will replace any given word on a page with another given word.
This works great, but I'd like to have another button in the popover ui that easily reverses this replace call. Currently I just have it perform the same replace function but in reverse, but I'm wondering if there's a way to reverse all extension actions performed without having to define them a second time, and without simply refreshing the page to revert all changes.
Hope this makes sense, would appreciate any pointers anyone could give!
You didn't show us the code with which you make the replacements, but if you want to revolve the process a possible solution could be to wrap every single word\sentence you want to replace within a tag (e.g. span) and adding to it a property which "remember" the sostituted value.
I usually do something like this:
<span class="myExtensionId_className" data-previuosValue="foo">bar</span>

SharePoint search box not encoding special characters

We have a modern SharePoint site. We are using pnp search results webpart for displaying search results in a page. In search settings we are using this customized search results page instead of using out of box search.aspx page
Issue:
When we are entering some special characters like "C++" keyword in search box, these characters are not encoded and hence results are not coming properly.
It is supposed to come like
/Search.aspx?q=C%2B%2B
But it is coming as
/CustomReults.aspx?q=C++
I presume if we can get the query like below, it will work. But how to get that. Need help badly..
/CustomReults.aspx?q=C%2B%2B

Is line number/sign click detectable in vim?

Is there any way to detect clicks on line numbers or signs (just on line numbers or signs and nowhere else on the line) via a vim-plugin (i.e not extending vim code itself)?
First, offering a feature that is accessible only through the mouse won't get you many fans of your plugin, as many users avoid using the mouse.
Second, features such as the signs column are only marginally related to text editing, and as such aren't so fully featured as in IDEs.
Therefore, I don't think that's possible. Neither v:mouse_col (to be used with getchar()) can address the display cells outside the text buffer, nor does v:beval_col (for the balloon tooltips). You can only determine the width of the side columns by comparing wincol() with virtcol().
Better provide a (configurable) mapping for your plugin's feature; this is more universal.

Saving history of usage to offer suggestions

I have a small extension that perform local search.
It searches for the files matching that name in the local company files list and then opens a page with the results.
The extension has a text box where users type in the query.
The problem is that if I click the extension again and want to do a query that I already did previously, I need to type it out again.
I want the textbox to save history, and show suggestions when I start typing a new query.
How can I do this? The suggestion matching can be a very simple string matching, nothing fancy. But how/where canI save the history?
If you are asking about standard browser's autocomplete then I don't think there is a way to programmatically create it.
You can build your own with jQuery's autocomplete plugin, for example. You will just feed it previous queries and it will do the rest.
To store previous queries you can use localStorage, which you would need to access from a background page.

How to search a PDF in Acrobat Reader AND jump to a certain page via parameter?

We are using lucene within a web application to search in a great number of PDF documents.
The workflow is like this:
A user enters a search term
A list of search results is presented to the user.
Each search result represents one PDF document and shows the user on which page the search term was found. Each of these pages is represented as a hyperlink.
If the user now clicks on such a hyperlink, he directly jumps to that page.
But now the user has the problem that the search term isn't highlighted on the page. Therefore the user has to look on his own to find the search term on the page.
What we wanted is a way to highlight the search term on the specific page in the PDF.
The open parameters for Acrobat Reader allow for either searching a PDF document (with hit highlighting) OR jumping to a specific page. But the combination of both parameters - which we would need - doesn't work.
Does anyone have an idea how jumping to a page and highlighting a search term in a PDF document could work?
I had a look at the Acrobat SDK but don't see how we can use it (it's terribly documented).
acrobat uses a plugin to hilite terms, and requires a fdf stream to indicate the words to hilite.
See here for pointers:
support.dtsearch.com/dts0152.htm
update:
assuming you know the page# and word# on the page to hilight, here is one way to do it:
On web page:
<iframe id="acroframe" src="pdfpage/example.pdf#xml=http://example.com/hilite.aspx?hilite=8e3302ee-ff88-41ee-bdfb-9e8df87cc3ad&toolbar=1&navpanes=0&statusbar=0&view=FitH">
</iframe>
The PDF will appear in the frame, it will show the toolbar, hide the navpane & status bars and fit page to horizontal. Then it will query the web site to get the xfdf data for hilighting: http://example.com/hilite.aspx?hilite=8e3302ee-ff88-41ee-bdfb-9e8df87cc3ad
Here I used a guid key that I previously saved in the session with the hilite xfdf value.
The hilite.aspx page will return something like the following to hilite words in the document:
<XML>
<Body units=characters color=#ff00ff mode=active version=2>
<Highlight>
<loc pg=15 pos=3583 len=5>
</Highlight>
</Body>
</XML>
This will hilight 5 chars on page 15 starting at position 3583. (note: xfdf is not real "XML" despite the similarity)
Note that acrobat reader will have to have the "Enable search highlights from external highlight server" option checked in preferences.
Sorry might not be an answer, but a workaround could be to covert the PDF to html and use Lucene highlighter (similar to what Google does)
You'd have to write a snippet of Javascript to get the behavior you are looking for.

Resources