Page 1 of 2

TWeb for mod Harbour is ready

Posted: Thu Apr 09, 2020 3:41 pm
by Carles
Hi,

I have published the TWeb for mod Harbour, so that it can be freely used in your programs in a web environment.

The easiest way to create a web screen using our usual xBase syntax

A simple example of how to create a web form that makes a request to our server and that returns a response

https://54.37.60.33/htweb/tutor10.prg

The code that designs the browser screen

Code: Select all

//  {% LoadHrb( 'lib/tweb/tweb.hrb' ) %}

#include {% TWebInclude() %}

function main()

    LOCAL o

    DEFINE WEB oWeb TITLE 'Tutor10' INIT

    DEFINE FORM o ID 'demo' 
        
        HTML o INLINE '<h3>Test MsgServer()</h3><hr>'

    INIT FORM o         
       
        GET ID 'myid'       VALUE '123' GRID 12 LABEL 'Id.' BUTTON 'GetId' ACTION 'GetId()' OF o            
    
        HTML o
        
            <script>
            
                function GetId() {              
                    var cId = $('#myid').val() 
                
                    MsgServer( 'tutor10-server.prg', cId, PostCall )
                }
                
                function PostCall( data ) {             
                    MsgInfo( data )             
                }           
                
            </script>   
            
        ENDTEXT
        
    END FORM o  
    
retu nil 
And the part of the backend that is in the server and listens to our requests

Code: Select all

function main()

    local hParam := AP_PostPairs()

    ?? 'Server time: ' + time() + '. Welcome ' +  hParam[ 'value' ] 
    
retu nil
 
And this is the basis to be able to quickly and easily create our web pages using the new mod_harbour.

You can easily test, modify, run the examples until you can manage browsers.

https://54.37.60.33/htweb/tutor4b.prg

In this link you will have all the information and the different examples that are already operational

https://54.37.60.33/htweb/index_en.html


I invite everyone to try mod Harbour to be able to make the definitive leap to the web using our usual xBase. It has never been so easy to access the web with our beloved Harbour.

Any questions you can post on the mod-harbour forum -> -> https://forum.mod-harbour.org/viewforum.php?f=7

Enjoy it


Regards

C.

Re: TWeb for mod Harbour is ready

Posted: Fri Apr 10, 2020 2:29 pm
by Taavi
Hello,
what could cause this error with tutor4.prg?

With the best,
Taavi.



Error: Syntax error "syntax error at '<'"
operation: line:8
called from: HB_COMPILEFROMBUF, line: 0
called from: ..\apache.prg, EXECUTE, line: 141
called from: ..\apache.prg, EXECINLINE, line: 323
called from: ..\apache.prg, INLINEPRG, line: 303
called from: C:/xampp/htdocs/tweb/lib/tweb/tweb.hrb, TWEBBROWSE:ACTIVATE, line: 212
called from: C:/xampp/htdocs/tweb/lib/tweb/tweb.hrb, TWEBFORM:ACTIVATE, line: 104
called from: pcode.hrb, MAIN, line: 63
called from: HB_HRBDO, line: 0
called from: ..\apache.prg, EXECUTE, line: 143

Source:
0001: function __Inline( ) local cHtml := "" local lMultiSelect := .F. local lSingleSelect := .F. local hCols := {<br>&nbsp;&nbsp;"last":<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;"head":&nbsp;"Last",<br>&nbsp;&nbsp;&nbsp;&nbsp;"width":&nbsp;"",<br>&nbsp;&nbsp;&nbsp;&nbsp;"sortable":&nbsp;false,<br>&nbsp;&nbsp;&nbsp;&nbsp;"align":&nbsp;"",<br>&nbsp;&nbsp;&nbsp;&nbsp;"formatter":&nbsp;""<br>&nbsp;&nbsp;},<br>&nbsp;&nbsp;"first":<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;"head":&nbsp;"First",<br>&nbsp;&nbsp;&nbsp;&nbsp;"width":&nbsp;"",<br>&nbsp;&nbsp;&nbsp;&nbsp;"sortable":&nbsp;false,<br>&nbsp;&nbsp;&nbsp;&nbsp;"align":&nbsp;"",<br>&nbsp;&nbsp;&nbsp;&nbsp;"formatter":&nbsp;""<br>&nbsp;&nbsp;},<br>&nbsp;&nbsp;"street":<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;"head":&nbsp;"Street",<br>&nbsp;&nbsp;&nbsp;&nbsp;"width":&nbsp;"",<br>&nbsp;&nbsp;&nbsp;&nbsp;"sortable":&nbsp;false,<br>&nbsp;&nbsp;&nbsp;&nbsp;"align":&nbsp;"",<br>&nbsp;&nbsp;&nbsp;&nbsp;"formatter":&nbsp;""<br>&nbsp;&nbsp;},<br>&nbsp;&nbsp;"age":<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;"head":&nbsp;"Age",<br>&nbsp;&nbsp;&nbsp;&nbsp;"width":&nbsp;"",<br>&nbsp;&nbsp;&nbsp;&nbsp;"sortable":&nbsp;false,<br>&nbsp;&nbsp;&nbsp;&nbsp;"align":&nbsp;"",<br>&nbsp;&nbsp;&nbsp;&nbsp;"formatter":&nbsp;""<br>&nbsp;&nbsp;}<br>}<br> local nWidth := 0 local n, cField, hDef IF lMultiSelect .OR. lSingleSelect cHtml += '<th data-field="st" data-checkbox="true"></th>' ENDIF FOR n := 1 TO Len(hCols) aField := HB_HPairAt( hCols, n ) cField := aField[1] hDef := aField[2] cHtml += '<th data-field="' + cField + '" ' cHtml += 'data-width="' + valtochar(hDef[ "width" ]) + '" ' cHtml += 'data-sortable="' + IF( hDef[ "sortable" ], "true", "false" ) + '" ' cHtml += 'data-align="' + hDef[ "align" ] + '" ' cHtml += 'data-formatter="' + hDef[ "formatter" ] + '" ' cHtml += ">" + hDef[ "head" ] + "</th>" NEXT retu cHtml

