musictopia2 / NewTestament5DayReadingProgram

This is a web assembly app where it allows people to participate in a program to read through the entire new testament in one year by reading Monday through Friday
MIT License
2 stars 0 forks source link

Incorporate Bible API #1

Open kevmoens opened 2 years ago

kevmoens commented 2 years ago

I downloaded the code and built it to run on a Mac. It ran. VS2019 Mac didn't work,I had to use command line for .NET 6. Yet when running I was only able to get day to show data. I am assuming that was the design, but could we implement an API?

I saw https://scripture.api.bible/ and it has 5,000 free API calls a day. That might be something that would be useful to make this app easier to use when people clone it down.

musictopia2 commented 2 years ago

It was by design to do by day. The only problem with using the api for the bible is then it requires internet access. Since my works as a PWA, then it works completely offline. What I did was I parsed the data from BibleGateway. Could never get it completely perfect (sometimes had extra spaces or occasionally 2 words lumped together). I was going to use static site eventually. What I don't know is if somebody cloned it and made their changes, not sure if it would suddenly update my site (hopefully not). I do have another site here https://musictopiabible.azurewebsites.net/ Which uses the same bible data that allows you to search for some translations and for books. Has different look for mobile than for desktop. Also, it can be easy to have a version of this that uses the api. Because the way this was designed is interfaces are used for actually getting the information (including figuring out what translations to show up). Means the main program does not care where the verses come from.

musictopia2 commented 2 years ago

Let me know what you think of the site mentioned. Currently, uses .net 5. eventually was going to upgrade to .net 6 but have not done yet. That was actually my first bible app created. I use that even on my phone that works with no internet access.

kevmoens commented 2 years ago

Not sure if there is a limitation but we could sync books or chapters from the API to a Sqlite database.
I am just learning Blazor. I am a WCF/WinForms/Xaml(WPF, XF, UWP) developer. I have been using the #CSHARPCHALLENGE to learn blazor. I am starting to feel more comfortable with pages, html and binding. I have even done playing to create MVVM with Blazor. Yet storing data, security, etc. The ins and outs of web / browser development I am still picking up on.

I think I will give a shot at creating a PR for you to see what I can put together. My first question I have is where do I put API key for the commit so you can use it and it isn't visible in GitHub.

musictopia2 commented 2 years ago

Only possible issue of using sqlite would be it would be very slow to load. Because it would have to load the entire file instead of what is needed. What happens currently is when asking for chapter/book/translation, then it asks for it (whatever is registered in dependency injection will run and return the data). If you are able to make it work with sqlite with webassembly and have just as fast performance, that would be great. However, if it takes a long time for the first load, that would not be good.

musictopia2 commented 2 years ago

Here is a repository for example for the new living translation https://github.com/musictopia2/BibleNLTTranslationLibrary I also created a source code generator here https://github.com/musictopia2/BibleTranslationsGenerator that generates c# strings for them to have the best performance possible.

kevmoens commented 2 years ago

So we probably need to have multiple SQLite repositories so there are multiple files so it loads fast.

One Nuget I like to use is Neleus.DependencyInjection.Extensions. Then I can have multiple implementations of the same interface. That way I then can resolve it with a key.

musictopia2 commented 2 years ago

Are you able to load sql lite databases with webassembly? Because the main requirement is it has to work completely offline so even if they have no internet access somewhere, it can still work.

kevmoens commented 2 years ago

This thread looks like there are conflicting views. Yet it sounds like .NET 6 is possible. https://stackoverflow.com/questions/67966259/why-is-it-not-possible-to-use-sqlite-in-blazor-webassembly

musictopia2 commented 2 years ago

There was a sample that Steve Sanderson did that showed it was possible via .net 6 but was very hard. I could not get it to work. They are expected to make it easier but not until .net 7. If you can somehow get it to work, that would be great.

kevmoens commented 2 years ago

It sounded like the sample link above is more of an in memory storage. Refreshing the client can clear the cache. Yet I saw a Nuget called "Blazored".

https://visualstudiomagazine.com/articles/2020/09/08/blazor-pwa-local-storage.aspx Maybe we don't need SQLite. We can just SetItemAsync and GetItemAsync.

musictopia2 commented 2 years ago

I do know you are limited to 5 megs of local storage though. That is the problem. I actually created something like blazored but better because its simply extensions instead of having to register the interface. I also know that for i phone users, if they don't use it in 7 days, then it gets deleted as well.

musictopia2 commented 2 years ago

My repository that has many blazor helpers is here https://github.com/musictopia2/BlazorBasicLibrariesSolution Let me know what you think of that one. That has something like Blazored but much better. I even have toasts, messagebox popups, combo boxes and many other things.

musictopia2 commented 2 years ago

Actually the issue of people having a hard time cloning is related to this issue that I posted in November https://github.com/dotnet/aspnetcore/issues/38371

The real issue is not even the bible verses but the BasicBlazorLibrary. That is because it requires lots of javascript. There is a bug currently in the cli that if you do the command to create nuget package without also doing a build, then it includes unnecessary assets. On my end, I was able to work around it. However, it makes it very difficult to make it work on other computers. I discovered that issue when I got a new computer and tried the site and it failed. However, the api site you gave can still be good. Because I could use it to slowly reimport the verses so I don't have my parsing errors. That can allow to eventually allow other translations (with the 5000 free limit), i can run a process that would do up to 5000 per day to capture the verses (i would still have in json format).

musictopia2 commented 2 years ago

Let me know if you are able to run the 5 day reading program on your computer now. I made the changes so it won't have the javascript files anymore (had to do a workaround temporarily until .net 7) because of a bug that they won't fix until .net 7.

kevmoens commented 2 years ago

I downloaded Visual Studio for Mac 2022 preview 7. It now loads and runs without having to use VS Code and terminal. I found that these buttons don't show text.

Screen Shot 2022-03-19 at 7 30 49 PM

Since those components live in a NuGet Package it makes working in this environment tough for me. I was thinking of jumping to that repo but updating the package and then referencing it by this repo. I don't know how to setup this environment to make it easy for me to develop. Sorry.

musictopia2 commented 2 years ago

The next days reading is monday. as far as i can tell, its still working. Let me know on monday if it works. since the readings are mondays through fridays.

musictopia2 commented 2 years ago

i can tell you this references all the latest stuff from all my libraries. let me know on monday if it works. what should happen is when you finish the reading, you will get the screenshot and then the next day should show the readings again.

musictopia2 commented 2 years ago

If you mean the part that shows no text is the circles, the purpose is for a drop out menu. I've seen some of those. Therefore, I created it so when you click, then can show a drop down. I created a special control for it (used svg for circles). This idea can be used in many places.