Closed daviddurand closed 12 years ago
This first batch of questions has already gotten larger than I expected. It's definitely helpful to me if you can answer what you can, what excites you, and what takes your fancy. I'll be proceeding in parallel with gathering your input, and as this is the foundation for what I expect will eventually be an important API, remember that I'm evaluating options, not simply taking orders for features.
While I have to be the final judge on the technical decisions, the result should meet as many of your use cases as we can in the available time. So try to explain not just what you prefer, but why you prefer it. I'm also especially interested in knowing about libraries that you are using that have expectations about APIs, as conforming to existing (popular) library expectations increases the reach of whatever we may do.
In particular I want to move a lot of Tizra stuff to jQuery as soon as it's practical, so I think we are in rough agreement about tooling.
It seems like it might make sense to filter metadata properties so that you can request exactly the properties that you want, and reduce data traffic -- also we know that list properties and some full-text items, like abstracts, homepage descriptions, and HTML fields can tend to be large. I'm thinking of a few possible options, which would be most helpful?
Independent of these are a number of global questions about how the API might work:
["value1", "value2" ... ]
Long arrays would return an object representing a continuable group:
{"paginated-list" : [ "value1" ... ],
"next" : { "JSon URL"} }
I'm looking at JSon->HTML packages, and a lot of them are pretty considerable templating packages. PURE is one option that seems pretty nice, and Mustache is also intriguing. But these are relatively large solutions.
Thanks David.
To your first question on metadata my preference would be for the default request mode to return a list of the most-likely useful information based on which fields are marked as shown to users or maybe even an "expose to API" option that would show up with "Shown to users?" and "Include in Advanced Search?" on the document properties screen.
To the more general question I'm usually in favor of getting the big pieces of data in one big chunk. As long as good visual feedback is provided to the user a longer load time doesn't bother me and actually cuts down on bandwidth since you have less overhead for http requests/headers. it also cuts down on the work you and I have to do to split this up and put it back together. If we did need to paginate something we would definitely need to have control over page size and position but I don't think we would need to get that information passed back from you.
It would probably come in handy at some point to have a "Type" field to switch on but I'm not 100% sure I would use it. I tend to just use a separate anonymous function for each request type.
I do like URL based parameters in this kind of application too. I can't think of a reason we would need to send very long values but I'm sure there are a lot of things I can't think of now. Either way its easy for me to use post too on my end so just let me know how it will work and It shouldn't be a big deal.
As for tools that I use JQuery pretty much covers it. I would probably use a templating plugin like PureJS or Mustache. jsRender isn't quite in beta yet but I'm a big fan of Boris' work: https://github.com/BorisMoore/jsrender.
I hope this feedback is helpful!
I've finally got the doc up. https://github.com/Tizra/Tizra-Customer-Tracker/wiki/JSon
I've got to add one more thing (notes about how paging through results works), but it should be pretty usable.
I'm looking into implementing this for a replacement for the collection list block. I'm going to extract the 'url-id' from window.location.href for now but in the future it might be useful to have a macro that would return this. Maybe something like this exists already but I'm not aware?
Is there a mechanism to sort collection listings? That's important for us.
We need property sort values to be respected (or at the very least exposed so I can sort them) as well
OK. Thanks David.
Sorting turns out to be hard, at the moment, because of some of the optimizations that make it fast, so you should probably sort in Javascript -- It'll be a while before sorting gets into the JSon stuff.
Because the field visibility thing was turning out to be a pain, (and would be worse for sort fields), I've added a new JSon visibility flag to properties, so you should be able to make any property visible without the hacking around we were doing.
This should make it easy for you to send JSon info for sorting even if you don't want people viewing and searching it.
You should use the field filtering parameters on the JSon stuff to send just the fields you actually need -- it should make a big performance difference.
If you can't sort on your end then the paging we were promised is useless because the first load won't be loading documents that belong on the first page.
In fact isn't paging mandatory on long lists? How is that going to work?
I would have to do multiple ajax requests, aggregate all of the documents into a huge array and sort that? I don't think we would see a performance increase doing things that way.
I was not thinking of the ajax queries as a replacement for the list block -- though it is one way to handle paging with less work on the server side than what I've been thinking of. I agree that paging of unsorted lists is pretty useless, although you can specify your own paging limit using the limit parameter. It will be respected up to 1000 items, which should meet any JSon needs for page display. For data export and the like, where the lists may be very long, limits really do make sense.
I do intend to look into the sorting for these reasons, but we are working on the static export fixes now (actually interrupting the reader work), and so it can't be immediate. Same for looking at the header macros. (issue #67)
Yes. Those static export items are definitely a higher priority. I'll just hold off on JSON dev tasks for now.
Thanks David!
Since I was looking at the api anyway, I've added sorting. It's live now.
api version is now 1.1.0. The /api/ result gives the basic documentation. Wiki updates will follow.
This doesn't seem to be listing collection contents properly now. This URL
http://omniplayground.tizrapublisher.com/api/query/contents?tizra-id=2btkr8&limit=100
Should be listing 10 to 15 documents but all I'm seeing are the sites collections.
After a few tests sort-prop seems to be working.
Thanks David.
Collection contents are fixed, and can be sorted. Change is already live.
Thank you David. Now I need a way to sort the properties under each document. Would it be hard to order those by the property sort value?
Also I'm not seeing how to get the display names of any of these document properties.
All metadata properties of content objects that you manipulate within Tizra: collections, books, excerpts, pages, etc.
Notes:
Will include account name, email, etc.