rejetto forum

Software => HFS ~ HTTP File Server => Topic started by: Zean on December 04, 2007, 06:04:03 AM

Title: Default file mask to ~setting
Post by: Zean on December 04, 2007, 06:04:03 AM
Is there a way to change the default file mask for the server root "/" to something listed in the server's HTML template?

For example, If I created a new section called "[index]" and enter the html for my homepage and type ~index this page views as I'd like. However, If I make the default file mask for the root "~index" It's looking for an actual which it wont find so the root and all the folders are shown.

The reason I'm trying to do this is so I can use the server templates functions such as %timestamp%, %connections% where as I can't using an actual file.
Title: Re: Default file mask to ~setting
Post by: rejetto on December 04, 2007, 07:37:22 AM
for now you can
1. put the content of [index] at the top of the template (the main section, with no name)
2. select all folders
3. diff template, put the original content of the main section

it should work
Title: Re: Default file mask to ~setting
Post by: bacter on December 04, 2007, 03:04:54 PM
Another approach could be: create two main sections, as follows.

Name the first one (for example) 'PageFiles' and copy there the content of your actual main body.

Create a second one 'PageHome' where you put the body of your home page.

Then in the original main section delete the content of body and put this:

{{if | {{=|%folder%|/|}} | {{section|PageHome}}  | {{section|PageFiles}} }}


So in PageHome you have all global hfs vars accessible (ip, speed-out,  user,conections...). Only add in your homepage a link (access to fileserver) to the mainfolder of your fileserver (something like '/root/' , not '/') ! You cant then let the users browse from '/' root, but you can put there more than one link to access: root for generic files, music for a tree with mp3, templates for a thread with templates and so on.
Title: Re: Default file mask to ~setting
Post by: rejetto on December 04, 2007, 06:17:08 PM
that's great bacter! :D
Title: Re: Default file mask to ~setting
Post by: Zean on December 04, 2007, 11:09:45 PM
Thanks, works just how I like now.  :D
Title: Re: Default file mask to ~setting
Post by: Mars on December 04, 2007, 11:32:30 PM
By looking at this post, I wondered if it was possible to add the equivalent of
{{=|%folder%|/|}}
Quote
if name = '=' then
  trueIf(sameText(par(0), par(1)));


{{equal|%folder%|/|}}
Quote
if name = 'equal' then
  trueIf(sameText(par(0), par(1)));

{{=|'{{=|#|&}}'|''}}   The syntax is obviously of use to nothing but is correct and to decipher it is another story 

{{equal|'{{equal|#|&}}'|''}} is a little easier to follow

{{if|{{=|'{{=|#|&}}'|''}}|You win|You lose}} or {{if|{{equal|'{{equal|#|&}}'|''}}|You win|You lose}}
Title: Re: Default file mask to ~setting
Post by: bacter on December 04, 2007, 11:39:35 PM
Thanks to you, Rejetto, because your macros allow to reduce the need of diff templates!

They are really usefull !

Only ... if we could find a way of evolution of RTL (Rejetto-Template-Language). Because the actual syntax - without trying to offend - is as useful as ugly. Now, a template is html (with optional java etc.) and embeded rtl, but complex macros are really difficult tu read.

RTL could progress to reverse: {rtl}{/rtl}  for macro text with simpler sintax, allowing {code}{/code} where resides standard browser language(html expressions), a section-name could directly be invoked (like named gosub). Mars says with enthusiasm... we will have something like old Basic. Also perhaps we do not need 'GOTO 2210' and no 'POKE's, rtl could be at least as readable as Basic. Without double braces, and without the first pipe character after macroname, we could already gain a lot. 

So templates would no longer be html with rejetto extensions, but a rtl-document that's used to create html.


Title: Re: Default file mask to ~setting
Post by: Mars on December 04, 2007, 11:53:17 PM
RTL
Quote
RTL (Rejetto-Template-Language).
It is the slow evolution or the migration towards the php ;D ;D
Title: Re: Default file mask to ~setting
Post by: rejetto on December 05, 2007, 12:58:43 AM
hehe, slow down guys :)
there's no point in creating a "full" new language.
even before CGI support i could add php support, but it's better to wait.
to have equal as alias for = it's ok, from next build.
to avoid the first separator | and have a space instead is apparently possible, BUT what if the first parameter need to be a blank space?
Title: Re: Default file mask to ~setting
Post by: bacter on December 05, 2007, 03:44:21 AM
If first parameter is blank space: {quote  } or &nbsp.

... or: allowing inside macros a new sintax for {{ section | somesection}} like $somesection (or for Basic-preference somesection$ ), there could be some prefefined 'sepecial section' like $space (-> space$) ..

from:
{{if | {{=|%folder%|/|}} | {{section | PageHome}}  | {{ ifnot %user% | {{section|PageLogin}} | {{section|PageFiles }}}}}}

to:
{{if  {{equal %folder%|/|}} | $PageHome  | {{ ifnot %user% | $PageForceToLogin | $PageFiles }} }}

