* * *

Author Topic: FpWeb and template  (Read 2273 times)

xinyiman

  • Hero Member
  • *****
  • Posts: 1583
FpWeb and template
« on: June 27, 2017, 12:42:04 pm »
Hi guys, I have a question! I'm working with fpweb, but I can not use the templates well. Attached an example, you will see that if you run the executable you will get a result, and if you launch the /files/index.html file manually in the browser you will see another result. It does not seem to load css and js files through templates. How can I do? Thank you
Ubuntu and Mint
Lazarus: 1.2.6
FPC: 2.6.4

xinyiman

  • Hero Member
  • *****
  • Posts: 1583
Re: FpWeb and template
« Reply #1 on: June 28, 2017, 08:24:31 am »
No help?
Ubuntu and Mint
Lazarus: 1.2.6
FPC: 2.6.4

nummer8

  • New member
  • *
  • Posts: 20
Re: FpWeb and template
« Reply #2 on: June 28, 2017, 09:30:50 am »
Hi,

If you view the source code of the web page and try to click one of the bootstrap file you will notice that the file is not accessible.
Try to make the project as a cgi and use a real web-server. The bootstrap files will be served by the webserver.
The internal http server has no knowledge of the external files.

Maybe some one else can explain how to achieve this with a http server project.

The only info I can find is how to serve statical files directly from the program as you did with your index.html.

Jos 

xinyiman

  • Hero Member
  • *****
  • Posts: 1583
Re: FpWeb and template
« Reply #3 on: June 28, 2017, 11:22:56 am »
Yes, after the tests have come to the same conclusion. Now I want to figure out how to fix the problem.
Ubuntu and Mint
Lazarus: 1.2.6
FPC: 2.6.4

xinyiman

  • Hero Member
  • *****
  • Posts: 1583
Re: FpWeb and template
« Reply #4 on: June 30, 2017, 03:08:09 pm »
A few steps forward has been made, now I search for all the files in a folder and their sub folders and I include them.
   But if you launch the example you will see that
         http://localhost:9020/index
   it's different from
         http://localhost:9020/home
 
What I do not understand is because home does not act as an index. In the index i refer to the libraries on the web, in the home I refer to the libraries on the filesystem. Who can explain why ?! Thank you
Ubuntu and Mint
Lazarus: 1.2.6
FPC: 2.6.4

Leledumbo

  • Hero Member
  • *****
  • Posts: 7721
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: FpWeb and template
« Reply #5 on: June 30, 2017, 11:28:03 pm »
You name the variables:
Quote
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- QUI CSS -->
  <!-- QUI JS -->
</head>
but you try to replace:
Quote
app.Text:=stringReplace(app.Text, '<!-- JS QUI -->', librerie_js, [RfReplaceAll]);
app.Text:=stringReplace(app.Text, '<!-- CSS QUI -->', fogli_stile, [RfReplaceAll]);
Still, even after fixing those, you won't get your bootstrap working because you're missing jquery in the line. You're also doing unnecessary things by including the CONTENTS of bootstrap CSS/JS, simply generate links to them as in the /index handler.
Maybe some one else can explain how to achieve this with a http server project.
Unit: https://svn.freepascal.org/svn/fpc/tags/release_3_0_2/packages/fcl-web/src/base/fpwebfile.pp
Example: https://svn.freepascal.org/svn/fpc/tags/release_3_0_2/packages/fcl-web/examples/httpapp/testhttp.pp

xinyiman

  • Hero Member
  • *****
  • Posts: 1583
Re: FpWeb and template
« Reply #6 on: July 01, 2017, 07:12:32 pm »
Hi leledumbo, thanks for the links. But I can not make it work as I want. The link below will let you download my new example (2.1 MB) including bootstrap sources. Can you tell me where I am wrong? You just have to run it

www.lazaruspascal.it/esempi/webproject_neutro.zip


localhost:9090

Code: Pascal  [Select]
  1. The application encountered the following error:
  2.  
  3.     Error: Could not determine HTTP module for request ""
  4.     Stack trace:
  5.     $00084EDD
  6.     $00084F96
  7.     $00084C3C
  8.     $00085443
  9.     $0007B4AE
  10.     $00089AAD
  11.     $000894F3
  12.     $0006945A
  13.  


You name the variables:
Quote
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- QUI CSS -->
  <!-- QUI JS -->
</head>
but you try to replace:
Quote
app.Text:=stringReplace(app.Text, '<!-- JS QUI -->', librerie_js, [RfReplaceAll]);
app.Text:=stringReplace(app.Text, '<!-- CSS QUI -->', fogli_stile, [RfReplaceAll]);
Still, even after fixing those, you won't get your bootstrap working because you're missing jquery in the line. You're also doing unnecessary things by including the CONTENTS of bootstrap CSS/JS, simply generate links to them as in the /index handler.
Maybe some one else can explain how to achieve this with a http server project.
Unit: https://svn.freepascal.org/svn/fpc/tags/release_3_0_2/packages/fcl-web/src/base/fpwebfile.pp
Example: https://svn.freepascal.org/svn/fpc/tags/release_3_0_2/packages/fcl-web/examples/httpapp/testhttp.pp
Ubuntu and Mint
Lazarus: 1.2.6
FPC: 2.6.4

Leledumbo

  • Hero Member
  • *****
  • Posts: 7721
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: FpWeb and template
« Reply #7 on: July 02, 2017, 12:24:00 am »
Re-read my tutorial about routing, you have multiple routes registered, none of these handle empty path info.

xinyiman

  • Hero Member
  • *****
  • Posts: 1583
Re: FpWeb and template
« Reply #8 on: July 02, 2017, 10:03:32 am »
Link of tutorial please
Ubuntu and Mint
Lazarus: 1.2.6
FPC: 2.6.4

nummer8

  • New member
  • *
  • Posts: 20

xinyiman

  • Hero Member
  • *****
  • Posts: 1583
Re: FpWeb and template
« Reply #10 on: July 02, 2017, 05:12:19 pm »
OK! I got it. I do not understand why I do not load bootstrap libraries. I can see the contents of the index.html file but can not see them as I should.
Ubuntu and Mint
Lazarus: 1.2.6
FPC: 2.6.4

Leledumbo

  • Hero Member
  • *****
  • Posts: 7721
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: FpWeb and template
« Reply #11 on: July 02, 2017, 06:29:13 pm »
Load just fine for me (except favicon.ico).

EDIT:
My bad, I didn't check those responses, actually those script's src and link's href are returning the same html. You should prepend them with /, otherwise it will be considered relative to the path info instead of the host. With that fixed, the resulting page should be like the second image.
« Last Edit: July 02, 2017, 07:05:00 pm by Leledumbo »

xinyiman

  • Hero Member
  • *****
  • Posts: 1583
Re: FpWeb and template
« Reply #12 on: July 02, 2017, 08:29:43 pm »
Sorry I did not understand, you could modify my source so I understand. Thank you
Ubuntu and Mint
Lazarus: 1.2.6
FPC: 2.6.4

xinyiman

  • Hero Member
  • *****
  • Posts: 1583
Re: FpWeb and template
« Reply #13 on: July 04, 2017, 11:49:05 am »
I apologize for leledumbo, where I have to go to put / to get the correct result. I did not understand it.
Ubuntu and Mint
Lazarus: 1.2.6
FPC: 2.6.4

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus