HBLOG - Creation our first Blog. Part - I

Post Reply
Posts: 6
Joined: Sun Nov 10, 2019 12:43 am

HBLOG - Creation our first Blog. Part - I

Post by apais » Fri Mar 06, 2020 10:35 pm

Post here all comments and suggestions about the new collective project of a Blog Manager/ Site.
Repository: https://github.com/mod-harbour/mh-blog


This app will be made using the mercury library and following MVC dev methodology.
So Apache needs some modifications besides the ones needed to run mod_harbour itself.

On httpd.conf:
1) Be sure that mod_rewrite is uncommented (active)

2) In section:
<Directory "${SRVROOT}/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
be sure AllowOverride is "All"

Posts: 13
Joined: Sun Nov 10, 2019 12:44 am

Re: HBLOG - Creating our first Blog. Part - I

Post by pablo-botella » Mon Mar 09, 2020 1:40 pm

( Translated from viewtopic.php?f=7&p=480#p480
Post by carles » Mon Mar 09, 2020 8:21 pm )

HBLOG - 1st Part


Like I promised we are going to build a blog as fancy as you want, step by step. The purpose is to learn how to build an application following the MVC architecture while help you to fully understand the approach that you will use to build your applications in a more professional way.

We agreed that we will start working with the bare concept of what a blog can be.
We also agreed that starting with a basic blog we will try to make it in the most simple way we can and starting from zero. At the beginning we are not going to use big templates or something like that. It is totally useless to do copy and paste of templates that we can get from the web, if we not fully understand the involved programming mechanisms. Will arrive the right time to enter in the mockup and layout business if we advanced enough.

So we started from the minimal expression of a blog and this was we got:


The idea is that the blog show some entries and we be able to navigate back and forward between them. So the first exercise is to create the project's structure and try that harbour returns the 5th starting records, and put a button at the end to request 5 more records.


And the last but not the least until now, we will do everything in text format, the purpose is to learn how to understand this kind of programming. ;-)

All the related code is in the repository https://github.com/carles9000/hblog , you can clone the repository or just a direct download. We will name the project hblog.

We will create a totally basic table with the following fields: id, fecha,titulo, texto

If you remember from the beginning, the MVC concept is the following:

One of the specific things of the system is that all the request that our program will receive will go always through our main file, that usually will be named index.prg

This is the reason why we need to activate the mod_rewrite in the Apache web server, because among other things it will be the responsible to redirect always the request to index.prg

From the first design we got:

index.prg -->
We will create the App() object that will allow us to create the different "routes" to our application.
This is the first controller we created, and will process the requests.
base 🡪 localhost/hblog/
The model that will be open the table and call a method lo load the records.
This is the first super-view, that will show the forst screen with the records and the forward button.

And this is the result

That was a Total Success!! We have now our first blog ( the ugliest blog of the history, <g> )

As you have been observed , the button create a request, and you must understand all the flow that it will produce:

The request will enter from index.prg
The request will be routed to the controller, named rootcontroller , that will be watching and interpreting what the request is trying to do, and the rootcontroller will open the data table and will load the data. Then the rootcontroller will call to the view providing these data, so the view can render it properly and return to the browser

And that's all

Now the objective is that you try to understand the whole process, and try to add more features by yourselves, like "Page Down", "Top" , "Bottom",...

You can found the whole explanation step by step is in this video ( spanish) 🡪 https://youtu.be/g7Fjk9BbZ24

After finish the exercise, I've uploaded to the server and without change anything was run properly

You can try it here 🡪

And you can drop here in the forum all the questions and doubts

Post Reply