or inside rtl:
{rtl}
{$GetLangFromCookie}
{if {notequal %folder%|/|} | $BuildFoldertree }
...
{if {equal %folder%|/|} | $PageHome  | {ifnot %user% | $PageForceToLogin | $PageFiles }}
...
{/rtl}
Title: Re: Default file mask to ~setting
Post by: rejetto on December 05, 2007, 04:12:42 AM
If first parameter is blank space: {quote  } or &nbsp.
"quote  " doesn't seem a good solution, and   would not work in many cases, like {{=}}

Quote
... or: allowing inside macros a new sintax for {{ section | somesection}} like $somesection

it's complex. i would try avoid introducing new special characters.
if %symbols% weren't there already, i would have used macros for all of them so that % was a normal char.
anyway, a possible solution is {{$name}} as alias for {{section|name}}.
if you like it i will introduce it in next build.
Title: Re: Default file mask to ~setting
Post by: rejetto on December 05, 2007, 04:31:51 AM
i worked out to get this working
{{ %folder% = / }}

with this one, i think we don't need the alias {{equal}} anymore ;)
Posted on: 05 December 2007, 05:22:42
just as for {{$section}} i could make {{?urlvar}} to have a shorter form in case this macro is very used. it's an idea.
anyway, characters like $ = and ? are few, and we should think twice before assigning them to a macro.
Title: Re: Default file mask to ~setting
Post by: bacter on December 05, 2007, 07:13:03 AM
I think we could even still use %somesection% !
The confusion created would not be any greater than the difference between defined and intrinsic functions y most languages.

As there is no way to assign variables, the logigal conditional operations 'if' or 'if not' (what sould be 'ifnot' to simplyfy parsing) could turn to if = and if #

Also to avoid problems with a future 'if >' (if greater)  (example: {{ if > %secuential%| dosomething}} ) perhaps Mars idea to use words instead of signs (equal, notequal, greater, less..) would be better.

In any case, you are right, we should think twice about changes and new creations, and polish definitions before implementing, to have more consistent syntax and avoid some strange orders like in substring and cut. First parameter (as in most languages) the object to work with, then how -> substring "thestring", form where, towhere, like it's in repeat: repeat what, howmanytimes.

urlvar will be used a lot less than sections, and there is think it contributes to see where the value comes from, because there are no intrinsic values for %sort% etc. , and perhaps nobody includes a section with that name.
Title: Re: Default file mask to ~setting
Post by: rejetto on December 05, 2007, 08:26:10 AM
As there is no way to assign variables, the logigal conditional operations 'if' or 'if not' (what sould be 'ifnot' to simplyfy parsing) could turn to if = and if #

yes, the if is a very frequent macro... but maybe it is already handy the way it is?

Quote
In any case, you are right, we should think twice about changes and new creations, and polish definitions before implementing, to have more consistent syntax and avoid some strange orders like in substring and cut. First parameter (as in most languages) the object to work with, then how -> substring "thestring", form where, towhere, like it's in repeat: repeat what, howmanytimes.

i often decide the order thinking on how big the parameters will be. E.g. substring, the first two parameters may be very much littler than the third. if a short parameter is after a long one, reading may be harder.
Title: Re: Default file mask to ~setting
Post by: Mars on December 05, 2007, 10:30:31 PM
Analyse de tout ça en cours avant de me pronocer

un oeil la dessus

http://www.laboiteaprog.com/article-35-1-delphi_modele_html
Title: Re: Default file mask to ~setting
Post by: TCube on December 06, 2007, 04:08:42 AM
mars,
ton lien m'a fait sourire  :D..  un retour vers le Sgml des années 1960 e quelque sorte. Le concept n'est guère utilisé sauf pour les courriers industriels de types factures/relevés bancaires, etc.
TCube
Title: Re: Default file mask to ~setting
Post by: Mars on December 06, 2007, 10:54:04 AM
{{$section}} ou <#section> ou toute autre forme quelle que soit la syntaxe , au final l'expression entière est remplacée, 2 choses comptent: la lisibilité des templates et aussi la difficulté d'interprétation au niveau de delphi ( faut aussi penser au programmeur)

