#1 2022-06-21 11:05:25

tbo
Member
Registered: 2015-04-20
Posts: 335

A small example in response to a question

You can find the example with explanations and sourecode here (forum Delphi-PRAXIS). The text is written in german, the sourcecode uses english names. Sourcecode and program can be found in the appendix.

The example is the answer to a forum member's question and the implementation of one of two solution variants, all with mORMot. I wrote this example because I noticed that answering a question with the reference to mORMot and the necessary functions has no effect. I think without concrete introduction with full source code to play with, mentioning mORMot makes no sense.

The example shows a very simplified image database with the following technical details:

  • An embedded SQLite database that can be optionally AES encrypted.

  • Complete tasks such as storing and reading records with the built-in ORM.

  • A full text search using the Title and Comment fields.

  • A field for meta data that can contain different fields for each record and can be queried via SQL.

  • Acceleration in saving and reading graphic formats JPEG, PNG, GIF, TIFF.

The interface is kept very simple and includes only a few functions. The source code is written in such a way that it invites you to try it out on your own.

With best regards
Thomas

Offline

#2 2022-06-21 12:53:01

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,207
Website

Re: A small example in response to a question

Thanks a lot Thomas.

Could we add this sample as third-party sample in the mORMot repository?

note:
Just instead of DynArrayCopy() you may have used directly pmResultIDs^ := searchIDs;

Offline

#3 2022-06-21 15:51:54

tbo
Member
Registered: 2015-04-20
Posts: 335

Re: A small example in response to a question

ab wrote:

Could we add this sample as third-party sample in the mORMot repository?

You are welcome to do that. I have no experience with licensing or legal issues. If a disclaimer is missing, please add it. Make any changes you feel are necessary.

ab wrote:

note:
Just instead of DynArrayCopy() you may have used directly pmResultIDs^ := searchIDs;

I thought of that, but out of caution, I preferred to make a copy of the array. Maybe that was a little too cautious. Thank you for the tip.

This was my first complete article with the topic mORMot. In the past I only posted hints about mORMot, or posted single functions like this as an answer. I hope the beginning with the help of the sourcecode is easier.

I have tested the article with Google Translator. The result is not perfect, also some formatting is destroyed, but it is readable.

With best regards
Thomas

Last edited by tbo (2022-06-21 16:17:49)

Offline

#4 2022-06-26 19:57:41

tbo
Member
Registered: 2015-04-20
Posts: 335

Re: A small example in response to a question

I have the example ready for my next article. Are you interested to see the source code in advance?

With best regards
Thomas

Offline

#5 2022-06-29 11:06:39

tbo
Member
Registered: 2015-04-20
Posts: 335

Re: A small example in response to a question

I have published my second article with the topic mORMot here (forum Delphi-PRAXIS). The text is written in german, the sourcecode uses english names. Sourcecode and program can be found in the appendix.

With the example code you get:

  • A ZIP file as data storage, which can optionally store entries encrypted with AES.

  • Connection of a progress indicator with the help of a mediator.

  • Introducing a function that can AES encrypt and decrypt a file.

  • Acceleration in saving and reading graphic formats JPEG, PNG, GIF, TIFF.

  • And some little things more...

Here is the translation into English with Google Translator. The result is not perfect, also some formatting is destroyed, but it is readable.

With best regards
Thomas

Offline

#6 2022-07-09 11:10:13

tbo
Member
Registered: 2015-04-20
Posts: 335

Re: A small example in response to a question

I have published my third article with the topic mORMot here (forum Delphi-PRAXIS). The title is: Introduction to method-based services - server and client. The text is written in german, the sourcecode uses english names. Sourcecode and program can be found in the appendix.

With the example code you get:

  • An HTTP server for HTTP/1.0/1.1 requests.

  • Authentication of the user on the server and creation of a user-specific directory.

  • Login with the client to the server and exchange content list and image documents.

  • Connection of a progress indicator with the help of a mediator.

  • Acceleration in saving and reading graphic formats JPEG, PNG, GIF, TIFF.

  • And some little things more...

Here is the translation into English with Google Translator. The result is not perfect, but it is readable.

With best regards
Thomas

Offline

#7 2022-07-09 13:51:16

Prometeus
Member
From: USA
Registered: 2020-11-20
Posts: 42

