Forum > Pas2JS
Example Code: Simple ObjectPascal program for hosting a static website
(1/1)
kveroneau:
Hello everyone,
I recently created, in I think 1 or 2 days of actually work, this static website solution which uses TDataSet for storage in the web application, and is used in the desktop application which can be used to update the website. The website itself can be really extended, and if you need extra metadata, since I have open sourced it, fork it, and add your own custom fields.
I think this could be really good example code for anyone starting out with ObjectPascal and/or Pas2Js. I have also created a very useful Lazarus package for pas2js developers that I highly recommend checking out, with many useful utilities making creating pas2js applications so much easier. I aptly called this package jslib, which I admit now sounds incredibly generic, but I am not a branding genius nor ever care to be one. Anyways, allow me to present you with the links, and I'd really love any feedback and suggestions of course.
Static website system: https://github.com/kveroneau/kveroneau.github.io
You can of course see it all live from here: https://kveroneau.github.io/
For my pas2js package, you can check it out here: https://github.com/kveroneau/jslib
For Pas2js beginners from the above source code, you can expect to learn the following:
* How to use a TExtJSONDataSet in a browser application, of which I highly recommend using my TJSONTable class in jslib.
* Supporting the obtaining of resources either through the {$R} directive or through a web request.
* The parsing and using of a TDataSet in your browser application.
* Basic usage of the webrouter.
* How to call ObjectPascal methods from JavaScript, if that's ever needed.
For ObjectPascal beginners, there is also a full desktop application which acts as the Database editor for the data which is used by the above web application, here is what you can expect to learn from this project:
* How to build a basic database desktop applications using Tdbf
* While Tdbf might sound like an outdated format from the 80s, the program shows how it is very useful as a local database.
* Demos the use of the TJSONExporter, which I believe still has a bug, which I needed to patch. I think I may contribute a brand-new component, but based on fpjson instead of trying to generate a JSON string.
If you are interested in seeing additional example ObjectPascal code, then my pim repository on GitHub is a nice resource: https://github.com/kveroneau/pim
Anyways, I hope the ObjectPascal static website is interesting to some of you as a way to host an ObjectPascal-based website on GitHub.io! I personally think Pas2Js is rather amazing at how little code I really need to write to do so much. When I see other web frameworks and people showing how to do this and that in these so-called modern web frameworks, I tend to scoff, especially after seeing just how powerful and seamless using a TExtJSONData is, and I have been playing around with the REST fp-web stuff, and can really see how much potential ObjectPascal has in this front.
I also created a page on this static website to learn more about how the website itself works: https://kveroneau.github.io/#/AboutSite
Screenshots of the Database Admin tool can be seen here: https://kveroneau.github.io/#/AdminTool
I made it as extendable as I could from the get-go, so someone could easily fork it, update the HTML file with their own theme, add new content-types to both the website and to the Admin tool all with general simplicity.
cdbc:
Hi
@kveroneau: NICE :) Good on you mate, I like your work...
Regards Benny
Navigation
[0] Message Index