faire un truc du genre  :(  

<script type="text/Rejetto">
{load nom-fichier};
{switch %user% ....};
{section|mysection}
</script>
selon moi c'est trop proche du javascript

pour ma part je préfère les chose plus simples où <#nom_employe> ou %user% sont remplacés par leur équivalent meme si on introduit un peu de language  style basic sans aller jusqu'au POKE ;D

Ce qui est interressant c'est de remplacer une partie du javascript par des macros HFS, comme cela moins de données transitent vers le navigateur et cela augmente la confidentialité des données. Prenons simplement l'exemple qui consiste à afficher le contenu d'un texte en fonction de l'utilisateur

Soit on transmet l'ensemble des messages et c'est le navigateur qui masque ou affiche ce qui doit être ou alors on utilise:

<p>{{load|/messages/message%user%.txt}<p>

à ce propos je propose à rejeto une extrension de la macro 'section'

{{ section | mysection }}  complétée par

{{ section | mysection | fichier_externe}}    (le code est deja sur papier brouillon)


pour finir un template principal

<HTML>
<head>
...
</head>
<body>
Choice your language/Choisir sa langue/.....
...
%login-link%
%loggedin%
.....
</body>
</html>

[style]

[login-link]
{{section | login-link | hfs{{urlvar|lang}}.tpl}}
OU
{{section | {{urlvar|lang}} | hfs.login-link.tpl}}


[loggedin]
{{section | loggedin | hfs{{urlvar|lang}}.tpl}}
OU
{{section | {{urlvar|lang}} | hfs.loggedin.tpl}}

....




Title: Re: Default file mask to ~setting
Post by: rejetto on December 06, 2007, 04:54:13 PM
pour ma part je préfère les chose plus simples où <#nom_employe> ou %user% sont remplacés par leur équivalent meme si on introduit un peu de language  style basic sans aller jusqu'au POKE ;D

yes, it's easier, but also inadequate.
the example of the link is indeed about simple %symbols%, not for a more complex language.
using > as closing sequence would be confused with the closing of html tags.

Quote
à ce propos je propose à rejeto une extrension de la macro 'section'
{{ section | mysection | fichier_externe}}    (le code est deja sur papier brouillon)

you'd better tell what is supposed to do ;)
if it loads the [mysection] from an external template file, then you can just do {{load|file}} {{$mysection}}
Title: Re: Default file mask to ~setting
Post by: Mars on December 06, 2007, 10:36:29 PM
Quote
Quote
à ce propos je propose à rejeto une extrension de la macro 'section'
{{ section | mysection | fichier_externe}}    (le code est deja sur papier brouillon)


you'd better tell what is supposed to do
if it loads the [mysection] from an external template file, then you can just do {{load|file}} {{$mysection}}

le but est de lire une partie (section) d'un fichier sans le charger complètement dans le template principal, au lieu d'avoir N fichiers contenant chacun 1 section, je préfère avoir 1 fichier contenant N sections et pouvoir charger la section qui m'intéresse.

si dans mon fichier j'ai des information confidentielles organisées en section comme par exemple

[user1]
name=toto
address= chez rejetto
tel=0123456789

[user2]
name=titi
address= toujours chez  rejetto
tel=0123456789

....
[user5265898]  // yes 5 265 898 users
name=mars
address= chez mars
tel=0123450000

il n'est pas nécessaire de charger tout le fichier dans le template par {{load|file}}  et d'afficher la section désirée par {{$mysection}}, sinon j'utiliserai cette syntaxe

{{section|mysection|{{load|myfile}}}}

en considérant [mysection] is in myfile

utiliser %mysection% dans la partie main de hfs.tpl
et {load|myfile} à lal fin de hfs.tpl comme il se doit,

je ne pense pas que ca puisse fonctionner: 1 chance sur 2 selon l'ordre de résolution des macros


en reprenant mon idée

dans le fichier myfile se trouve la section

Quote
.
[section-précédente].
.
.
[mysection]
//begin mysection
...
//end mysection
[section-suivante]
.
.
.
le resultat obtenu serait:

Quote
//begin mysection
...
//end mysection

Tout ce blabla au dessus pour en arriver à ça:

en code delphi

if name = 'section' then
 if pars.count=2 then begin
      result:= loadFile(par(1));           //avec la syntaxe {{section|mysection|myfile}}
ou    result:= par(1);           //avec la syntaxe {{section|mysection|{{load|myfile}}}}  plus de possibilités avec cette dernière
      chop('['+par(0)+']',result);    //suppression jusqu'au  nom de section
      chopline(result);                 //suppression de la ligne [mysection]
      result:=chop('#13#10[',result); //  couper en debut de section suivante ou si fin de fichier atteinte
      end
    else
    try result:=md.tpl[p] except end;

Répons : oui la syntaxe est bonne et les fonctions sont judicieusement choisies pour ne pas exiger plus de code, et donner le résultat escompté.
Title: Re: Default file mask to ~setting
Post by: rejetto on December 07, 2007, 12:31:52 PM
ok

your code is good mars, but it has a problem: it would consider [section] even if in the middle of a line, while it must be placed at the beginning. This way it shold fix the problem

Code: [Select]
  s:=loadFile(par(1));
  p:=chop('['+p+']', s);
  if (p > '') and (p[length(p)] <> #10) then
    result:=''
  else
    begin
    chopline(s);
    result:=chop('#10[', s);
    end;

anyway i opted for another version 50% longer, but faster, just in case we handle a big file.

Code: [Select]
  result:='';
  s:=loadFile(par(1));
  // search the starting pattern
  p:='['+p+']';
  b:=0;
    repeat
    b:=posEx(p, s, b+1);
    if b = 0 then exit;
    until (b = 1) or (s[b-1]  = #10);
  b:=1+posEx(#10, s, b); // skip this line
  if b = 1 then exit;
  // calculates the end of the section
  e:=posEx(#10'[', s, b);
  if e = 0 then e:=length(s);
  result:=substr(s,b,e);
Title: Re: Default file mask to ~setting
Post by: Mars on December 07, 2007, 06:56:47 PM
j'en conclus donc que la macro

{{ section | mysection | fichier_externe}}   

sera dans la prochaine build?
 ;)