Re: A small example in response to a question

Hi Thomas!


   Thank you for your series of articles and samples! Have sure that they are helping clarify a little more the "how-to" in the mORMot world, that powerful but sometimes hermetic (until you figure it out...) series of frameworks.

   Have a great day!

Offline

#8 2022-07-14 11:09:01

tbo
Member
Registered: 2015-04-20
Posts: 335

Re: A small example in response to a question

I have published my fourth article with the topic mORMot here (forum Delphi-PRAXIS). The title is: Introduction to interface-based services - server and client. The text is written in german, the sourcecode uses english names. Sourcecode and program can be found in the appendix.

With the example code you get:

  • An HTTP server for HTTP/1.0/1.1 requests.

  • Authentication of the user on the server and creation of a user-specific directory.

  • Login with the client to the server and exchange content list and text documents.

  • A simple Markdown editor with preview of HTML output in the browser window.

  • And some little things more...

Here is the translation into English with Google Translator. The result is not perfect (rather average), also some formatting is destroyed, but it is readable.

With best regards
Thomas

Offline

#9 2022-07-14 12:41:38

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 392

Re: A small example in response to a question

Thanks a lot Thomas!!!

Offline

#10 2022-07-14 16:12:18

Prometeus
Member
From: USA
Registered: 2020-11-20
Posts: 42

Re: A small example in response to a question

tbo wrote:

I have published my fourth article with the topic mORMot ...

Awesome!

Offline

#11 2022-07-15 10:10:15

edwinsn
Member
Registered: 2010-07-02
Posts: 1,215

Re: A small example in response to a question

That's how a great library gets popularized. Well done, tbo!

Is it about mORMot 1 or mORMot 2?


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#12 2022-07-15 12:29:42

tbo
Member
Registered: 2015-04-20
Posts: 335

Re: A small example in response to a question

Thank you for the kind words to all.

edwinsn wrote:

Is it about mORMot 1 or mORMot 2?

The source code for the examples are for the latest version of mORMot2.

With best regards
Thomas

Offline

#13 2022-07-19 16:04:24

flydev
Member
From: France
Registered: 2020-11-27
Posts: 50
Website

Re: A small example in response to a question

Nice serie ! Keep up the good work Thomas cool

Offline

#14 2022-07-20 03:29:08

edwinsn
Member
Registered: 2010-07-02
Posts: 1,215

Re: A small example in response to a question

Maybe put all the code in a github repository?


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#15 2022-07-30 10:01:55

tbo
Member
Registered: 2015-04-20
Posts: 335

Re: A small example in response to a question

I have published my fifth article with the topic mORMot here (forum Delphi-PRAXIS). The title is: Mustache editor with integrated HTTP server for displaying HTML pages. The text is written in german, the sourcecode uses english names. Sourcecode and program can be found in the appendix.

With the example code you get:

  • A simple mustache editor (TMemo/TSynEdit component) with auto-completion for common HTML tags.

  • An integrated HTTP server for HTTP/1.0, HTTP/1.1, HTTPS with self-signed or own certificate.

  • The Edge web browser for viewing HTML pages with undockable stand-alone window.

  • Direct linking of images, CSS, JavaScript from ZIP files into the HTML page.

  • And some little things more...

Mustache Editor Instruction Manual:

  • Edge Browser is used for the display. With the function key "F5" the display is refreshed. With "F6" the project data are saved. If a project name has been assigned, it is saved immediately.

  • Images, CSS, JavaScript, JSON or ZIP files are loaded only from the assets directory. The folder structure/directory depth in a ZIP file is not limited. Example of a path is: Bootstrap.zip/bootstrap.min.css

  • Partials for Mustache Renderer can only be loaded from the Partials directory. Partials correspond to Pascal include files.

  • The Bootstrap files "bootstrap.min.css" and "bootstrap.bundle.min.js" are always added.

  • External files are loaded in order of appearance. Possible to specify the order of Bootstrap files by entering "*.css" or "*.js" in the order.

  • JavaScript files are loaded with option "defer". This behavior can be influenced. By prepending a "!" directly to the file name, it is loaded immediately. Prefixing a "?" will load with the "async" option.

  • The root for loaded JSON data is the filename. The JSON object from the Person.json file is addressed with "Person.FirstName".

  • The auto-complete for Mustache Editor covers common HTML tags. The definitions are stored in the file HtmlAutoComplete.dci.

  • The browser window can be undocked and placed as a stand-alone view.

