hashcss / hashcss.com

Official Site for #CSS on Libera Chat
MIT License
5 stars 0 forks source link

Build API for selvvir commands #1

Open pudly opened 10 years ago

pudly commented 10 years ago

As discussed, lets get a JSON api going for all the selvvir commands, I'll build out everything to absorb it on the front

AMcBain commented 10 years ago

Do you care to have the URLs in the factoid values delimited in some manner? I think it inappropriate to deliver markup of any kind in the value (as that makes an assumption) but perhaps as a list of indexes. It's easy to do it but if you wouldn't use it, then no need for me to bother. I already do it in some form for the dump visible at https://selvvir.asmcbain.net/factoids

AMcBain commented 10 years ago

I can also potentially offer a more concise API output if I don't need anything other than just the raw name to values.

oksushi commented 10 years ago

Could be handy to break the factoids out into cue:text:url groups, like:

["alot","Beware of the Alot","http://hyperboleandahalf.blogspot.com/2010/04/alot-is-better-than-you-at-everything.html"]

AMcBain commented 10 years ago

Some have more than one URL, though.

Some thoughts I had, and these are by no means exhaustive of the options or the only combinations of sub bits:

{
    "key1": {
        "value": "this is a value with a URL: http://example.com and following text",
        "urls": {
            "28": 45
        }
    }
}

[{
    "name": "key1",
    "value": "this is a value with a URL: http://example.com and following text",
    "urls": [[28,45]]
}]

Without any extra info included, then there's no need to for a sub object and I could provide:

{
    "key1": "value1"
}

The only issue with the top-level-map ones is that there's no default ordering that can be implied (like alphabetical).

AMcBain commented 10 years ago

At least as a quick temporary for review I've got https://selvvir.asmcbain.net/api/factoids and https://selvvir.asmcbain.net/api/factoids/simple running. The former does the second idea in the first box in my previous post, and the latter does the idea in the last box. The former actively indicates aliases, the latter dumps an internal representation. We can tweak what we want from at least seeing those--such as perhaps having aliases return the value of the factoid they point to instead of being marked as an alias--and get rid of the URLs we don't want.

Also, they're like my existing website: one large dump. An alternate API URL as part of offering ways to access the non-admin commands will be available to return only matching factoids instead of all when I get there. It'll return the preferred output we decide upon here.

pudly commented 10 years ago

This looks great, i'll do a quick parser by Tuesday, just finished implementing foundation framework on the front end of things, and wrote the jekyll structure for the wiki section

AMcBain commented 10 years ago

The commands: https://selvvir.asmcbain.net/api/commands This doesn't include the usage bits (how to use flags, or the "@" syntax), but I consider those in stone: I don't foresee myself changing them. So the paragraphs and such about that ( https://selvvir.asmcbain.net/ ) can be copied without a real fear of going stale.

I also now have https://selvvir.asmcbain.net/api/factoids/flat which is the same as the base /api/factoids list-based results except aliases are expanded to the same value as what they point to. One of these will end up being useful ...

AMcBain commented 10 years ago

Except for admin-only commands, I can make available an ability to call the commands listed by /api/commands if wanted, but I don't know if this is of use, and some of them like g, v, and short can be interfaced directly to the original services if needed instead of going through an extra layer (Selvvir's code).