A 4kb mini interface for SuttaCentral.net suttas and Vinaya

Doh! :man_facepalming:t2: So obvious now. Thanks!

Well, itā€™s really all just because Bhante Sujato is making all the data public.

If you have any ideas for other things, Iā€™m always looking for practice projects.

1 Like

WAIT You know what I actually need? An interface this simple and clean which just searches the SuttaCentral edition of the PED. That would rule!

2 Likes

(whispers : the css is more expensive if you define element + class than if you just use the class. The browser has to match the class, then figure out if it matches the element. The general rule is, make selectors as complex as needed and no more.)

We should make a SuttaCentral Awesome page on Github that collects all the tools and stuff built on our data. Another one came up yesterday, a group in Malaysia is printing books.

Why donā€™t I do that, please remind me what Iā€™ve forgotten:

1 Like

Would you be willing to download the whole dictionary at once? Bhante @sujato, is there a search or dictionary API?

1 Like

The search is all going to be changing so I wouldnā€™t build on it.

3 Likes

Sure! If Iā€™m looking up one word, Iā€™m probably looking up several.

Also, netlify allows you to specify the cache length on a per-file basis I believe. So you can set the wholedictionary.js file to have a really long cache and then itā€™ll only need to be downloaded once (per month or whatever)

1 Like

I just updated this to allow for Kp, Dhp, Ud, Iti, Snp, Thag, Thig. Dhp has to be in the form of verse ranges exactly for the whole chapter.

2 Likes

Cool! Also I added this to our Awesome page.

Thanks, Bhante. Itā€™s really more of a test project, but maybe people will find it useful.

Right now it is getting itā€™s data directly from the github files. To me that seems like a really hacky way of doing things and that the ā€œtrueā€ way would be to use the official API. Would you agree? Is it somehow wrong to be using the Github files?

No problem using the Github files. The API is really just ā€œget the data from the Github files and assemble it in a way that is convenient for SCā€™s needsā€. So itā€™s up to what you want to achieve.

Ah, thatā€™s great. I had assumed that there was a ā€œbuildā€ of the website on different servers and that the API was somehow pulling from that.

For sure getting the data from the API will be an improvement once it is working. Only need to call one file and it includes previous/next info.

1 Like

OK! So the code for this app has been rewritten so that the content of the sutta is pulled from the SC API instead of from the files hosted on GitHub. To the ordinary user this wonā€™t matter at all. However it enabled me to easily add the previous and next suttas as links at the bottom.

The size of the downloded sutta information is slightly larger (a few kbs) but now there are only two fetch calls instead of three.

The original code can be found in this repository.

2 Likes

UPDATE:

Now you can access Bhante Brahmaliā€™s Vinaya translation with this tool. The code has to be slightly more complicated to figure out which authour to get, but the API works the same for sutta and vinaya.

Iā€™ve also added some code so instead of typing pli-tv-bi-vb-ss1 you can just type bi-ss1.

It still requires a perfect citation, though.

Please share any feedback.

2 Likes

Thank you for that one! :heart: :+1: :grin:

1 Like

OK! So Iā€™ve had to change the description in this part of the original post:

Is it really only 4kb?

Yes. And you get what you pay for, as you will see. There is no nothinā€™ except the Pali and English of the sutta and Vinaya. And the 4kb doesnā€™t count the data of the sutta itself. Just the interface. If you can even call it that.

Well, no. Not any more. Itā€™s still really small. And after the first time you visit the page it should cache everything, so you really will just be downloading a few kb to get the body of the text. The biggest part is now the font, which is a custom subset of Roboto Serif, at ~20kb. I felt that this would give a better reading experience overall. There are also several icons that are less than a kb each. And lots of little interface improvements (including a dark mode) have bumped things up to about 19kb + the font + the actual sutta you want to download. So, yeah, itā€™s probably smaller than any web page you are going to visit this week. And getting it back down to ~5kb would simply be a matter of pulling out things that arenā€™t essential.

Hopefully all of the added features are worth the extra 35kb the page takes when it loads the first time.

The biggest changes are the font and the dark mode. This is the first time Iā€™ve created a subset of a font, so hopefully I didnā€™t screw anything up. Iā€™m also very open to suggestions on the styling of the dark mode.

2 Likes