Re: TWeb for mod Harbour is ready

Posted: Sat Apr 11, 2020 8:46 am
by Carles
Taavi,

It's strange. I just downloaded the repository and it works fine. What operating system do you have the mod installed on?

Do the other examples work well?

C.

Re: TWeb for mod Harbour is ready

Posted: Sat Apr 11, 2020 9:10 am
by Taavi
Win10 + XAMPP + mod_harbour installed yesterday.


Other examples work ok , problem only with 4 and 4b

Re: TWeb for mod Harbour is ready

Posted: Sat Apr 11, 2020 9:42 am
by Carles
Taavi,

Solved ! git pull and try again

C.

Re: TWeb for mod Harbour is ready

Posted: Sat Apr 11, 2020 10:23 am
by Taavi
Thanks, Carles
samples working ok now here.

Do You have any docs in english for tWeb xbase commands?

Taavi.

Re: TWeb for mod Harbour is ready

Posted: Sat Apr 11, 2020 10:48 am
by Carles
Taavi,

Not yet, I'm sorry and it's not in Spanish yet either. The reason is simple, we have a few documents of techniques carried out but that have not just been consolidated.

When we see that people are comfortable with some style of coding on the web, then we will create doc. At the moment you can review the examples, modify them, see all the source code, ... You can also see the file tweb.ch where there are the directives of all the elbow so far.

Hopefully this model can be well adapted to your needs and then we will try to create the doc. I think for the moment to be able to see the philosophy there is enough to be able to try it.

I hope you understand :-)

Thank you.
C.

Re: TWeb for mod Harbour is ready

Posted: Sun Apr 12, 2020 10:30 am
by Taavi
Helli Carles,
seems that with yesterday patch something went wrong with special characters.

If I insert special characrets in In tutor02.prg

GET ID 'myid' VALUE '123' GRID 4 LABEL 'Special characters ÄäÕõüÜ' PLACEHOLDER 'User Id.' BUTTON 'GetId' ACTION 'GetIdphone()' OF o

With yesterday patch In get in browser label /copy from browser screen/:

Special characters ������


With previous version I get correct characters in browser:

Special characters ÄäÕõüÜ

Taavi.

Re: TWeb for mod Harbour is ready

Posted: Sun Apr 12, 2020 11:00 am
by Carles
Taavi,

Try save code with utf8 format and normal.

I will see the last changes
C.

Re: TWeb for mod Harbour is ready

Posted: Sun Apr 12, 2020 4:41 pm
by Carles
Taavi

I have created a forum post https://forum.mod-harbour.org/viewtopic.php?f=7&t=457 for your problem, explaining the charset topic (currently only in Spanish)

Basically, if you save your code with utf-8 format, you simply define the web as it is

DEFINE WEB oWeb TITLE 'Test CharSet - UTF8' INIT

But if you save your web (prg file) in ANSI format you should define it this way

DEFINE WEB oWeb TITLE 'Test CharSet - ANSI'
             oWeb: cCharset: = 'Latin-1'
INIT WEB oWeb

Try it and we comment


Remember ... Git pull

Re: TWeb for mod Harbour is ready

Posted: Wed Apr 15, 2020 6:13 pm
by Taavi
Thanks, characters seems to be ok now.

With latest git tutor3, 7 and 8 are giving errors.


Tutor 20 was really helpful, thanks.

Taavi

Re: TWeb for mod Harbour is ready

Posted: Wed Apr 15, 2020 6:15 pm
by Carles
Taavi

Whats erors ?

What os and brwower ?

Thanks.

Re: TWeb for mod Harbour is ready

Posted: Thu Apr 16, 2020 6:45 am
by Carles
Taavi,

Taavi wrote:With latest git tutor3, 7 and 8 are giving errors.
Solved !

C.

Re: TWeb for mod Harbour is ready

Posted: Wed May 06, 2020 8:36 am
by Maurizio
Hello Charly

I have Apache24 + mod_harbour windows x64 no installation

now I would like to try TWEB

can you help me how to install and configure TWEB?

Maurizio

Re: TWeb for mod Harbour is ready

Posted: Wed May 06, 2020 10:10 am
by Carles
Hi Maurizio,

I assume you have mod harbour installed and it is working correctly.

Installing TWeb is very easy.

You just have to download tweb (or make a git clone) from https://github.com/carles9000/tweb . By default you can install it in htdocs\tweb. Once this is done you go to the browser and type localhost/tweb/tutor.prg

If the version of TWeb appears on the screen, the system is ready. Otherwise something in your configuration would have to be revised

In case the system works, check all the tutorxxx files to see the different possibilities