Here is the translation into English with Google Translator. The result is not perfect (rather not so good), also some formatting is destroyed, but it is readable.

With best regards
Thomas

Offline

#16 2022-07-30 11:31:02

Prometeus
Member
From: USA
Registered: 2020-11-20
Posts: 42

Re: A small example in response to a question

One more great contribution!

Thanks, Thomas!

Offline

#17 2022-07-30 17:04:44

igors233
Member
Registered: 2012-09-10
Posts: 234

Re: A small example in response to a question

Perhaps your samples could be introduced to thirdparty demos.

Offline

#18 2022-08-16 13:13:42

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,207
Website

Re: A small example in response to a question

I took the liberty to integrate all five articles into the thirdparty demos folder.
https://github.com/synopse/mORMot2/tree … yDemos/tbo

It was a quick & dirty inclusion, with only a very quick review of the google-translated content.
I used basic markdown formatting, and made only a very few minor changes.

Thanks again Thomas for sharing!

Offline

#19 2022-08-16 21:21:59

tbo
Member
Registered: 2015-04-20
Posts: 335

Re: A small example in response to a question

ab wrote:

I took the liberty to integrate all five articles into the thirdparty demos folder.

Thanks for including my examples.

For the 05-WebMustache example, a readme should be created with the link to the WebView2Loader.dll download page. The DLL should simply be copied into the program directory. It can be loaded from here: Microsoft.Web.WebView2. The file are located in the nupkg "build\native" or "runtimes" directory.

With best regards
Thomas

Offline

#20 2022-08-17 15:04:53

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,207
Website

Re: A small example in response to a question

Good point.

I have just forced the file to be included in the repository.
https://github.com/synopse/mORMot2/commit/5e4d33db
It is a small file, anyway.

Thanks for sharing!

Offline

#21 2022-08-17 17:51:38

tbo
Member
Registered: 2015-04-20
Posts: 335

Re: A small example in response to a question

It would be good if it was mentioned that the attached version of WebView2Loader.dll is for 32-bit. If someone wants to create a 64-bit version of the program, he has to replace the DLL. Both versions for x64 and x86 are available in the NuGet file (see link above). Or you add the 64-bit version with the name x64_WebView2Loader.dll. I think a programmer should then know what to do.

With best regards
Thomas

Offline

#22 2022-09-16 13:44:18

tbo
Member
Registered: 2015-04-20
Posts: 335

Re: A small example in response to a question

@Arnaud: The source code is not complete and cannot be compiled! Therefore, it is not usable as an example.

I have published my sixth article with the topic mORMot here (forum Delphi-PRAXIS). The title is: Mediator for connecting FastReport with Preview and/or Designer. The article describes how to create your own TfrxUserDataSet using DocVariant. The text is written in german, the sourcecode uses english names. In the appendix you can find a sample application to play with. Only the source code for the program itself is included, not for the libraries.

The program is a test environment for mORMot and FastReport. There are five functions available: New project, open and close project, show report preview or report designer. To get started right away, a project "Test01" is ready created. Basic operation:

  • Each project has its own folder. The default Projects directory is located below the Program directory.

  • The FastReport layout file name is the directory name plus extension ".fr3". It is created by saving a report in the designer.

  • The name of the variable file in JSON object format is the directory name plus extension ".variables". When creating a new project, an empty file is created.

  • All files with the extension "*.json" are included as DataSets. The name of the DataSet is the file name. JSON object and array format is supported. A DataSet is included in the report by adding the JSON data file to the project directory. Drag-and-drop to/from the file view is supported.

  • And some little things more...

Here is the translation into English with Google Translator. The result is not perfect (rather not so good), also some formatting is destroyed, but it is readable.

With best regards
Thomas

Offline

#23 2022-09-16 13:54:04

flydev
Member
From: France
Registered: 2020-11-27
Posts: 50
Website

Re: A small example in response to a question

I just tested the application, your examples really make things easier and give a lot of good implementation ideas, thanks you @tbo smile

Offline

Board footer

Powered by FluxBB